restructured and simplified favicon
This commit is contained in:
parent
259ccfe851
commit
08c127f637
28 changed files with 320 additions and 260 deletions
0
src/client/.gitkeep
Normal file
0
src/client/.gitkeep
Normal file
25
src/images.d.ts
vendored
Normal file
25
src/images.d.ts
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
|
||||
declare module '*.png' {
|
||||
const value: Uint8Array<ArrayBufferLike>;
|
||||
// const file: Bun.BunFile;
|
||||
// export { file };
|
||||
export default value;
|
||||
}
|
||||
declare module '*.jpeg' {
|
||||
const value: Uint8Array<ArrayBufferLike>;
|
||||
// const file: Bun.BunFile;
|
||||
// export { file };
|
||||
export default value;
|
||||
}
|
||||
declare module '*.jpg' {
|
||||
const value: Uint8Array<ArrayBufferLike>;
|
||||
// const file: Bun.BunFile;
|
||||
// export { file };
|
||||
export default value;
|
||||
}
|
||||
declare module '*.webp' {
|
||||
const value: Uint8Array<ArrayBufferLike>;
|
||||
// const file: Bun.BunFile;
|
||||
// export { file };
|
||||
export default value;
|
||||
}
|
112
src/index.html
112
src/index.html
File diff suppressed because one or more lines are too long
110
src/index.ts
110
src/index.ts
|
@ -0,0 +1,110 @@
|
|||
import homepage from "@routes/index.html";
|
||||
import favicon from "@static/favicon.png";
|
||||
import robotsTxt from "@static/robots.txt";
|
||||
import sitemapTxt from "@static/sitemap.txt";
|
||||
import { env } from "bun";
|
||||
import path from "path";
|
||||
|
||||
const development = env.NODE_ENV !== "production";
|
||||
|
||||
const faviconInit = { headers: new Headers({ 'Content-Type': 'image/png' }) };
|
||||
|
||||
let htmlFiles: Set<string>;
|
||||
let scriptFiles: Set<string>;
|
||||
let cssFiles: Set<string>;
|
||||
|
||||
const globScanOptions: Bun.GlobScanOptions = {
|
||||
absolute: true,
|
||||
};
|
||||
|
||||
async function load() {
|
||||
await Bun.$`bun run src/server/build.ts`;
|
||||
const tempHtml: Set<string> = new Set();
|
||||
const userHtml = new Bun.Glob("./build/*.html");
|
||||
for await (const filePath of userHtml.scan(globScanOptions)) {
|
||||
tempHtml.add(path.parse(filePath).base);
|
||||
}
|
||||
htmlFiles = tempHtml;
|
||||
|
||||
const tempScripts: Set<string> = new Set();
|
||||
const userJs = new Bun.Glob("./build/*.user.js");
|
||||
for await (const filePath of userJs.scan(globScanOptions)) {
|
||||
tempScripts.add(path.parse(filePath).base);
|
||||
}
|
||||
scriptFiles = tempScripts;
|
||||
|
||||
const tempStyles: Set<string> = new Set();
|
||||
const css = new Bun.Glob("./build/*.user.css");
|
||||
for await (const filePath of css.scan(globScanOptions)) {
|
||||
tempStyles.add(path.parse(filePath).base);
|
||||
}
|
||||
cssFiles = tempStyles;
|
||||
}
|
||||
await load();
|
||||
|
||||
Bun.serve({
|
||||
routes: {
|
||||
"/": homepage,
|
||||
"/robots.txt": new Response(robotsTxt, {
|
||||
headers: { "Content-Type": "text/plain" },
|
||||
}),
|
||||
"/sitemap.txt": new Response(sitemapTxt, {
|
||||
headers: { "Content-Type": "text/plain" },
|
||||
}),
|
||||
"/favicon.ico": new Response(favicon, faviconInit),
|
||||
"/health": new Response("OK"),
|
||||
"/html/:html": async (req) => {
|
||||
const html = req.params.html.toLocaleLowerCase();
|
||||
|
||||
if (!htmlFiles.has(html)) {
|
||||
return new Response("Not found", { status: 404 });
|
||||
}
|
||||
|
||||
const file = Bun.file(`./build/${html}`);
|
||||
|
||||
return new Response(file, {
|
||||
headers: { "Content-Type": "text/css" },
|
||||
});
|
||||
},
|
||||
"/scripts/:script": async (req) => {
|
||||
const script = req.params.script.toLocaleLowerCase();
|
||||
|
||||
if (!scriptFiles.has(script)) {
|
||||
return new Response("Not found", { status: 404 });
|
||||
}
|
||||
|
||||
const file = Bun.file(`./build/${script}`);
|
||||
|
||||
return new Response(file, {
|
||||
headers: { "Content-Type": "application/javascript" },
|
||||
});
|
||||
},
|
||||
"/styles/:style": async (req) => {
|
||||
const style = req.params.style.toLocaleLowerCase();
|
||||
|
||||
if (!cssFiles.has(style)) {
|
||||
return new Response("Not found", { status: 404 });
|
||||
}
|
||||
|
||||
const file = Bun.file(`./build/${style}`);
|
||||
|
||||
return new Response(file, {
|
||||
headers: { "Content-Type": "text/css" },
|
||||
});
|
||||
},
|
||||
},
|
||||
development,
|
||||
// async fetch(req, server) {
|
||||
// return new Response("Not found", { status: 404 });
|
||||
// },
|
||||
});
|
||||
|
||||
if (development) {
|
||||
setInterval(async () => {
|
||||
try {
|
||||
await load();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}, 2500);
|
||||
}
|
108
src/routes/index.html
Normal file
108
src/routes/index.html
Normal file
|
@ -0,0 +1,108 @@
|
|||
<!doctype html>
|
||||
<html lang="en" class="min-h-dvh">
|
||||
<head>
|
||||
<title>Userscripts - skaarup.dev</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" href="@static/favicon.png" />
|
||||
<link rel="stylesheet" href="./index.css" />
|
||||
</head>
|
||||
|
||||
<body
|
||||
class="min-h-dvh bg-gray-950 bg-cover bg-fixed bg-center bg-no-repeat font-mono text-pretty text-gray-100 selection:bg-pink-600 selection:text-gray-200"
|
||||
>
|
||||
<a
|
||||
href="#main-content"
|
||||
class="absolute top-0 left-0 z-50 rounded-b-sm bg-pink-600 px-1 pt-0.5 text-xs text-gray-100 not-focus:sr-only focus:outline-none"
|
||||
>
|
||||
Skip to main content
|
||||
</a>
|
||||
<header class="content sticky top-0 z-20 grid bg-gray-950 py-2 font-mono sm:px-2">
|
||||
<div class="col-[content] grid grid-cols-3">
|
||||
<div class="flex items-center gap-8"></div>
|
||||
|
||||
<div class="flex items-center justify-center">
|
||||
<a
|
||||
href="/"
|
||||
class="block text-center underline decoration-transparent transition-colors hover:decoration-pink-600"
|
||||
>Userscripts</a>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-end gap-2 py-2 md:gap-4">
|
||||
<a
|
||||
class="block"
|
||||
href="https://git.skaarup.dev/nikiskaarup/userscripts"
|
||||
target="_blank"
|
||||
referrerpolicy="no-referrer"
|
||||
>
|
||||
<span class="sr-only">git.skaarup.dev/nikiskaarup/userscripts</span>
|
||||
<svg
|
||||
class="aspect-square h-8"
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 98 96"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
clip-rule="evenodd"
|
||||
d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"
|
||||
fill="#fff"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main id="main-content">
|
||||
<article class="content grid">
|
||||
<header class="col-[content] flex flex-col gap-2 py-8">
|
||||
<h1 class="text-center text-3xl">Typing..</h1>
|
||||
</header>
|
||||
|
||||
<section class="content bg-neutral col-[content] grid gap-2 py-8">
|
||||
<h2 class="scroll-m-24 text-2xl" id="userscripts">
|
||||
<a href="#userscripts"> Userscripts </a>
|
||||
</h2>
|
||||
|
||||
<ul class="flex list-inside list-disc flex-row gap-2">
|
||||
<li>
|
||||
<a
|
||||
href="/scripts/manga-reading.user.js"
|
||||
class="underline decoration-indigo-500 transition-colors hover:decoration-pink-600"
|
||||
target="_blank"
|
||||
referrerpolicy="no-referrer"
|
||||
>Manga Reading</a
|
||||
>
|
||||
-
|
||||
<a
|
||||
href="https://git.skaarup.dev/nikiskaarup/userscripts"
|
||||
class="underline decoration-indigo-500 transition-colors hover:decoration-pink-600"
|
||||
target="_blank"
|
||||
referrerpolicy="no-referrer"
|
||||
>Repository</a
|
||||
>
|
||||
- Adds keyboard navigation to manganato like sites, and
|
||||
<a
|
||||
href="https://git.skaarup.dev/nikiskaarup/progress-tracker-api-v2"
|
||||
class="underline decoration-indigo-500 transition-colors hover:decoration-pink-600"
|
||||
target="_blank"
|
||||
referrerpolicy="no-referrer"
|
||||
>progress</a
|
||||
>
|
||||
<a
|
||||
href="https://git.skaarup.dev/nikiskaarup/progress-tracker-v3"
|
||||
class="underline decoration-indigo-500 transition-colors hover:decoration-pink-600"
|
||||
target="_blank"
|
||||
referrerpolicy="no-referrer"
|
||||
>tracking</a
|
||||
>
|
||||
updated via hotkeys
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
</article>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
113
src/server.ts
113
src/server.ts
|
@ -1,113 +0,0 @@
|
|||
import { env } from "bun";
|
||||
import homepage from "./index.html";
|
||||
import robotsTxt from "./static/robots.txt";
|
||||
import sitemapTxt from "./static/sitemap.txt";
|
||||
// @ts-ignore ts2307
|
||||
import icon from "./static/favicon.png" with { type: "file" };
|
||||
import path from "path";
|
||||
|
||||
const favicon = await Bun.file(icon).bytes();
|
||||
|
||||
let htmlFiles: Set<string>;
|
||||
let scriptFiles: Set<string>;
|
||||
let cssFiles: Set<string>;
|
||||
|
||||
const development = env.NODE_ENV !== "production";
|
||||
|
||||
const globScanOptions: Bun.GlobScanOptions = {
|
||||
absolute: true,
|
||||
};
|
||||
|
||||
async function load() {
|
||||
await Bun.$`bun run src/build.ts`;
|
||||
const tempHtml: Set<string> = new Set();
|
||||
const userHtml = new Bun.Glob("./build/*.html");
|
||||
for await (const filePath of userHtml.scan(globScanOptions)) {
|
||||
tempHtml.add(path.parse(filePath).base);
|
||||
}
|
||||
htmlFiles = tempHtml;
|
||||
|
||||
const tempScripts: Set<string> = new Set();
|
||||
const userJs = new Bun.Glob("./build/*.user.js");
|
||||
for await (const filePath of userJs.scan(globScanOptions)) {
|
||||
tempScripts.add(path.parse(filePath).base);
|
||||
}
|
||||
scriptFiles = tempScripts;
|
||||
|
||||
const tempStyles: Set<string> = new Set();
|
||||
const css = new Bun.Glob("./build/*.user.css");
|
||||
for await (const filePath of css.scan(globScanOptions)) {
|
||||
tempStyles.add(path.parse(filePath).base);
|
||||
}
|
||||
cssFiles = tempStyles;
|
||||
}
|
||||
await load();
|
||||
|
||||
Bun.serve({
|
||||
routes: {
|
||||
"/": homepage,
|
||||
"/robots.txt": new Response(robotsTxt, {
|
||||
headers: { "Content-Type": "text/plain" },
|
||||
}),
|
||||
"/sitemap.txt": new Response(sitemapTxt, {
|
||||
headers: { "Content-Type": "text/plain" },
|
||||
}),
|
||||
"/favicon.ico": new Response(favicon, {
|
||||
headers: { "Content-Type": "image/png" },
|
||||
}),
|
||||
"/health": new Response("OK"),
|
||||
"/html/:html": async (req) => {
|
||||
const html = req.params.html.toLocaleLowerCase();
|
||||
|
||||
if (!htmlFiles.has(html)) {
|
||||
return new Response("Not found", { status: 404 });
|
||||
}
|
||||
|
||||
const file = Bun.file(`./build/${html}`);
|
||||
|
||||
return new Response(file, {
|
||||
headers: { "Content-Type": "text/css" },
|
||||
});
|
||||
},
|
||||
"/scripts/:script": async (req) => {
|
||||
const script = req.params.script.toLocaleLowerCase();
|
||||
|
||||
if (!scriptFiles.has(script)) {
|
||||
return new Response("Not found", { status: 404 });
|
||||
}
|
||||
|
||||
const file = Bun.file(`./build/${script}`);
|
||||
|
||||
return new Response(file, {
|
||||
headers: { "Content-Type": "application/javascript" },
|
||||
});
|
||||
},
|
||||
"/styles/:style": async (req) => {
|
||||
const style = req.params.style.toLocaleLowerCase();
|
||||
|
||||
if (!cssFiles.has(style)) {
|
||||
return new Response("Not found", { status: 404 });
|
||||
}
|
||||
|
||||
const file = Bun.file(`./build/${style}`);
|
||||
|
||||
return new Response(file, {
|
||||
headers: { "Content-Type": "text/css" },
|
||||
});
|
||||
},
|
||||
},
|
||||
development,
|
||||
// async fetch(req, server) {
|
||||
// return new Response("Not found", { status: 404 });
|
||||
// },
|
||||
});
|
||||
|
||||
if (development) {
|
||||
setInterval(async () => {
|
||||
try {
|
||||
await load();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}, 2500);
|
||||
}
|
0
src/server/.gitkeep
Normal file
0
src/server/.gitkeep
Normal file
|
@ -26,7 +26,7 @@ const globScanOptions: Bun.GlobScanOptions = {
|
|||
absolute: true,
|
||||
};
|
||||
|
||||
const userscripts = new Bun.Glob("./src/userscripts/*/*.user.ts");
|
||||
const userscripts = new Bun.Glob("./src/server/userscripts/*/*.user.ts");
|
||||
for await (const absPath of userscripts.scan(globScanOptions)) {
|
||||
const parsed = path.parse(absPath);
|
||||
console.log(`Building ${parsed.base}...`);
|
||||
|
@ -63,7 +63,7 @@ for await (const absPath of userscripts.scan(globScanOptions)) {
|
|||
await swapHtmlImports(fileText, `./build/${parsed.name}.js`);
|
||||
}
|
||||
|
||||
const styles = new Bun.Glob("./src/userscripts/*/*.user.css");
|
||||
const styles = new Bun.Glob("./src/server/userscripts/*/*.user.css");
|
||||
for await (const absPath of styles.scan(globScanOptions)) {
|
||||
const name = path.parse(absPath).base;
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue