From 9ba8d6f075418544599b1d633061024bc343088a Mon Sep 17 00:00:00 2001 From: clover caruso Date: Mon, 19 Oct 2026 02:12:08 -0700 Subject: [PATCH] chore: i forgot --- framework/font.ts | 3 +- framework/lib/sitegen.ts | 5 +-- lib/subprocess.ts | 27 +++++++++------- src/bin/deploy.ts | 25 +++----------- src/bin/download-db.ts | 32 +++++++++--------- src/bin/trigger-live-rebuild.ts | 10 ++++++ src/blog/tags/blog-layout.marko | 2 +- src/cspell.ts | 1 + src/databases.test.ts | 2 +- src/file-viewer/tags/media-panel.marko | 4 ++- src/global.css | 10 +++--- src/pages/dream.mdo | 16 +++++---- src/pages/in-the-summer.marko | 2 +- src/pages/index.css | 27 ++++++++++------ src/pages/index.marko | 14 ++++---- src/paperclover.net.ts | 45 ++++++++++++++++++++++---- src/q+a/backend.ts | 4 +-- src/q+a/pages/q+a.marko | 2 +- src/q+a/questions.css | 8 +---- src/q+a/tags/question-form.marko | 4 --- src/q+a/tags/question-layout.marko | 8 ++++- src/site.ts | 2 +- src/tags/photo-grid.css | 4 +++ 23 files changed, 150 insertions(+), 107 deletions(-) create mode 100644 src/bin/trigger-live-rebuild.ts diff --git a/framework/font.ts b/framework/font.ts index b4e46bc43fcc3faadca8179e9ef8618f7cf959d4..1bfa21126cacb0f44522aff75c8067b40222b8ea 100644 --- a/framework/font.ts +++ b/framework/font.ts @@ -4,8 +4,9 @@ * none of them. the build keeps what was found, so nothing is fetched twice. */ export async function fetchFont(b: incremental.Build, name: string, sources: readonly string[]) { - using _ = b.start(`fetch ${name}`); + using node = b.start(`fetch ${name}`); for (const source of sources) { + using _ = node.start(`try ${source}`); if (source.startsWith("https://")) { const response = await fetch(source).catch(() => null); if (response?.ok) return new Uint8Array(await response.arrayBuffer()); diff --git a/framework/lib/sitegen.ts b/framework/lib/sitegen.ts index 69ded1d11a0b6eebc461608e7f14312a48e0d5f1..772614f1d90d2e5f0e6e2fd691c3aef07ee36dd0 100644 --- a/framework/lib/sitegen.ts +++ b/framework/lib/sitegen.ts @@ -45,14 +45,11 @@ export type FontVars = Record; export type FontVariableAxis = number | [min: number, max: number]; export type FontRange = string | number | { start: number; end: number }; -// TODO: self-host plausible for extra privacy. i am in a rush as i write this -// TODO: properly locate this constant in `site.ts` -// // I have this so I can see if the blog is actually seen by people. And for // understanding where paperclover.net gets its load for. When I need to scale // large enough, analytics will determine the location of the second web // hosting node. -export const analytics = ` +export const analytics = ` `; export function wrapDocument({ diff --git a/lib/subprocess.ts b/lib/subprocess.ts index 845b662dd418db56b658aeadc79b3c5988acf58c..31c1c61019cabad998728db4c878b7417ac26c78 100644 --- a/lib/subprocess.ts +++ b/lib/subprocess.ts @@ -248,17 +248,7 @@ interface ProcessLookup { command: string; } -/** - * open a file in the text editor that is already in front of the user, at a - * line and column, a port of vite's `launch-editor`. - * - * `file` is a path, a path with `:line:column` appended, or a `file://` url. - * resolves once the editor process exits, which is immediate for the editors - * that hand the file to a window already open. - * - * what happens to a path that does not exist is up to the editor; most open an - * empty buffer for it. - */ +/** opens a file in the logically configured text/code editor */ export async function launchEditor(file: string, options: EditorOptions = {}): Promise { const { fileName, line: fileLine, column: fileColumn } = parsePosition(file); const line = options.line ?? fileLine; @@ -304,6 +294,21 @@ export async function launchEditor(file: string, options: EditorOptions = {}): P } } +/** opens a url in the default browser */ +export async function launchBrowser(url: string) { + switch (process.platform) { + case "darwin": + await execute(["open", url]); + break; + case "win32": + await execute(["cmd.exe", "/c", "start", "\"\"", url]); + break; + default: + await execute(["xdg-open", url]); + break; + } +} + export interface EditorOptions { /** * the editor to run, as a shell command so that arguments may be included. diff --git a/src/bin/deploy.ts b/src/bin/deploy.ts index d48d1f020bc9ccac194871778f1591a61dde0a5d..00fb3d720d65f5c5a5c9b823f77688786d7900e1 100644 --- a/src/bin/deploy.ts +++ b/src/bin/deploy.ts @@ -20,9 +20,7 @@ export async function main(graph: incremental.Graph) { await downloadDb.main().catch((error) => console.warn("building with the local databases:", error)); // any error stops the deploy, including the ones a build can still be served with - await graph.incrementalBuild({ progress, buildAndWriteOutput }); - // the cache is copied as one file - graph.db.sql.exec("pragma wal_checkpoint(truncate);"); + await graph.incrementalBuild({ progress, buildAndWriteOutput: (b) => buildAndWriteOutput(b, "local build") }); await rsync.spawn({ cwd, @@ -31,6 +29,7 @@ export async function main(graph: incremental.Graph) { "-r", "--delete", "--exclude=node_modules", + "cspell.json", "run.js", "package.json", "package-lock.json", @@ -41,29 +40,13 @@ export async function main(graph: incremental.Graph) { ], progress: progress.start("copy site files"), }); - await rsync.spawn({ - cwd, - args: [ - "-a", - ".clover/incremental.db", - `${remote}:~/paperclover.net/.clover/incremental.db.next`, - ], - progress: progress.start("copy build cache"), - }); await subprocess.spawn([ "ssh", + "-t", remote, "cd paperclover.net && " + `PATH=${node}:$PATH npm i && ` - + "pm2 stop site && " - // the server leaves a write-ahead log beside the cache it had open, which is not this cache's - + "rm -f .clover/incremental.db-wal .clover/incremental.db-shm && " - + "mv .clover/incremental.db.next .clover/incremental.db && " - // started again with this checkout's command. secrets are in the server's `.env` - + "pm2 delete site && " - + `pm2 start run.js --name site --interpreter ${node}/node --kill-timeout 5000 ` - + `--node-args="--env-file=.env --experimental-vm-modules --no-warnings" -- --prod && ` - + "pm2 save", + + node + "/node run trigger-live-rebuild http://localhost:10000" ], { stdin: "inherit" }).wait(); } diff --git a/src/bin/download-db.ts b/src/bin/download-db.ts index eb55512d36cf35f9006c56fc39c954c1c18069e9..d841888a681332be922c67117cb424cba4a70062 100644 --- a/src/bin/download-db.ts +++ b/src/bin/download-db.ts @@ -5,22 +5,22 @@ const site = "https://paperclover.net"; const token = process.env.CLOVER_SOT_KEY ?? null; export async function main() { - for (const name of ["cache.sqlite", "questions.sqlite"]) { - using node = progress.start(`download ${name}`, { units: "bytes" }); - const response = await fetch(`${site}/db/${name}`, { headers: token ? { Authorization: token } : {} }); - if (!response.ok || !response.body) { - throw new Error(`${site}/db/${name} responded ${response.status} ${response.statusText}`); - } - node.total = Number(response.headers.get("Content-Length")); - await getDatabase(name).restore(response.body.pipeThrough( - new TransformStream({ - transform(chunk, controller) { - node.value += chunk.byteLength; - controller.enqueue(chunk); - }, - }), - )); - } + // for (const name of ["cache.sqlite", "questions.sqlite"]) { + // using node = progress.start(`download ${name}`, { units: "bytes" }); + // const response = await fetch(`${site}/db/${name}`, { headers: token ? { Authorization: token } : {} }); + // if (!response.ok || !response.body) { + // throw new Error(`${site}/db/${name} responded ${response.status} ${response.statusText}`); + // } + // node.total = Number(response.headers.get("Content-Length")); + // await getDatabase(name).restore(response.body.pipeThrough( + // new TransformStream({ + // transform(chunk, controller) { + // node.value += chunk.byteLength; + // controller.enqueue(chunk); + // }, + // }), + // )); + // } } import { getDatabase } from "#sitegen/drizzle"; diff --git a/src/bin/trigger-live-rebuild.ts b/src/bin/trigger-live-rebuild.ts new file mode 100644 index 0000000000000000000000000000000000000000..b85c369458e7f2c2fcbe7e961c1b5bc0f86fd620 --- /dev/null +++ b/src/bin/trigger-live-rebuild.ts @@ -0,0 +1,10 @@ +export async function main() { + const response = await fetch("http://localhost:10000/.sitegen/rebuild"); + if (!response.ok) throw new Error(response.statusText); + using node = progress.start("remote build"); + using remoteNode = progress.decodeByteStream(UNWRAP(response.body), node); + await remoteNode.once("end"); +} + +import { UNWRAP } from "@clo/lib/assert"; +import * as progress from "@clo/lib/progress"; diff --git a/src/blog/tags/blog-layout.marko b/src/blog/tags/blog-layout.marko index 5fdbe78fc1d750ed925aa2a1a9c88001ede282d0..1ce3a76ae5eb413b00cf8d523d55d7d85ef0092a 100644 --- a/src/blog/tags/blog-layout.marko +++ b/src/blog/tags/blog-layout.marko @@ -52,7 +52,7 @@ export interface Context {
- ${t.return} + [${t.return}]

${title}

${description}

diff --git a/src/cspell.ts b/src/cspell.ts index e6041e95c684d582e0f7b8a39b0f7ee9978e6046..95812eb4577b5de698ddb634c9419a70ba126c71 100644 --- a/src/cspell.ts +++ b/src/cspell.ts @@ -18,6 +18,7 @@ export async function spellCheck(uri: string, text: string, settings: ts.DeepRea for (const errors of result.dictionaryErrors?.values() ?? []) { for (const error of errors) throw error; } + // meowd if (!result.checked) throw new Error(`CSpell did not check ${uri}.`); const { settingsUsed } = result; const issues = result.issues.filter((issue) => { diff --git a/src/databases.test.ts b/src/databases.test.ts index 0dc5f970856951b8bc9534c370d2287771f7c7dc..106fbbc2a2914a347422a4d512d5612b5f6950e6 100644 --- a/src/databases.test.ts +++ b/src/databases.test.ts @@ -10,7 +10,7 @@ const dir = vi.hoisted(() => { return dir; }); afterAll(() => fs.rmSync(dir, { recursive: true, force: true })); - +// for (const path of ["/2025/song.mp3", "/2025/.date", "/_unlisted/font.ttf", "/friends/2025/photo.jpg"]) { const file = mediaFiles.createFile({ path, diff --git a/src/file-viewer/tags/media-panel.marko b/src/file-viewer/tags/media-panel.marko index 9d312f43c1f58c3f17c8cca0904cc0fe86fa3965..8086045f04a10d22326890c36bad1cf7ce0e52e9 100644 --- a/src/file-viewer/tags/media-panel.marko +++ b/src/file-viewer/tags/media-panel.marko @@ -128,7 +128,9 @@ static const cotyledonEndingFile = "/2024/for everyone"; diff --git a/src/global.css b/src/global.css index b263baf4115615ec9f832909f3e288bb87450847..4d7a069f0f4e20e6875ba038f05bb2ecc840c684 100644 --- a/src/global.css +++ b/src/global.css @@ -128,15 +128,17 @@ a:where([href]:not(.custom)) { margin: -0.2em -0.3em; padding: 0.2em 0.3em; border-radius: 4px; + text-decoration: underline; + text-decoration-color: var(--primary); + text-decoration-color: rgb(from var(--primary) r g b / 0.45); + text-decoration-thickness: 1.5px; + text-underline-offset: 1.5px; &:hover { - text-decoration: underline; - /* font-weight: 600; */ color: var(--primary); color: lch(from var(--primary) calc(l) calc(c + 30) h); + text-decoration-color: lch(from var(--primary) calc(l) calc(c + 30) h); } &:active { - text-decoration: underline; - /* font-weight: 600; */ text-decoration: none; color: black; background-color: var(--primary); diff --git a/src/pages/dream.mdo b/src/pages/dream.mdo index 69f3591933d804abc22d6edf1904db82686caa00..0b3644ab3fb7f03b8bea82524abf7dc88f65a47c 100644 --- a/src/pages/dream.mdo +++ b/src/pages/dream.mdo @@ -10,14 +10,16 @@ meta: # my life's dream if i could make art (music and videos) full time, forever, i would take that -life in a heartbeat, never looking back. this has happened once in may 2025 for -a month (an interlude between jobs). i called this **ART MONTH**, and it was the -best month of my life. i want to do it again, for longer: **ART DECADE**. or if it was possible, **ART -FOREVER**. the desire has been in me since age 16 or so. i don't want to work in -the music industry, and i don't want to be contingent on my music being -profitable. i want to make my art, the way i envision it. +life in a heartbeat, never looking back. with a world confused on the meaning, i +decided that *this*, dedicating to the arts, would be *the* meaning of my life. +this choice was set at around age 15. so far, i've had one time where i could, +without worry, execute on this dream full time, in may 2025 for a month. i +called this **ART MONTH**, and it was the best month of my life. i want to do it +again, for longer: **ART DECADE**. or if it was possible, **ART FOREVER**. i +don't want to work in the music industry, and i don't want to be contingent on +my music being profitable. i want to make my art, the way i envision it, alone. -currently, i have a stupid tech job, which i am exceptionally good at. too good +currently, my time is taken by a tech job, which i am exceptionally good at. too good at it maybe. my knowledge and experience was built from doing crazy things in school and is the reason my colleagues rely on me for accurate technical advice. i'm the one to attempt and succeed with large, technically intricate projects. diff --git a/src/pages/in-the-summer.marko b/src/pages/in-the-summer.marko index 30c143ca5f0d55e5181ef491dbb8312b07328736..2141ebf745a755618020b08e1cc4a546cfcd7707 100644 --- a/src/pages/in-the-summer.marko +++ b/src/pages/in-the-summer.marko @@ -8,7 +8,7 @@ export const theme = { import "./in-the-summer.css";
- +

in the summer

diff --git a/src/pages/index.css b/src/pages/index.css index f22b304b3c42744dc507371b9ada7847a1c9ecf5..9a9a3b8a2f4f33eb8c383d0d14593a637a3f0503 100644 --- a/src/pages/index.css +++ b/src/pages/index.css @@ -5,22 +5,33 @@ main { justify-content: center; align-items: center; min-height: 100vh; + & > div { width: 450px; margin: auto; } } h1 { - margin: -0.5rem 0 3rem 0; - font-size: 5rem; - font-weight: 400; + margin: 0; + font-size: 4rem; + font-weight: 100; + color: #430e8a; + text-decoration: underline; + text-decoration-color: #430e8a44; + text-decoration-style: wavy; + text-underline-offset: 8px; } h2 { font-size: 1.15rem; - text-decoration: underline; - color: #000e; + background-color: #003a; + outline: 4px solid #003c; + padding: 2px 4px; + width: max-content; + color: #fff; + margin-top: 32px; + margin-bottom: 8px; } -p, h2 { +p { margin: 0.75rem 0rem; } .section-list { @@ -44,10 +55,6 @@ p, h2 { .link-list a { white-space: nowrap; } -hr { - width: 100%; - border: 1px solid #000b; -} .cite { color: inherit; text-decoration-line: underline; diff --git a/src/pages/index.marko b/src/pages/index.marko index c60b9500c64f6fc96118f5d3bfe4132ff12f4967..21dd2b4fe58beef635d3593de51dd7013cca8306 100644 --- a/src/pages/index.marko +++ b/src/pages/index.marko @@ -1,7 +1,7 @@ import type { Meta } from "#meta"; import "./index.css"; -export const theme = { bg: "#fff", fg: "#666" }; +export const theme = { bg: "#fff0fb", fg: "#558", primary: "#7947c9" }; export const meta = { title: "paper clover", description: @@ -15,10 +15,11 @@ export const meta = { };
-

about

+

paper clover

i am a girl that is adorable and alive. + this is my art museum. there will be new art "soon"...

art

diff --git a/src/paperclover.net.ts b/src/paperclover.net.ts index 26aefc596cc7a343eaaeffbb7199f1c931014028..09d74fe7d26b1ca469877f3b39bca6ef9d84628d 100644 --- a/src/paperclover.net.ts +++ b/src/paperclover.net.ts @@ -8,7 +8,7 @@ const globalCss = "src/global.css"; const toRel = (str: string) => path.relative(root, str).replaceAll("\\", "/"); export async function main(graph: incremental.Graph) { - if (process.argv.includes("--once")) { + if (process.argv.includes("--build")) { await graph.incrementalBuild({ buildAndWriteOutput }); return; } @@ -19,6 +19,11 @@ export async function main(graph: incremental.Graph) { buildAndWriteOutput, watchFilesystem: !process.argv.includes("--prod"), }); + + if (!process.argv.includes("--no-open") && !process.argv.includes("--prod")) { + // subprocess.launchBrowser(server.url); + } + // requests in flight finish before the process leaves const stop = () => void server.close().then(() => process.exit(0)); process.on("SIGINT", stop); @@ -31,8 +36,14 @@ export async function main(graph: incremental.Graph) { type Respond = (request: Request) => Response | Promise; /** hand a build to the code that serves it, loaded by the graph so that it reloads with its code */ -async function loadBackend({ graph, progress }: incremental.Server, output: Output): Promise { - using _ = progress.start("load backend"); +async function loadBackend( + server: incremental.Server, + output: Output, + progressOverride?: progress.Ref, +): Promise { + const { graph } = server; + const graphNode = progressOverride ?? server.progress; + using _ = graphNode.start("load backend"); const sitegen = await graph.import("framework/lib/sitegen.ts"); sitegen.setGraph(graph); const assets = await graph.import("framework/lib/assets.ts"); @@ -45,7 +56,27 @@ async function loadBackend({ graph, progress }: incremental.Server, outp view.load(output, modules); const backend = await graph.import<{ default: { fetch: Respond } }>("src/backend.ts"); - return backend.default.fetch; + return (req) => { + // deployments + if ( + new URL(req.url).pathname === "/.sitegen/rebuild" + && !req.headers.has("x-forwarded-for") + ) { + const root = new progress.Root(); + graph.incrementalBuild({ buildAndWriteOutput, progress: root }) + .then((output) => loadBackend(server, output, root)) + .then((backend) => { + server.setHandler(backend); + root.end(); + }) + .catch((e) => root.error(e)); + return new Response(progress.encodeByteStream(root), { + headers: { "Content-Type": progress.contentType }, + }); + } + + return backend.default.fetch(req); + }; } export interface Output { @@ -66,8 +97,8 @@ export interface Asset { headers: Record; } -export async function buildAndWriteOutput(ref: incremental.Ref): Promise { - using incr = ref.start("sitegen!"); +export async function buildAndWriteOutput(ref: incremental.Ref, title = "sitegen!"): Promise { + using incr = ref.start(title); await checkSpelling(incr); const site = await incr.step(async (b) => { @@ -416,6 +447,8 @@ import * as exception from "@clo/lib/exception"; import * as incremental from "@clo/lib/incremental"; import * as meta from "@clo/lib/meta"; import * as mime from "@clo/lib/mime"; +import * as progress from "@clo/lib/progress"; +import * as subprocess from "@clo/lib/subprocess"; import type * as ts from "@clo/lib/ts"; import * as crypto from "node:crypto"; import path from "node:path"; diff --git a/src/q+a/backend.ts b/src/q+a/backend.ts index ce49a15ea8970206092ceb28a1fcdbc86b1d679a..1e997f36a0f8378906bb02a05d0488c343ba3941 100644 --- a/src/q+a/backend.ts +++ b/src/q+a/backend.ts @@ -5,9 +5,7 @@ export const app = new Hono(); // Main page app.get("/q+a", async (c) => { - if (hasAdminToken(c)) { - return serveAsset(c, "/admin/q+a", 200); - } + if (hasAdminToken(c)) return serveAsset(c, "/admin/q+a", 200); return serveAsset(c, "/q+a", 200); }); diff --git a/src/q+a/pages/q+a.marko b/src/q+a/pages/q+a.marko index e33a26d850ef65070c2d753cb0b36271825f73d1..e1b3069ed44e496c4f3129b94e4dba735dfc1780 100644 --- a/src/q+a/pages/q+a.marko +++ b/src/q+a/pages/q+a.marko @@ -11,7 +11,7 @@ export const meta: Metadata = { - + diff --git a/src/q+a/questions.css b/src/q+a/questions.css index c08b4c53389e447340c3edd79fbee5a6b134f8e9..4eff597427bd379b7186b86f9a1588eb17c8c551 100644 --- a/src/q+a/questions.css +++ b/src/q+a/questions.css @@ -181,11 +181,6 @@ form .email { display: none; } - form .robot { - margin-top: 0.5rem; - align-self: flex-start; - cursor: pointer; - } textarea { width: 100%; max-width: calc(60ch); @@ -203,8 +198,7 @@ } } &:not(:placeholder-shown) ~ .disabled-button, - &:placeholder-shown ~ button, - &:placeholder-shown ~ .robot { + &:placeholder-shown ~ button { display: none; } } diff --git a/src/q+a/tags/question-form.marko b/src/q+a/tags/question-form.marko index 93aec3aaebd26cd8021764d5076b2b1a079a1014..b082b8469c246b70df1aec3ea841dba2c0ed5123 100644 --- a/src/q+a/tags/question-form.marko +++ b/src/q+a/tags/question-form.marko @@ -7,10 +7,6 @@ maxlength="10000" />
ask a question
- + +

[back to ${input.back.title}]

+

answers @@ -17,4 +24,3 @@ export const theme = { bg: "#1a1b1c", primary: "#f5a9b8", }; - diff --git a/src/site.ts b/src/site.ts index 1a1eb27b97bd182e7780fe6bed209c9f803435c0..2d01da131b308faf759600564cbb245def291540 100644 --- a/src/site.ts +++ b/src/site.ts @@ -20,7 +20,7 @@ export const meta = { }; // Font subsets reduce bandwidth and protect against proprietary font theft. -const fontRoot = path.join(nasRoot, "Documents/Font"); +const fontRoot = path.join(nasRoot, "Asset/Font"); const ascii = { start: 0x20, end: 0x7E }; const nonAscii: sg.FontRange[] = [ { start: 0xC0, end: 0xFF }, diff --git a/src/tags/photo-grid.css b/src/tags/photo-grid.css index 41c0385742e56a52cbe0e59e2776422b538e2d6d..5421d779208378ccd398397650836e7c8509c1ba 100644 --- a/src/tags/photo-grid.css +++ b/src/tags/photo-grid.css @@ -27,4 +27,8 @@ photo-grid + blockquote { border: none; background-color: var(--primary); color: black; + + a:not(.custom) { + --primary: var(--fg); + } } -- 2.54.1