diff --git a/README.md b/README.md index 5a78d25..655d467 100644 --- a/README.md +++ b/README.md @@ -1 +1,8 @@ -Test line added by Claude Code. +# NGU-Web + +Website for NGU (Next Generation of Unity): a public site and a role-based admin panel. + +- Frontend: React, TypeScript, Tailwind, Vite (`src/`). `pnpm dev`, `pnpm build`. +- API: Hono on Node 22.13+, SQLite (`server/`). `DB_PATH=./dev.db pnpm dev`. +- Accounts are made with `server/src/admin-cli.js`. +- Deployment and setup notes are in `docs/`; working notes for contributors are in `CLAUDE.md`. diff --git a/server/src/admin-cli.js b/server/src/admin-cli.js index 7c907f3..8153a8d 100644 --- a/server/src/admin-cli.js +++ b/server/src/admin-cli.js @@ -28,7 +28,7 @@ The list comes from auth.js rather than being repeated here, so the CLI can't drift from what requireRole will actually accept. - This is also how the first superadmin is made — there's no + This is also how the first superadmin is made, there's no bootstrap path in the web interface, on purpose: node src/admin-cli.js role you@ngu.org superadmin @@ -82,7 +82,7 @@ async function readPassword() { if (first === "") { const generated = randomBytes(12).toString("base64url"); console.log(`\nGenerated password: ${generated}`); - console.log("Copy it now — it isn't stored anywhere readable.\n"); + console.log("Copy it now, it isn't stored anywhere readable.\n"); return generated; } @@ -116,7 +116,7 @@ function checkRole(role) { return role; } -/* Printed, never enforced — see the note at the top of the file. +/* Printed, never enforced, see the note at the top of the file. Worth saying out loud, because the person doing it is usually tidying up accounts rather than thinking about lockouts. */ function warnIfLastSuper(db, user) { @@ -183,7 +183,7 @@ function setRole(db, email, role) { db.prepare("UPDATE admin_users SET role = ? WHERE id = ?").run(role, user.id); // The session they're holding was issued against the old role. - // Every check reads the row fresh, so it isn't a security hole — + // Every check reads the row fresh, so it isn't a security hole, // but their open tab would keep drawing buttons that now 403. destroyAllSessionsFor(db, user.id); diff --git a/server/src/admin-schema-sync.js b/server/src/admin-schema-sync.js index 6487d0c..3dd7c6a 100644 --- a/server/src/admin-schema-sync.js +++ b/server/src/admin-schema-sync.js @@ -18,7 +18,7 @@ ever set it, so every insert through the admin will fail. The first is a silent repair. The other two are deployment bugs, - so with { strict: true } they stop the service starting rather + so they stop the service starting rather than waiting to surface one row at a time. ═══════════════════════════════════════════════════════════════ */ @@ -84,7 +84,7 @@ function collectGroups(entity) { return groups; } -export function syncDescriptorsWithSchema(db, entities, { strict = true } = {}) { +export function syncDescriptorsWithSchema(db, entities) { const list = Array.isArray(entities) ? entities.map((e) => [e.name ?? e.table, e]) : Object.entries(entities); const inferred = []; @@ -136,8 +136,7 @@ export function syncDescriptorsWithSchema(db, entities, { strict = true } = {}) if (problems.length) { const report = `[admin-schema] descriptor does not match the database:\n ${problems.join("\n ")}`; - if (strict) throw new Error(report); - console.error(report); + throw new Error(report); } return { inferred, problems }; diff --git a/server/src/index.js b/server/src/index.js index 4c47ee6..ed72ec4 100644 --- a/server/src/index.js +++ b/server/src/index.js @@ -3,7 +3,7 @@ Binds to localhost only. nginx is the only thing that talks to it, which is what lets the routes trust X-Forwarded-For and skip - CORS entirely — in production the API and the site share an + CORS entirely, in production the API and the site share an origin, and in development Vite proxies /api so they share one there too. ═══════════════════════════════════════════════════════════════ */ @@ -174,7 +174,7 @@ const server = serve({ fetch: app.fetch, hostname: HOST, port: PORT }, (info) => for (const signal of ["SIGTERM", "SIGINT"]) { process.on(signal, () => { - console.log(`${signal} — shutting down`); + console.log(`${signal}, shutting down`); server.close(() => { try { db.close(); diff --git a/server/src/migrations/023_schema.sql b/server/src/migrations/023_schema.sql index 71e0565..56dbee4 100644 --- a/server/src/migrations/023_schema.sql +++ b/server/src/migrations/023_schema.sql @@ -180,7 +180,7 @@ CREATE TABLE event_scopes ( -- an every-other-week series is "on", which day -- of the month a monthly one keeps, and the -- weekday used when none is ticked --- ends_on when set, the last day it can meet — which +-- ends_on when set, the last day it can meet, which -- also keeps effective_status right -- series_count when set, stops it after that many meetings, -- whichever comes first @@ -297,7 +297,7 @@ CREATE UNIQUE INDEX event_hosts_person_uniq -- -- Public by design. Everything in this table can appear on a card, -- and is_published = 0 is the only thing between a row and the open --- web — hence the default of 0, unlike organizations. Anything that +-- web, hence the default of 0, unlike organizations. Anything that -- must never be served lives in person_private, so a careless -- SELECT * can't leak it. Bios and pages go in content_blocks, -- socials in links. People sort by sort_name; there is no @@ -306,7 +306,7 @@ CREATE UNIQUE INDEX event_hosts_person_uniq CREATE TABLE people ( id TEXT PRIMARY KEY, -- slug: 'jane-doe' display_name TEXT NOT NULL, -- 'Jane Doe' - sort_name TEXT, -- 'Doe, Jane' — list ordering + sort_name TEXT, -- 'Doe, Jane', list ordering pronouns TEXT, -- 'she/her' tagline TEXT, -- fallback when no title applies photo TEXT, -- filename in public/people/ @@ -346,7 +346,7 @@ CREATE TABLE person_private ( -- A team belongs to exactly one organization: NGU national has a -- Board and a Leadership Team, a region or chapter can have its own. -- UNIQUE (id, org_id) looks redundant against the primary key, and --- is — except that it gives affiliations a composite foreign key to +-- is, except that it gives affiliations a composite foreign key to -- point at, which stops someone filing a person under a team -- belonging to a different organization. CREATE TABLE teams ( @@ -548,7 +548,7 @@ CREATE TABLE timeline_entries ( -- Null inherits from the referenced row: an event's starts_on. A -- hand-authored entry has to supply its own, which the descriptor - -- can't require conditionally — the read layer reports an entry + -- can't require conditionally, the read layer reports an entry -- with neither rather than the table refusing it. occurred_on TEXT, @@ -604,9 +604,9 @@ CREATE INDEX timeline_entry_people_person_idx -- FRONT PAGE -- ═══════════════════════════════════════════════════════════════ -- --- The home page's editable half. One row in front_page — the CHECK +-- The home page's editable half. One row in front_page, the CHECK -- on id makes a second one impossible, and the admin engine treats --- it as a singleton — and ordered collections hanging off it, each +-- it as a singleton, and ordered collections hanging off it, each -- replaced wholesale on save. Nothing has a foreign key into them, -- which is what makes that safe. -- @@ -759,7 +759,7 @@ CREATE TABLE admin_users ( -- password at all. A row with both can use either route in. password_hash TEXT, - -- Google's stable subject id. Nullable, unique when present — + -- Google's stable subject id. Nullable, unique when present, -- SQLite allows any number of NULLs in a unique index. google_sub TEXT UNIQUE, @@ -935,7 +935,7 @@ SELECT tm.name AS team_name, -- Whether the referenced record is itself visible. An entry must not - -- outlive the thing it points at being unpublished — a draft event + -- outlive the thing it points at being unpublished, a draft event -- would otherwise leak its title and date onto a public page. Null -- for a standalone milestone, which answers to nothing but its own -- is_published. @@ -964,7 +964,7 @@ LEFT JOIN person_awards pa ON t.ref_kind = 'award' AND pa.award_id = t.re -- ═══════════════════════════════════════════════════════════════ -- -- What a new database needs before anyone signs in: the scopes an --- event can be filed under, and the front page as it ships — every +-- event can be filed under, and the front page as it ships, every -- section, the stats that need no typing, and the Church Center -- forms sorted into paths. Everything else comes in through the -- admin. diff --git a/server/src/rateLimit.js b/server/src/rateLimit.js index 5c46744..ee881f7 100644 --- a/server/src/rateLimit.js +++ b/server/src/rateLimit.js @@ -7,7 +7,7 @@ The client IP comes from clientIp() in auth.js (the entry nginx adds to X-Forwarded-For). That is only trustworthy because - nothing but nginx can reach this port — it binds to 127.0.0.1. Don't expose the port. + nothing but nginx can reach this port, it binds to 127.0.0.1. Don't expose the port. ═══════════════════════════════════════════════════════════════ */ import { clientIp } from "./auth.js"; diff --git a/server/src/routes/blog.js b/server/src/routes/blog.js index 835de5f..3a6e665 100644 --- a/server/src/routes/blog.js +++ b/server/src/routes/blog.js @@ -24,7 +24,7 @@ import { Hono } from "hono"; -import { asBool, loadBlocks, loadFeaturedCards, paragraphs } from "../shape.js"; +import { asBool, loadBlocks, marks, loadFeaturedCards, paragraphs } from "../shape.js"; import { readFeeds } from "../feeds.js"; const blog = new Hono(); @@ -33,7 +33,6 @@ const CACHE = "public, max-age=60, stale-while-revalidate=300"; const json = (c, body) => c.json(body, 200, { "Cache-Control": CACHE }); -const marks = (n) => Array(n).fill("?").join(","); const PAGE_ID = "community"; diff --git a/server/src/routes/content.js b/server/src/routes/content.js index 1e56055..a8dd3f6 100644 --- a/server/src/routes/content.js +++ b/server/src/routes/content.js @@ -1,5 +1,5 @@ /* ═══════════════════════════════════════════════════════════════ - CONTENT ROUTES — read-only, mounted under /api + CONTENT ROUTES: read-only, mounted under /api GET /events list + the event scopes GET /events/:id one event, full body, people @@ -12,7 +12,7 @@ Organizations are one table, so they're one endpoint. A region and a chapter differ by a handful of fields, which arrive under - `details` rather than as separate routes — that's what lets a + `details` rather than as separate routes, that's what lets a list component be written once and pointed at any kind. The lists leave out unlisted records (is_listed = 0); the @@ -32,7 +32,7 @@ every event. An event's hosts are a list, in billing order, and each one is - either an organization or a person — `kind` says which, and + either an organization or a person, `kind` says which, and `org_kind` is there for the three organization routes. The first is the one the colour and logo fell back to, which is why order is data and not a display choice. @@ -56,6 +56,7 @@ import { asBool, loadBlocks, loadLinks, + marks, paragraphs, shapeSeries, splitLinks, @@ -72,7 +73,6 @@ const json = (c, body) => c.json(body, 200, { "Cache-Control": CACHE }); const ORG_KINDS = ["national", "region", "chapter", "partner"]; -const marks = (n) => Array(n).fill("?").join(","); /* ── Loaders ───────────────────────────────────────────────── */ @@ -83,7 +83,7 @@ const marks = (n) => Array(n).fill("?").join(","); Unpublished hosts are dropped here rather than in the view: the admin reads the same view and needs to see them. An event whose only host is unpublished comes back with an empty list, which is - the right answer — there is nobody to name and nowhere to link. */ + the right answer, there is nobody to name and nowhere to link. */ function loadHosts(db, ids) { const byEvent = new Map(); if (ids.length === 0) return byEvent; @@ -230,8 +230,8 @@ function shapeTeam(row, links, cardBlocks) { }; } -/* awards.org_id is nullable — an award can predate any decision - about which organization owns it — so `org` genuinely can be +/* awards.org_id is nullable, an award can predate any decision + about which organization owns it, so `org` genuinely can be null, and is also null when the awarding org is unpublished. */ function shapeAward(row) { return { @@ -372,7 +372,7 @@ function attachLeadership(db, orgs) { /* Every team this organization has, including ones with nobody currently filed under them. `leadership` already carries team_id - and team_name, so the page can group people without this — but + and team_name, so the page can group people without this, but grouping alone would make an empty team invisible rather than listed, which is the wrong answer for a team that exists. */ function attachTeams(db, orgs) { diff --git a/server/src/routes/feedback.js b/server/src/routes/feedback.js index beb5335..25fb7f2 100644 --- a/server/src/routes/feedback.js +++ b/server/src/routes/feedback.js @@ -1,5 +1,5 @@ /* ═══════════════════════════════════════════════════════════════ - FEEDBACK ROUTE — the only public write on the site + FEEDBACK ROUTE: the only public write on the site Everything hostile that will ever reach this service arrives here, so the defences live here rather than being sprinkled @@ -30,7 +30,7 @@ const LIMITS = { const MIN_MESSAGE = 10; // Must match FEEDBACK_TYPES in src/pages/sections/FeedbackForm.jsx. -// Anything else falls back to 'general' rather than being rejected — +// Anything else falls back to 'general' rather than being rejected, // a renamed option shouldn't lose someone's submission. const TYPES = ["broken", "confusing", "outdated", "request", "praise", "other"]; diff --git a/server/src/routes/history.js b/server/src/routes/history.js index e7beca1..8641ed0 100644 --- a/server/src/routes/history.js +++ b/server/src/routes/history.js @@ -1,5 +1,5 @@ /* ═══════════════════════════════════════════════════════════════ - HISTORY ROUTE — read-only, mounted under /api + HISTORY ROUTE: read-only, mounted under /api GET /history every published timeline entry @@ -17,7 +17,7 @@ queries doesn't grow with the number of entries. · precision that outruns the date. An entry can hold '2012' with - precision 'day' — the admin doesn't stop you. Trusting that + precision 'day', the admin doesn't stop you. Trusting that pair would put the entry in a month node built from a month that isn't there, so precision is capped at what the string actually carries. @@ -31,6 +31,7 @@ ═══════════════════════════════════════════════════════════════ */ import { Hono } from "hono"; +import { marks } from "../shape.js"; const history = new Hono(); @@ -38,7 +39,6 @@ const CACHE = "public, max-age=60, stale-while-revalidate=300"; const json = (c, body) => c.json(body, 200, { "Cache-Control": CACHE }); -const marks = (n) => Array(n).fill("?").join(","); /* 'YYYY' → year, 'YYYY-MM' → month, 'YYYY-MM-DD' → day. */ function precisionOfString(date) { @@ -115,7 +115,7 @@ history.get("/history", (c) => { ) .all(); - // How many entries exist but can't be placed. Worth knowing about — + // How many entries exist but can't be placed. Worth knowing about, // an entry nobody gave a date to is invisible, and silence is how it // stays that way. const undated = db @@ -153,7 +153,7 @@ function loadRosters(db, rows) { const teamIds = [...new Set(teamEntries.map((row) => row.ref_id))]; // v_org_leadership already decides who counts as current and - // public — affiliation still open, marked public, person + // public, affiliation still open, marked public, person // published. Restating those conditions here is how they drift. const members = db .prepare( diff --git a/server/src/routes/people.js b/server/src/routes/people.js index 8d094e9..e09288b 100644 --- a/server/src/routes/people.js +++ b/server/src/routes/people.js @@ -1,12 +1,12 @@ /* ═══════════════════════════════════════════════════════════════ - PEOPLE ROUTES — read-only, mounted under /api + PEOPLE ROUTES: read-only, mounted under /api GET /teams/:id/people current public members of a team GET /people?ids=a,b,c named people, any order GET /people/:id one person's page The team route reads v_org_leadership, which already decides who - counts as current and public — affiliation still open, marked + counts as current and public, affiliation still open, marked public, person published. Restating those conditions here is how they drift apart. @@ -21,7 +21,7 @@ import { Hono } from "hono"; -import { asBool, loadBlocks, loadLinks, paragraphs, splitLinks } from "../shape.js"; +import { asBool, loadBlocks, loadLinks, marks, paragraphs, splitLinks } from "../shape.js"; const people = new Hono(); @@ -29,7 +29,6 @@ const CACHE = "public, max-age=60, stale-while-revalidate=300"; const json = (c, body) => c.json(body, 200, { "Cache-Control": CACHE }); -const marks = (n) => Array(n).fill("?").join(","); /* How many slugs one request may name. Keeps the URL sane. */ const MAX_IDS = 50; @@ -55,7 +54,7 @@ function shapePerson(row) { } /* people.bio is one run of prose with blank lines between - paragraphs — unrelated to shape.js's paragraphs(), which turns + paragraphs, unrelated to shape.js's paragraphs(), which turns content_block rows into text. */ function splitParagraphs(text) { if (!text) return null; @@ -144,7 +143,7 @@ people.get("/people", (c) => { the same visibility rules its own page applies: a role needs a public affiliation and a published organization, an event must be published, an award must be published and the citation - public. A hidden team drops its name rather than the role — + public. A hidden team drops its name rather than the role, the seat is still real, it just has no page to link to. Roles are current and past. v_org_leadership only knows diff --git a/server/src/shape.js b/server/src/shape.js index 179d71c..970cec9 100644 --- a/server/src/shape.js +++ b/server/src/shape.js @@ -3,7 +3,7 @@ Blocks and links are polymorphic: any organization, event, person or team can own them. Every list endpoint therefore needs the - same move — fetch the parent rows, then fetch all their children + same move, fetch the parent rows, then fetch all their children in one query each and stitch. The alternative is a query per row, which at a dozen events is @@ -139,7 +139,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") { /* ── Card description ────────────────────────────────────────── The card slot is paragraphs by convention, so it collapses to - an array of strings — desc_a and desc_b become description[0] + an array of strings, desc_a and desc_b become description[0] and description[1]. A non-paragraph block in the card slot is ignored here; put it in the body slot instead. ───────────────────────────────────────────────────────────── */ @@ -172,7 +172,7 @@ export function splitLinks(links = []) { collapse from seven flags to a list of the ticked ones, Sunday first; an empty list means "starts_on's weekday", which the client resolves since it already holds starts_on. Occurrences - are not sent — they are derived, and the client derives them + are not sent, they are derived, and the client derives them against its own today. Shared by /events and /front-page. ───────────────────────────────────────────────────────────── */ const SERIES_WEEKDAYS = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]; @@ -300,3 +300,6 @@ export function loadFeaturedCards(db, ownerKind, ownerId) { } export { asBool }; + +// "?,?,?" for an IN (...) list of n values. +export const marks = (n) => Array(n).fill("?").join(","); diff --git a/src/components/Banner.tsx b/src/components/Banner.tsx index f713b67..01841e7 100644 --- a/src/components/Banner.tsx +++ b/src/components/Banner.tsx @@ -12,7 +12,7 @@ export default function Banner() { try { if (!localStorage.getItem(storageKey)) setVisible(true); } catch { - setVisible(true); // storage blocked — show it anyway + setVisible(true); // storage blocked, show it anyway } }, [storageKey]); diff --git a/src/components/DoveMark.tsx b/src/components/DoveMark.tsx index 675a5a7..1c011b8 100644 --- a/src/components/DoveMark.tsx +++ b/src/components/DoveMark.tsx @@ -3,7 +3,7 @@ NGU's dove, lifted from the original home page. The path and its two transforms are the drawing as exported, untouched; only the - wrapper changed — sized by the caller, coloured by currentColor, + wrapper changed, sized by the caller, coloured by currentColor, and hidden from screen readers since it's decoration wherever it appears. diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx index d04bf59..82b00e8 100644 --- a/src/components/Layout.tsx +++ b/src/components/Layout.tsx @@ -1,7 +1,7 @@ import { useState, useEffect, useRef } from "react"; import { NavLink, Link, Outlet, useLocation } from "react-router-dom"; import { PAGE_LINKS, PAGE_SECTIONS, NAV_ACTIONS } from "../navConfig.ts"; -import Banner from "./Banner.jsx"; +import Banner from "./Banner.tsx"; import nguLogo from "../assets/logos/NGU_Logo.svg"; import Footer from "./Footer.tsx"; @@ -147,10 +147,10 @@ export default function Layout() { className="fixed top-0 left-0 right-0 z-50 backdrop-blur-md" > - {/* Tier 0 — site-wide announcement */} + {/* Tier 0, site-wide announcement */} - {/* Tier 1 — site navigation */} + {/* Tier 1, site navigation */} - {/* Tier 2 — sections of the current page */} + {/* Tier 2, sections of the current page */} {sections.length > 0 && (