authorgravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-04-06 03:08:32-07:00
committergravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-04-06 13:11:39-07:00
logb3b4d0c104c93d533b94d4e4f804ea7e48032893
tree142eb8f047162bdff85879ffeec15791c37b4415
parent16a49c71c15bdc3a8fc3a2d1a430c56a0035049e
signature Signed by SSH key SHA256:xbd+BjjhyBfwk7GVoURf9Yx0gzDerHbvYv7SddNWmAs

file viewer bug fixes oops


5 files changed, 37 insertions(+), 44 deletions(-)

src/file-viewer/rules.ts-12
......@@ -140,18 +140,6 @@ export function fileIcon(
140140 return "file";
141141}
142142
143// -- viewer rules --
144const pathToCanvas = new Map<string, string>(Object.entries({
145 "/2017": "2017",
146 "/2018": "2018",
147 "/2019": "2019",
148 "/2020": "2020",
149 "/2021": "2021",
150 "/2022": "2022",
151 "/2023": "2023",
152 "/2024": "2024",
153}));
154
155143import { MediaFile, MediaFileKind } from "#src/file-viewer/models/MediaFile.ts";
156144import * as path from "node:path";
157145import type * as highlight from "./highlight.ts";
src/file-viewer/tags/media-panel.marko+9-1
......@@ -124,7 +124,15 @@ static const cotyledonEndingFile = "/2024/for everone";
124124 </else>
125125 <else if=rules.extsReadContents.has(ext)>
126126 <ContainerDiv kind="text">
127 <view-text ...{ file } siblings=UNWRAP(file.parent).getPublicChildren()/>
127 <view-text
128 ...{ file }
129 siblings=UNWRAP(file.getParent()).getPublicChildren()
130 />
131 </ContainerDiv>
132 </else>
133 <else if=rules.extsImageLike.has(ext)>
134 <ContainerDiv kind="image">
135 <view-image ...{ file }/>
128136 </ContainerDiv>
129137 </else>
130138 <else if=rules.extsVideo.has(ext)>
src/file-viewer/tags/view-audio.marko+26-29
......@@ -4,41 +4,38 @@ export interface Input {
44}
55
66<const/{ file, onlyAudio }=input>
7<const/lyricsFile=() => {
8 const parent = file.getParent();
9 if (parent && !onlyAudio) {
10 const siblings = parent.getPublicChildren();
11
12 // show lyrics only if
13 // - this media file is the only audio file
14 // - there is lyrics.txt in the same directory
15 const audioFiles = siblings.filter(
16 (f) =>
17 f.kind === MediaFileKind.file &&
18 extensionToViewer[path.extname(f.basename)] === AudioView,
19 );
20 if (
21 audioFiles.length === 1 &&
22 siblings.find((f) => f.basename === "lyrics.txt")
23 ) {
24 return siblings.find((f) => f.basename === "lyrics.txt")!;
25 }
26 }
27
28 return null;
29}>
7//<const/lyricsFile=() => {
8// const parent = file.getParent();
9// if (parent && !onlyAudio) {
10// const siblings = parent.getPublicChildren();
11//
12// // show lyrics only if
13// // - this media file is the only audio file
14// // - there is lyrics.txt in the same directory
15// const audioFiles = siblings.filter(
16// (f) => f.kind === MediaFileKind.file && f.path.endsWith(".mp3"),
17// );
18// if (audioFiles.length === 1) {
19// return siblings.find((f) => f.basename === "lyrics.txt") ?? null;
20// }
21// }
22//
23// return null;
24//}>
3025<audio controls preload="none" style="width: 100%">
3126 <source
3227 src="/file" + file.path
3328 type=`audio/${path.extname(file.path).substring(1)}`
3429 >
3530</audio>
36<div class="lyrics">
37 <h2 style="margin-left:1rem;margin-bottom:-0.2rem;margin-top:0.5rem;">
38 lyrics
39 </h2>
40 <view-text file=lyricsFile siblings=[]/>
41</div>
31//<if=lyricsFile>
32// <div class="lyrics">
33// <h2 style="margin-left:1rem;margin-bottom:-0.2rem;margin-top:0.5rem;">
34// lyrics
35// </h2>
36// <view-text file=lyricsFile siblings=[]/>
37// </div>
38//</if>
4239
4340import * as path from "node:path";
4441import { MediaFile, MediaFileKind } from "#src/file-viewer/models/MediaFile.ts";
src/file-viewer/tags/view-download.marko+1-1
......@@ -53,7 +53,7 @@ export interface Input {
5353 <p>
5454 Instead, you may download it:
5555 <a href="/file" + file.path + "?dl" aria-label="download">
56 {file.basename}
56 ${file.basename}
5757 </a>.
5858 </p>
5959</else>
src/tags/photo-grid.css+1-1
......@@ -23,7 +23,7 @@ photo-grid-item {
2323 }
2424}
2525photo-grid + blockquote {
26 margin: 0 -4px;
26 margin: 0 -4px 1rem -4px;
2727 border: none;
2828 background-color: var(--primary);
2929 color: black;