This commit is contained in:
monoid 2023-01-14 03:03:58 +09:00
parent e2ee2c6375
commit 21111549b6
16 changed files with 124 additions and 110 deletions

View File

@ -12,12 +12,17 @@ export function MarkdownRenderer(props: { text: string | undefined }) {
meta = text.slice(4, index);
c = text.slice(index + 4, text.length);
}
return (<>
{meta ? <div>
return (
<>
{meta
? (
<div>
<h2>Meta</h2>
<pre>{meta}</pre>
<hr class="mt-2 mb-2"></hr>
</div> : <div></div>}
</div>
)
: <div></div>}
<div
class="markdown-body"
dangerouslySetInnerHTML={{ __html: marked.parse(c) }}

View File

@ -50,7 +50,7 @@ function FetchAndRender(props: { src: string; type: string }) {
}
}
export function RenderView(props: { src: string, mdbase?: string }) {
export function RenderView(props: { src: string; mdbase?: string }) {
const src = props.src;
const type = extToType(extname(src));
switch (type) {

View File

@ -61,7 +61,9 @@ export function DirList(props: DirListProps) {
{files.map((file) => (
<ListItem
key={file.name}
href={`/dir/${encodePath(join(data.path, file.name))}${(file.isDirectory ? "/" : "")}?pretty`}
href={`/dir/${
encodePath(join(data.path, file.name))
}${(file.isDirectory ? "/" : "")}?pretty`}
icon={file.isDirectory
? "/icon/folder.svg"
: extToIcon(extname(file.name))}

View File

@ -1,11 +1,9 @@
export default function LoginForm({
redirect = "/",
failed = false,
}: { redirect?: string
failed?: boolean }
) {
return <div class="p-4 absolute top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%]
}: { redirect?: string; failed?: boolean }) {
return (
<div class="p-4 absolute top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%]
flex flex-col items-center border-gray-500 border-2 rounded-md
sm:max-w-screen-sm max-w-screen-md">
<img
@ -49,4 +47,5 @@ export default function LoginForm({
</button>
</form>
</div>
);
}

View File

@ -5,7 +5,7 @@ import { encodePath } from "../util/util.ts";
function stairs(path: string) {
if (path === ".") return [];
const uplist = path.split("/").filter(x=> x.length > 0);
const uplist = path.split("/").filter((x) => x.length > 0);
let current = ".";
const stairs = [];
for (const up of uplist) {

View File

@ -4,11 +4,7 @@
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />
import {
Manifest,
ServerContext,
StartOptions,
} from "$fresh/server.ts";
import { Manifest, ServerContext, StartOptions } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts";
import twindPlugin from "$fresh/plugins/twind.ts";
@ -25,7 +21,6 @@ import { prepareDocs } from "./src/store/doc.ts";
import { connectDB } from "./src/user/db.ts";
import * as users from "./src/user/user.ts";
async function startServer(manifest: Manifest, options: StartOptions = {}) {
const ctx = await ServerContext.fromManifest(manifest, options);

View File

@ -1,4 +1,8 @@
import { HandlerContext, MiddlewareHandlerContext, Status } from "$fresh/server.ts";
import {
HandlerContext,
MiddlewareHandlerContext,
Status,
} from "$fresh/server.ts";
import { getCookies } from "http/cookie.ts";
import { verify } from "djwt";
import { prepareSecretKey } from "../util/secret.ts";
@ -17,4 +21,4 @@ export const handler = async (
ctx.state["login"] = null;
}
return await ctx.next();
}
};

View File

@ -28,9 +28,13 @@ export type DirOrFileProps = DirProps | FileProps;
type RenderOption = {
fileInfo?: Deno.FileInfo;
}
};
async function renderFile(req: Request, path: string, { fileInfo }: RenderOption = {}) {
async function renderFile(
req: Request,
path: string,
{ fileInfo }: RenderOption = {},
) {
try {
if (!fileInfo) {
fileInfo = await Deno.stat(path);
@ -82,7 +86,12 @@ async function renderFile(req: Request, path: string, { fileInfo }: RenderOption
}
}
async function renderPage(_req: Request, path: string, ctx: HandlerContext, { fileInfo }: RenderOption = {}) {
async function renderPage(
_req: Request,
path: string,
ctx: HandlerContext,
{ fileInfo }: RenderOption = {},
) {
try {
if (!fileInfo) {
fileInfo = await Deno.stat(path);

View File

@ -5,7 +5,6 @@ export default function Home() {
<>
<Head>
<title>Simple file server</title>
</Head>
<div class="p-4 mx-auto max-w-screen-md">
<img

View File

@ -58,7 +58,9 @@ async function POST(req: Request, _ctx: HandlerContext): Promise<Response> {
<h1> Login Failed </h1>
<p> <a href="/"> Back to Home </a> </p>
<script>
document.location.href = "/login?failed=true&redirect=${url.searchParams.get("redirect")}";
document.location.href = "/login?failed=true&redirect=${
url.searchParams.get("redirect")
}";
</script>
</body>
</html>`,

View File

@ -12,9 +12,9 @@ export const handler = async (
status: Status.Found,
headers: {
Location: `/login?redirect=${encodeURIComponent(req.url)}`,
}
},
});
}
}
return await ctx.next();
}
};

View File

@ -11,8 +11,7 @@ tags: ["한글", "테스트"]
2. asdf
3. sdf
* a
* b
* c
* d
- a
- b
- c
- d