Web host: give the page a moon favicon
CI / test (push) Failing after 2m59s

- Add favicon.svg: a crescent moon on a dark rounded tile
- Link it from host/web/index.html as the page icon
- serve.mjs: allow /favicon.svg through the path filter and serve it as image/svg+xml
This commit is contained in:
nandi committed 2026-11-27 16:14:41 -08:00
1 parent 1871d50a3e
commit c1c4349584
3 files changed
+32 -2

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
<defs>
<linearGradient id="sky" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-color="#16213e"/>
<stop offset="100%" stop-color="#0b1020"/>
</linearGradient>
<linearGradient id="moon" x1="0.15" y1="0.1" x2="0.85" y2="0.9">
<stop offset="0%" stop-color="#eef4ff"/>
<stop offset="48%" stop-color="#a5bdff"/>
<stop offset="100%" stop-color="#7c9cff"/>
</linearGradient>
<clipPath id="tile">
<rect width="64" height="64" rx="14"/>
</clipPath>
</defs>
<g clip-path="url(#tile)">
<rect width="64" height="64" fill="url(#sky)"/>
<circle cx="33" cy="32" r="36" fill="#7c9cff" fill-opacity="0.06"/>
<circle cx="33" cy="32" r="29" fill="#7c9cff" fill-opacity="0.09"/>
<circle cx="33" cy="32" r="23" fill="#7c9cff" fill-opacity="0.13"/>
<path
d="M 30.66 13.15 A 19 19 0 1 0 50.44 39.53 A 16.5 16.5 0 0 1 30.66 13.15 Z"
fill="url(#moon)"/>
</g>
<rect x="0.75" y="0.75" width="62.5" height="62.5" rx="13.25" fill="none" stroke="#7c9cff" stroke-opacity="0.24" stroke-width="1.5"/>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

+3 -2
View File
@@ -7,7 +7,7 @@ import { join, extname, normalize } from 'node:path';
import { fileURLToPath } from 'node:url';
const ROOT = join(fileURLToPath(import.meta.url), '..', '..');
const MIME = { '.html': 'text/html', '.mjs': 'text/javascript', '.js': 'text/javascript', '.json': 'application/json', '.wasm': 'application/wasm' };
const MIME = { '.html': 'text/html', '.mjs': 'text/javascript', '.js': 'text/javascript', '.json': 'application/json', '.wasm': 'application/wasm', '.svg': 'image/svg+xml' };
const ALLOWED = ['host/', 'config/', 'build/'];
export function serve(port = 0) {
@@ -16,7 +16,8 @@ export function serve(port = 0) {
let p = decodeURIComponent(new URL(req.url, 'http://x').pathname);
if (p === '/') p = '/host/web/index.html';
const rel = normalize(p).replace(/^\/+/, '');
if (rel.includes('..') || !ALLOWED.some((a) => rel.startsWith(a)) || rel.startsWith('host/node_modules')) { res.writeHead(404).end('not found'); return; }
const isAllowed = rel === 'favicon.svg' || ALLOWED.some((a) => rel.startsWith(a));
if (rel.includes('..') || !isAllowed || rel.startsWith('host/node_modules')) { res.writeHead(404).end('not found'); return; }
const body = await readFile(join(ROOT, rel));
res.writeHead(200, { 'content-type': MIME[extname(rel)] ?? 'application/octet-stream', 'cache-control': 'no-store' }).end(body);
} catch { res.writeHead(404).end('not found'); }
+1
View File
@@ -3,6 +3,7 @@
<head>
<meta charset="utf-8">
<title>chandra</title>
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<style>
html, body { margin: 0; background: #05070d; color: #aab; font: 12px/1.4 system-ui, sans-serif; }
#screen { display: block; margin: 0 auto; max-width: 100vw; }