From 8b3db1e2f17042eab5ee4cecb3e96a2f96ddbe2d Mon Sep 17 00:00:00 2001 From: monoid Date: Fri, 6 Jan 2023 18:24:27 +0900 Subject: [PATCH] fmt --- README.md | 2 +- islands/ContentRenderer.tsx | 104 +++++---- islands/DirList.tsx | 168 +++++++------- islands/DocSearch.tsx | 81 ++++--- islands/FileViewer.tsx | 24 +- islands/MarkdownRenderer.tsx | 19 +- islands/UpList.tsx | 72 +++--- keyout.ts | 29 +-- main.ts | 118 +++++----- routes/_middleware.ts | 29 +-- routes/api/login.ts | 84 +++---- routes/api/logout.ts | 2 +- routes/dir/[...path].tsx | 88 ++++---- routes/doc/index.tsx | 33 ++- routes/fs/[...path].ts | 132 ++++++----- routes/index.tsx | 3 +- routes/login.tsx | 79 ++++--- search.ts | 152 +++++++------ src/client_search.ts | 51 +++-- src/collect.ts | 376 +++++++++++++++---------------- src/media.ts | 115 +++++----- src/readDoc.ts | 51 +++-- src/store/doc.ts | 65 +++--- src/user/db.ts | 22 +- src/user/user.ts | 103 +++++---- static/icon/bootstrap-icons.json | 2 +- tailwind.config.cjs | 2 +- test_data/d/SUMMARY.md | 3 +- test_data/e/SUMMARY.md | 6 +- test_data/f/SUMMARY.md | 2 +- user.ts | 119 +++++----- util/secret.ts | 45 ++-- util/util.ts | 27 ++- 33 files changed, 1174 insertions(+), 1034 deletions(-) diff --git a/README.md b/README.md index 5eefd44..e0bb2c5 100644 --- a/README.md +++ b/README.md @@ -23,4 +23,4 @@ Start the project: deno task start ``` -This will watch the project directory and restart as necessary. \ No newline at end of file +This will watch the project directory and restart as necessary. diff --git a/islands/ContentRenderer.tsx b/islands/ContentRenderer.tsx index e831976..bc12057 100644 --- a/islands/ContentRenderer.tsx +++ b/islands/ContentRenderer.tsx @@ -3,63 +3,67 @@ import MarkdownRenderer from "./MarkdownRenderer.tsx"; import { useEffect, useState } from "preact/hooks"; const TypeToExt = { - "image": new Set([".png", ".jpg", ".jpeg", ".gif", ".svg"]), - "video": new Set([".mp4", ".webm", ".ogg"]), - "audio": new Set([".mp3", ".wav", ".flac"]), - "md": new Set([".md"]), - "text": new Set([".txt"]), - "code": new Set([".json", ".js", ".ts", ".css", ".tsx", ".jsx"]), -} + "image": new Set([".png", ".jpg", ".jpeg", ".gif", ".svg"]), + "video": new Set([".mp4", ".webm", ".ogg"]), + "audio": new Set([".mp3", ".wav", ".flac"]), + "md": new Set([".md"]), + "text": new Set([".txt"]), + "code": new Set([".json", ".js", ".ts", ".css", ".tsx", ".jsx"]), +}; function extToType(ext: string) { - for (const [type, exts] of Object.entries(TypeToExt)) { - if (exts.has(ext)) { - return type; - } + for (const [type, exts] of Object.entries(TypeToExt)) { + if (exts.has(ext)) { + return type; } - return "unknown"; + } + return "unknown"; } -function FetchAndRender(props: {src: string, type: string}){ - const src = props.src; - const ext = extname(src); - const [content, setContent] = useState(""); - useEffect(() => { - fetch(src).then(res => res.text()).then(setContent); - }, [src]); - switch (props.type) { - case "text": - return
{content}
; - case "md": - return ; - case "code": - return
{content}
; - //case "csv": - // return ; - default: - return <>error: invalid type: {props.type} content: {content}; - } +function FetchAndRender(props: { src: string; type: string }) { + const src = props.src; + const ext = extname(src); + const [content, setContent] = useState(""); + useEffect(() => { + fetch(src).then((res) => res.text()).then(setContent); + }, [src]); + switch (props.type) { + case "text": + return
{content}
; + case "md": + return ; + case "code": + return ( +
{content}
+ ); + //case "csv": + // return ; + default: + return <>error: invalid type: {props.type} content: {content}; + } } -export function RenderView(props: {src: string}) { - const src = props.src; - const type = extToType(extname(src)); - switch (type) { - case "text": - case "md": - case "code": - return - //case "csv": - // return ; - case "image": - return ; - case "video": - return