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(...@@ -140,18 +140,6 @@ export function fileIcon(
140 return "file";140 return "file";
141}141}
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
155import { MediaFile, MediaFileKind } from "#src/file-viewer/models/MediaFile.ts";143import { MediaFile, MediaFileKind } from "#src/file-viewer/models/MediaFile.ts";
156import * as path from "node:path";144import * as path from "node:path";
157import type * as highlight from "./highlight.ts";145import 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";...@@ -124,7 +124,15 @@ static const cotyledonEndingFile = "/2024/for everone";
124 </else>124 </else>
125 <else if=rules.extsReadContents.has(ext)>125 <else if=rules.extsReadContents.has(ext)>
126 <ContainerDiv kind="text">126 <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 }/>
128 </ContainerDiv>136 </ContainerDiv>
129 </else>137 </else>
130 <else if=rules.extsVideo.has(ext)>138 <else if=rules.extsVideo.has(ext)>
src/file-viewer/tags/view-audio.marko+26-29
...@@ -4,41 +4,38 @@ export interface Input {...@@ -4,41 +4,38 @@ export interface Input {
4}4}
55
6<const/{ file, onlyAudio }=input>6<const/{ file, onlyAudio }=input>
7<const/lyricsFile=() => {7//<const/lyricsFile=() => {
8 const parent = file.getParent();8// const parent = file.getParent();
9 if (parent && !onlyAudio) {9// if (parent && !onlyAudio) {
10 const siblings = parent.getPublicChildren();10// const siblings = parent.getPublicChildren();
1111//
12 // show lyrics only if12// // show lyrics only if
13 // - this media file is the only audio file13// // - this media file is the only audio file
14 // - there is lyrics.txt in the same directory14// // - there is lyrics.txt in the same directory
15 const audioFiles = siblings.filter(15// const audioFiles = siblings.filter(
16 (f) =>16// (f) => f.kind === MediaFileKind.file && f.path.endsWith(".mp3"),
17 f.kind === MediaFileKind.file &&17// );
18 extensionToViewer[path.extname(f.basename)] === AudioView,18// if (audioFiles.length === 1) {
19 );19// return siblings.find((f) => f.basename === "lyrics.txt") ?? null;
20 if (20// }
21 audioFiles.length === 1 &&21// }
22 siblings.find((f) => f.basename === "lyrics.txt")22//
23 ) {23// return null;
24 return siblings.find((f) => f.basename === "lyrics.txt")!;24//}>
25 }
26 }
27
28 return null;
29}>
30<audio controls preload="none" style="width: 100%">25<audio controls preload="none" style="width: 100%">
31 <source26 <source
32 src="/file" + file.path27 src="/file" + file.path
33 type=`audio/${path.extname(file.path).substring(1)}`28 type=`audio/${path.extname(file.path).substring(1)}`
34 >29 >
35</audio>30</audio>
36<div class="lyrics">31//<if=lyricsFile>
37 <h2 style="margin-left:1rem;margin-bottom:-0.2rem;margin-top:0.5rem;">32// <div class="lyrics">
38 lyrics33// <h2 style="margin-left:1rem;margin-bottom:-0.2rem;margin-top:0.5rem;">
39 </h2>34// lyrics
40 <view-text file=lyricsFile siblings=[]/>35// </h2>
41</div>36// <view-text file=lyricsFile siblings=[]/>
37// </div>
38//</if>
4239
43import * as path from "node:path";40import * as path from "node:path";
44import { MediaFile, MediaFileKind } from "#src/file-viewer/models/MediaFile.ts";41import { 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 {...@@ -53,7 +53,7 @@ export interface Input {
53 <p>53 <p>
54 Instead, you may download it:54 Instead, you may download it:
55 <a href="/file" + file.path + "?dl" aria-label="download">55 <a href="/file" + file.path + "?dl" aria-label="download">
56 {file.basename}56 ${file.basename}
57 </a>.57 </a>.
58 </p>58 </p>
59</else>59</else>
src/tags/photo-grid.css+1-1
...@@ -23,7 +23,7 @@ photo-grid-item {...@@ -23,7 +23,7 @@ photo-grid-item {
23 }23 }
24}24}
25photo-grid + blockquote {25photo-grid + blockquote {
26 margin: 0 -4px;26 margin: 0 -4px 1rem -4px;
27 border: none;27 border: none;
28 background-color: var(--primary);28 background-color: var(--primary);
29 color: black;29 color: black;