From 2a0f022e3f66701459a9c2429fb2fe8b2722ef4b Mon Sep 17 00:00:00 2001 From: zoop Date: Tue, 8 Sep 2026 19:29:17 -0400 Subject: [PATCH] set up for matrix --- astro.config.mjs | 7 -- public/.well-known/matrix/client | 1 + public/.well-known/matrix/server | 1 + public/_headers | 4 + scripts/commit.mjs | 118 +++++++++++++++----------- scripts/gen-cork.mjs | 4 - scripts/gen-favicon.mjs | 4 - scripts/spotify-auth.mjs | 10 --- src/components/Buttons.astro | 28 ++---- src/components/ContactAccordion.astro | 5 -- src/components/ContactFinger.astro | 1 - src/components/CopyText.astro | 1 - src/components/Egg.astro | 2 - src/components/Music.astro | 6 -- src/data/site.ts | 7 -- src/layouts/Base.astro | 6 -- src/lib/content.ts | 8 +- src/lib/md.ts | 10 +-- src/lib/session.ts | 5 +- src/pages/404.astro | 1 - src/pages/api/spotify.json.ts | 7 -- src/pages/notes.astro | 1 - src/pages/projects.astro | 1 - src/scripts/music.ts | 2 - src/styles/global.css | 20 +---- wrangler.jsonc | 7 -- 26 files changed, 86 insertions(+), 181 deletions(-) create mode 100644 public/.well-known/matrix/client create mode 100644 public/.well-known/matrix/server create mode 100644 public/_headers diff --git a/astro.config.mjs b/astro.config.mjs index 28246c9..87eea06 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,22 +1,15 @@ - import { defineConfig } from 'astro/config'; import cloudflare from '@astrojs/cloudflare'; - export default defineConfig({ - - output: 'server', adapter: cloudflare({ - platformProxy: { enabled: true }, }), vite: { server: { watch: { - - ignored: ['**/.wrangler/**', '**/.dev.vars', '**/.mf/**'], }, }, diff --git a/public/.well-known/matrix/client b/public/.well-known/matrix/client new file mode 100644 index 0000000..3bf6cb3 --- /dev/null +++ b/public/.well-known/matrix/client @@ -0,0 +1 @@ +{"m.homeserver":{"base_url":"https://continuwuity.zachy.cc"}} \ No newline at end of file diff --git a/public/.well-known/matrix/server b/public/.well-known/matrix/server new file mode 100644 index 0000000..c5beaa4 --- /dev/null +++ b/public/.well-known/matrix/server @@ -0,0 +1 @@ +{"m.server":"continuwuity.zachy.cc:443"} \ No newline at end of file diff --git a/public/_headers b/public/_headers new file mode 100644 index 0000000..ac52e9c --- /dev/null +++ b/public/_headers @@ -0,0 +1,4 @@ +/.well-known/matrix/* + Content-Type: application/json + Access-Control-Allow-Origin: * + Cache-Control: public, max-age=3600 diff --git a/scripts/commit.mjs b/scripts/commit.mjs index 489fe17..3b01f76 100644 --- a/scripts/commit.mjs +++ b/scripts/commit.mjs @@ -1,24 +1,4 @@ #!/usr/bin/env node - - - - - - - - - - - - - - - - - - - - import { execFileSync } from "node:child_process"; import { @@ -53,7 +33,6 @@ const LOADER_BY_EXT = { ".jsx": "jsx", ".tsx": "tsx", }; - const KW_REGEX = new Set([ "return", "typeof", "instanceof", "in", "of", "yield", "await", "case", "delete", "void", "throw", "new", "do", "else", @@ -77,38 +56,75 @@ process.on("SIGINT", () => { }); - - - - function stripJs(code, { lineComments = true, stats } = {}) { const out = []; const n = code.length; let i = 0; - let state = "code"; - const frames = []; + let state = "code"; + const frames = []; let braceDepth = 0; - let inClass = false; - let lastSig = ""; - let lastWord = ""; + let inClass = false; + let lastSig = ""; + let lastWord = ""; + let lineStart = 0; + let lineContentEnd = 0; + let skipTerminator = false; + + const truncateTo = (idx) => { + out.length = idx; + lastSig = ""; + lastWord = ""; + for (let j = idx - 1; j >= 0; j--) { + const ch = out[j]; + if (/\s/.test(ch)) continue; + lastSig = ch; + let k = j; + while (k >= 0 && /[A-Za-z0-9_$]/.test(out[k])) k--; + lastWord = out.slice(k + 1, j + 1).join(""); + break; + } + }; const emit = (s) => { for (const ch of s) { out.push(ch); - if (/\s/.test(ch)) continue; - lastSig = ch; - if (/[A-Za-z0-9_$]/.test(ch)) lastWord += ch; - else lastWord = ""; + if (ch === "\n") { + lineStart = lineContentEnd = out.length; + } else if (/\s/.test(ch)) { + } else { + lastSig = ch; + if (/[A-Za-z0-9_$]/.test(ch)) lastWord += ch; + else lastWord = ""; + lineContentEnd = out.length; + } } }; + const nextOnLine = (idx) => { + while (idx < n && (code[idx] === " " || code[idx] === "\t" || code[idx] === "\r")) idx++; + if (idx >= n || code[idx] === "\n") return ""; + return code[idx]; + }; + while (i < n) { const c = code[i]; const nx = code[i + 1]; switch (state) { case "code": + if (skipTerminator && (c === "\r" || c === "\n")) { + skipTerminator = false; + if (c === "\r" && nx === "\n") i += 2; + else i++; + break; + } if (c === "/" && nx === "/" && lineComments) { if (stats) stats.removed++; + if (lineContentEnd === lineStart) { + truncateTo(lineStart); + skipTerminator = true; + } else { + truncateTo(lineContentEnd); + } state = "line"; i += 2; } else if (c === "/" && nx === "*") { @@ -154,9 +170,13 @@ function stripJs(code, { lineComments = true, stats } = {}) { } break; - case "line": + case "line": if (c === "\r" || c === "\n") { - if (c === "\r" && nx === "\n") { + if (skipTerminator) { + skipTerminator = false; + if (c === "\r" && nx === "\n") i += 2; + else i++; + } else if (c === "\r" && nx === "\n") { emit("\r\n"); i += 2; } else { @@ -169,11 +189,21 @@ function stripJs(code, { lineComments = true, stats } = {}) { } break; - case "block": + case "block": if (c === "*" && nx === "/") { - emit(" "); i += 2; state = "code"; + if (lineContentEnd === lineStart) { + truncateTo(lineStart); + skipTerminator = nextOnLine(i) === ""; + } else { + truncateTo(lineContentEnd); + const prev = out[lineContentEnd - 1]; + const next = nextOnLine(i); + if (prev !== undefined && next && /[A-Za-z0-9_$'"`]/.test(prev) && /[A-Za-z0-9_$'"`]/.test(next)) { + emit(" "); + } + } } else { i++; } @@ -239,8 +269,6 @@ function stripCss(code, stats) { return stripJs(code, { lineComments: false, stats }); } - - function stripAstro(code, stats, parts) { let rest = code; let head = ""; @@ -304,9 +332,6 @@ function stripAstro(code, stats, parts) { } - - - function collect() { const out = []; const walk = (dir) => { @@ -343,8 +368,6 @@ function stripFile(rel) { return { rel, src, out, stats, parts, changed: src !== out }; } - - async function validate(r) { const problems = []; for (const { code, loader, label } of r.parts) { @@ -365,9 +388,6 @@ async function validate(r) { } - - - async function main() { if (DRY) { console.log("dry run — stripping in memory, touching nothing\n"); @@ -424,8 +444,6 @@ async function main() { try { execFileSync("git", ["add", "-A"], { stdio: "inherit" }); - - let hasChanges = true; try { execFileSync("git", ["diff", "--cached", "--quiet"], { stdio: "pipe" }); diff --git a/scripts/gen-cork.mjs b/scripts/gen-cork.mjs index 2ab5320..be9c37d 100644 --- a/scripts/gen-cork.mjs +++ b/scripts/gen-cork.mjs @@ -12,7 +12,6 @@ function mulberry32(a) { } const rand = mulberry32(20260906); - const shades = [ [0x60, 0x47, 0x2b], [0x6b, 0x4f, 0x30], [0x6b, 0x4f, 0x30], [0x6b, 0x4f, 0x30], @@ -26,10 +25,8 @@ const grid = new Array(W * H); const wrap = (v, m) => ((v % m) + m) % m; const idx = (x, y) => wrap(y, H) * W + wrap(x, W); - for (let i = 0; i < W * H; i++) grid[i] = shades[Math.floor(rand() * shades.length)]; - for (let pass = 0; pass < 3; pass++) { const next = grid.slice(); for (let y = 0; y < H; y++) @@ -43,7 +40,6 @@ for (let pass = 0; pass < 3; pass++) { for (let i = 0; i < W * H; i++) grid[i] = next[i]; } - const dark = [0x40, 0x2e, 0x1b]; const darker = [0x33, 0x24, 0x14]; const light = [0x9c, 0x7c, 0x54]; diff --git a/scripts/gen-favicon.mjs b/scripts/gen-favicon.mjs index 9eb30ca..ae8ec51 100644 --- a/scripts/gen-favicon.mjs +++ b/scripts/gen-favicon.mjs @@ -1,5 +1,3 @@ - - import { execFileSync } from "node:child_process"; import { mkdtempSync, readFileSync, rmSync } from "node:fs"; import { tmpdir } from "node:os"; @@ -14,7 +12,6 @@ try { const pngs = []; for (const s of sizes) { const out = join(tmp, `${s}.png`); - await sharp(svg, { density: 384 }) .resize(s, s, { fit: "contain", background: { r: 0, g: 0, b: 0, alpha: 0 } }) .png() @@ -22,7 +19,6 @@ try { pngs.push(out); } - execFileSync("magick", [...pngs, "public/favicon.ico"], { stdio: "inherit" }); console.log(`wrote public/favicon.ico (${sizes.join(", ")} px)`); } finally { diff --git a/scripts/spotify-auth.mjs b/scripts/spotify-auth.mjs index 6660c16..9c7effd 100644 --- a/scripts/spotify-auth.mjs +++ b/scripts/spotify-auth.mjs @@ -1,12 +1,3 @@ - - - - - - - - - import { createServer } from "node:http"; import { appendFileSync, readFileSync, writeFileSync, existsSync } from "node:fs"; @@ -71,7 +62,6 @@ const server = createServer(async (req, res) => { `SPOTIFY_CLIENT_SECRET=${clientSecret}\n` + `SPOTIFY_REFRESH_TOKEN=${data.refresh_token}\n`; - if (existsSync(".dev.vars")) { const cur = readFileSync(".dev.vars", "utf8").replace(/^SPOTIFY_[A-Z_]+=.*$/gm, "").replace(/\n{3,}/g, "\n\n"); writeFileSync(".dev.vars", cur.trimEnd() + "\n" + block); diff --git a/src/components/Buttons.astro b/src/components/Buttons.astro index f5fea9d..42a604e 100644 --- a/src/components/Buttons.astro +++ b/src/components/Buttons.astro @@ -3,22 +3,19 @@ import { buttons, site } from "../data/site"; import CopyText from "./CopyText.astro"; import Egg from "./Egg.astro"; - const rnd = (i: number, seed: number) => { const x = Math.sin((i + 1) * 127.1 + seed * 311.7) * 43758.5453; return x - Math.floor(x); }; const r1 = (i: number, seed: number, spread: number) => Math.round((rnd(i, seed) - 0.5) * spread * 100) / 100; - const PINS = [ - ["#ff9a9a", "#d64545", "#7a1f1f"], - ["#9ec9ff", "#4a7fd6", "#1f3f7a"], - ["#ffd98a", "#e0a83c", "#8a5f16"], - ["#a8e6b0", "#4caf68", "#1f5c33"], - ["#d9b8ff", "#9a6cff", "#4a2f8a"], + ["#ff9a9a", "#d64545", "#7a1f1f"], + ["#9ec9ff", "#4a7fd6", "#1f3f7a"], + ["#ffd98a", "#e0a83c", "#8a5f16"], + ["#a8e6b0", "#4caf68", "#1f5c33"], + ["#d9b8ff", "#9a6cff", "#4a2f8a"], ]; - const scatter = (i: number) => { const [pl, pb, pd] = PINS[i % PINS.length]; return `--t:${r1(i, 1, 12)}deg;--x:${r1(i, 2, 14)}px;--y:${r1(i, 3, 12)}px;--pl:${pl};--pb:${pb};--pd:${pd}`; @@ -132,7 +129,6 @@ const badgeUrl = `https://${site.domain}/badges/zachy.gif`;