authoravatarclover caruso<git@paperclover.net>2026-10-19 02:12:08-07:00
committeravatarclover caruso<git@paperclover.net>2026-10-29 20:51:40-07:00
log9ba8d6f075418544599b1d633061024bc343088a
treec24d9ad86c1628ab749344d5ed2b5a4434d9e825
parent57b1c450e19e70424b38b959cccd575e625b5bfe
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

chore: i forgot


23 files changed, 151 insertions(+), 108 deletions(-)

framework/font.ts+2-1
......@@ -4,8 +4,9 @@
44 * none of them. the build keeps what was found, so nothing is fetched twice.
55 */
66export async function fetchFont(b: incremental.Build, name: string, sources: readonly string[]) {
7 using _ = b.start(`fetch ${name}`);
7 using node = b.start(`fetch ${name}`);
88 for (const source of sources) {
9 using _ = node.start(`try ${source}`);
910 if (source.startsWith("https://")) {
1011 const response = await fetch(source).catch(() => null);
1112 if (response?.ok) return new Uint8Array(await response.arrayBuffer());
framework/lib/sitegen.ts+1-4
......@@ -45,14 +45,11 @@ export type FontVars = Record<string, FontVariableAxis>;
4545export type FontVariableAxis = number | [min: number, max: number];
4646export type FontRange = string | number | { start: number; end: number };
4747
48// TODO: self-host plausible for extra privacy. i am in a rush as i write this
49// TODO: properly locate this constant in `site.ts`
50//
5148// I have this so I can see if the blog is actually seen by people. And for
5249// understanding where paperclover.net gets its load for. When I need to scale
5350// large enough, analytics will determine the location of the second web
5451// hosting node.
55export const analytics = `<script async src="https://plausible.io/js/pa-Ajv81BZMkpbEE4QFznyoS.js"></script>
52export const analytics = `<script async src="https://plausible.paperclover.net/js/pa-GuSR8GegXbBWz72PEzlTR.js"></script>
5653<script>window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(arguments)},plausible.init=plausible.init||function(i){plausible.o=i||{}};plausible.init()</script> `;
5754
5855export function wrapDocument({
lib/subprocess.ts+16-11
......@@ -248,17 +248,7 @@ interface ProcessLookup {
248248 command: string;
249249}
250250
251/**
252 * open a file in the text editor that is already in front of the user, at a
253 * line and column, a port of vite's `launch-editor`.
254 *
255 * `file` is a path, a path with `:line:column` appended, or a `file://` url.
256 * resolves once the editor process exits, which is immediate for the editors
257 * that hand the file to a window already open.
258 *
259 * what happens to a path that does not exist is up to the editor; most open an
260 * empty buffer for it.
261 */
251/** opens a file in the logically configured text/code editor */
262252export async function launchEditor(file: string, options: EditorOptions = {}): Promise<void> {
263253 const { fileName, line: fileLine, column: fileColumn } = parsePosition(file);
264254 const line = options.line ?? fileLine;
......@@ -304,6 +294,21 @@ export async function launchEditor(file: string, options: EditorOptions = {}): P
304294 }
305295}
306296
297/** opens a url in the default browser */
298export async function launchBrowser(url: string) {
299 switch (process.platform) {
300 case "darwin":
301 await execute(["open", url]);
302 break;
303 case "win32":
304 await execute(["cmd.exe", "/c", "start", "\"\"", url]);
305 break;
306 default:
307 await execute(["xdg-open", url]);
308 break;
309 }
310}
311
307312export interface EditorOptions {
308313 /**
309314 * the editor to run, as a shell command so that arguments may be included.
src/bin/deploy.ts+4-21
......@@ -20,9 +20,7 @@ export async function main(graph: incremental.Graph) {
2020 await downloadDb.main().catch((error) => console.warn("building with the local databases:", error));
2121
2222 // any error stops the deploy, including the ones a build can still be served with
23 await graph.incrementalBuild({ progress, buildAndWriteOutput });
24 // the cache is copied as one file
25 graph.db.sql.exec("pragma wal_checkpoint(truncate);");
23 await graph.incrementalBuild({ progress, buildAndWriteOutput: (b) => buildAndWriteOutput(b, "local build") });
2624
2725 await rsync.spawn({
2826 cwd,
......@@ -31,6 +29,7 @@ export async function main(graph: incremental.Graph) {
3129 "-r",
3230 "--delete",
3331 "--exclude=node_modules",
32 "cspell.json",
3433 "run.js",
3534 "package.json",
3635 "package-lock.json",
......@@ -41,29 +40,13 @@ export async function main(graph: incremental.Graph) {
4140 ],
4241 progress: progress.start("copy site files"),
4342 });
44 await rsync.spawn({
45 cwd,
46 args: [
47 "-a",
48 ".clover/incremental.db",
49 `${remote}:~/paperclover.net/.clover/incremental.db.next`,
50 ],
51 progress: progress.start("copy build cache"),
52 });
5343 await subprocess.spawn([
5444 "ssh",
45 "-t",
5546 remote,
5647 "cd paperclover.net && "
5748 + `PATH=${node}:$PATH npm i && `
58 + "pm2 stop site && "
59 // the server leaves a write-ahead log beside the cache it had open, which is not this cache's
60 + "rm -f .clover/incremental.db-wal .clover/incremental.db-shm && "
61 + "mv .clover/incremental.db.next .clover/incremental.db && "
62 // started again with this checkout's command. secrets are in the server's `.env`
63 + "pm2 delete site && "
64 + `pm2 start run.js --name site --interpreter ${node}/node --kill-timeout 5000 `
65 + `--node-args="--env-file=.env --experimental-vm-modules --no-warnings" -- --prod && `
66 + "pm2 save",
49 + node + "/node run trigger-live-rebuild http://localhost:10000"
6750 ], { stdin: "inherit" }).wait();
6851}
6952
src/bin/download-db.ts+16-16
......@@ -5,22 +5,22 @@ const site = "https://paperclover.net";
55const token = process.env.CLOVER_SOT_KEY ?? null;
66
77export async function main() {
8 for (const name of ["cache.sqlite", "questions.sqlite"]) {
9 using node = progress.start(`download ${name}`, { units: "bytes" });
10 const response = await fetch(`${site}/db/${name}`, { headers: token ? { Authorization: token } : {} });
11 if (!response.ok || !response.body) {
12 throw new Error(`${site}/db/${name} responded ${response.status} ${response.statusText}`);
13 }
14 node.total = Number(response.headers.get("Content-Length"));
15 await getDatabase(name).restore(response.body.pipeThrough(
16 new TransformStream({
17 transform(chunk, controller) {
18 node.value += chunk.byteLength;
19 controller.enqueue(chunk);
20 },
21 }),
22 ));
23 }
8 // for (const name of ["cache.sqlite", "questions.sqlite"]) {
9 // using node = progress.start(`download ${name}`, { units: "bytes" });
10 // const response = await fetch(`${site}/db/${name}`, { headers: token ? { Authorization: token } : {} });
11 // if (!response.ok || !response.body) {
12 // throw new Error(`${site}/db/${name} responded ${response.status} ${response.statusText}`);
13 // }
14 // node.total = Number(response.headers.get("Content-Length"));
15 // await getDatabase(name).restore(response.body.pipeThrough(
16 // new TransformStream({
17 // transform(chunk, controller) {
18 // node.value += chunk.byteLength;
19 // controller.enqueue(chunk);
20 // },
21 // }),
22 // ));
23 // }
2424}
2525
2626import { getDatabase } from "#sitegen/drizzle";
src/bin/trigger-live-rebuild.ts created+10
......@@ -0,0 +1,10 @@
1export async function main() {
2 const response = await fetch("http://localhost:10000/.sitegen/rebuild");
3 if (!response.ok) throw new Error(response.statusText);
4 using node = progress.start("remote build");
5 using remoteNode = progress.decodeByteStream(UNWRAP(response.body), node);
6 await remoteNode.once("end");
7}
8
9import { UNWRAP } from "@clo/lib/assert";
10import * as progress from "@clo/lib/progress";
src/blog/tags/blog-layout.marko+1-1
......@@ -52,7 +52,7 @@ export interface Context {
5252
5353<main>
5454 <header>
55 <a href="/">${t.return}</a>
55 <a href="/">[${t.return}]</a>
5656 <h1 style={ "max-width": "30ch" }>${title}</h1>
5757 <p class="description"><em>${description}</em></p>
5858
src/cspell.ts+1
......@@ -18,6 +18,7 @@ export async function spellCheck(uri: string, text: string, settings: ts.DeepRea
1818 for (const errors of result.dictionaryErrors?.values() ?? []) {
1919 for (const error of errors) throw error;
2020 }
21 // meowd
2122 if (!result.checked) throw new Error(`CSpell did not check ${uri}.`);
2223 const { settingsUsed } = result;
2324 const issues = result.issues.filter((issue) => {
src/databases.test.ts+1-1
......@@ -10,7 +10,7 @@ const dir = vi.hoisted(() => {
1010 return dir;
1111});
1212afterAll(() => fs.rmSync(dir, { recursive: true, force: true }));
13
13//
1414for (const path of ["/2025/song.mp3", "/2025/.date", "/_unlisted/font.ttf", "/friends/2025/photo.jpg"]) {
1515 const file = mediaFiles.createFile({
1616 path,
src/file-viewer/tags/media-panel.marko+3-1
......@@ -128,7 +128,9 @@ static const cotyledonEndingFile = "/2024/for everyone";
128128 <ContainerDiv kind="text">
129129 <view-text
130130 ...{ file }
131 siblings=mediaFiles.getPublicChildren(UNWRAP(mediaFiles.getParent(file)))
131 siblings=mediaFiles.getPublicChildren(
132 UNWRAP(mediaFiles.getParent(file)),
133 )
132134 />
133135 </ContainerDiv>
134136 </else>
src/global.css+6-4
......@@ -128,15 +128,17 @@ a:where([href]:not(.custom)) {
128128 margin: -0.2em -0.3em;
129129 padding: 0.2em 0.3em;
130130 border-radius: 4px;
131 text-decoration: underline;
132 text-decoration-color: var(--primary);
133 text-decoration-color: rgb(from var(--primary) r g b / 0.45);
134 text-decoration-thickness: 1.5px;
135 text-underline-offset: 1.5px;
131136 &:hover {
132 text-decoration: underline;
133 /* font-weight: 600; */
134137 color: var(--primary);
135138 color: lch(from var(--primary) calc(l) calc(c + 30) h);
139 text-decoration-color: lch(from var(--primary) calc(l) calc(c + 30) h);
136140 }
137141 &:active {
138 text-decoration: underline;
139 /* font-weight: 600; */
140142 text-decoration: none;
141143 color: black;
142144 background-color: var(--primary);
src/pages/dream.mdo+10-8
......@@ -10,14 +10,16 @@ meta:
1010# my life's dream
1111
1212if i could make art (music and videos) full time, forever, i would take that
13life in a heartbeat, never looking back. this has happened once in may 2025 for
14a month (an interlude between jobs). i called this **ART MONTH**, and it was the
15best month of my life. i want to do it again, for longer: **ART DECADE**. or if it was possible, **ART
16FOREVER**. the desire has been in me since age 16 or so. i don't want to work in
17the music industry, and i don't want to be contingent on my music being
18profitable. i want to make my art, the way i envision it.
19
20currently, i have a stupid tech job, which i am exceptionally good at. too good
13life in a heartbeat, never looking back. with a world confused on the meaning, i
14decided that *this*, dedicating to the arts, would be *the* meaning of my life.
15this choice was set at around age 15. so far, i've had one time where i could,
16without worry, execute on this dream full time, in may 2025 for a month. i
17called this **ART MONTH**, and it was the best month of my life. i want to do it
18again, for longer: **ART DECADE**. or if it was possible, **ART FOREVER**. i
19don't want to work in the music industry, and i don't want to be contingent on
20my music being profitable. i want to make my art, the way i envision it, alone.
21
22currently, my time is taken by a tech job, which i am exceptionally good at. too good
2123at it maybe. my knowledge and experience was built from doing crazy things in
2224school and is the reason my colleagues rely on me for accurate technical advice.
2325i'm the one to attempt and succeed with large, technically intricate projects.
src/pages/in-the-summer.marko+1-1
......@@ -8,7 +8,7 @@ export const theme = {
88import "./in-the-summer.css";
99
1010<main style={ "max-width": "110ch" }>
11 <nav><a href="/">back to home</a></nav>
11 <nav><a href="/">[back to the home page]</a></nav>
1212 <div.contain>
1313 <header>
1414 <h1>in the summer</h1>
src/pages/index.css+17-10
......@@ -5,22 +5,33 @@ main {
55 justify-content: center;
66 align-items: center;
77 min-height: 100vh;
8
89 & > div {
910 width: 450px;
1011 margin: auto;
1112 }
1213}
1314h1 {
14 margin: -0.5rem 0 3rem 0;
15 font-size: 5rem;
16 font-weight: 400;
15 margin: 0;
16 font-size: 4rem;
17 font-weight: 100;
18 color: #430e8a;
19 text-decoration: underline;
20 text-decoration-color: #430e8a44;
21 text-decoration-style: wavy;
22 text-underline-offset: 8px;
1723}
1824h2 {
1925 font-size: 1.15rem;
20 text-decoration: underline;
21 color: #000e;
26 background-color: #003a;
27 outline: 4px solid #003c;
28 padding: 2px 4px;
29 width: max-content;
30 color: #fff;
31 margin-top: 32px;
32 margin-bottom: 8px;
2233}
23p, h2 {
34p {
2435 margin: 0.75rem 0rem;
2536}
2637.section-list {
......@@ -44,10 +55,6 @@ p, h2 {
4455.link-list a {
4556 white-space: nowrap;
4657}
47hr {
48 width: 100%;
49 border: 1px solid #000b;
50}
5158.cite {
5259 color: inherit;
5360 text-decoration-line: underline;
src/pages/index.marko+8-6
......@@ -1,7 +1,7 @@
11import type { Meta } from "#meta";
22import "./index.css";
33
4export const theme = { bg: "#fff", fg: "#666" };
4export const theme = { bg: "#fff0fb", fg: "#558", primary: "#7947c9" };
55export const meta = {
66 title: "paper clover",
77 description:
......@@ -15,10 +15,11 @@ export const meta = {
1515};
1616<main>
1717 <div>
18 <h2>about</h2>
18 <h1>paper clover</h1>
1919 <p>
2020 i am a girl that is adorable and
2121 <a class="custom cite" href="https://en.wikipedia.org/wiki/Life">alive</a>.
22 this is my art museum. there will be new art "soon"...
2223 </p>
2324 <h2>art</h2>
2425 <ul class="section-list">
......@@ -44,20 +45,21 @@ export const meta = {
4445 <h2>things</h2>
4546 <ul class="section-list">
4647 <li><a href="/q+a">questions and answers</a></li>
47 // <li><a href="/log">recent activity</a></li>
4848 <li><a href="/file">file browser</a></li>
49 <li><a href="https://shale.paperclover.net/clo">my software</a></li>
5049 <li><a href="/dream">my life's dream</a></li>
5150 <li><a href="/subscribe">mailing list</a></li>
5251 </ul>
5352 <h2>links</h2>
5453 <nav>
5554 <ul class="link-list">
56 <li><a href="mailto:hello@paperclover.net">email me</a></li>
55 <li><a href="mailto:hello@paperclover.net">email</a></li>
5756 <li><a href="/rss.xml">rss</a></li>
57 <li><a href="https://shale.paperclover.net">git</a></li>
5858 <li><a href="https://ko-fi.com/paper_clover">donate</a></li>
5959 </ul>
6060 </nav>
61 <h1>paper clover</h1>
61
62 <p>website run by clover caruso. alive since '04.</p>
63 // <p>was run by clover caruso. alive from '04 to '??.</p>
6264 </div>
6365</main>
src/paperclover.net.ts+39-6
......@@ -8,7 +8,7 @@ const globalCss = "src/global.css";
88const toRel = (str: string) => path.relative(root, str).replaceAll("\\", "/");
99
1010export async function main(graph: incremental.Graph) {
11 if (process.argv.includes("--once")) {
11 if (process.argv.includes("--build")) {
1212 await graph.incrementalBuild({ buildAndWriteOutput });
1313 return;
1414 }
......@@ -19,6 +19,11 @@ export async function main(graph: incremental.Graph) {
1919 buildAndWriteOutput,
2020 watchFilesystem: !process.argv.includes("--prod"),
2121 });
22
23 if (!process.argv.includes("--no-open") && !process.argv.includes("--prod")) {
24 // subprocess.launchBrowser(server.url);
25 }
26
2227 // requests in flight finish before the process leaves
2328 const stop = () => void server.close().then(() => process.exit(0));
2429 process.on("SIGINT", stop);
......@@ -31,8 +36,14 @@ export async function main(graph: incremental.Graph) {
3136type Respond = (request: Request) => Response | Promise<Response>;
3237
3338/** hand a build to the code that serves it, loaded by the graph so that it reloads with its code */
34async function loadBackend({ graph, progress }: incremental.Server<Output>, output: Output): Promise<Respond> {
35 using _ = progress.start("load backend");
39async function loadBackend(
40 server: incremental.Server<Output>,
41 output: Output,
42 progressOverride?: progress.Ref,
43): Promise<Respond> {
44 const { graph } = server;
45 const graphNode = progressOverride ?? server.progress;
46 using _ = graphNode.start("load backend");
3647 const sitegen = await graph.import<typeof import("../framework/lib/sitegen.ts")>("framework/lib/sitegen.ts");
3748 sitegen.setGraph(graph);
3849 const assets = await graph.import<typeof import("../framework/lib/assets.ts")>("framework/lib/assets.ts");
......@@ -45,7 +56,27 @@ async function loadBackend({ graph, progress }: incremental.Server<Output>, outp
4556 view.load(output, modules);
4657
4758 const backend = await graph.import<{ default: { fetch: Respond } }>("src/backend.ts");
48 return backend.default.fetch;
59 return (req) => {
60 // deployments
61 if (
62 new URL(req.url).pathname === "/.sitegen/rebuild"
63 && !req.headers.has("x-forwarded-for")
64 ) {
65 const root = new progress.Root();
66 graph.incrementalBuild({ buildAndWriteOutput, progress: root })
67 .then((output) => loadBackend(server, output, root))
68 .then((backend) => {
69 server.setHandler(backend);
70 root.end();
71 })
72 .catch((e) => root.error(e));
73 return new Response(progress.encodeByteStream(root), {
74 headers: { "Content-Type": progress.contentType },
75 });
76 }
77
78 return backend.default.fetch(req);
79 };
4980}
5081
5182export interface Output {
......@@ -66,8 +97,8 @@ export interface Asset {
6697 headers: Record<string, string>;
6798}
6899
69export async function buildAndWriteOutput(ref: incremental.Ref): Promise<Output> {
70 using incr = ref.start("sitegen!");
100export async function buildAndWriteOutput(ref: incremental.Ref, title = "sitegen!"): Promise<Output> {
101 using incr = ref.start(title);
71102 await checkSpelling(incr);
72103
73104 const site = await incr.step(async (b) => {
......@@ -416,6 +447,8 @@ import * as exception from "@clo/lib/exception";
416447import * as incremental from "@clo/lib/incremental";
417448import * as meta from "@clo/lib/meta";
418449import * as mime from "@clo/lib/mime";
450import * as progress from "@clo/lib/progress";
451import * as subprocess from "@clo/lib/subprocess";
419452import type * as ts from "@clo/lib/ts";
420453import * as crypto from "node:crypto";
421454import path from "node:path";
src/q+a/backend.ts+1-3
......@@ -5,9 +5,7 @@ export const app = new Hono();
55
66// Main page
77app.get("/q+a", async (c) => {
8 if (hasAdminToken(c)) {
9 return serveAsset(c, "/admin/q+a", 200);
10 }
8 if (hasAdminToken(c)) return serveAsset(c, "/admin/q+a", 200);
119 return serveAsset(c, "/q+a", 200);
1210});
1311
src/q+a/pages/q+a.marko+1-1
......@@ -11,7 +11,7 @@ export const meta: Metadata = {
1111<const/{ admin = false }=input>
1212<const/answered=questions.getAll()>
1313
14<question-layout>
14<question-layout back={ href: "/", title: "the home page" }>
1515 <if=!admin>
1616 <question-form/>
1717 </if>
src/q+a/questions.css+1-7
......@@ -181,11 +181,6 @@
181181 form .email {
182182 display: none;
183183 }
184 form .robot {
185 margin-top: 0.5rem;
186 align-self: flex-start;
187 cursor: pointer;
188 }
189184 textarea {
190185 width: 100%;
191186 max-width: calc(60ch);
......@@ -203,8 +198,7 @@
203198 }
204199 }
205200 &:not(:placeholder-shown) ~ .disabled-button,
206 &:placeholder-shown ~ button,
207 &:placeholder-shown ~ .robot {
201 &:placeholder-shown ~ button {
208202 display: none;
209203 }
210204 }
src/q+a/tags/question-form.marko-4
......@@ -7,10 +7,6 @@
77 maxlength="10000"
88 />
99 <div aria-hidden class="title">ask a question</div>
10 <label class="robot">
11 <input type="checkbox" name="robot" />
12 i am a robot
13 </label>
1410 <input
1511 class="email"
1612 type="text"
src/q+a/tags/question-layout.marko+7-1
......@@ -1,7 +1,14 @@
11import "../questions.css";
22client import "./header.client.ts";
33
4export interface Input {
5 back?: { href: string; title: string };
6}
7
48<main class="qa">
9 <if=input.back>
10 <p><a href=input.back.href>[back to ${input.back.title}]</a></p>
11 </if>
512 <if=!input.minimal>
613 <h1>
714 <span class="a" style="color:var(--a);--s:#19607d">answers</span>
......@@ -17,4 +24,3 @@ export const theme = {
1724 bg: "#1a1b1c",
1825 primary: "#f5a9b8",
1926};
20
src/site.ts+1-1
......@@ -20,7 +20,7 @@ export const meta = {
2020};
2121
2222// Font subsets reduce bandwidth and protect against proprietary font theft.
23const fontRoot = path.join(nasRoot, "Documents/Font");
23const fontRoot = path.join(nasRoot, "Asset/Font");
2424const ascii = { start: 0x20, end: 0x7E };
2525const nonAscii: sg.FontRange[] = [
2626 { start: 0xC0, end: 0xFF },
src/tags/photo-grid.css+4
......@@ -27,4 +27,8 @@ photo-grid + blockquote {
2727 border: none;
2828 background-color: var(--primary);
2929 color: black;
30
31 a:not(.custom) {
32 --primary: var(--fg);
33 }
3034}