Codebase audits, privacy, dark mode, palette (v1.9.0 to v1.9.4-audit) #14
185 changed files with 6932 additions and 5345 deletions
9
.gitignore
vendored
9
.gitignore
vendored
|
|
@ -13,15 +13,22 @@ build/
|
||||||
# local databases
|
# local databases
|
||||||
*.db
|
*.db
|
||||||
*.db-journal
|
*.db-journal
|
||||||
|
*.db-wal
|
||||||
|
*.db-shm
|
||||||
|
|
||||||
# editor and OS files
|
# editor and OS files
|
||||||
.vscode/*
|
.vscode/*
|
||||||
!.vscode/extensions.json
|
!.vscode/extensions.json
|
||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
nginx-dev
|
||||||
|
|
||||||
# plain txt files
|
# plain txt files
|
||||||
.txt
|
*.txt
|
||||||
|
|
||||||
# uploaded media (local dev)
|
# uploaded media (local dev)
|
||||||
server/uploads/
|
server/uploads/
|
||||||
server/clips/
|
server/clips/
|
||||||
|
|
||||||
|
# skills
|
||||||
|
graphify-out/
|
||||||
30
CLAUDE.md
30
CLAUDE.md
|
|
@ -8,17 +8,17 @@ Website for NGU (Next Generation of Unity), a Unity movement organization with r
|
||||||
|
|
||||||
## Stack
|
## Stack
|
||||||
- Frontend: React, TypeScript, Tailwind CSS, React Router, Vite (in `src/`)
|
- Frontend: React, TypeScript, Tailwind CSS, React Router, Vite (in `src/`)
|
||||||
- Backend: Hono on Node.js, SQLite (WAL mode, STRICT tables) via better-sqlite3 / node:sqlite (in `server/`)
|
- Backend: Hono on Node.js, SQLite (WAL mode, STRICT tables) via node:sqlite (in `server/`)
|
||||||
- Package manager: pnpm only (never npm or yarn)
|
- Package manager: pnpm only (never npm or yarn)
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
Frontend (repo root):
|
Frontend (repo root):
|
||||||
- `pnpm dev` / `pnpm build` / `pnpm preview`: Vite
|
- `pnpm dev` / `pnpm build` / `pnpm preview`: Vite
|
||||||
- `pnpm format`: oxfmt
|
- `pnpm format`: oxfmt
|
||||||
- `pnpm exec tsc`: type-check (`noEmit`; there is no separate lint or typecheck script)
|
- `pnpm exec tsc`: type-check (`noEmit`; there is no separate lint or typecheck script). `noImplicitAny` is off on purpose: turning it on shows about 480 errors (untyped props and params, mostly in OrgList-Map, admin fields, EntityEdit, EventList-Cards). Decided 2026-09-29 not to fix them; don't turn it on or start typing files for it unless asked. New code should still type its props.
|
||||||
- There is no test suite.
|
- There is no test suite.
|
||||||
|
|
||||||
Backend (`server/`, Node >= 22). The server reads `HOST` (default `127.0.0.1`), `PORT` (default `3001`), `DB_PATH` (default `./ngu.db`) and `UPLOADS_DIR` (default `./uploads`); locally, use `DB_PATH=./dev.db`:
|
Backend (`server/`, Node >= 22.13). The server reads `HOST` (default `127.0.0.1`), `PORT` (default `3001`), `DB_PATH` (default `./ngu.db`) and `UPLOADS_DIR` (default `./uploads`); locally, use `DB_PATH=./dev.db`:
|
||||||
- `DB_PATH=./dev.db pnpm dev`: run with `node --watch`
|
- `DB_PATH=./dev.db pnpm dev`: run with `node --watch`
|
||||||
- `DB_PATH=./dev.db pnpm migrate`: apply migrations without starting the server
|
- `DB_PATH=./dev.db pnpm migrate`: apply migrations without starting the server
|
||||||
- `DB_PATH=./dev.db node src/admin-cli.js add|list|passwd|role|disable|enable ...`: the only way accounts are created
|
- `DB_PATH=./dev.db node src/admin-cli.js add|list|passwd|role|disable|enable ...`: the only way accounts are created
|
||||||
|
|
@ -34,6 +34,8 @@ In dev, Vite proxies `/api` to the target set in `vite.config.ts`, so the API mu
|
||||||
- Uploaded media: `UPLOADS_DIR=/var/lib/ngu/uploads`, served by nginx at `/uploads/`. Setup and the nginx block are in `docs/media-uploads.md`.
|
- Uploaded media: `UPLOADS_DIR=/var/lib/ngu/uploads`, served by nginx at `/uploads/`. Setup and the nginx block are in `docs/media-uploads.md`.
|
||||||
- Page HTML goes through the API, which fills in each page's title, description, preview image and structured data (`server/src/pageMeta.js`), and serves `/sitemap.xml`. It reads `SITE_CONFIG` (site.json) and `SITE_INDEX` (the built index.html), with Panel → Site settings (the `site_settings` table) laid over site.json, and serves `/robots.txt` from the same merge. nginx setup: `docs/seo.md`.
|
- Page HTML goes through the API, which fills in each page's title, description, preview image and structured data (`server/src/pageMeta.js`), and serves `/sitemap.xml`. It reads `SITE_CONFIG` (site.json) and `SITE_INDEX` (the built index.html), with Panel → Site settings (the `site_settings` table) laid over site.json, and serves `/robots.txt` from the same merge. nginx setup: `docs/seo.md`.
|
||||||
- Video clips (Tools, admins and up): yt-dlp downloads our YouTube/Facebook videos into `CLIPS_DIR`, ffmpeg cuts them; one job at a time, files swept after a day (`server/src/clips.js`). Needs yt-dlp and ffmpeg on the VPS: `docs/video-clips.md`.
|
- Video clips (Tools, admins and up): yt-dlp downloads our YouTube/Facebook videos into `CLIPS_DIR`, ffmpeg cuts them; one job at a time, files swept after a day (`server/src/clips.js`). Needs yt-dlp and ffmpeg on the VPS: `docs/video-clips.md`.
|
||||||
|
- Speed: nginx must gzip JS/CSS/JSON/SVG and speak HTTP/2; page HTML is `no-cache`; uploads get a `-640.webp` small copy made at upload and at boot: `docs/performance.md`.
|
||||||
|
- Security headers: the API sends them (Hono `secureHeaders()`, plus a CSRF check on `/api` writes); nginx sends HSTS on everything and must pass `Host` and `X-Forwarded-For` to the API: `docs/security-headers.md`.
|
||||||
- Google sign-in for @nextgenerationofunity.org admin accounts: on when `GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET` are set on the service. Only existing accounts (made by admin-cli) get in; passwords still work. Setup: `docs/google-sign-in.md`.
|
- Google sign-in for @nextgenerationofunity.org admin accounts: on when `GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET` are set on the service. Only existing accounts (made by admin-cli) get in; passwords still work. Setup: `docs/google-sign-in.md`.
|
||||||
|
|
||||||
## Git workflow
|
## Git workflow
|
||||||
|
|
@ -54,24 +56,28 @@ In dev, Vite proxies `/api` to the target set in `vite.config.ts`, so the API mu
|
||||||
## Project layout
|
## Project layout
|
||||||
- All pages use `PageShell.tsx` as the wrapper unless explicitly noted otherwise.
|
- All pages use `PageShell.tsx` as the wrapper unless explicitly noted otherwise.
|
||||||
- Pages live in `src/pages/`; section-level components go in `src/pages/sections/`.
|
- Pages live in `src/pages/`; section-level components go in `src/pages/sections/`.
|
||||||
- `src/data/` holds only hardcoded data shared across multiple section files (e.g. `historyDecades.ts`, map grid). Everything else comes from SQLite.
|
- `src/data/` holds only hardcoded data shared across multiple section files (e.g. `historyDecades.ts`, map grid). Everything else comes from SQLite, through hooks in `src/lib/`.
|
||||||
- `navConfig.ts` is the single source of truth for navigation, routes, and actions (header, footer, pages).
|
- `navConfig.ts` is the single source of truth for navigation, routes, and actions (header, footer, pages).
|
||||||
- `api.ts` is the shared caching client used by frontend data hooks.
|
- `api.ts` is the shared caching client used by frontend data hooks.
|
||||||
- `docs/updating-data-in-code.md`: where content that isn't in the database lives (admin dropdown labels, fixed value lists, nav, banner, decades, map grid) and how to change it. Keep it current when adding a dropdown or code-owned content.
|
- `docs/updating-data-in-code.md`: where content that isn't in the database lives (admin dropdown labels, fixed value lists, nav, banner, decades, map grid) and how to change it. Keep it current when adding a dropdown or code-owned content.
|
||||||
- Images: every record image (logos, photos, backgrounds, block images) is an upload. A bare filename resolves to `/uploads/<file>` (`src/lib/media.ts`, and `server/src/pageMeta.js` for previews). Only the site's own chosen assets, the NGU logos in the nav, footer and admin, are bundled from `src/assets/logos/`. The `<Logo>` component hides itself on load error.
|
- Images: every record image (logos, photos, backgrounds, block images) is an upload. A bare filename resolves to `/uploads/<file>` (`src/lib/media.ts`, and `server/src/pageMeta.js` for previews). Only the site's own chosen assets, the NGU logos in the nav, footer and admin, are bundled from `src/assets/logos/`. Logo images hide themselves on load error (`onError`).
|
||||||
|
|
||||||
## Rules and gotchas
|
## Rules and gotchas
|
||||||
- **Role checks must use ladder comparisons, never equality.** Roles rank viewer → editor → admin → superadmin. Use the minimum-rank helpers from `src/lib/roles.ts` (`canWrite`, `canDelete`, `isSuper`, `atLeast`). Where a local variable shadows the name, import with an alias, e.g. `canWrite as roleCanWrite`. `role === "admin"` silently excludes higher roles and has caused repeated bugs.
|
- **Role checks must use ladder comparisons, never equality.** Roles rank viewer → editor → admin → superadmin. Use the minimum-rank helpers from `src/lib/roles.ts` (`canWrite`, `canDelete`, `isSuper`, `atLeast`). Where a local variable shadows the name, import with an alias, e.g. `canWrite as roleCanWrite`. `role === "admin"` silently excludes higher roles and has caused repeated bugs.
|
||||||
- **Imports need explicit extensions** (`.ts`, `.tsx`, `.js`) everywhere.
|
- **Imports need explicit extensions** (`.ts`, `.tsx`, `.js`) everywhere.
|
||||||
- **Vite resolves `.js` before `.ts`**, so a `.js` and `.ts` file with the same base name will import the wrong one. Give new hooks distinct names.
|
- **Vite resolves `.js` before `.ts`**, so a `.js` and `.ts` file with the same base name will import the wrong one. Give new hooks distinct names.
|
||||||
- **Don't use `fallback: EMPTY` in api.ts hooks.** It silently returns empty arrays and hides server errors; let the error state surface.
|
- **Don't use `fallback: EMPTY` in api.ts hooks.** It silently returns empty arrays and hides server errors; let the error state surface.
|
||||||
|
- **Colours are tokens, not hex.** Admins can override any token (Panel → Site settings → Colours). The defaults are `server/src/themeDefaults.js` plus the same values as CSS in `src/index.css`; the build fails if they differ (`themeDefaultsCheck` in `vite.config.ts`), and migration 041's CHECK lists the token names. Use the utilities from `src/index.css` (`text-ink`, `text-body`, `text-muted`, `text-link`, `bg-surface`, `bg-tint`, `bg-action`, `border-brand/20`...) so dark mode works; a literal only for something that must look the same in both modes (white on a dark band, a platform's colour). Data colours (accents, event and region colours) go through `withAlpha`, `accentText` and `readableOn` in `src/lib/color.ts`, never `${color}55`.
|
||||||
|
- **Icons are Phosphor** (`@phosphor-icons/react`), weight `bold` (or `fill` for play/star). No hand-drawn `<svg>` icons and no Unicode glyphs as icons (× › ▶ →). Brand marks are the exception: `DoveMark`, `PlatformIcon`, the Google logo, the chapter map.
|
||||||
|
- **Accents come from `src/lib/color.ts`:** `BRAND` (the teal, via the button token so the admin palette reaches it) and `ACCENTS` (deep, green, mint). Not a new hex in a page.
|
||||||
- **No em-dashes** (U+2014) anywhere: UI text, help text, comments, docs, commit messages. Use a colon, comma or parentheses. An empty table cell shows `-`.
|
- **No em-dashes** (U+2014) anywhere: UI text, help text, comments, docs, commit messages. Use a colon, comma or parentheses. An empty table cell shows `-`.
|
||||||
- **Admin editor text:** blank select options read `Default: …` (what blank means), examples in help text start with `eg.`, and record ids are called "URL ID". Cut-off preview text uses `preview()` from `src/lib/text.ts`, which ends it with an ellipsis. See `docs/updating-data-in-code.md`.
|
- **Admin editor text:** blank select options read `Default: …` (what blank means), examples in help text start with `eg.`, and record ids are called "URL ID". Cut-off preview text uses `preview()` from `src/lib/text.ts`, which ends it with an ellipsis. See `docs/updating-data-in-code.md`.
|
||||||
|
|
||||||
## Admin CRUD engine
|
## Admin CRUD engine
|
||||||
Descriptor-driven: `server/admin-crud.js` and `admin-schema.js` (server) and `adminSchema.ts` (client) generate SQL and form fields from declarative entity configs. Adding an entity should mean adding a descriptor, not new CRUD code.
|
Descriptor-driven: `server/src/admin-crud.js` and `server/src/admin-schema/` (server, one file per entity, registered in `admin-schema.js`) and `src/lib/adminSchema/` (client, one file per entity, registered in `adminSchema.ts`) generate SQL and form fields from declarative entity configs. Adding an entity should mean adding a descriptor, not new CRUD code.
|
||||||
- Child collections are deleted and reinserted wholesale. Unsafe for entities referenced by foreign keys elsewhere.
|
- Child collections are deleted and reinserted wholesale. Unsafe for entities referenced by foreign keys elsewhere.
|
||||||
- `reindex: false` prevents cross-entity sort order collisions.
|
- `reindex: false` prevents cross-entity sort order collisions.
|
||||||
|
- `check: (db, id) => void` runs after a save has written everything, inside its transaction; throwing an `HttpError` refuses the save (Site settings uses it for the colour contrast check, `server/src/theme.js`).
|
||||||
- The `OMIT` sentinel distinguishes unsent fields from deliberate clears.
|
- The `OMIT` sentinel distinguishes unsent fields from deliberate clears.
|
||||||
- `admin-schema-sync.js` runs at boot and throws if descriptors don't match live `PRAGMA table_info`. If boot fails after a schema change, update the descriptor or migration so they agree.
|
- `admin-schema-sync.js` runs at boot and throws if descriptors don't match live `PRAGMA table_info`. If boot fails after a schema change, update the descriptor or migration so they agree.
|
||||||
- `admin-cli.js` imports `ROLES` and `destroyAllSessionsFor` from `auth.js`. Keep it that way to prevent drift.
|
- `admin-cli.js` imports `ROLES` and `destroyAllSessionsFor` from `auth.js`. Keep it that way to prevent drift.
|
||||||
|
|
@ -83,4 +89,14 @@ Descriptor-driven: `server/admin-crud.js` and `admin-schema.js` (server) and `ad
|
||||||
- The runner turns foreign keys off around every migration (it can't be done inside the file's transaction) and runs `PRAGMA foreign_key_check` before committing, so a table rebuild needs no `PRAGMA foreign_keys` of its own. When views or triggers name the table being rebuilt, wrap the drop-and-rename in `PRAGMA legacy_alter_table = ON` ... `OFF`, then recreate the rebuilt table's own indexes and triggers.
|
- The runner turns foreign keys off around every migration (it can't be done inside the file's transaction) and runs `PRAGMA foreign_key_check` before committing, so a table rebuild needs no `PRAGMA foreign_keys` of its own. When views or triggers name the table being rebuilt, wrap the drop-and-rename in `PRAGMA legacy_alter_table = ON` ... `OFF`, then recreate the rebuilt table's own indexes and triggers.
|
||||||
|
|
||||||
## Integrations
|
## Integrations
|
||||||
- Church Center (ngu.churchcenteronline.com): Planning Center embeds for giving and the calendar.
|
- Church Center (ngu.churchcenteronline.com): Planning Center embeds for giving.
|
||||||
|
|
||||||
|
## graphify
|
||||||
|
|
||||||
|
This project has a knowledge graph at graphify-out/ with god nodes, community structure, and cross-file relationships.
|
||||||
|
|
||||||
|
Rules:
|
||||||
|
- For codebase questions, first run `graphify query "<question>"` when graphify-out/graph.json exists. Use `graphify path "<A>" "<B>"` for relationships and `graphify explain "<concept>"` for focused concepts. These return a scoped subgraph, usually much smaller than GRAPH_REPORT.md or raw grep output.
|
||||||
|
- If graphify-out/wiki/index.md exists, use it for broad navigation instead of raw source browsing.
|
||||||
|
- Read graphify-out/GRAPH_REPORT.md only for broad architecture review or when query/path/explain do not surface enough context.
|
||||||
|
- After modifying code, run `graphify update .` to keep the graph current (AST-only, no API cost).
|
||||||
|
|
|
||||||
|
|
@ -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`.
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,9 @@ which git ignores). The API serves `/uploads/` itself, and Vite proxies
|
||||||
add_header X-Content-Type-Options nosniff;
|
add_header X-Content-Type-Options nosniff;
|
||||||
# An uploaded SVG opened on its own can't run script.
|
# An uploaded SVG opened on its own can't run script.
|
||||||
add_header Content-Security-Policy "default-src 'none'; style-src 'unsafe-inline'; sandbox";
|
add_header Content-Security-Policy "default-src 'none'; style-src 'unsafe-inline'; sandbox";
|
||||||
|
# add_header here replaces the server-level HSTS; say it again
|
||||||
|
# (docs/security-headers.md).
|
||||||
|
add_header Strict-Transport-Security "max-age=31536000" always;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
71
docs/performance.md
Normal file
71
docs/performance.md
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
# Performance
|
||||||
|
|
||||||
|
What keeps the site fast, and what nginx has to do for it.
|
||||||
|
|
||||||
|
## nginx
|
||||||
|
|
||||||
|
In the site's `server` block (both are in `nginx-dev`):
|
||||||
|
|
||||||
|
```nginx
|
||||||
|
gzip on;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_proxied any;
|
||||||
|
gzip_comp_level 5;
|
||||||
|
gzip_min_length 1024;
|
||||||
|
gzip_types text/css application/javascript text/javascript application/json
|
||||||
|
image/svg+xml application/xml application/rss+xml text/plain;
|
||||||
|
|
||||||
|
listen 443 ssl http2;
|
||||||
|
listen [::]:443 ssl http2;
|
||||||
|
```
|
||||||
|
|
||||||
|
Ubuntu's `nginx.conf` turns gzip on for `text/html` only, so without
|
||||||
|
`gzip_types` the JS, CSS, JSON and SVG go out full size (the main JS is
|
||||||
|
about 314 kB, about 98 kB gzipped). Check with
|
||||||
|
`curl -sI -H 'Accept-Encoding: gzip' https://<site>/assets/<file>.js | grep -i content-encoding`.
|
||||||
|
`http2` on the `listen` line works on every nginx; 1.25.1 and later
|
||||||
|
also take a separate `http2 on;`.
|
||||||
|
|
||||||
|
## Caching
|
||||||
|
|
||||||
|
- `/assets/` (hashed build files): a year, `immutable` (nginx).
|
||||||
|
- `/uploads/`: 30 days, `immutable` (nginx). Filenames are random and
|
||||||
|
never reused.
|
||||||
|
- Page HTML: `no-cache` (the API, `routes/pages.js`). The page names the
|
||||||
|
build's hashed assets, so a cached old page after a deploy would ask
|
||||||
|
for files that are gone.
|
||||||
|
- Public API reads: 60 s, plus 5 minutes stale while revalidating
|
||||||
|
(`CACHE` in `server/src/shape.js`).
|
||||||
|
- RSS feeds: read at most every 30 minutes; a visitor never waits for
|
||||||
|
one after the first read (`server/src/feeds.js`).
|
||||||
|
|
||||||
|
## The bundle
|
||||||
|
|
||||||
|
Only the home page is in the main bundle. Every other page, and the
|
||||||
|
whole admin, loads when first visited (`src/App.tsx`). A tab still
|
||||||
|
running an old build that asks for a page removed by a deploy reloads
|
||||||
|
once to pick up the new one.
|
||||||
|
|
||||||
|
The home page asks for events and the timeline alongside its own data
|
||||||
|
(`src/pages/Home.tsx`), and the server tells the browser to fetch
|
||||||
|
`/api/front-page` and the first hero photo while the JS downloads
|
||||||
|
(`preload` in `server/src/pageMeta.js`).
|
||||||
|
|
||||||
|
## Images
|
||||||
|
|
||||||
|
Every raster upload gets a copy at most 640 px on its longer side,
|
||||||
|
`<name>-640.webp`, beside it in the uploads folder
|
||||||
|
(`server/src/media.js`). Logos, avatars and card pictures load that copy
|
||||||
|
(`useSmallImage` in `src/lib/useSmallImage.ts`) and fall back to the
|
||||||
|
full file if it's missing. The server makes any missing copies in the
|
||||||
|
background when it starts, so older uploads and files copied in by hand
|
||||||
|
get one too; deleting an upload deletes its copy.
|
||||||
|
|
||||||
|
## Server
|
||||||
|
|
||||||
|
- Password checks run off the event loop (`verifyPassword`, async
|
||||||
|
scrypt), so a login doesn't stall other requests.
|
||||||
|
- Only `/api/admin/*` is logged per request; nginx's access log has the
|
||||||
|
rest.
|
||||||
|
- ffmpeg encodes run at `nice 19` on Linux, so a clip doesn't slow the
|
||||||
|
site down.
|
||||||
99
docs/security-headers.md
Normal file
99
docs/security-headers.md
Normal file
|
|
@ -0,0 +1,99 @@
|
||||||
|
# Security headers
|
||||||
|
|
||||||
|
Who sends what, and what nginx has to do for it.
|
||||||
|
|
||||||
|
## From the API
|
||||||
|
|
||||||
|
Every response the API sends (pages, `/api`, the sitemap, robots.txt)
|
||||||
|
carries Hono's `secureHeaders()` (`server/src/index.js`):
|
||||||
|
|
||||||
|
- `X-Frame-Options: SAMEORIGIN`: the site can't be framed by another site.
|
||||||
|
- `X-Content-Type-Options: nosniff`
|
||||||
|
- `Referrer-Policy: strict-origin-when-cross-origin`: kept to the origin,
|
||||||
|
because YouTube embeds refuse to play without a referrer.
|
||||||
|
- `Cross-Origin-Opener-Policy` and `Cross-Origin-Resource-Policy: same-origin`
|
||||||
|
- no HSTS (nginx sends it, below)
|
||||||
|
- `Content-Security-Policy-Report-Only`: blocks nothing yet. Browsers
|
||||||
|
post what it would have blocked to `/api/csp-report`, which logs one
|
||||||
|
line per report (`journalctl -u ngu-api | grep csp`). The allowed
|
||||||
|
embed hosts are `EMBEDS` in `server/src/index.js`. After a while of
|
||||||
|
real use with nothing unexpected in the log, rename
|
||||||
|
`contentSecurityPolicyReportOnly` to `contentSecurityPolicy` there to
|
||||||
|
enforce it. A new embed host (a new video site, say) has to be added
|
||||||
|
to `EMBEDS` first.
|
||||||
|
|
||||||
|
The API also refuses a form-style write (`text/plain`, form or
|
||||||
|
multipart body) sent from another site, including a sibling subdomain
|
||||||
|
(`hono/csrf`). Browsers mark their own requests
|
||||||
|
`Sec-Fetch-Site: same-origin`; for older ones it compares `Origin` with
|
||||||
|
the `Host` header, so **nginx must pass `Host`**:
|
||||||
|
|
||||||
|
```nginx
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
```
|
||||||
|
|
||||||
|
Rate limits and stored IP hashes use the **last** `X-Forwarded-For`
|
||||||
|
entry, the one nginx adds from the connection, so each block that
|
||||||
|
proxies to the API needs:
|
||||||
|
|
||||||
|
```nginx
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
```
|
||||||
|
|
||||||
|
Both lines are already in every proxied block in `nginx-dev` and in
|
||||||
|
`docs/seo.md`.
|
||||||
|
|
||||||
|
## Sign-in
|
||||||
|
|
||||||
|
- The session cookie is `__Host-site_session`: the browser only
|
||||||
|
accepts it Secure, on path `/`, with no Domain, so another
|
||||||
|
subdomain can't set or overwrite it. With `COOKIE_SECURE=false`
|
||||||
|
(plain-http local work) it's `site_session`, since the prefix needs
|
||||||
|
Secure.
|
||||||
|
- Logins are limited per IP where `/api/auth/login` is mounted (10
|
||||||
|
per 15 minutes, `server/src/index.js`) and per email in
|
||||||
|
`routes/auth.js`: five wrong passwords for one address lock it for
|
||||||
|
the rest of 15 minutes, from anywhere; a correct one clears the
|
||||||
|
count. Both are in memory and reset when the service restarts.
|
||||||
|
- The per-email lock is a trade-off: anyone who knows an admin's
|
||||||
|
address can keep password sign-in for it locked by guessing wrong
|
||||||
|
five times every 15 minutes. Google sign-in still works for that
|
||||||
|
account, and the lock clears on a restart.
|
||||||
|
- `clientIp` trusts the last `X-Forwarded-For` entry, the one nginx
|
||||||
|
adds. If a CDN or another proxy is ever put in front of nginx, that
|
||||||
|
entry becomes the proxy's address and every visitor shares one
|
||||||
|
rate-limit bucket: set nginx's `real_ip_header` and
|
||||||
|
`set_real_ip_from` for the proxy first.
|
||||||
|
- The Google sign-in state cookie is `__Host-site_oauth` (plain
|
||||||
|
`site_oauth` over local http), and the page it returns to is checked
|
||||||
|
again when the browser comes back.
|
||||||
|
|
||||||
|
## From nginx: HSTS
|
||||||
|
|
||||||
|
nginx terminates TLS and serves files from disk (`/assets/`,
|
||||||
|
`/uploads/`, `index.html` when the API is down), so it sends HSTS for
|
||||||
|
everything:
|
||||||
|
|
||||||
|
```nginx
|
||||||
|
# In the server block (the 443 one).
|
||||||
|
add_header Strict-Transport-Security "max-age=31536000" always;
|
||||||
|
```
|
||||||
|
|
||||||
|
`add_header` in a `location` replaces the server-level ones, so every
|
||||||
|
block with an `add_header` of its own repeats that line (and, on the
|
||||||
|
dev site, the `X-Robots-Tag` one). In `nginx-dev` that's `@file`,
|
||||||
|
`/uploads/`, `/assets/`, `@static` and `= /index.html`. Blocks with no
|
||||||
|
`add_header` (the proxied ones) inherit it.
|
||||||
|
|
||||||
|
No `includeSubDomains`: each subdomain (eg. dev) sends its own. Only
|
||||||
|
add it, or `preload`, once every subdomain is on HTTPS for good; both
|
||||||
|
are hard to undo.
|
||||||
|
|
||||||
|
Check it:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
curl -sI https://nextgenerationofunity.org/ | grep -i strict
|
||||||
|
curl -sI https://nextgenerationofunity.org/assets/<any file> | grep -i strict
|
||||||
|
```
|
||||||
|
|
||||||
|
Each should print the header once.
|
||||||
|
|
@ -90,6 +90,8 @@ with it off it blocks everything.
|
||||||
location @static {
|
location @static {
|
||||||
try_files /index.html =404;
|
try_files /index.html =404;
|
||||||
}
|
}
|
||||||
|
# (A block that adds headers of its own, eg. Cache-Control, must
|
||||||
|
# repeat the server-level HSTS line: docs/security-headers.md.)
|
||||||
|
|
||||||
# From the API, so Site settings' indexing switch applies; the
|
# From the API, so Site settings' indexing switch applies; the
|
||||||
# build's own robots.txt if the API is down.
|
# build's own robots.txt if the API is down.
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ what a dropdown in the admin editor says.
|
||||||
| The **label** a dropdown shows in the admin | code | [one file](#renaming-what-a-dropdown-shows) |
|
| The **label** a dropdown shows in the admin | code | [one file](#renaming-what-a-dropdown-shows) |
|
||||||
| The **list of allowed values** behind a fixed dropdown | database CHECK + code | [a migration and three files](#adding-removing-or-renaming-a-stored-value) |
|
| The **list of allowed values** behind a fixed dropdown | database CHECK + code | [a migration and three files](#adding-removing-or-renaming-a-stored-value) |
|
||||||
| Navigation, page section titles, colours, the site banner, history decades, the map grid | code | [the file named below](#other-content-that-lives-in-code) |
|
| Navigation, page section titles, colours, the site banner, history decades, the map grid | code | [the file named below](#other-content-that-lives-in-code) |
|
||||||
| A static page's title and intro (also its search title and description), the site's name, description, preview image, icons, search indexing | the database, over `site.json` | Admin → Panel → Site settings (superadmins). Blank uses `site.json`, which also holds the site's address and the pages' defaults. See `docs/seo.md` |
|
| A static page's title and intro (also its search title and description), the site's name, description, preview image, icons, search indexing, privacy contact email | the database, over `site.json` | Admin → Panel → Site settings (superadmins). Blank uses `site.json`, which also holds the site's address and the pages' defaults. See `docs/seo.md` |
|
||||||
| Uploaded images | disk + the `media` table | Admin → Tools → Media, or any image field. See `docs/media-uploads.md` |
|
| Uploaded images | disk + the `media` table | Admin → Tools → Media, or any image field. See `docs/media-uploads.md` |
|
||||||
|
|
||||||
The rule of thumb from `CLAUDE.md`: data belongs in the database,
|
The rule of thumb from `CLAUDE.md`: data belongs in the database,
|
||||||
|
|
@ -49,8 +49,8 @@ each entity:
|
||||||
|
|
||||||
| File | What it holds |
|
| File | What it holds |
|
||||||
| ----------------------------- | ----------------------------------------------------- |
|
| ----------------------------- | ----------------------------------------------------- |
|
||||||
| `src/lib/adminSchema.ts` | The **form**: field labels, help text, dropdown labels, list columns and filters |
|
| `src/lib/adminSchema/` (one file per entity, `shared.ts` for common fields; `src/lib/adminSchema.ts` lists them) | The **form**: field labels, help text, dropdown labels, list columns and filters |
|
||||||
| `server/src/admin-schema.js` | What the server **accepts**: columns, types, the allowed values of each `enumeration(...)` |
|
| `server/src/admin-schema/` (one file per entity, `columns.js` for shared helpers; `server/src/admin-schema.js` lists them) | What the server **accepts**: columns, types, the allowed values of each `enumeration(...)` |
|
||||||
|
|
||||||
And the database itself holds the final word: most fixed lists are a
|
And the database itself holds the final word: most fixed lists are a
|
||||||
`CHECK (... IN (...))` constraint on the column (read them in
|
`CHECK (... IN (...))` constraint on the column (read them in
|
||||||
|
|
@ -76,7 +76,7 @@ organization name in the label, as the `awards` query does.
|
||||||
> are changed with a migration: `UPDATE event_scopes SET name = '…' WHERE id = '…';`
|
> are changed with a migration: `UPDATE event_scopes SET name = '…' WHERE id = '…';`
|
||||||
|
|
||||||
**2. A fixed list in code (`options`).** The choices are written in
|
**2. A fixed list in code (`options`).** The choices are written in
|
||||||
`src/lib/adminSchema.ts`. Each option is one of two shapes:
|
the entity's file in `src/lib/adminSchema/`. Each option is one of two shapes:
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
options: ["speaker", "leader", "host"] // shows: speaker, leader, host
|
options: ["speaker", "leader", "host"] // shows: speaker, leader, host
|
||||||
|
|
@ -90,7 +90,7 @@ relabelling cheap.
|
||||||
### Renaming what a dropdown shows
|
### Renaming what a dropdown shows
|
||||||
|
|
||||||
If the stored value stays the same and you only want the dropdown to
|
If the stored value stays the same and you only want the dropdown to
|
||||||
read differently, **only `src/lib/adminSchema.ts` changes**. No
|
read differently, **only the file in `src/lib/adminSchema/` changes**. No
|
||||||
migration, no server change, and every existing row keeps working.
|
migration, no server change, and every existing row keeps working.
|
||||||
|
|
||||||
Find the field (search for its column name) and give the option a
|
Find the field (search for its column name) and give the option a
|
||||||
|
|
@ -145,9 +145,9 @@ together, in one branch:
|
||||||
**Renaming** a value also needs an `UPDATE` in the same migration so
|
**Renaming** a value also needs an `UPDATE` in the same migration so
|
||||||
existing rows move to the new value. **Removing** one needs you to
|
existing rows move to the new value. **Removing** one needs you to
|
||||||
decide what existing rows become first.
|
decide what existing rows become first.
|
||||||
2. **`server/src/admin-schema.js`**: the `enumeration("column", [...])`
|
2. **`server/src/admin-schema/<entity>.js`**: the `enumeration("column", [...])`
|
||||||
list for that column.
|
list for that column.
|
||||||
3. **`src/lib/adminSchema.ts`**: the `options` on the form field, and on
|
3. **`src/lib/adminSchema/<entity>.ts`**: the `options` on the form field, and on
|
||||||
the list filter if there is one.
|
the list filter if there is one.
|
||||||
4. **Anywhere the public site renders or relies on the value**, listed in
|
4. **Anywhere the public site renders or relies on the value**, listed in
|
||||||
the table below (for example `EVENT_TYPES` for event types, or the
|
the table below (for example `EVENT_TYPES` for event types, or the
|
||||||
|
|
@ -160,12 +160,12 @@ wrong rather than working around it.
|
||||||
|
|
||||||
### Every dropdown in the editor
|
### Every dropdown in the editor
|
||||||
|
|
||||||
**Fixed lists** (`options`: labels in `src/lib/adminSchema.ts`, values
|
**Fixed lists** (`options`: labels in `src/lib/adminSchema/`, values
|
||||||
also in `admin-schema.js` and a CHECK):
|
also in `server/src/admin-schema/` and a CHECK):
|
||||||
|
|
||||||
| Entity → field | Stored values | Labelled? | Also used on the public site by |
|
| Entity → field | Stored values | Labelled? | Also used on the public site by |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| Organizations → Kind (+ list filter) | national, region, chapter, partner | no, shows values | `ORG_KIND_LABEL` in `src/lib/hrefs.ts`, and the route each kind uses |
|
| Organizations → Kind (+ list filter) | national, region, chapter, partner | no, shows values | `ORG_BASE` in `src/lib/hrefs.ts` (the route each kind uses) and `orgListHref` there (its back link) |
|
||||||
| Organizations → Region → Scope | domestic, international, virtual | no | the Community page groups regions by it |
|
| Organizations → Region → Scope | domestic, international, virtual | no | the Community page groups regions by it |
|
||||||
| Organizations → Region areas → Edge | top, bottom | no | the chapter map (`OrgList-Map.tsx`) |
|
| Organizations → Region areas → Edge | top, bottom | no | the chapter map (`OrgList-Map.tsx`) |
|
||||||
| Events → Type (+ list filter) | retreat, class, workshop, meeting, other | no | `EVENT_TYPES` in `src/lib/eventTypes.ts` (public labels and plurals) |
|
| Events → Type (+ list filter) | retreat, class, workshop, meeting, other | no | `EVENT_TYPES` in `src/lib/eventTypes.ts` (public labels and plurals) |
|
||||||
|
|
@ -176,7 +176,7 @@ also in `admin-schema.js` and a CHECK):
|
||||||
| Links → Kind (on organizations, events, people, teams) | action, social, website, email | no | `splitLinks` in `server/src/shape.js` |
|
| Links → Kind (on organizations, events, people, teams) | action, social, website, email | no | `splitLinks` in `server/src/shape.js` |
|
||||||
| Links → Platform | instagram, facebook, discord, youtube, tiktok, x, substack, spotify, linkedin | **yes**, `PLATFORMS` | `PlatformIcon.tsx` draws the icon on the button. **No CHECK and no `enumeration`**: the column is plain text, so adding one is an entry in `PLATFORMS` (`src/lib/platforms.ts`) and its icon in `src/components/PlatformIcon.tsx`, no migration. |
|
| Links → Platform | instagram, facebook, discord, youtube, tiktok, x, substack, spotify, linkedin | **yes**, `PLATFORMS` | `PlatformIcon.tsx` draws the icon on the button. **No CHECK and no `enumeration`**: the column is plain text, so adding one is an entry in `PLATFORMS` (`src/lib/platforms.ts`) and its icon in `src/components/PlatformIcon.tsx`, no migration. |
|
||||||
| Content blocks → Shown in (slot) | card, body | **yes** | `paragraphs()` in `server/src/shape.js` (card), `ContentBlocks.tsx` (body) |
|
| Content blocks → Shown in (slot) | card, body | **yes** | `paragraphs()` in `server/src/shape.js` (card), `ContentBlocks.tsx` (body) |
|
||||||
| Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout, schedule | **yes**, `BLOCK_TYPES` (with each type's description) | `ContentBlocks.tsx` (one renderer per type). Which fields each type shows is `when` on the fields in `blocksChild` (`src/lib/adminSchema.ts`). |
|
| Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout, schedule | **yes**, `BLOCK_TYPES` (with each type's description) | `ContentBlocks.tsx` (one renderer per type). Which fields each type shows is `when` on the fields in `blocksChild` (`src/lib/adminSchema/shared.ts`). |
|
||||||
| Timeline → Kind (+ list filter) | milestone, event, organization, award, people | no | `KIND_NAMES` in `src/pages/sections/history/TimelineEntry.tsx` |
|
| Timeline → Kind (+ list filter) | milestone, event, organization, award, people | no | `KIND_NAMES` in `src/pages/sections/history/TimelineEntry.tsx` |
|
||||||
| Timeline → Points at (+ list filter) | event, organization, award, person, team | no | `refHref` in `src/lib/hrefs.ts` |
|
| Timeline → Points at (+ list filter) | event, organization, award, person, team | no | `refHref` in `src/lib/hrefs.ts` |
|
||||||
| Timeline → Precision (and on events/orgs) | year, month, day | no | the history page's grouping |
|
| Timeline → Precision (and on events/orgs) | year, month, day | no | the history page's grouping |
|
||||||
|
|
@ -206,7 +206,6 @@ code):
|
||||||
| Affiliations → Team | `teams` | teams, filtered to the chosen organization |
|
| Affiliations → Team | `teams` | teams, filtered to the chosen organization |
|
||||||
| Person awards → Award | `awards` | awards, labelled "Award (Organization)" |
|
| Person awards → Award | `awards` | awards, labelled "Award (Organization)" |
|
||||||
| Person awards → Presented at; Front page → Count down to; Front page → Featured event | `events` | events |
|
| Person awards → Presented at; Front page → Count down to; Front page → Featured event | `events` | events |
|
||||||
| Timeline → Record | `timeline_refs` | all five kinds, filtered by "Points at" |
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
@ -219,7 +218,7 @@ each is changed in a different place:
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| **The heading on the page** ("National Retreats", "What's on") | **Admin → Pages → Front page → Page sections → Heading.** Blank uses the default below. |
|
| **The heading on the page** ("National Retreats", "What's on") | **Admin → Pages → Front page → Page sections → Heading.** Blank uses the default below. |
|
||||||
| The default heading when that field is blank | `SECTIONS` in `src/pages/Home.tsx`, the `title` of each entry |
|
| The default heading when that field is blank | `SECTIONS` in `src/pages/Home.tsx`, the `title` of each entry |
|
||||||
| **The name in the admin's Section dropdown** ("Events Carousel (National Retreats)") | `FRONT_PAGE_SECTIONS` in `src/lib/adminSchema.ts` |
|
| **The name in the admin's Section dropdown** ("Events Carousel (National Retreats)") | `FRONT_PAGE_SECTIONS` in `src/lib/adminSchema/frontPage.ts` |
|
||||||
| The subnav links under the header ("#Retreats", "#Calendar") | `PAGE_SECTIONS["/"]` in `src/navConfig.ts` |
|
| The subnav links under the header ("#Retreats", "#Calendar") | `PAGE_SECTIONS["/"]` in `src/navConfig.ts` |
|
||||||
|
|
||||||
To rename a band **for visitors**, use the admin. To rename how it
|
To rename a band **for visitors**, use the admin. To rename how it
|
||||||
|
|
@ -243,7 +242,7 @@ change the band's `id`.
|
||||||
**Adding a new kind of band** (not just renaming one) is a feature,
|
**Adding a new kind of band** (not just renaming one) is a feature,
|
||||||
not a relabel: it needs a component, an entry in `SECTIONS` in
|
not a relabel: it needs a component, an entry in `SECTIONS` in
|
||||||
`Home.tsx`, the key added to `FRONT_PAGE_SECTIONS`, to the
|
`Home.tsx`, the key added to `FRONT_PAGE_SECTIONS`, to the
|
||||||
`enumeration("section", …)` in `server/src/admin-schema.js`, to the
|
`enumeration("section", …)` in `server/src/admin-schema/frontPage.js`, to the
|
||||||
`FrontPageSectionKey` type in `src/lib/useFrontPage.ts`, and to the
|
`FrontPageSectionKey` type in `src/lib/useFrontPage.ts`, and to the
|
||||||
CHECK on `front_page_sections.section` via a migration.
|
CHECK on `front_page_sections.section` via a migration.
|
||||||
|
|
||||||
|
|
@ -253,13 +252,13 @@ CHECK on `front_page_sections.section` via a migration.
|
||||||
|
|
||||||
The numbers band's "Number Source" dropdown works the same way:
|
The numbers band's "Number Source" dropdown works the same way:
|
||||||
|
|
||||||
- **Relabel a source:** `STAT_SOURCES` in `src/lib/adminSchema.ts`.
|
- **Relabel a source:** `STAT_SOURCES` in `src/lib/adminSchema/frontPage.ts`.
|
||||||
- **Change what a count counts:** its query in `STAT_QUERIES` in
|
- **Change what a count counts:** its query in `STAT_QUERIES` in
|
||||||
`server/src/routes/home.js`. Keep it counting exactly what the
|
`server/src/routes/home.js`. Keep it counting exactly what the
|
||||||
matching public page shows (published rows), or the number and the
|
matching public page shows (published rows), or the number and the
|
||||||
page will disagree.
|
page will disagree.
|
||||||
- **Add a source:** the CHECK on `front_page_stats.source` (migration),
|
- **Add a source:** the CHECK on `front_page_stats.source` (migration),
|
||||||
the `enumeration("source", …)` in `server/src/admin-schema.js`,
|
the `enumeration("source", …)` in `server/src/admin-schema/frontPage.js`,
|
||||||
`STAT_SOURCES`, and a query in `STAT_QUERIES`.
|
`STAT_SOURCES`, and a query in `STAT_QUERIES`.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
@ -273,10 +272,14 @@ The numbers band's "Number Source" dropdown works the same way:
|
||||||
| Site-wide announcement banner | `src/data/bannerConfig.ts` | `enabled: false` hides it. Bump `id` when the message changes, so people who dismissed the old one see the new one. |
|
| Site-wide announcement banner | `src/data/bannerConfig.ts` | `enabled: false` hides it. Bump `id` when the message changes, so people who dismissed the old one see the new one. |
|
||||||
| History page decade headers | `src/data/historyDecades.ts` | Title, tagline and blurb per decade. |
|
| History page decade headers | `src/data/historyDecades.ts` | Title, tagline and blurb per decade. |
|
||||||
| Chapter map tiles and area names | `src/data/mapGrid.ts` | `AREAS` (tile positions) and `AREA_NAMES`. Which region paints which tile is in the database (Admin → Data → Organizations → a region → Map areas). |
|
| Chapter map tiles and area names | `src/data/mapGrid.ts` | `AREAS` (tile positions) and `AREA_NAMES`. Which region paints which tile is in the database (Admin → Data → Organizations → a region → Map areas). |
|
||||||
| Feedback form types | `src/data/feedbackTypes.ts` **and** `TYPES` in `server/src/routes/feedback.js` | Keep the ids identical in both; the server stores unknown ids as `general`. Labels and hints are client-only. |
|
| Feedback form types | `src/data/feedbackTypes.ts` **and** `TYPES` in `server/src/routes/feedback.js` | Keep the ids identical in both; the server stores unknown ids as `general`. Labels and hints are client-only. `DATA_REQUEST` ('privacy') isn't a tile: the Privacy page's form sends it, and the server requires an email for it. |
|
||||||
|
| The site's colours, light and dark | the database over `src/index.css` | Admin → Panel → Site settings → Colours (superadmins): pick a colour, set its light and/or dark value; saving refuses anything that makes text hard to read. The defaults are `THEME_DEFAULTS` in `server/src/themeDefaults.js` (the admin and the contrast check read it) and the same values as CSS in `src/index.css`; the build stops if the two differ. The admin's labels for them are `THEME_LABELS` in `src/lib/adminSchema/siteSettings.ts`. Change a token's value in both modes and every use follows. Use the token utilities (`text-muted`, `bg-surface`, `border-brand/20`) or `var(--color-…)`, not hex. A colour that arrives as data (a page accent, an event's or region's colour) goes through `src/lib/color.ts`: `withAlpha` for tints, `accentText` for text in it, `readableOn` for text on it. |
|
||||||
|
| The icons a Front page "Find your way in" path can pick | `src/data/pathIcons.ts` (keys and labels) **and** `ICONS` in `src/pages/sections/home/Pathfinder.tsx` (the Phosphor icon for each key) | Add a line to both. A path saved with an emoji from before the list shows it as it is. |
|
||||||
|
| A page section's accent colour | `BRAND` and `ACCENTS` in `src/lib/color.ts` | Pages pick from these (`accent: ACCENTS.green`); add a colour there, not a hex in a page. Each is readable as text on white and the tints. |
|
||||||
|
| Privacy Policy and Terms wording | `src/pages/Privacy.tsx`, `src/pages/Terms.tsx` | The `PARTS` list, and `LAST_UPDATED` whenever the wording changes. The Privacy page must stay true of the code: what the feedback form stores, what the browser keeps, which embeds wait for a click. |
|
||||||
| Event type labels and plurals (public site) | `src/lib/eventTypes.ts` | Also the order of the type filter chips. |
|
| Event type labels and plurals (public site) | `src/lib/eventTypes.ts` | Also the order of the type filter chips. |
|
||||||
| Event and person role labels (public site) | `ROLE_LABEL` in `src/pages/EventDetail.tsx` and `src/pages/PersonDetail.tsx` | |
|
| Event and person role labels (public site) | `ROLE_LABEL` in `src/pages/EventDetail.tsx` and `src/pages/PersonDetail.tsx` | |
|
||||||
| Organization kind labels ("Region", "Chapter") | `ORG_KIND_LABEL` in `src/lib/hrefs.ts` | |
|
| Organization kind labels ("Region", "Chapter") | the Kind options in `src/lib/adminSchema/organizations.ts` (admin); `orgListHref` in `src/lib/hrefs.ts` (the public back link, "All regions") | |
|
||||||
| Admin account roles | `src/lib/roles.ts` (labels, notes) and `ROLES` in `server/src/auth.js` | Adding a role is also a CHECK change on `admin_users.role`. |
|
| Admin account roles | `src/lib/roles.ts` (labels, notes) and `ROLES` in `server/src/auth.js` | Adding a role is also a CHECK change on `admin_users.role`. |
|
||||||
| Admin navigation | `src/pages/admin/adminNav.ts` | |
|
| Admin navigation | `src/pages/admin/adminNav.ts` | |
|
||||||
| The live site's address (used by QR codes) | `SITE_ORIGIN` in `src/lib/site.ts` | |
|
| The live site's address (used by QR codes) | `SITE_ORIGIN` in `src/lib/site.ts` | |
|
||||||
|
|
|
||||||
23
index.html
23
index.html
|
|
@ -5,7 +5,28 @@
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title><!-- site:title --></title>
|
<title><!-- site:title --></title>
|
||||||
<script src="https://js.churchcenter.com/modal/v1"></script>
|
<!-- The browser chrome around the page, for each mode. -->
|
||||||
|
<meta name="theme-color" content="#073d4a" media="(prefers-color-scheme: light)" />
|
||||||
|
<meta name="theme-color" content="#0c1d21" media="(prefers-color-scheme: dark)" />
|
||||||
|
<!-- Theme before first paint, so a dark visitor never sees a white
|
||||||
|
flash: this browser's choice (ThemeToggle), else the system. -->
|
||||||
|
<script>
|
||||||
|
try {
|
||||||
|
// Once: browser keys used to start "ngu-"; move them to "site-"
|
||||||
|
// so a visitor keeps their theme and closed notices.
|
||||||
|
for (var i = localStorage.length - 1; i >= 0; i--) {
|
||||||
|
var k = localStorage.key(i);
|
||||||
|
if (k && k.indexOf("ngu-") === 0) {
|
||||||
|
var nk = "site-" + k.slice(4);
|
||||||
|
if (localStorage.getItem(nk) === null) localStorage.setItem(nk, localStorage.getItem(k));
|
||||||
|
localStorage.removeItem(k);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var t = localStorage.getItem("site-theme");
|
||||||
|
document.documentElement.dataset.theme =
|
||||||
|
t === "dark" || t === "light" ? t : matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
||||||
|
} catch (e) {}
|
||||||
|
</script>
|
||||||
<!-- site:head-end -->
|
<!-- site:head-end -->
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fontsource/montserrat": "^5.3.0",
|
"@fontsource/montserrat": "^5.3.0",
|
||||||
"@fontsource/poppins": "^5.3.0",
|
"@fontsource/poppins": "^5.3.0",
|
||||||
|
"@phosphor-icons/react": "^2.1.10",
|
||||||
"qrcode": "^1.5.4",
|
"qrcode": "^1.5.4",
|
||||||
"react": "^19.0.0",
|
"react": "^19.0.0",
|
||||||
"react-dom": "^19.0.0",
|
"react-dom": "^19.0.0",
|
||||||
|
|
|
||||||
15
pnpm-lock.yaml
generated
15
pnpm-lock.yaml
generated
|
|
@ -14,6 +14,9 @@ importers:
|
||||||
'@fontsource/poppins':
|
'@fontsource/poppins':
|
||||||
specifier: ^5.3.0
|
specifier: ^5.3.0
|
||||||
version: 5.3.0
|
version: 5.3.0
|
||||||
|
'@phosphor-icons/react':
|
||||||
|
specifier: ^2.1.10
|
||||||
|
version: 2.1.10(react-dom@19.3.0(react@19.3.0))(react@19.3.0)
|
||||||
qrcode:
|
qrcode:
|
||||||
specifier: ^1.5.4
|
specifier: ^1.5.4
|
||||||
version: 1.5.4
|
version: 1.5.4
|
||||||
|
|
@ -129,6 +132,13 @@ packages:
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
||||||
|
'@phosphor-icons/react@2.1.10':
|
||||||
|
resolution: {integrity: sha512-vt8Tvq8GLjheAZZYa+YG/pW7HDbov8El/MANW8pOAz4eGxrwhnbfrQZq0Cp4q8zBEu8NIhHdnr+r8thnfRSNYA==}
|
||||||
|
engines: {node: '>=10'}
|
||||||
|
peerDependencies:
|
||||||
|
react: '>= 16.8'
|
||||||
|
react-dom: '>= 16.8'
|
||||||
|
|
||||||
'@rolldown/binding-android-arm-eabi@1.2.9':
|
'@rolldown/binding-android-arm-eabi@1.2.9':
|
||||||
resolution: {integrity: sha512-tNISae1QEf/vkb3xkRcjV5SEdzPE97We5IVaa2Z8jSszQPZ8U60B/YCYpw4QI7VidYsBtKavczXf+DyDs9WGxw==}
|
resolution: {integrity: sha512-tNISae1QEf/vkb3xkRcjV5SEdzPE97We5IVaa2Z8jSszQPZ8U60B/YCYpw4QI7VidYsBtKavczXf+DyDs9WGxw==}
|
||||||
engines: {node: ^20.19.0 || >=22.12.0}
|
engines: {node: ^20.19.0 || >=22.12.0}
|
||||||
|
|
@ -823,6 +833,11 @@ snapshots:
|
||||||
'@oxfmt/win32-x64@0.2.0':
|
'@oxfmt/win32-x64@0.2.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@phosphor-icons/react@2.1.10(react-dom@19.3.0(react@19.3.0))(react@19.3.0)':
|
||||||
|
dependencies:
|
||||||
|
react: 19.3.0
|
||||||
|
react-dom: 19.3.0(react@19.3.0)
|
||||||
|
|
||||||
'@rolldown/binding-android-arm-eabi@1.2.9':
|
'@rolldown/binding-android-arm-eabi@1.2.9':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=22"
|
"node": ">=22.13"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "node --watch src/index.js",
|
"dev": "node --watch src/index.js",
|
||||||
|
|
|
||||||
|
|
@ -21,14 +21,14 @@
|
||||||
admin + delete records
|
admin + delete records
|
||||||
superadmin + accounts, roles and sessions, via /admin/panel
|
superadmin + accounts, roles and sessions, via /admin/panel
|
||||||
|
|
||||||
add takes --role=editor, --name="Full Name". It defaults to
|
add takes --role=admin, --name="Full Name". It defaults to
|
||||||
admin. Press enter at the password prompt and it generates one
|
editor, the least that can change content; raise it on purpose. Press enter at the password prompt and it generates one
|
||||||
and prints it once.
|
and prints it once.
|
||||||
|
|
||||||
The list comes from auth.js rather than being repeated here, so
|
The list comes from auth.js rather than being repeated here, so
|
||||||
the CLI can't drift from what requireRole will actually accept.
|
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:
|
bootstrap path in the web interface, on purpose:
|
||||||
|
|
||||||
node src/admin-cli.js role you@ngu.org superadmin
|
node src/admin-cli.js role you@ngu.org superadmin
|
||||||
|
|
@ -82,7 +82,7 @@ async function readPassword() {
|
||||||
if (first === "") {
|
if (first === "") {
|
||||||
const generated = randomBytes(12).toString("base64url");
|
const generated = randomBytes(12).toString("base64url");
|
||||||
console.log(`\nGenerated password: ${generated}`);
|
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;
|
return generated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,7 +116,7 @@ function checkRole(role) {
|
||||||
return 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
|
Worth saying out loud, because the person doing it is usually
|
||||||
tidying up accounts rather than thinking about lockouts. */
|
tidying up accounts rather than thinking about lockouts. */
|
||||||
function warnIfLastSuper(db, user) {
|
function warnIfLastSuper(db, user) {
|
||||||
|
|
@ -139,7 +139,7 @@ function warnIfLastSuper(db, user) {
|
||||||
async function add(db, email, flags) {
|
async function add(db, email, flags) {
|
||||||
if (findUser(db, email)) fail(`${email} already exists. Use passwd to change it.`);
|
if (findUser(db, email)) fail(`${email} already exists. Use passwd to change it.`);
|
||||||
|
|
||||||
const role = checkRole(flags.role ?? "admin");
|
const role = checkRole(flags.role ?? "editor");
|
||||||
|
|
||||||
const password = await readPassword();
|
const password = await readPassword();
|
||||||
|
|
||||||
|
|
@ -183,7 +183,7 @@ function setRole(db, email, role) {
|
||||||
db.prepare("UPDATE admin_users SET role = ? WHERE id = ?").run(role, user.id);
|
db.prepare("UPDATE admin_users SET role = ? WHERE id = ?").run(role, user.id);
|
||||||
|
|
||||||
// The session they're holding was issued against the old role.
|
// 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.
|
// but their open tab would keep drawing buttons that now 403.
|
||||||
destroyAllSessionsFor(db, user.id);
|
destroyAllSessionsFor(db, user.id);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,11 @@ export class HttpError extends Error {
|
||||||
const SLUG = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
const SLUG = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
||||||
const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
|
const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
|
||||||
const CLOCK_TIME = /^([01]\d|2[0-3]):[0-5]\d$/;
|
const CLOCK_TIME = /^([01]\d|2[0-3]):[0-5]\d$/;
|
||||||
|
// A url column may hold a full link, a site path, an anchor, a bare
|
||||||
|
// domain or a filename, but a scheme other than these is refused
|
||||||
|
// (javascript:, data:), whatever the page does with it later.
|
||||||
|
const URL_SCHEME = /^([a-z][a-z0-9+.-]*):/i;
|
||||||
|
const SAFE_SCHEMES = new Set(["http", "https", "mailto", "tel"]);
|
||||||
|
|
||||||
/* Not a value the caller can ever send, so it can mean "leave this
|
/* Not a value the caller can ever send, so it can mean "leave this
|
||||||
column out of the statement" without colliding with real data. */
|
column out of the statement" without colliding with real data. */
|
||||||
|
|
@ -106,6 +111,17 @@ function coerceValue(column, raw, errors, prefix = "") {
|
||||||
if (!CLOCK_TIME.test(value)) errors[key] = "Use HH:MM, 24-hour.";
|
if (!CLOCK_TIME.test(value)) errors[key] = "Use HH:MM, 24-hour.";
|
||||||
return CLOCK_TIME.test(value) ? value : null;
|
return CLOCK_TIME.test(value) ? value : null;
|
||||||
}
|
}
|
||||||
|
case "url": {
|
||||||
|
const value = String(raw).trim();
|
||||||
|
// The URL parser ignores control characters, spaces and tabs
|
||||||
|
// inside a scheme ("java\tscript:"), so read it the same way.
|
||||||
|
const scheme = URL_SCHEME.exec(value.replace(/[\u0000-\u0020\u007f]/g, ""))?.[1].toLowerCase();
|
||||||
|
if (scheme && !SAFE_SCHEMES.has(scheme)) {
|
||||||
|
errors[key] = "Links must start with http://, https://, mailto: or tel:, or be a site path like /retreats.";
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return value === "" ? null : value;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
const value = String(raw).trim();
|
const value = String(raw).trim();
|
||||||
return value === "" ? null : value;
|
return value === "" ? null : value;
|
||||||
|
|
@ -146,7 +162,7 @@ export function listRows(db, entity, query = {}) {
|
||||||
params.push(...search.map(() => term));
|
params.push(...search.map(() => term));
|
||||||
}
|
}
|
||||||
|
|
||||||
const limit = Math.min(Number(query.limit) || 200, 500);
|
const limit = Math.max(1, Math.min(Number(query.limit) || 200, 500));
|
||||||
|
|
||||||
const rows = db
|
const rows = db
|
||||||
.prepare(
|
.prepare(
|
||||||
|
|
@ -304,7 +320,7 @@ export function createRow(db, entity, payload) {
|
||||||
)
|
)
|
||||||
.run(...Object.values(values))
|
.run(...Object.values(values))
|
||||||
: db.prepare(`INSERT INTO ${entity.table} DEFAULT VALUES`).run();
|
: db.prepare(`INSERT INTO ${entity.table} DEFAULT VALUES`).run();
|
||||||
// better-sqlite3 and node:sqlite disagree about BigInt here.
|
// node:sqlite may hand back a BigInt here.
|
||||||
newId = Number(result.lastInsertRowid);
|
newId = Number(result.lastInsertRowid);
|
||||||
} else {
|
} else {
|
||||||
const names = [entity.idColumn, ...Object.keys(values)];
|
const names = [entity.idColumn, ...Object.keys(values)];
|
||||||
|
|
@ -316,6 +332,7 @@ export function createRow(db, entity, payload) {
|
||||||
|
|
||||||
writeExtensions(db, entity, newId, payload, values);
|
writeExtensions(db, entity, newId, payload, values);
|
||||||
writeChildren(db, entity, newId, payload, values);
|
writeChildren(db, entity, newId, payload, values);
|
||||||
|
entity.check?.(db, newId);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -365,6 +382,9 @@ export function updateRow(db, entity, rawId, payload) {
|
||||||
|
|
||||||
writeExtensions(db, entity, id, payload, merged);
|
writeExtensions(db, entity, id, payload, merged);
|
||||||
writeChildren(db, entity, id, payload, merged);
|
writeChildren(db, entity, id, payload, merged);
|
||||||
|
// The descriptor's own rule over the saved result, children
|
||||||
|
// included. Throwing rolls the whole save back.
|
||||||
|
entity.check?.(db, id);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,19 @@
|
||||||
ever set it, so every insert through the admin will fail.
|
ever set it, so every insert through the admin will fail.
|
||||||
|
|
||||||
The first is a silent repair. The other two are deployment bugs,
|
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.
|
than waiting to surface one row at a time.
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
/* The values a CHECK (column IN (...)) on the table allows, read from
|
||||||
|
its CREATE TABLE, or null when there's no such CHECK. */
|
||||||
|
function checkValues(db, table, column) {
|
||||||
|
const sql = db.prepare(`SELECT sql FROM sqlite_schema WHERE type = 'table' AND name = ?`).get(table)?.sql ?? "";
|
||||||
|
const match = new RegExp(`\\b${column}"?\\s+IN\\s*\\(([^)]*)\\)`, "i").exec(sql);
|
||||||
|
if (!match) return null;
|
||||||
|
return new Set([...match[1].matchAll(/'((?:[^']|'')*)'/g)].map((m) => m[1].replace(/''/g, "'")));
|
||||||
|
}
|
||||||
|
|
||||||
function tableMeta(db, table) {
|
function tableMeta(db, table) {
|
||||||
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
||||||
if (!rows.length) return null;
|
if (!rows.length) return null;
|
||||||
|
|
@ -84,7 +93,7 @@ function collectGroups(entity) {
|
||||||
return groups;
|
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 list = Array.isArray(entities) ? entities.map((e) => [e.name ?? e.table, e]) : Object.entries(entities);
|
||||||
|
|
||||||
const inferred = [];
|
const inferred = [];
|
||||||
|
|
@ -114,6 +123,19 @@ export function syncDescriptorsWithSchema(db, entities, { strict = true } = {})
|
||||||
inferred.push(`${name}: ${group.table}.${column.name}`);
|
inferred.push(`${name}: ${group.table}.${column.name}`);
|
||||||
}
|
}
|
||||||
if (info.notNullable) column.notNullable = true;
|
if (info.notNullable) column.notNullable = true;
|
||||||
|
|
||||||
|
// A dropdown value the table's CHECK refuses would only fail
|
||||||
|
// when someone saves it; say so at boot instead.
|
||||||
|
if (column.type === "enum") {
|
||||||
|
const allowed = checkValues(db, group.table, column.name);
|
||||||
|
const refused = allowed ? column.values.filter((value) => !allowed.has(value)) : [];
|
||||||
|
if (refused.length) {
|
||||||
|
problems.push(
|
||||||
|
`${name}: ${group.table}.${column.name} offers ${refused.join(", ")}, ` +
|
||||||
|
`which the table's CHECK doesn't allow.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [columnName, info] of meta) {
|
for (const [columnName, info] of meta) {
|
||||||
|
|
@ -136,8 +158,7 @@ export function syncDescriptorsWithSchema(db, entities, { strict = true } = {})
|
||||||
|
|
||||||
if (problems.length) {
|
if (problems.length) {
|
||||||
const report = `[admin-schema] descriptor does not match the database:\n ${problems.join("\n ")}`;
|
const report = `[admin-schema] descriptor does not match the database:\n ${problems.join("\n ")}`;
|
||||||
if (strict) throw new Error(report);
|
throw new Error(report);
|
||||||
console.error(report);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { inferred, problems };
|
return { inferred, problems };
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
/* ═══════════════════════════════════════════════════════════════
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
ADMIN ENTITY DESCRIPTORS
|
ADMIN ENTITY DESCRIPTORS
|
||||||
|
|
||||||
|
One object per editable entity, one file each in admin-schema/
|
||||||
|
(the shared column helpers and child collections are in
|
||||||
|
admin-schema/columns.js); this file lists them.
|
||||||
|
|
||||||
One object per editable entity. Everything the CRUD handlers do
|
One object per editable entity. Everything the CRUD handlers do
|
||||||
(validation, SQL, nesting) is read from here, so adding a
|
(validation, SQL, nesting) is read from here, so adding a
|
||||||
table later is a descriptor rather than another set of
|
table later is a descriptor rather than another set of
|
||||||
|
|
@ -15,6 +19,9 @@
|
||||||
children ordered collections, replaced wholesale on save
|
children ordered collections, replaced wholesale on save
|
||||||
singleton the one id this entity ever has; the engine
|
singleton the one id this entity ever has; the engine
|
||||||
refuses create and delete (see front_page)
|
refuses create and delete (see front_page)
|
||||||
|
check (db, id) => void, run after a save has written
|
||||||
|
everything, inside its transaction: throw an
|
||||||
|
HttpError to refuse it (site settings' colours)
|
||||||
|
|
||||||
Replacing children wholesale is only safe because nothing has a
|
Replacing children wholesale is only safe because nothing has a
|
||||||
foreign key INTO these tables. That is the dividing line, and
|
foreign key INTO these tables. That is the dividing line, and
|
||||||
|
|
@ -35,915 +42,15 @@
|
||||||
what the other side owns rather than blanking it.
|
what the other side owns rather than blanking it.
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
/* ── Column helpers ──────────────────────────────────────────── */
|
import { organizations } from "./admin-schema/organizations.js";
|
||||||
|
import { events } from "./admin-schema/events.js";
|
||||||
const text = (name, opts = {}) => ({ name, type: "text", ...opts });
|
import { people } from "./admin-schema/people.js";
|
||||||
const int = (name, opts = {}) => ({ name, type: "int", ...opts });
|
import { teams } from "./admin-schema/teams.js";
|
||||||
const real = (name, opts = {}) => ({ name, type: "real", ...opts });
|
import { awards } from "./admin-schema/awards.js";
|
||||||
const bool = (name, opts = {}) => ({ name, type: "bool", ...opts });
|
import { timeline } from "./admin-schema/timeline.js";
|
||||||
const date = (name, opts = {}) => ({ name, type: "date", ...opts });
|
import { frontPage } from "./admin-schema/frontPage.js";
|
||||||
const time = (name, opts = {}) => ({ name, type: "time", ...opts });
|
import { blogPosts, communityPage } from "./admin-schema/blog.js";
|
||||||
const enumeration = (name, values, opts = {}) => ({
|
import { siteSettings } from "./admin-schema/siteSettings.js";
|
||||||
name,
|
|
||||||
type: "enum",
|
|
||||||
values,
|
|
||||||
...opts,
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Place columns shared by organizations and events, in schema order. */
|
|
||||||
const placeColumns = [
|
|
||||||
text("venue"),
|
|
||||||
text("address"),
|
|
||||||
text("locality"),
|
|
||||||
text("state_code"),
|
|
||||||
text("country"),
|
|
||||||
text("location_label"),
|
|
||||||
real("latitude"),
|
|
||||||
real("longitude"),
|
|
||||||
bool("is_online"),
|
|
||||||
];
|
|
||||||
|
|
||||||
/* The affiliation's own fields, minus whichever end owns the row.
|
|
||||||
Both editors write the same shape so neither loses the other's
|
|
||||||
values on save. */
|
|
||||||
const affiliationRole = [
|
|
||||||
text("title"),
|
|
||||||
enumeration("role", ["lead", "board", "staff", "volunteer", "member"], {
|
|
||||||
required: true,
|
|
||||||
}),
|
|
||||||
bool("is_owner"),
|
|
||||||
date("started_on"),
|
|
||||||
date("ended_on"),
|
|
||||||
bool("is_public"),
|
|
||||||
];
|
|
||||||
|
|
||||||
/* The editable half of a timeline entry, shared by the standalone
|
|
||||||
editor and by the in_timeline extension on events and organizations.
|
|
||||||
|
|
||||||
occurred_on is text, not date. "2012" and "2025-07" are legitimate
|
|
||||||
values (a backfilled entry often knows the year and nothing more),
|
|
||||||
and the date coercion would reject both. `precision` is what says how
|
|
||||||
much of it to believe. */
|
|
||||||
const timelineFields = [
|
|
||||||
text("occurred_on"),
|
|
||||||
enumeration("precision", ["year", "month", "day"]),
|
|
||||||
text("title"),
|
|
||||||
text("blurb"),
|
|
||||||
text("meta"),
|
|
||||||
text("link_url"),
|
|
||||||
bool("is_featured"),
|
|
||||||
bool("is_published"),
|
|
||||||
int("sort_order"),
|
|
||||||
];
|
|
||||||
|
|
||||||
/* The extension that the in_timeline checkbox drives. Ticked, the row
|
|
||||||
is upserted; unticked, writeExtensions deletes it. Both happen in the
|
|
||||||
parent's transaction, so the flag and the row cannot disagree.
|
|
||||||
|
|
||||||
The conflict target is the UNIQUE (ref_kind, ref_id) constraint
|
|
||||||
on timeline_entries, which is also what stops a second save creating a
|
|
||||||
duplicate instead of updating the first. */
|
|
||||||
const timelineExtension = (refKind) => ({
|
|
||||||
key: "timeline",
|
|
||||||
table: "timeline_entries",
|
|
||||||
owner: { column: "ref_id", kindColumn: "ref_kind", kindValue: refKind },
|
|
||||||
conflict: ["ref_kind", "ref_id"],
|
|
||||||
when: { column: "in_timeline", value: 1 },
|
|
||||||
columns: [
|
|
||||||
// Fixed for this end: an event's entry is always an event entry.
|
|
||||||
// Declared as a default rather than a form field so the column is
|
|
||||||
// written without asking.
|
|
||||||
enumeration(
|
|
||||||
"kind",
|
|
||||||
["milestone", "event", "organization", "award", "people"],
|
|
||||||
{ default: refKind === "organization" ? "organization" : refKind },
|
|
||||||
),
|
|
||||||
...timelineFields,
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Featured cards (030_featured_cards.sql): polymorphic like links,
|
|
||||||
so the Community blog can own a set too. */
|
|
||||||
const featuredCardsChild = (ownerKind) => ({
|
|
||||||
key: "featured_cards",
|
|
||||||
table: "featured_cards",
|
|
||||||
owner: { column: "owner_id", kindColumn: "owner_kind", kindValue: ownerKind },
|
|
||||||
order: "sort_order",
|
|
||||||
columns: [
|
|
||||||
enumeration("kind", ["record", "link", "video"], { required: true }),
|
|
||||||
enumeration("ref_kind", ["event", "organization", "person", "team", "award"]),
|
|
||||||
text("ref_id"),
|
|
||||||
text("url"),
|
|
||||||
text("eyebrow"),
|
|
||||||
text("title"),
|
|
||||||
text("blurb"),
|
|
||||||
text("image"),
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
/* The two polymorphic collections, parameterised by owner_kind. */
|
|
||||||
const linksChild = (ownerKind) => ({
|
|
||||||
key: "links",
|
|
||||||
table: "links",
|
|
||||||
owner: { column: "owner_id", kindColumn: "owner_kind", kindValue: ownerKind },
|
|
||||||
order: "sort_order",
|
|
||||||
columns: [
|
|
||||||
enumeration("kind", ["action", "social", "website", "email"], {
|
|
||||||
required: true,
|
|
||||||
}),
|
|
||||||
text("platform"),
|
|
||||||
text("label", { required: true }),
|
|
||||||
text("url", { required: true }),
|
|
||||||
bool("is_primary"),
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const blocksChild = (ownerKind) => ({
|
|
||||||
key: "content_blocks",
|
|
||||||
table: "content_blocks",
|
|
||||||
owner: { column: "owner_id", kindColumn: "owner_kind", kindValue: ownerKind },
|
|
||||||
order: "sort_order",
|
|
||||||
columns: [
|
|
||||||
enumeration("slot", ["card", "body"], { required: true }),
|
|
||||||
enumeration(
|
|
||||||
"type",
|
|
||||||
[
|
|
||||||
"heading",
|
|
||||||
"subheading",
|
|
||||||
"paragraph",
|
|
||||||
"list",
|
|
||||||
"links",
|
|
||||||
"quote",
|
|
||||||
"image",
|
|
||||||
"divider",
|
|
||||||
"video",
|
|
||||||
"button",
|
|
||||||
"callout",
|
|
||||||
"schedule",
|
|
||||||
],
|
|
||||||
{ required: true },
|
|
||||||
),
|
|
||||||
text("text"),
|
|
||||||
text("media"),
|
|
||||||
text("href"),
|
|
||||||
text("alt"),
|
|
||||||
text("cite"),
|
|
||||||
],
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
key: "items",
|
|
||||||
table: "content_block_items",
|
|
||||||
owner: { column: "block_id" },
|
|
||||||
order: "sort_order",
|
|
||||||
columns: [
|
|
||||||
text("text", { required: true }),
|
|
||||||
text("detail"),
|
|
||||||
text("url"),
|
|
||||||
// Schedule entries only (034_schedule_block.sql).
|
|
||||||
text("day"),
|
|
||||||
text("time"),
|
|
||||||
text("location"),
|
|
||||||
text("person_id"),
|
|
||||||
text("description"),
|
|
||||||
text("media"),
|
|
||||||
text("map"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
/* Hosts. One row is one host, ordered, each either an organization
|
|
||||||
or a person. The CHECK on event_hosts rejects both and the blank
|
|
||||||
filter drops neither, so the only bad row that reaches SQLite is
|
|
||||||
one with both selects filled, and that comes back keyed to the
|
|
||||||
row like any other field error.
|
|
||||||
|
|
||||||
Not parameterised the way links and blocks are: this table is
|
|
||||||
events-only, and the owner column says so.
|
|
||||||
|
|
||||||
sort_order isn't declared. The engine writes it from the row's
|
|
||||||
position because `order` is "sort_order", which is what makes
|
|
||||||
the first row the one v_events takes the logo and colour from. */
|
|
||||||
const hostsChild = {
|
|
||||||
key: "event_hosts",
|
|
||||||
table: "event_hosts",
|
|
||||||
owner: { column: "event_id" },
|
|
||||||
order: "sort_order",
|
|
||||||
columns: [text("org_id"), text("person_id")],
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ── Organizations ───────────────────────────────────────────── */
|
|
||||||
|
|
||||||
const organizations = {
|
|
||||||
key: "organizations",
|
|
||||||
table: "organizations",
|
|
||||||
idColumn: "id",
|
|
||||||
idKind: "slug",
|
|
||||||
concurrency: "updated_at",
|
|
||||||
|
|
||||||
list: {
|
|
||||||
columns: [
|
|
||||||
"id",
|
|
||||||
"kind",
|
|
||||||
"name",
|
|
||||||
"short_name",
|
|
||||||
"locality",
|
|
||||||
"state_code",
|
|
||||||
"is_published",
|
|
||||||
"is_listed",
|
|
||||||
"sort_order",
|
|
||||||
"updated_at",
|
|
||||||
],
|
|
||||||
filters: ["kind", "is_published", "is_listed"],
|
|
||||||
search: ["name", "id", "locality"],
|
|
||||||
order: "kind, sort_order, name",
|
|
||||||
},
|
|
||||||
|
|
||||||
columns: [
|
|
||||||
enumeration("kind", ["national", "region", "chapter", "partner"], {
|
|
||||||
required: true,
|
|
||||||
}),
|
|
||||||
text("name", { required: true }),
|
|
||||||
text("short_name"),
|
|
||||||
text("tagline"),
|
|
||||||
text("color"),
|
|
||||||
text("logo"),
|
|
||||||
...placeColumns,
|
|
||||||
bool("is_published"),
|
|
||||||
bool("is_listed"),
|
|
||||||
int("sort_order"),
|
|
||||||
bool("in_timeline"),
|
|
||||||
],
|
|
||||||
|
|
||||||
extensions: [
|
|
||||||
timelineExtension("organization"),
|
|
||||||
{
|
|
||||||
key: "region",
|
|
||||||
table: "regions",
|
|
||||||
idColumn: "id",
|
|
||||||
when: { column: "kind", value: "region" },
|
|
||||||
columns: [
|
|
||||||
enumeration("scope", ["domestic", "international", "virtual"], {
|
|
||||||
required: true,
|
|
||||||
}),
|
|
||||||
text("map_note"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "chapter",
|
|
||||||
table: "chapters",
|
|
||||||
idColumn: "id",
|
|
||||||
when: { column: "kind", value: "chapter" },
|
|
||||||
columns: [text("region_id"), text("meets"), text("started")],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
children: [
|
|
||||||
linksChild("organization"),
|
|
||||||
blocksChild("organization"),
|
|
||||||
{
|
|
||||||
key: "region_areas",
|
|
||||||
table: "region_areas",
|
|
||||||
owner: { column: "region_id" },
|
|
||||||
when: { column: "kind", value: "region" },
|
|
||||||
order: "area_code",
|
|
||||||
columns: [
|
|
||||||
text("area_code", { required: true }),
|
|
||||||
real("share"),
|
|
||||||
enumeration("edge", ["top", "bottom"]),
|
|
||||||
text("note"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ── Events ──────────────────────────────────────────────────── */
|
|
||||||
|
|
||||||
/* Column suffixes for the series weekday flags, Sunday first to
|
|
||||||
match Date#getDay. */
|
|
||||||
const SERIES_WEEKDAYS = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
|
|
||||||
|
|
||||||
const events = {
|
|
||||||
key: "events",
|
|
||||||
table: "events",
|
|
||||||
idColumn: "id",
|
|
||||||
idKind: "slug",
|
|
||||||
concurrency: "updated_at",
|
|
||||||
|
|
||||||
list: {
|
|
||||||
columns: [
|
|
||||||
"id",
|
|
||||||
"title",
|
|
||||||
"scope_id",
|
|
||||||
"event_type",
|
|
||||||
"date_label",
|
|
||||||
"starts_on",
|
|
||||||
"status",
|
|
||||||
"is_published",
|
|
||||||
"is_listed",
|
|
||||||
"updated_at",
|
|
||||||
],
|
|
||||||
// No host filter: hosts are rows in another table now, and the
|
|
||||||
// engine's filters are columns on this one. The events a host
|
|
||||||
// owns are on that host's own page.
|
|
||||||
filters: ["scope_id", "event_type", "status", "is_published", "is_listed"],
|
|
||||||
search: ["title", "id", "theme"],
|
|
||||||
order: "starts_on IS NULL, starts_on DESC, title",
|
|
||||||
},
|
|
||||||
|
|
||||||
columns: [
|
|
||||||
text("scope_id", { required: true }),
|
|
||||||
|
|
||||||
// What kind of gathering, as against scope_id's whose gathering
|
|
||||||
// it is. Declared required even though the column has a
|
|
||||||
// DEFAULT: every select renders a blank first option, so without
|
|
||||||
// it a new event files itself as a retreat while nobody is
|
|
||||||
// looking. An existing row always loads with its value set, so
|
|
||||||
// this only ever asks on create.
|
|
||||||
enumeration(
|
|
||||||
"event_type",
|
|
||||||
["retreat", "class", "workshop", "meeting", "other"],
|
|
||||||
{ required: true },
|
|
||||||
),
|
|
||||||
|
|
||||||
text("title", { required: true }),
|
|
||||||
text("theme"),
|
|
||||||
text("tagline"),
|
|
||||||
date("starts_on"),
|
|
||||||
date("ends_on"),
|
|
||||||
text("date_label"),
|
|
||||||
enumeration("status", ["upcoming", "past", "cancelled"]),
|
|
||||||
...placeColumns,
|
|
||||||
text("org_logo"),
|
|
||||||
text("event_logo"),
|
|
||||||
text("color"),
|
|
||||||
text("gradient"),
|
|
||||||
text("card_image"),
|
|
||||||
bool("is_published"),
|
|
||||||
bool("is_listed"),
|
|
||||||
bool("in_timeline"),
|
|
||||||
|
|
||||||
// A repeating schedule. Columns rather than a side table: the
|
|
||||||
// schedule is always exactly one per event, and the public view
|
|
||||||
// is SELECT e.*, so it reaches the site with no join. Ignored
|
|
||||||
// while is_series is 0. The events table in the schema says
|
|
||||||
// what each means.
|
|
||||||
bool("is_series"),
|
|
||||||
enumeration("series_frequency", ["weekly", "monthly_date", "monthly_weekday"]),
|
|
||||||
int("series_interval"),
|
|
||||||
...SERIES_WEEKDAYS.map((day) => bool(`series_${day}`)),
|
|
||||||
time("series_start_time"),
|
|
||||||
time("series_end_time"),
|
|
||||||
int("series_count"),
|
|
||||||
],
|
|
||||||
|
|
||||||
extensions: [timelineExtension("event")],
|
|
||||||
|
|
||||||
children: [
|
|
||||||
hostsChild,
|
|
||||||
linksChild("event"),
|
|
||||||
blocksChild("event"),
|
|
||||||
{
|
|
||||||
key: "event_people",
|
|
||||||
table: "event_people",
|
|
||||||
owner: { column: "event_id" },
|
|
||||||
order: "sort_order",
|
|
||||||
columns: [
|
|
||||||
text("person_id", { required: true }),
|
|
||||||
enumeration(
|
|
||||||
"role",
|
|
||||||
[
|
|
||||||
"speaker",
|
|
||||||
"leader",
|
|
||||||
"facilitator",
|
|
||||||
"host",
|
|
||||||
"musician",
|
|
||||||
"volunteer",
|
|
||||||
"attendee",
|
|
||||||
],
|
|
||||||
{ required: true },
|
|
||||||
),
|
|
||||||
text("title"),
|
|
||||||
bool("is_public"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ── People ──────────────────────────────────────────────────── */
|
|
||||||
|
|
||||||
const people = {
|
|
||||||
key: "people",
|
|
||||||
table: "people",
|
|
||||||
idColumn: "id",
|
|
||||||
idKind: "slug",
|
|
||||||
concurrency: "updated_at",
|
|
||||||
|
|
||||||
list: {
|
|
||||||
columns: [
|
|
||||||
"id",
|
|
||||||
"display_name",
|
|
||||||
"sort_name",
|
|
||||||
"tagline",
|
|
||||||
"locality",
|
|
||||||
"is_published",
|
|
||||||
"is_listed",
|
|
||||||
"updated_at",
|
|
||||||
],
|
|
||||||
filters: ["is_published", "is_listed"],
|
|
||||||
search: ["display_name", "sort_name", "id"],
|
|
||||||
order: "sort_name, display_name",
|
|
||||||
},
|
|
||||||
|
|
||||||
columns: [
|
|
||||||
text("display_name", { required: true }),
|
|
||||||
text("sort_name"),
|
|
||||||
text("pronouns"),
|
|
||||||
text("tagline"),
|
|
||||||
text("photo"),
|
|
||||||
text("bio"),
|
|
||||||
text("primary_org_id"),
|
|
||||||
text("public_email"),
|
|
||||||
text("public_phone"),
|
|
||||||
text("locality"),
|
|
||||||
text("state_code"),
|
|
||||||
text("country"),
|
|
||||||
text("location_label"),
|
|
||||||
bool("is_published"),
|
|
||||||
bool("is_listed"),
|
|
||||||
],
|
|
||||||
|
|
||||||
extensions: [
|
|
||||||
{
|
|
||||||
key: "private",
|
|
||||||
table: "person_private",
|
|
||||||
idColumn: "person_id",
|
|
||||||
touch: true, // has its own updated_at with no trigger behind it
|
|
||||||
columns: [
|
|
||||||
date("birth_date"),
|
|
||||||
text("private_email"),
|
|
||||||
text("private_phone"),
|
|
||||||
text("address"),
|
|
||||||
text("notes"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
|
|
||||||
children: [
|
|
||||||
linksChild("person"),
|
|
||||||
blocksChild("person"),
|
|
||||||
{
|
|
||||||
key: "affiliations",
|
|
||||||
table: "affiliations",
|
|
||||||
owner: { column: "person_id" },
|
|
||||||
|
|
||||||
// sort_order is where this person sits on that team, so it
|
|
||||||
// belongs to the team's editor. reindex: false stops this
|
|
||||||
// form renumbering by row position; declaring the column
|
|
||||||
// keeps the team's value intact across a save here.
|
|
||||||
reindex: false,
|
|
||||||
order: "org_id, team_id, sort_order",
|
|
||||||
|
|
||||||
columns: [
|
|
||||||
text("org_id", { required: true }),
|
|
||||||
text("team_id"),
|
|
||||||
...affiliationRole,
|
|
||||||
int("sort_order"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "person_awards",
|
|
||||||
table: "person_awards",
|
|
||||||
owner: { column: "person_id" },
|
|
||||||
order: "awarded_on",
|
|
||||||
columns: [
|
|
||||||
text("award_id", { required: true }),
|
|
||||||
text("event_id"),
|
|
||||||
date("awarded_on"),
|
|
||||||
text("citation"),
|
|
||||||
bool("is_public"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ── Teams ───────────────────────────────────────────────────── */
|
|
||||||
|
|
||||||
// A team belongs to exactly one organization, and affiliations
|
|
||||||
// point at the pair (team_id, org_id) rather than the team alone.
|
|
||||||
// Two consequences the form has to live with:
|
|
||||||
//
|
|
||||||
// · org_id cannot be changed once anyone is filed under the
|
|
||||||
// team. The composite foreign key has no ON UPDATE CASCADE, so
|
|
||||||
// SQLite aborts the UPDATE. That surfaces as a constraint
|
|
||||||
// error, which is the correct answer: reassign the members
|
|
||||||
// first.
|
|
||||||
//
|
|
||||||
// · deleting a team with members fails the same way, rather than
|
|
||||||
// quietly detaching them. Emptying the members list first is
|
|
||||||
// now something the form can do.
|
|
||||||
const teams = {
|
|
||||||
key: "teams",
|
|
||||||
table: "teams",
|
|
||||||
idColumn: "id",
|
|
||||||
idKind: "slug",
|
|
||||||
concurrency: "updated_at",
|
|
||||||
|
|
||||||
list: {
|
|
||||||
columns: ["id", "org_id", "name", "tagline", "is_published", "is_listed", "sort_order", "updated_at"],
|
|
||||||
filters: ["org_id", "is_published", "is_listed"],
|
|
||||||
search: ["name", "id", "tagline"],
|
|
||||||
order: "org_id, sort_order, name",
|
|
||||||
},
|
|
||||||
|
|
||||||
columns: [
|
|
||||||
text("org_id", { required: true }),
|
|
||||||
text("name", { required: true }),
|
|
||||||
text("tagline"),
|
|
||||||
text("color"),
|
|
||||||
text("logo"),
|
|
||||||
bool("is_published"),
|
|
||||||
bool("is_listed"),
|
|
||||||
int("sort_order"),
|
|
||||||
],
|
|
||||||
|
|
||||||
children: [
|
|
||||||
// 'team' is already a valid owner_kind in both polymorphic
|
|
||||||
// tables, and teams_cleanup drops the rows on delete, so a team
|
|
||||||
// page comes free.
|
|
||||||
linksChild("team"),
|
|
||||||
blocksChild("team"),
|
|
||||||
{
|
|
||||||
key: "members",
|
|
||||||
table: "affiliations",
|
|
||||||
|
|
||||||
// org_id is inherited from the team rather than asked for:
|
|
||||||
// the composite foreign key (team_id, org_id) means a member
|
|
||||||
// of this team can only belong to this team's organization,
|
|
||||||
// so a second dropdown could only ever be wrong.
|
|
||||||
owner: { column: "team_id", inherit: { org_id: "org_id" } },
|
|
||||||
|
|
||||||
// Row position is the order they appear on the public site.
|
|
||||||
// This is the only editor that writes it.
|
|
||||||
order: "sort_order",
|
|
||||||
|
|
||||||
columns: [text("person_id", { required: true }), ...affiliationRole],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ── Awards ──────────────────────────────────────────────────── */
|
|
||||||
|
|
||||||
// org_id is who gives the award. Nullable, because
|
|
||||||
// an award can predate any decision about which organization owns
|
|
||||||
// it, and because person_awards rows must survive the awarding
|
|
||||||
// org being deleted.
|
|
||||||
//
|
|
||||||
// No children: 'award' is not in the owner_kind CHECK on
|
|
||||||
// content_blocks or links. If awards ever need a page of their
|
|
||||||
// own, that CHECK is a table rebuild, so decide before adding one
|
|
||||||
// rather than after.
|
|
||||||
const awards = {
|
|
||||||
key: "awards",
|
|
||||||
table: "awards",
|
|
||||||
idColumn: "id",
|
|
||||||
idKind: "slug",
|
|
||||||
|
|
||||||
list: {
|
|
||||||
columns: ["id", "org_id", "name", "description", "is_published", "is_listed", "sort_order"],
|
|
||||||
filters: ["org_id", "is_published", "is_listed"],
|
|
||||||
search: ["name", "id", "description"],
|
|
||||||
order: "org_id, sort_order, name",
|
|
||||||
},
|
|
||||||
|
|
||||||
columns: [
|
|
||||||
text("org_id"),
|
|
||||||
text("name", { required: true }),
|
|
||||||
text("description"),
|
|
||||||
text("logo"),
|
|
||||||
bool("is_published"),
|
|
||||||
bool("is_listed"),
|
|
||||||
int("sort_order"),
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ── Timeline ────────────────────────────────────────────────── */
|
|
||||||
|
|
||||||
// The history page's spine, and the only entity whose id the table
|
|
||||||
// assigns. There is nothing to slug: an entry referencing an event has
|
|
||||||
// no name of its own, and one gets created every time somebody ticks a
|
|
||||||
// checkbox. idKind "auto" is what lets createRow skip the id entirely.
|
|
||||||
//
|
|
||||||
// ref_kind and ref_id are writable here and only here. The extension on
|
|
||||||
// events and organizations owns those two columns for rows it created,
|
|
||||||
// which is why they aren't in timelineFields.
|
|
||||||
//
|
|
||||||
// Deleting an entry takes its people with it (ON DELETE CASCADE) and
|
|
||||||
// nothing points at an entry, so the delete-and-reinsert child engine
|
|
||||||
// is safe on this one.
|
|
||||||
const timeline = {
|
|
||||||
key: "timeline",
|
|
||||||
table: "timeline_entries",
|
|
||||||
idColumn: "id",
|
|
||||||
idKind: "auto",
|
|
||||||
concurrency: "updated_at",
|
|
||||||
|
|
||||||
list: {
|
|
||||||
columns: [
|
|
||||||
"id",
|
|
||||||
"kind",
|
|
||||||
"ref_kind",
|
|
||||||
"ref_id",
|
|
||||||
"occurred_on",
|
|
||||||
"title",
|
|
||||||
"is_featured",
|
|
||||||
"is_published",
|
|
||||||
"updated_at",
|
|
||||||
],
|
|
||||||
filters: ["kind", "ref_kind", "is_featured", "is_published"],
|
|
||||||
search: ["title", "blurb", "meta", "ref_id"],
|
|
||||||
// Undated entries sort last rather than first, so a missing date
|
|
||||||
// reads as something to fix instead of something to scroll past.
|
|
||||||
order: "occurred_on IS NULL, occurred_on DESC, sort_order",
|
|
||||||
},
|
|
||||||
|
|
||||||
columns: [
|
|
||||||
enumeration(
|
|
||||||
"kind",
|
|
||||||
["milestone", "event", "organization", "award", "people"],
|
|
||||||
{ required: true },
|
|
||||||
),
|
|
||||||
enumeration("ref_kind", ["event", "organization", "award", "person", "team"]),
|
|
||||||
text("ref_id"),
|
|
||||||
...timelineFields,
|
|
||||||
],
|
|
||||||
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
key: "people",
|
|
||||||
table: "timeline_entry_people",
|
|
||||||
owner: { column: "entry_id" },
|
|
||||||
order: "sort_order",
|
|
||||||
columns: [text("person_id", { required: true }), text("note")],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ── Front page ──────────────────────────────────────────────────
|
|
||||||
|
|
||||||
A singleton: one row, id 'home', seeded by the schema and never
|
|
||||||
created by the admin. `singleton` tells the engine to refuse create
|
|
||||||
and delete, and the CHECK on front_page.id is what makes a second
|
|
||||||
row impossible even without it.
|
|
||||||
|
|
||||||
Every collection here is owned by page_id and replaced wholesale.
|
|
||||||
That is safe for the same reason it is for links and blocks
|
|
||||||
(nothing has a foreign key into these tables), and paths carry
|
|
||||||
their actions as a nested collection, the shape content blocks
|
|
||||||
and their items already use. */
|
|
||||||
|
|
||||||
const frontPage = {
|
|
||||||
key: "front_page",
|
|
||||||
table: "front_page",
|
|
||||||
idColumn: "id",
|
|
||||||
idKind: "slug",
|
|
||||||
singleton: "home",
|
|
||||||
concurrency: "updated_at",
|
|
||||||
|
|
||||||
list: {
|
|
||||||
columns: ["id", "headline", "hero_backdrop", "hero_feature", "updated_at"],
|
|
||||||
filters: [],
|
|
||||||
search: [],
|
|
||||||
order: "id",
|
|
||||||
},
|
|
||||||
|
|
||||||
columns: [
|
|
||||||
enumeration("hero_backdrop", ["brand", "photos"]),
|
|
||||||
enumeration("hero_feature", ["none", "livestream", "video", "event"]),
|
|
||||||
text("hero_event_id"),
|
|
||||||
text("eyebrow"),
|
|
||||||
text("headline"),
|
|
||||||
text("subhead"),
|
|
||||||
text("primary_label"),
|
|
||||||
text("primary_url"),
|
|
||||||
text("secondary_label"),
|
|
||||||
text("secondary_url"),
|
|
||||||
int("slide_seconds"),
|
|
||||||
text("livestream_url"),
|
|
||||||
text("livestream_title"),
|
|
||||||
text("video_url"),
|
|
||||||
text("video_title"),
|
|
||||||
text("countdown_event_id"),
|
|
||||||
text("countdown_scope_id"),
|
|
||||||
enumeration("countdown_event_type", ["retreat", "class", "workshop", "meeting", "other"]),
|
|
||||||
],
|
|
||||||
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
key: "slides",
|
|
||||||
table: "front_page_slides",
|
|
||||||
owner: { column: "page_id" },
|
|
||||||
order: "sort_order",
|
|
||||||
columns: [
|
|
||||||
text("media", { required: true }),
|
|
||||||
text("alt"),
|
|
||||||
text("caption"),
|
|
||||||
text("link_url"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "sections",
|
|
||||||
table: "front_page_sections",
|
|
||||||
owner: { column: "page_id" },
|
|
||||||
order: "sort_order",
|
|
||||||
columns: [
|
|
||||||
enumeration(
|
|
||||||
"section",
|
|
||||||
["countdown", "retreats", "calendar", "stats", "timeline", "connect", "featured"],
|
|
||||||
{ required: true },
|
|
||||||
),
|
|
||||||
text("title"),
|
|
||||||
text("blurb"),
|
|
||||||
bool("is_hidden"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "stats",
|
|
||||||
table: "front_page_stats",
|
|
||||||
owner: { column: "page_id" },
|
|
||||||
order: "sort_order",
|
|
||||||
columns: [
|
|
||||||
text("label", { required: true }),
|
|
||||||
enumeration("source", [
|
|
||||||
"manual",
|
|
||||||
"years_since",
|
|
||||||
"regions",
|
|
||||||
"chapters",
|
|
||||||
"partners",
|
|
||||||
"events_held",
|
|
||||||
"retreats_held",
|
|
||||||
"people",
|
|
||||||
"awards_given",
|
|
||||||
]),
|
|
||||||
text("value"),
|
|
||||||
text("suffix"),
|
|
||||||
text("note"),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
featuredCardsChild("front_page"),
|
|
||||||
{
|
|
||||||
key: "paths",
|
|
||||||
table: "front_page_paths",
|
|
||||||
owner: { column: "page_id" },
|
|
||||||
order: "sort_order",
|
|
||||||
columns: [text("label", { required: true }), text("icon"), text("blurb")],
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
key: "actions",
|
|
||||||
table: "front_page_path_actions",
|
|
||||||
owner: { column: "path_id" },
|
|
||||||
order: "sort_order",
|
|
||||||
columns: [
|
|
||||||
text("label", { required: true }),
|
|
||||||
text("description"),
|
|
||||||
text("url", { required: true }),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ── Blog (031_blog.sql) ─────────────────────────────────────────
|
|
||||||
|
|
||||||
Posts of our own, with a content-block body and people as
|
|
||||||
authors, and the Community page's blog section, a singleton like
|
|
||||||
the front page. The section's community posts are featured cards
|
|
||||||
owned by 'community_page'. ─────────────────────────────────── */
|
|
||||||
|
|
||||||
const blogPosts = {
|
|
||||||
key: "blog_posts",
|
|
||||||
table: "blog_posts",
|
|
||||||
idColumn: "id",
|
|
||||||
idKind: "slug",
|
|
||||||
concurrency: "updated_at",
|
|
||||||
|
|
||||||
list: {
|
|
||||||
columns: ["id", "title", "published_on", "tags", "is_published", "is_listed", "updated_at"],
|
|
||||||
filters: ["is_published", "is_listed"],
|
|
||||||
search: ["title", "id", "tags"],
|
|
||||||
order: "published_on IS NULL, published_on DESC, title",
|
|
||||||
},
|
|
||||||
|
|
||||||
columns: [
|
|
||||||
text("title", { required: true }),
|
|
||||||
text("excerpt"),
|
|
||||||
text("cover_image"),
|
|
||||||
date("published_on"),
|
|
||||||
text("tags"),
|
|
||||||
text("guest_author"),
|
|
||||||
text("guest_photo"),
|
|
||||||
bool("is_published"),
|
|
||||||
bool("is_listed"),
|
|
||||||
],
|
|
||||||
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
key: "authors",
|
|
||||||
table: "blog_post_authors",
|
|
||||||
owner: { column: "post_id" },
|
|
||||||
order: "sort_order",
|
|
||||||
columns: [text("person_id", { required: true })],
|
|
||||||
},
|
|
||||||
blocksChild("blog_post"),
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const communityPage = {
|
|
||||||
key: "community_page",
|
|
||||||
table: "community_page",
|
|
||||||
idColumn: "id",
|
|
||||||
idKind: "slug",
|
|
||||||
singleton: "community",
|
|
||||||
concurrency: "updated_at",
|
|
||||||
|
|
||||||
list: {
|
|
||||||
columns: ["id", "blog_title", "updated_at"],
|
|
||||||
filters: [],
|
|
||||||
search: [],
|
|
||||||
order: "id",
|
|
||||||
},
|
|
||||||
|
|
||||||
columns: [
|
|
||||||
text("blog_title"),
|
|
||||||
text("blog_blurb"),
|
|
||||||
text("internal_title"),
|
|
||||||
int("internal_slots"),
|
|
||||||
text("external_title"),
|
|
||||||
int("external_slots"),
|
|
||||||
text("external_url"),
|
|
||||||
text("external_label"),
|
|
||||||
],
|
|
||||||
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
key: "pinned_posts",
|
|
||||||
table: "community_page_pinned_posts",
|
|
||||||
owner: { column: "page_id" },
|
|
||||||
order: "sort_order",
|
|
||||||
columns: [text("post_id", { required: true })],
|
|
||||||
},
|
|
||||||
featuredCardsChild("community_page"),
|
|
||||||
{
|
|
||||||
key: "feeds",
|
|
||||||
table: "community_page_feeds",
|
|
||||||
owner: { column: "page_id" },
|
|
||||||
order: "sort_order",
|
|
||||||
columns: [text("url", { required: true }), text("label")],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
/* ── Site settings (035_site_settings.sql) ──────────────────────
|
|
||||||
A singleton of overrides for what site.json says: name,
|
|
||||||
description, preview image, icons, search indexing, and static
|
|
||||||
pages' titles and intros. Superadmins only. pageMeta.js merges it
|
|
||||||
over site.json. */
|
|
||||||
const siteSettings = {
|
|
||||||
key: "site_settings",
|
|
||||||
table: "site_settings",
|
|
||||||
idColumn: "id",
|
|
||||||
idKind: "slug",
|
|
||||||
singleton: "site",
|
|
||||||
concurrency: "updated_at",
|
|
||||||
writeRole: "superadmin",
|
|
||||||
|
|
||||||
list: {
|
|
||||||
columns: ["id", "site_name", "updated_at"],
|
|
||||||
filters: [],
|
|
||||||
search: [],
|
|
||||||
order: "id",
|
|
||||||
},
|
|
||||||
|
|
||||||
columns: [
|
|
||||||
text("site_name"),
|
|
||||||
text("description"),
|
|
||||||
text("preview_image"),
|
|
||||||
text("favicon"),
|
|
||||||
text("apple_touch_icon"),
|
|
||||||
enumeration("indexing", ["on", "off"]),
|
|
||||||
],
|
|
||||||
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
key: "pages",
|
|
||||||
table: "site_setting_pages",
|
|
||||||
owner: { column: "settings_id" },
|
|
||||||
order: "sort_order",
|
|
||||||
columns: [text("path", { required: true }), text("title"), text("description")],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
export const ENTITIES = {
|
export const ENTITIES = {
|
||||||
organizations,
|
organizations,
|
||||||
|
|
|
||||||
36
server/src/admin-schema/awards.js
Normal file
36
server/src/admin-schema/awards.js
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
import { text, int, bool } from "./columns.js";
|
||||||
|
|
||||||
|
/* ── Awards ──────────────────────────────────────────────────── */
|
||||||
|
|
||||||
|
// org_id is who gives the award. Nullable, because
|
||||||
|
// an award can predate any decision about which organization owns
|
||||||
|
// it, and because person_awards rows must survive the awarding
|
||||||
|
// org being deleted.
|
||||||
|
//
|
||||||
|
// No children: 'award' is not in the owner_kind CHECK on
|
||||||
|
// content_blocks or links. If awards ever need a page of their
|
||||||
|
// own, that CHECK is a table rebuild, so decide before adding one
|
||||||
|
// rather than after.
|
||||||
|
export const awards = {
|
||||||
|
key: "awards",
|
||||||
|
table: "awards",
|
||||||
|
idColumn: "id",
|
||||||
|
idKind: "slug",
|
||||||
|
|
||||||
|
list: {
|
||||||
|
columns: ["id", "org_id", "name", "description", "is_published", "is_listed", "sort_order"],
|
||||||
|
filters: ["org_id", "is_published", "is_listed"],
|
||||||
|
search: ["name", "id", "description"],
|
||||||
|
order: "org_id, sort_order, name",
|
||||||
|
},
|
||||||
|
|
||||||
|
columns: [
|
||||||
|
text("org_id"),
|
||||||
|
text("name", { required: true }),
|
||||||
|
text("description"),
|
||||||
|
text("logo"),
|
||||||
|
bool("is_published"),
|
||||||
|
bool("is_listed"),
|
||||||
|
int("sort_order"),
|
||||||
|
],
|
||||||
|
};
|
||||||
93
server/src/admin-schema/blog.js
Normal file
93
server/src/admin-schema/blog.js
Normal file
|
|
@ -0,0 +1,93 @@
|
||||||
|
import { text, url, int, bool, date, featuredCardsChild, blocksChild } from "./columns.js";
|
||||||
|
|
||||||
|
/* ── Blog (031_blog.sql) ─────────────────────────────────────────
|
||||||
|
|
||||||
|
Posts of our own, with a content-block body and people as
|
||||||
|
authors, and the Community page's blog section, a singleton like
|
||||||
|
the front page. The section's community posts are featured cards
|
||||||
|
owned by 'community_page'. ─────────────────────────────────── */
|
||||||
|
|
||||||
|
export const blogPosts = {
|
||||||
|
key: "blog_posts",
|
||||||
|
table: "blog_posts",
|
||||||
|
idColumn: "id",
|
||||||
|
idKind: "slug",
|
||||||
|
concurrency: "updated_at",
|
||||||
|
|
||||||
|
list: {
|
||||||
|
columns: ["id", "title", "published_on", "tags", "is_published", "is_listed", "updated_at"],
|
||||||
|
filters: ["is_published", "is_listed"],
|
||||||
|
search: ["title", "id", "tags"],
|
||||||
|
order: "published_on IS NULL, published_on DESC, title",
|
||||||
|
},
|
||||||
|
|
||||||
|
columns: [
|
||||||
|
text("title", { required: true }),
|
||||||
|
text("excerpt"),
|
||||||
|
text("cover_image"),
|
||||||
|
text("cover_alt"),
|
||||||
|
bool("show_contents"),
|
||||||
|
date("published_on"),
|
||||||
|
text("tags"),
|
||||||
|
text("guest_author"),
|
||||||
|
text("guest_photo"),
|
||||||
|
bool("is_published"),
|
||||||
|
bool("is_listed"),
|
||||||
|
],
|
||||||
|
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: "authors",
|
||||||
|
table: "blog_post_authors",
|
||||||
|
owner: { column: "post_id" },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [text("person_id", { required: true })],
|
||||||
|
},
|
||||||
|
blocksChild("blog_post"),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const communityPage = {
|
||||||
|
key: "community_page",
|
||||||
|
table: "community_page",
|
||||||
|
idColumn: "id",
|
||||||
|
idKind: "slug",
|
||||||
|
singleton: "community",
|
||||||
|
concurrency: "updated_at",
|
||||||
|
|
||||||
|
list: {
|
||||||
|
columns: ["id", "blog_title", "updated_at"],
|
||||||
|
filters: [],
|
||||||
|
search: [],
|
||||||
|
order: "id",
|
||||||
|
},
|
||||||
|
|
||||||
|
columns: [
|
||||||
|
text("blog_title"),
|
||||||
|
text("blog_blurb"),
|
||||||
|
text("internal_title"),
|
||||||
|
int("internal_slots"),
|
||||||
|
text("external_title"),
|
||||||
|
int("external_slots"),
|
||||||
|
url("external_url"),
|
||||||
|
text("external_label"),
|
||||||
|
],
|
||||||
|
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: "pinned_posts",
|
||||||
|
table: "community_page_pinned_posts",
|
||||||
|
owner: { column: "page_id" },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [text("post_id", { required: true })],
|
||||||
|
},
|
||||||
|
featuredCardsChild("community_page"),
|
||||||
|
{
|
||||||
|
key: "feeds",
|
||||||
|
table: "community_page_feeds",
|
||||||
|
owner: { column: "page_id" },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [url("url", { required: true }), text("label")],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
202
server/src/admin-schema/columns.js
Normal file
202
server/src/admin-schema/columns.js
Normal file
|
|
@ -0,0 +1,202 @@
|
||||||
|
/* Column helpers, and the field sets and child collections several
|
||||||
|
entities share. The descriptor anatomy is in ../admin-schema.js. */
|
||||||
|
|
||||||
|
/* ── Column helpers ──────────────────────────────────────────── */
|
||||||
|
|
||||||
|
export const text = (name, opts = {}) => ({ name, type: "text", ...opts });
|
||||||
|
// Text that is a link: refuses javascript:, data: and other schemes.
|
||||||
|
export const url = (name, opts = {}) => ({ name, type: "url", ...opts });
|
||||||
|
export const int = (name, opts = {}) => ({ name, type: "int", ...opts });
|
||||||
|
export const real = (name, opts = {}) => ({ name, type: "real", ...opts });
|
||||||
|
export const bool = (name, opts = {}) => ({ name, type: "bool", ...opts });
|
||||||
|
export const date = (name, opts = {}) => ({ name, type: "date", ...opts });
|
||||||
|
export const time = (name, opts = {}) => ({ name, type: "time", ...opts });
|
||||||
|
export const enumeration = (name, values, opts = {}) => ({
|
||||||
|
name,
|
||||||
|
type: "enum",
|
||||||
|
values,
|
||||||
|
...opts,
|
||||||
|
});
|
||||||
|
|
||||||
|
/* Place columns shared by organizations and events, in schema order. */
|
||||||
|
export const placeColumns = [
|
||||||
|
text("venue"),
|
||||||
|
text("address"),
|
||||||
|
text("locality"),
|
||||||
|
text("state_code"),
|
||||||
|
text("country"),
|
||||||
|
text("location_label"),
|
||||||
|
real("latitude"),
|
||||||
|
real("longitude"),
|
||||||
|
bool("is_online"),
|
||||||
|
];
|
||||||
|
|
||||||
|
/* The affiliation's own fields, minus whichever end owns the row.
|
||||||
|
Both editors write the same shape so neither loses the other's
|
||||||
|
values on save. */
|
||||||
|
export const affiliationRole = [
|
||||||
|
text("title"),
|
||||||
|
enumeration("role", ["lead", "board", "staff", "volunteer", "member"], {
|
||||||
|
required: true,
|
||||||
|
}),
|
||||||
|
bool("is_owner"),
|
||||||
|
date("started_on"),
|
||||||
|
date("ended_on"),
|
||||||
|
bool("is_public"),
|
||||||
|
];
|
||||||
|
|
||||||
|
/* The editable half of a timeline entry, shared by the standalone
|
||||||
|
editor and by the in_timeline extension on events and organizations.
|
||||||
|
|
||||||
|
occurred_on is text, not date. "2012" and "2025-07" are legitimate
|
||||||
|
values (a backfilled entry often knows the year and nothing more),
|
||||||
|
and the date coercion would reject both. `precision` is what says how
|
||||||
|
much of it to believe. */
|
||||||
|
export const timelineFields = [
|
||||||
|
text("occurred_on"),
|
||||||
|
enumeration("precision", ["year", "month", "day"]),
|
||||||
|
text("title"),
|
||||||
|
text("blurb"),
|
||||||
|
text("meta"),
|
||||||
|
url("link_url"),
|
||||||
|
bool("is_featured"),
|
||||||
|
bool("is_published"),
|
||||||
|
int("sort_order"),
|
||||||
|
];
|
||||||
|
|
||||||
|
/* The extension that the in_timeline checkbox drives. Ticked, the row
|
||||||
|
is upserted; unticked, writeExtensions deletes it. Both happen in the
|
||||||
|
parent's transaction, so the flag and the row cannot disagree.
|
||||||
|
|
||||||
|
The conflict target is the UNIQUE (ref_kind, ref_id) constraint
|
||||||
|
on timeline_entries, which is also what stops a second save creating a
|
||||||
|
duplicate instead of updating the first. */
|
||||||
|
export const timelineExtension = (refKind) => ({
|
||||||
|
key: "timeline",
|
||||||
|
table: "timeline_entries",
|
||||||
|
owner: { column: "ref_id", kindColumn: "ref_kind", kindValue: refKind },
|
||||||
|
conflict: ["ref_kind", "ref_id"],
|
||||||
|
when: { column: "in_timeline", value: 1 },
|
||||||
|
columns: [
|
||||||
|
// Fixed for this end: an event's entry is always an event entry.
|
||||||
|
// Declared as a default rather than a form field so the column is
|
||||||
|
// written without asking.
|
||||||
|
enumeration(
|
||||||
|
"kind",
|
||||||
|
["milestone", "event", "organization", "award", "people"],
|
||||||
|
{ default: refKind === "organization" ? "organization" : refKind },
|
||||||
|
),
|
||||||
|
...timelineFields,
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
/* Featured cards (030_featured_cards.sql): polymorphic like links,
|
||||||
|
so the Community blog can own a set too. */
|
||||||
|
export const featuredCardsChild = (ownerKind) => ({
|
||||||
|
key: "featured_cards",
|
||||||
|
table: "featured_cards",
|
||||||
|
owner: { column: "owner_id", kindColumn: "owner_kind", kindValue: ownerKind },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [
|
||||||
|
enumeration("kind", ["record", "link", "video"], { required: true }),
|
||||||
|
enumeration("ref_kind", ["event", "organization", "person", "team", "award"]),
|
||||||
|
text("ref_id"),
|
||||||
|
url("url"),
|
||||||
|
text("eyebrow"),
|
||||||
|
text("title"),
|
||||||
|
text("blurb"),
|
||||||
|
text("image"),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
/* The two polymorphic collections, parameterised by owner_kind. */
|
||||||
|
export const linksChild = (ownerKind) => ({
|
||||||
|
key: "links",
|
||||||
|
table: "links",
|
||||||
|
owner: { column: "owner_id", kindColumn: "owner_kind", kindValue: ownerKind },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [
|
||||||
|
enumeration("kind", ["action", "social", "website", "email"], {
|
||||||
|
required: true,
|
||||||
|
}),
|
||||||
|
text("platform"),
|
||||||
|
text("label", { required: true }),
|
||||||
|
url("url", { required: true }),
|
||||||
|
bool("is_primary"),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const blocksChild = (ownerKind) => ({
|
||||||
|
key: "content_blocks",
|
||||||
|
table: "content_blocks",
|
||||||
|
owner: { column: "owner_id", kindColumn: "owner_kind", kindValue: ownerKind },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [
|
||||||
|
enumeration("slot", ["card", "body"], { required: true }),
|
||||||
|
enumeration(
|
||||||
|
"type",
|
||||||
|
[
|
||||||
|
"heading",
|
||||||
|
"subheading",
|
||||||
|
"paragraph",
|
||||||
|
"list",
|
||||||
|
"links",
|
||||||
|
"quote",
|
||||||
|
"image",
|
||||||
|
"divider",
|
||||||
|
"video",
|
||||||
|
"button",
|
||||||
|
"callout",
|
||||||
|
"schedule",
|
||||||
|
],
|
||||||
|
{ required: true },
|
||||||
|
),
|
||||||
|
text("text"),
|
||||||
|
text("media"),
|
||||||
|
url("href"),
|
||||||
|
text("alt"),
|
||||||
|
text("cite"),
|
||||||
|
],
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: "items",
|
||||||
|
table: "content_block_items",
|
||||||
|
owner: { column: "block_id" },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [
|
||||||
|
text("text", { required: true }),
|
||||||
|
text("detail"),
|
||||||
|
url("url"),
|
||||||
|
// Schedule entries only (034_schedule_block.sql).
|
||||||
|
text("day"),
|
||||||
|
text("time"),
|
||||||
|
text("location"),
|
||||||
|
text("person_id"),
|
||||||
|
text("description"),
|
||||||
|
text("media"),
|
||||||
|
text("media_alt"),
|
||||||
|
text("map"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
/* Hosts. One row is one host, ordered, each either an organization
|
||||||
|
or a person. The CHECK on event_hosts rejects both and the blank
|
||||||
|
filter drops neither, so the only bad row that reaches SQLite is
|
||||||
|
one with both selects filled, and that comes back keyed to the
|
||||||
|
row like any other field error.
|
||||||
|
|
||||||
|
Not parameterised the way links and blocks are: this table is
|
||||||
|
events-only, and the owner column says so.
|
||||||
|
|
||||||
|
sort_order isn't declared. The engine writes it from the row's
|
||||||
|
position because `order` is "sort_order", which is what makes
|
||||||
|
the first row the one v_events takes the logo and colour from. */
|
||||||
|
export const hostsChild = {
|
||||||
|
key: "event_hosts",
|
||||||
|
table: "event_hosts",
|
||||||
|
owner: { column: "event_id" },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [text("org_id"), text("person_id")],
|
||||||
|
};
|
||||||
113
server/src/admin-schema/events.js
Normal file
113
server/src/admin-schema/events.js
Normal file
|
|
@ -0,0 +1,113 @@
|
||||||
|
import { text, int, bool, date, time, enumeration, placeColumns, timelineExtension, linksChild, blocksChild, hostsChild } from "./columns.js";
|
||||||
|
|
||||||
|
/* ── Events ──────────────────────────────────────────────────── */
|
||||||
|
|
||||||
|
/* Column suffixes for the series weekday flags, Sunday first to
|
||||||
|
match Date#getDay. */
|
||||||
|
const SERIES_WEEKDAYS = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
|
||||||
|
|
||||||
|
export const events = {
|
||||||
|
key: "events",
|
||||||
|
table: "events",
|
||||||
|
idColumn: "id",
|
||||||
|
idKind: "slug",
|
||||||
|
concurrency: "updated_at",
|
||||||
|
|
||||||
|
list: {
|
||||||
|
columns: [
|
||||||
|
"id",
|
||||||
|
"title",
|
||||||
|
"scope_id",
|
||||||
|
"event_type",
|
||||||
|
"date_label",
|
||||||
|
"starts_on",
|
||||||
|
"status",
|
||||||
|
"is_published",
|
||||||
|
"is_listed",
|
||||||
|
"updated_at",
|
||||||
|
],
|
||||||
|
// No host filter: hosts are rows in another table now, and the
|
||||||
|
// engine's filters are columns on this one. The events a host
|
||||||
|
// owns are on that host's own page.
|
||||||
|
filters: ["scope_id", "event_type", "status", "is_published", "is_listed"],
|
||||||
|
search: ["title", "id", "theme"],
|
||||||
|
order: "starts_on IS NULL, starts_on DESC, title",
|
||||||
|
},
|
||||||
|
|
||||||
|
columns: [
|
||||||
|
text("scope_id", { required: true }),
|
||||||
|
|
||||||
|
// What kind of gathering, as against scope_id's whose gathering
|
||||||
|
// it is. Declared required even though the column has a
|
||||||
|
// DEFAULT: every select renders a blank first option, so without
|
||||||
|
// it a new event files itself as a retreat while nobody is
|
||||||
|
// looking. An existing row always loads with its value set, so
|
||||||
|
// this only ever asks on create.
|
||||||
|
enumeration(
|
||||||
|
"event_type",
|
||||||
|
["retreat", "class", "workshop", "meeting", "other"],
|
||||||
|
{ required: true },
|
||||||
|
),
|
||||||
|
|
||||||
|
text("title", { required: true }),
|
||||||
|
text("theme"),
|
||||||
|
text("tagline"),
|
||||||
|
date("starts_on"),
|
||||||
|
date("ends_on"),
|
||||||
|
text("date_label"),
|
||||||
|
enumeration("status", ["upcoming", "past", "cancelled"]),
|
||||||
|
...placeColumns,
|
||||||
|
text("org_logo"),
|
||||||
|
text("event_logo"),
|
||||||
|
text("color"),
|
||||||
|
text("card_image"),
|
||||||
|
bool("is_published"),
|
||||||
|
bool("is_listed"),
|
||||||
|
bool("in_timeline"),
|
||||||
|
|
||||||
|
// A repeating schedule. Columns rather than a side table: the
|
||||||
|
// schedule is always exactly one per event, and the public view
|
||||||
|
// is SELECT e.*, so it reaches the site with no join. Ignored
|
||||||
|
// while is_series is 0. The events table in the schema says
|
||||||
|
// what each means.
|
||||||
|
bool("is_series"),
|
||||||
|
enumeration("series_frequency", ["weekly", "monthly_date", "monthly_weekday"]),
|
||||||
|
int("series_interval"),
|
||||||
|
...SERIES_WEEKDAYS.map((day) => bool(`series_${day}`)),
|
||||||
|
time("series_start_time"),
|
||||||
|
time("series_end_time"),
|
||||||
|
int("series_count"),
|
||||||
|
],
|
||||||
|
|
||||||
|
extensions: [timelineExtension("event")],
|
||||||
|
|
||||||
|
children: [
|
||||||
|
hostsChild,
|
||||||
|
linksChild("event"),
|
||||||
|
blocksChild("event"),
|
||||||
|
{
|
||||||
|
key: "event_people",
|
||||||
|
table: "event_people",
|
||||||
|
owner: { column: "event_id" },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [
|
||||||
|
text("person_id", { required: true }),
|
||||||
|
enumeration(
|
||||||
|
"role",
|
||||||
|
[
|
||||||
|
"speaker",
|
||||||
|
"leader",
|
||||||
|
"facilitator",
|
||||||
|
"host",
|
||||||
|
"musician",
|
||||||
|
"volunteer",
|
||||||
|
"attendee",
|
||||||
|
],
|
||||||
|
{ required: true },
|
||||||
|
),
|
||||||
|
text("title"),
|
||||||
|
bool("is_public"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
126
server/src/admin-schema/frontPage.js
Normal file
126
server/src/admin-schema/frontPage.js
Normal file
|
|
@ -0,0 +1,126 @@
|
||||||
|
import { text, url, int, bool, enumeration, featuredCardsChild } from "./columns.js";
|
||||||
|
|
||||||
|
/* ── Front page ──────────────────────────────────────────────────
|
||||||
|
|
||||||
|
A singleton: one row, id 'home', seeded by the schema and never
|
||||||
|
created by the admin. `singleton` tells the engine to refuse create
|
||||||
|
and delete, and the CHECK on front_page.id is what makes a second
|
||||||
|
row impossible even without it.
|
||||||
|
|
||||||
|
Every collection here is owned by page_id and replaced wholesale.
|
||||||
|
That is safe for the same reason it is for links and blocks
|
||||||
|
(nothing has a foreign key into these tables), and paths carry
|
||||||
|
their actions as a nested collection, the shape content blocks
|
||||||
|
and their items already use. */
|
||||||
|
|
||||||
|
export const frontPage = {
|
||||||
|
key: "front_page",
|
||||||
|
table: "front_page",
|
||||||
|
idColumn: "id",
|
||||||
|
idKind: "slug",
|
||||||
|
singleton: "home",
|
||||||
|
concurrency: "updated_at",
|
||||||
|
|
||||||
|
list: {
|
||||||
|
columns: ["id", "headline", "hero_backdrop", "hero_feature", "updated_at"],
|
||||||
|
filters: [],
|
||||||
|
search: [],
|
||||||
|
order: "id",
|
||||||
|
},
|
||||||
|
|
||||||
|
columns: [
|
||||||
|
enumeration("hero_backdrop", ["brand", "photos"]),
|
||||||
|
enumeration("hero_feature", ["none", "livestream", "video", "event"]),
|
||||||
|
text("hero_event_id"),
|
||||||
|
text("eyebrow"),
|
||||||
|
text("headline"),
|
||||||
|
text("subhead"),
|
||||||
|
text("primary_label"),
|
||||||
|
url("primary_url"),
|
||||||
|
text("secondary_label"),
|
||||||
|
url("secondary_url"),
|
||||||
|
int("slide_seconds"),
|
||||||
|
url("livestream_url"),
|
||||||
|
text("livestream_title"),
|
||||||
|
url("video_url"),
|
||||||
|
text("video_title"),
|
||||||
|
text("countdown_event_id"),
|
||||||
|
text("countdown_scope_id"),
|
||||||
|
enumeration("countdown_event_type", ["retreat", "class", "workshop", "meeting", "other"]),
|
||||||
|
],
|
||||||
|
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: "slides",
|
||||||
|
table: "front_page_slides",
|
||||||
|
owner: { column: "page_id" },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [
|
||||||
|
text("media", { required: true }),
|
||||||
|
text("alt"),
|
||||||
|
text("caption"),
|
||||||
|
url("link_url"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "sections",
|
||||||
|
table: "front_page_sections",
|
||||||
|
owner: { column: "page_id" },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [
|
||||||
|
enumeration(
|
||||||
|
"section",
|
||||||
|
["countdown", "retreats", "calendar", "stats", "timeline", "connect", "featured"],
|
||||||
|
{ required: true },
|
||||||
|
),
|
||||||
|
text("title"),
|
||||||
|
text("blurb"),
|
||||||
|
bool("is_hidden"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "stats",
|
||||||
|
table: "front_page_stats",
|
||||||
|
owner: { column: "page_id" },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [
|
||||||
|
text("label", { required: true }),
|
||||||
|
enumeration("source", [
|
||||||
|
"manual",
|
||||||
|
"years_since",
|
||||||
|
"regions",
|
||||||
|
"chapters",
|
||||||
|
"partners",
|
||||||
|
"events_held",
|
||||||
|
"retreats_held",
|
||||||
|
"people",
|
||||||
|
"awards_given",
|
||||||
|
]),
|
||||||
|
text("value"),
|
||||||
|
text("suffix"),
|
||||||
|
text("note"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
featuredCardsChild("front_page"),
|
||||||
|
{
|
||||||
|
key: "paths",
|
||||||
|
table: "front_page_paths",
|
||||||
|
owner: { column: "page_id" },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [text("label", { required: true }), text("icon"), text("blurb")],
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: "actions",
|
||||||
|
table: "front_page_path_actions",
|
||||||
|
owner: { column: "path_id" },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [
|
||||||
|
text("label", { required: true }),
|
||||||
|
text("description"),
|
||||||
|
url("url", { required: true }),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
86
server/src/admin-schema/organizations.js
Normal file
86
server/src/admin-schema/organizations.js
Normal file
|
|
@ -0,0 +1,86 @@
|
||||||
|
import { text, int, real, bool, enumeration, placeColumns, timelineExtension, linksChild, blocksChild } from "./columns.js";
|
||||||
|
|
||||||
|
/* ── Organizations ───────────────────────────────────────────── */
|
||||||
|
|
||||||
|
export const organizations = {
|
||||||
|
key: "organizations",
|
||||||
|
table: "organizations",
|
||||||
|
idColumn: "id",
|
||||||
|
idKind: "slug",
|
||||||
|
concurrency: "updated_at",
|
||||||
|
|
||||||
|
list: {
|
||||||
|
columns: [
|
||||||
|
"id",
|
||||||
|
"kind",
|
||||||
|
"name",
|
||||||
|
"short_name",
|
||||||
|
"locality",
|
||||||
|
"state_code",
|
||||||
|
"is_published",
|
||||||
|
"is_listed",
|
||||||
|
"sort_order",
|
||||||
|
"updated_at",
|
||||||
|
],
|
||||||
|
filters: ["kind", "is_published", "is_listed"],
|
||||||
|
search: ["name", "id", "locality"],
|
||||||
|
order: "kind, sort_order, name",
|
||||||
|
},
|
||||||
|
|
||||||
|
columns: [
|
||||||
|
enumeration("kind", ["national", "region", "chapter", "partner"], {
|
||||||
|
required: true,
|
||||||
|
}),
|
||||||
|
text("name", { required: true }),
|
||||||
|
text("short_name"),
|
||||||
|
text("tagline"),
|
||||||
|
text("color"),
|
||||||
|
text("logo"),
|
||||||
|
...placeColumns,
|
||||||
|
bool("is_published"),
|
||||||
|
bool("is_listed"),
|
||||||
|
int("sort_order"),
|
||||||
|
bool("in_timeline"),
|
||||||
|
],
|
||||||
|
|
||||||
|
extensions: [
|
||||||
|
timelineExtension("organization"),
|
||||||
|
{
|
||||||
|
key: "region",
|
||||||
|
table: "regions",
|
||||||
|
idColumn: "id",
|
||||||
|
when: { column: "kind", value: "region" },
|
||||||
|
columns: [
|
||||||
|
enumeration("scope", ["domestic", "international", "virtual"], {
|
||||||
|
required: true,
|
||||||
|
}),
|
||||||
|
text("map_note"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "chapter",
|
||||||
|
table: "chapters",
|
||||||
|
idColumn: "id",
|
||||||
|
when: { column: "kind", value: "chapter" },
|
||||||
|
columns: [text("region_id"), text("meets"), text("started")],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
children: [
|
||||||
|
linksChild("organization"),
|
||||||
|
blocksChild("organization"),
|
||||||
|
{
|
||||||
|
key: "region_areas",
|
||||||
|
table: "region_areas",
|
||||||
|
owner: { column: "region_id" },
|
||||||
|
when: { column: "kind", value: "region" },
|
||||||
|
order: "area_code",
|
||||||
|
columns: [
|
||||||
|
text("area_code", { required: true }),
|
||||||
|
real("share"),
|
||||||
|
enumeration("edge", ["top", "bottom"]),
|
||||||
|
text("note"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
99
server/src/admin-schema/people.js
Normal file
99
server/src/admin-schema/people.js
Normal file
|
|
@ -0,0 +1,99 @@
|
||||||
|
import { text, int, bool, date, affiliationRole, linksChild, blocksChild } from "./columns.js";
|
||||||
|
|
||||||
|
/* ── People ──────────────────────────────────────────────────── */
|
||||||
|
|
||||||
|
export const people = {
|
||||||
|
key: "people",
|
||||||
|
table: "people",
|
||||||
|
idColumn: "id",
|
||||||
|
idKind: "slug",
|
||||||
|
concurrency: "updated_at",
|
||||||
|
|
||||||
|
list: {
|
||||||
|
columns: [
|
||||||
|
"id",
|
||||||
|
"display_name",
|
||||||
|
"sort_name",
|
||||||
|
"tagline",
|
||||||
|
"locality",
|
||||||
|
"is_published",
|
||||||
|
"is_listed",
|
||||||
|
"updated_at",
|
||||||
|
],
|
||||||
|
filters: ["is_published", "is_listed"],
|
||||||
|
search: ["display_name", "sort_name", "id"],
|
||||||
|
order: "sort_name, display_name",
|
||||||
|
},
|
||||||
|
|
||||||
|
columns: [
|
||||||
|
text("display_name", { required: true }),
|
||||||
|
text("sort_name"),
|
||||||
|
text("pronouns"),
|
||||||
|
text("tagline"),
|
||||||
|
text("photo"),
|
||||||
|
text("bio"),
|
||||||
|
text("primary_org_id"),
|
||||||
|
text("public_email"),
|
||||||
|
text("public_phone"),
|
||||||
|
text("locality"),
|
||||||
|
text("state_code"),
|
||||||
|
text("country"),
|
||||||
|
text("location_label"),
|
||||||
|
bool("is_published"),
|
||||||
|
bool("is_listed"),
|
||||||
|
],
|
||||||
|
|
||||||
|
extensions: [
|
||||||
|
{
|
||||||
|
key: "private",
|
||||||
|
table: "person_private",
|
||||||
|
idColumn: "person_id",
|
||||||
|
readRole: "editor", // viewers don't see birth dates, addresses, phones
|
||||||
|
touch: true, // has its own updated_at with no trigger behind it
|
||||||
|
columns: [
|
||||||
|
date("birth_date"),
|
||||||
|
text("private_email"),
|
||||||
|
text("private_phone"),
|
||||||
|
text("address"),
|
||||||
|
text("notes"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
children: [
|
||||||
|
linksChild("person"),
|
||||||
|
blocksChild("person"),
|
||||||
|
{
|
||||||
|
key: "affiliations",
|
||||||
|
table: "affiliations",
|
||||||
|
owner: { column: "person_id" },
|
||||||
|
|
||||||
|
// sort_order is where this person sits on that team, so it
|
||||||
|
// belongs to the team's editor. reindex: false stops this
|
||||||
|
// form renumbering by row position; declaring the column
|
||||||
|
// keeps the team's value intact across a save here.
|
||||||
|
reindex: false,
|
||||||
|
order: "org_id, team_id, sort_order",
|
||||||
|
|
||||||
|
columns: [
|
||||||
|
text("org_id", { required: true }),
|
||||||
|
text("team_id"),
|
||||||
|
...affiliationRole,
|
||||||
|
int("sort_order"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "person_awards",
|
||||||
|
table: "person_awards",
|
||||||
|
owner: { column: "person_id" },
|
||||||
|
order: "awarded_on",
|
||||||
|
columns: [
|
||||||
|
text("award_id", { required: true }),
|
||||||
|
text("event_id"),
|
||||||
|
date("awarded_on"),
|
||||||
|
text("citation"),
|
||||||
|
bool("is_public"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
58
server/src/admin-schema/siteSettings.js
Normal file
58
server/src/admin-schema/siteSettings.js
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
import { THEME_TOKENS, checkTheme } from "../theme.js";
|
||||||
|
import { text, enumeration } from "./columns.js";
|
||||||
|
|
||||||
|
/* ── Site settings (035_site_settings.sql) ──────────────────────
|
||||||
|
A singleton of overrides for what site.json says: name,
|
||||||
|
description, preview image, icons, search indexing, and static
|
||||||
|
pages' titles and intros. Superadmins only. pageMeta.js merges it
|
||||||
|
over site.json. */
|
||||||
|
export const siteSettings = {
|
||||||
|
key: "site_settings",
|
||||||
|
table: "site_settings",
|
||||||
|
idColumn: "id",
|
||||||
|
idKind: "slug",
|
||||||
|
singleton: "site",
|
||||||
|
concurrency: "updated_at",
|
||||||
|
writeRole: "superadmin",
|
||||||
|
|
||||||
|
list: {
|
||||||
|
columns: ["id", "site_name", "updated_at"],
|
||||||
|
filters: [],
|
||||||
|
search: [],
|
||||||
|
order: "id",
|
||||||
|
},
|
||||||
|
|
||||||
|
columns: [
|
||||||
|
text("site_name"),
|
||||||
|
text("description"),
|
||||||
|
text("preview_image"),
|
||||||
|
text("favicon"),
|
||||||
|
text("apple_touch_icon"),
|
||||||
|
enumeration("indexing", ["on", "off"]),
|
||||||
|
text("privacy_email"),
|
||||||
|
],
|
||||||
|
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: "pages",
|
||||||
|
table: "site_setting_pages",
|
||||||
|
owner: { column: "settings_id" },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [text("path", { required: true }), text("title"), text("description")],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "colors",
|
||||||
|
table: "site_setting_colors",
|
||||||
|
owner: { column: "settings_id" },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [
|
||||||
|
enumeration("token", THEME_TOKENS, { required: true }),
|
||||||
|
text("light"),
|
||||||
|
text("dark"),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
// Refuses a palette that would make text hard to read (theme.js).
|
||||||
|
check: checkTheme,
|
||||||
|
};
|
||||||
66
server/src/admin-schema/teams.js
Normal file
66
server/src/admin-schema/teams.js
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
import { text, int, bool, affiliationRole, linksChild, blocksChild } from "./columns.js";
|
||||||
|
|
||||||
|
/* ── Teams ───────────────────────────────────────────────────── */
|
||||||
|
|
||||||
|
// A team belongs to exactly one organization, and affiliations
|
||||||
|
// point at the pair (team_id, org_id) rather than the team alone.
|
||||||
|
// Two consequences the form has to live with:
|
||||||
|
//
|
||||||
|
// · org_id cannot be changed once anyone is filed under the
|
||||||
|
// team. The composite foreign key has no ON UPDATE CASCADE, so
|
||||||
|
// SQLite aborts the UPDATE. That surfaces as a constraint
|
||||||
|
// error, which is the correct answer: reassign the members
|
||||||
|
// first.
|
||||||
|
//
|
||||||
|
// · deleting a team with members fails the same way, rather than
|
||||||
|
// quietly detaching them. Emptying the members list first is
|
||||||
|
// now something the form can do.
|
||||||
|
export const teams = {
|
||||||
|
key: "teams",
|
||||||
|
table: "teams",
|
||||||
|
idColumn: "id",
|
||||||
|
idKind: "slug",
|
||||||
|
concurrency: "updated_at",
|
||||||
|
|
||||||
|
list: {
|
||||||
|
columns: ["id", "org_id", "name", "tagline", "is_published", "is_listed", "sort_order", "updated_at"],
|
||||||
|
filters: ["org_id", "is_published", "is_listed"],
|
||||||
|
search: ["name", "id", "tagline"],
|
||||||
|
order: "org_id, sort_order, name",
|
||||||
|
},
|
||||||
|
|
||||||
|
columns: [
|
||||||
|
text("org_id", { required: true }),
|
||||||
|
text("name", { required: true }),
|
||||||
|
text("tagline"),
|
||||||
|
text("color"),
|
||||||
|
text("logo"),
|
||||||
|
bool("is_published"),
|
||||||
|
bool("is_listed"),
|
||||||
|
int("sort_order"),
|
||||||
|
],
|
||||||
|
|
||||||
|
children: [
|
||||||
|
// 'team' is already a valid owner_kind in both polymorphic
|
||||||
|
// tables, and teams_cleanup drops the rows on delete, so a team
|
||||||
|
// page comes free.
|
||||||
|
linksChild("team"),
|
||||||
|
blocksChild("team"),
|
||||||
|
{
|
||||||
|
key: "members",
|
||||||
|
table: "affiliations",
|
||||||
|
|
||||||
|
// org_id is inherited from the team rather than asked for:
|
||||||
|
// the composite foreign key (team_id, org_id) means a member
|
||||||
|
// of this team can only belong to this team's organization,
|
||||||
|
// so a second dropdown could only ever be wrong.
|
||||||
|
owner: { column: "team_id", inherit: { org_id: "org_id" } },
|
||||||
|
|
||||||
|
// Row position is the order they appear on the public site.
|
||||||
|
// This is the only editor that writes it.
|
||||||
|
order: "sort_order",
|
||||||
|
|
||||||
|
columns: [text("person_id", { required: true }), ...affiliationRole],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
63
server/src/admin-schema/timeline.js
Normal file
63
server/src/admin-schema/timeline.js
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
import { text, date, time, enumeration, timelineFields } from "./columns.js";
|
||||||
|
|
||||||
|
/* ── Timeline ────────────────────────────────────────────────── */
|
||||||
|
|
||||||
|
// The history page's spine, and the only entity whose id the table
|
||||||
|
// assigns. There is nothing to slug: an entry referencing an event has
|
||||||
|
// no name of its own, and one gets created every time somebody ticks a
|
||||||
|
// checkbox. idKind "auto" is what lets createRow skip the id entirely.
|
||||||
|
//
|
||||||
|
// ref_kind and ref_id are writable here and only here. The extension on
|
||||||
|
// events and organizations owns those two columns for rows it created,
|
||||||
|
// which is why they aren't in timelineFields.
|
||||||
|
//
|
||||||
|
// Deleting an entry takes its people with it (ON DELETE CASCADE) and
|
||||||
|
// nothing points at an entry, so the delete-and-reinsert child engine
|
||||||
|
// is safe on this one.
|
||||||
|
export const timeline = {
|
||||||
|
key: "timeline",
|
||||||
|
table: "timeline_entries",
|
||||||
|
idColumn: "id",
|
||||||
|
idKind: "auto",
|
||||||
|
concurrency: "updated_at",
|
||||||
|
|
||||||
|
list: {
|
||||||
|
columns: [
|
||||||
|
"id",
|
||||||
|
"kind",
|
||||||
|
"ref_kind",
|
||||||
|
"ref_id",
|
||||||
|
"occurred_on",
|
||||||
|
"title",
|
||||||
|
"is_featured",
|
||||||
|
"is_published",
|
||||||
|
"updated_at",
|
||||||
|
],
|
||||||
|
filters: ["kind", "ref_kind", "is_featured", "is_published"],
|
||||||
|
search: ["title", "blurb", "meta", "ref_id"],
|
||||||
|
// Undated entries sort last rather than first, so a missing date
|
||||||
|
// reads as something to fix instead of something to scroll past.
|
||||||
|
order: "occurred_on IS NULL, occurred_on DESC, sort_order",
|
||||||
|
},
|
||||||
|
|
||||||
|
columns: [
|
||||||
|
enumeration(
|
||||||
|
"kind",
|
||||||
|
["milestone", "event", "organization", "award", "people"],
|
||||||
|
{ required: true },
|
||||||
|
),
|
||||||
|
enumeration("ref_kind", ["event", "organization", "award", "person", "team"]),
|
||||||
|
text("ref_id"),
|
||||||
|
...timelineFields,
|
||||||
|
],
|
||||||
|
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: "people",
|
||||||
|
table: "timeline_entry_people",
|
||||||
|
owner: { column: "entry_id" },
|
||||||
|
order: "sort_order",
|
||||||
|
columns: [text("person_id", { required: true }), text("note")],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
@ -18,21 +18,29 @@
|
||||||
import {
|
import {
|
||||||
createHash,
|
createHash,
|
||||||
randomBytes,
|
randomBytes,
|
||||||
|
scrypt,
|
||||||
scryptSync,
|
scryptSync,
|
||||||
timingSafeEqual,
|
timingSafeEqual,
|
||||||
} from "node:crypto";
|
} from "node:crypto";
|
||||||
|
import { promisify } from "node:util";
|
||||||
import { getCookie, setCookie, deleteCookie } from "hono/cookie";
|
import { getCookie, setCookie, deleteCookie } from "hono/cookie";
|
||||||
|
|
||||||
export const COOKIE_NAME = "ngu_session";
|
|
||||||
|
|
||||||
const SESSION_DAYS = 30;
|
const SESSION_DAYS = 30;
|
||||||
// Re-issue the expiry when a session is used with less than this
|
// Re-issue the expiry when a session is used with less than this
|
||||||
// left, so an active person is never signed out mid-task.
|
// left, so an active person is never signed out mid-task.
|
||||||
const REFRESH_WITHIN_DAYS = 7;
|
const REFRESH_WITHIN_DAYS = 7;
|
||||||
|
// However active, a session ends this long after sign-in.
|
||||||
|
const MAX_SESSION_DAYS = 90;
|
||||||
|
|
||||||
// Off only for plain-http local work. Production is behind TLS.
|
// Off only for plain-http local work. Production is behind TLS.
|
||||||
export const SECURE_COOKIE = (process.env.COOKIE_SECURE ?? "true") !== "false";
|
export const SECURE_COOKIE = (process.env.COOKIE_SECURE ?? "true") !== "false";
|
||||||
|
|
||||||
|
// __Host- makes the browser refuse the cookie unless it's Secure, on
|
||||||
|
// path /, with no Domain, so a sibling subdomain can't plant or
|
||||||
|
// overwrite it. Plain http (local work, COOKIE_SECURE=false) can't
|
||||||
|
// use the prefix, so it keeps the plain name.
|
||||||
|
export const COOKIE_NAME = SECURE_COOKIE ? "__Host-site_session" : "site_session";
|
||||||
|
|
||||||
const IP_SALT = process.env.IP_SALT ?? randomBytes(16).toString("hex");
|
const IP_SALT = process.env.IP_SALT ?? randomBytes(16).toString("hex");
|
||||||
|
|
||||||
/* ── Passwords ─────────────────────────────────────────────────
|
/* ── Passwords ─────────────────────────────────────────────────
|
||||||
|
|
@ -62,7 +70,11 @@ export function hashPassword(password) {
|
||||||
].join("$");
|
].join("$");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function verifyPassword(password, stored) {
|
/* Async: a login's hash runs on libuv's thread pool, so the ~100 ms it
|
||||||
|
takes doesn't stall every other request while it runs. */
|
||||||
|
const scryptAsync = promisify(scrypt);
|
||||||
|
|
||||||
|
export async function verifyPassword(password, stored) {
|
||||||
if (typeof stored !== "string") return false;
|
if (typeof stored !== "string") return false;
|
||||||
|
|
||||||
const [scheme, N, r, p, saltHex, keyHex] = stored.split("$");
|
const [scheme, N, r, p, saltHex, keyHex] = stored.split("$");
|
||||||
|
|
@ -70,7 +82,7 @@ export function verifyPassword(password, stored) {
|
||||||
|
|
||||||
let candidate;
|
let candidate;
|
||||||
try {
|
try {
|
||||||
candidate = scryptSync(
|
candidate = await scryptAsync(
|
||||||
password.normalize("NFKC"),
|
password.normalize("NFKC"),
|
||||||
Buffer.from(saltHex, "hex"),
|
Buffer.from(saltHex, "hex"),
|
||||||
Buffer.from(keyHex, "hex").length,
|
Buffer.from(keyHex, "hex").length,
|
||||||
|
|
@ -85,6 +97,12 @@ export function verifyPassword(password, stored) {
|
||||||
return timingSafeEqual(candidate, expected);
|
return timingSafeEqual(candidate, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Text a visitor controls, made safe for one log line: control
|
||||||
|
characters (a newline would start a forged line) become "?", and
|
||||||
|
it's cut short. */
|
||||||
|
export const logSafe = (value, max = 200) =>
|
||||||
|
String(value ?? "").replace(/[\u0000-\u001f\u007f]/g, "?").slice(0, max);
|
||||||
|
|
||||||
/* ── Hashing helpers ─────────────────────────────────────────── */
|
/* ── Hashing helpers ─────────────────────────────────────────── */
|
||||||
|
|
||||||
const sha256 = (value) => createHash("sha256").update(value).digest("hex");
|
const sha256 = (value) => createHash("sha256").update(value).digest("hex");
|
||||||
|
|
@ -95,9 +113,11 @@ export function hashIp(ip) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function clientIp(c) {
|
export function clientIp(c) {
|
||||||
// Trustworthy only because this service binds to 127.0.0.1 and
|
// The last X-Forwarded-For entry is the one nginx (or Vite in dev)
|
||||||
// nginx is the only thing that can reach it.
|
// added from the connection itself; anything before it is whatever
|
||||||
return c.req.header("x-forwarded-for")?.split(",")[0].trim() ?? null;
|
// the client sent. Trustworthy only because this service binds to
|
||||||
|
// 127.0.0.1 and nginx is the only thing that can reach it.
|
||||||
|
return c.req.header("x-forwarded-for")?.split(",").at(-1).trim() || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Sessions ────────────────────────────────────────────────── */
|
/* ── Sessions ────────────────────────────────────────────────── */
|
||||||
|
|
@ -160,9 +180,10 @@ export function currentUser(db, c) {
|
||||||
JOIN admin_users u ON u.id = s.user_id
|
JOIN admin_users u ON u.id = s.user_id
|
||||||
WHERE s.token_hash = ?
|
WHERE s.token_hash = ?
|
||||||
AND s.expires_at > datetime('now')
|
AND s.expires_at > datetime('now')
|
||||||
|
AND s.created_at > datetime('now', ?)
|
||||||
AND u.is_active = 1`,
|
AND u.is_active = 1`,
|
||||||
)
|
)
|
||||||
.get(tokenHash);
|
.get(tokenHash, `-${MAX_SESSION_DAYS} days`);
|
||||||
|
|
||||||
if (!row) return null;
|
if (!row) return null;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -150,11 +150,16 @@ export function checkClip(input, source) {
|
||||||
|
|
||||||
/* Runs a tool, calling onLine for each line of its output, and
|
/* Runs a tool, calling onLine for each line of its output, and
|
||||||
resolves with the tail of stderr, or rejects with it. */
|
resolves with the tail of stderr, or rejects with it. */
|
||||||
function run(command, args, { onLine } = {}) {
|
function run(command, args, { onLine, background = false } = {}) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let child;
|
let child;
|
||||||
|
// An encode takes every core it can get; at the lowest priority it
|
||||||
|
// still does, but the API and its pages come first. Linux only
|
||||||
|
// (the VPS); elsewhere it runs as it is.
|
||||||
|
const [cmd, argv] =
|
||||||
|
background && process.platform === "linux" ? ["nice", ["-n", "19", command, ...args]] : [command, args];
|
||||||
try {
|
try {
|
||||||
child = spawn(command, args, { stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
|
child = spawn(cmd, argv, { stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
return;
|
return;
|
||||||
|
|
@ -291,8 +296,9 @@ async function download(db, job) {
|
||||||
await run(
|
await run(
|
||||||
YTDLP,
|
YTDLP,
|
||||||
[
|
[
|
||||||
|
// Our options only: no yt-dlp.conf on the box changes them.
|
||||||
|
"--ignore-config",
|
||||||
...cookies.args,
|
...cookies.args,
|
||||||
job.source_url,
|
|
||||||
// YouTube needs a JavaScript runtime to list formats; the one
|
// YouTube needs a JavaScript runtime to list formats; the one
|
||||||
// running this server will do.
|
// running this server will do.
|
||||||
"--js-runtimes",
|
"--js-runtimes",
|
||||||
|
|
@ -319,6 +325,9 @@ async function download(db, job) {
|
||||||
...(process.env.FFMPEG_PATH ? ["--ffmpeg-location", process.env.FFMPEG_PATH] : []),
|
...(process.env.FFMPEG_PATH ? ["--ffmpeg-location", process.env.FFMPEG_PATH] : []),
|
||||||
"-o",
|
"-o",
|
||||||
template,
|
template,
|
||||||
|
// Last, after --, so the link can never be read as an option.
|
||||||
|
"--",
|
||||||
|
job.source_url,
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
onLine: (line) => {
|
onLine: (line) => {
|
||||||
|
|
@ -326,8 +335,17 @@ async function download(db, job) {
|
||||||
if (percent) update(db, job.id, { progress: Math.min(0.99, Number(percent[1]) / 100) });
|
if (percent) update(db, job.id, { progress: Math.min(0.99, Number(percent[1]) / 100) });
|
||||||
const t = line.match(/^TITLE (.+)$/);
|
const t = line.match(/^TITLE (.+)$/);
|
||||||
if (t) title = t[1].slice(0, 300);
|
if (t) title = t[1].slice(0, 300);
|
||||||
|
// Only this job's own output file counts: a video title with
|
||||||
|
// a newline in it could print a "FILE ..." line of its own.
|
||||||
const f = line.match(/^FILE (.+)$/);
|
const f = line.match(/^FILE (.+)$/);
|
||||||
if (f) file = f[1].trim();
|
const candidate = f?.[1].trim();
|
||||||
|
if (
|
||||||
|
candidate &&
|
||||||
|
path.resolve(path.dirname(candidate)) === path.resolve(CLIPS_DIR) &&
|
||||||
|
path.basename(candidate).startsWith(`source-${job.id}.`)
|
||||||
|
) {
|
||||||
|
file = candidate;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
@ -412,6 +430,7 @@ async function cut(db, job) {
|
||||||
args.push("-progress", "pipe:1", "-nostats", filePath(name));
|
args.push("-progress", "pipe:1", "-nostats", filePath(name));
|
||||||
|
|
||||||
await run(FFMPEG, args, {
|
await run(FFMPEG, args, {
|
||||||
|
background: true,
|
||||||
onLine: (line) => {
|
onLine: (line) => {
|
||||||
const us = line.match(/^out_time_us=(\d+)/);
|
const us = line.match(/^out_time_us=(\d+)/);
|
||||||
if (us) update(db, job.id, { progress: Math.min(0.99, Number(us[1]) / 1e6 / length) });
|
if (us) update(db, job.id, { progress: Math.min(0.99, Number(us[1]) / 1e6 / length) });
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,12 @@
|
||||||
DATABASE
|
DATABASE
|
||||||
|
|
||||||
One SQLite file, opened once at boot and held for the life of
|
One SQLite file, opened once at boot and held for the life of
|
||||||
the process. Node's own sqlite module is used when it's there
|
the process, through Node's own node:sqlite (Node 22.13+).
|
||||||
(Node 24+), better-sqlite3 otherwise. Their APIs overlap enough
|
House rules:
|
||||||
that everything below works against either, as long as you:
|
|
||||||
|
|
||||||
• use positional ? parameters, never named ones
|
• use positional ? parameters, never named ones
|
||||||
• pass 0/1 for booleans, never true/false
|
• pass 0/1 for booleans, never true/false
|
||||||
• use tx() rather than db.transaction()
|
• use tx(): node:sqlite has no db.transaction()
|
||||||
|
|
||||||
Those three rules are the whole compatibility story.
|
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
import { readdirSync, readFileSync } from "node:fs";
|
import { readdirSync, readFileSync } from "node:fs";
|
||||||
|
|
@ -20,18 +17,6 @@ import { fileURLToPath } from "node:url";
|
||||||
const HERE = dirname(fileURLToPath(import.meta.url));
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
||||||
const MIGRATIONS_DIR = join(HERE, "migrations");
|
const MIGRATIONS_DIR = join(HERE, "migrations");
|
||||||
|
|
||||||
/* ── Driver selection ──────────────────────────────────────── */
|
|
||||||
|
|
||||||
async function loadDriver() {
|
|
||||||
try {
|
|
||||||
const { DatabaseSync } = await import("node:sqlite");
|
|
||||||
return { Driver: DatabaseSync, name: "node:sqlite" };
|
|
||||||
} catch {
|
|
||||||
const { default: BetterSqlite3 } = await import("better-sqlite3");
|
|
||||||
return { Driver: BetterSqlite3, name: "better-sqlite3" };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Open ──────────────────────────────────────────────────────
|
/* ── Open ──────────────────────────────────────────────────────
|
||||||
WAL readers never block the writer, which matters the
|
WAL readers never block the writer, which matters the
|
||||||
moment a feedback POST lands mid page-load
|
moment a feedback POST lands mid page-load
|
||||||
|
|
@ -42,15 +27,15 @@ async function loadDriver() {
|
||||||
───────────────────────────────────────────────────────────── */
|
───────────────────────────────────────────────────────────── */
|
||||||
|
|
||||||
export async function openDatabase(path) {
|
export async function openDatabase(path) {
|
||||||
const { Driver, name } = await loadDriver();
|
const { DatabaseSync } = await import("node:sqlite");
|
||||||
const db = new Driver(path);
|
const db = new DatabaseSync(path);
|
||||||
|
|
||||||
db.exec("PRAGMA journal_mode = WAL");
|
db.exec("PRAGMA journal_mode = WAL");
|
||||||
db.exec("PRAGMA foreign_keys = ON");
|
db.exec("PRAGMA foreign_keys = ON");
|
||||||
db.exec("PRAGMA synchronous = NORMAL");
|
db.exec("PRAGMA synchronous = NORMAL");
|
||||||
db.exec("PRAGMA busy_timeout = 5000");
|
db.exec("PRAGMA busy_timeout = 5000");
|
||||||
|
|
||||||
db.driverName = name;
|
db.driverName = "node:sqlite";
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
image on the page.
|
image on the page.
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
import { decodeEntities, safeGet } from "./linkPreview.js";
|
import { decodeEntities, elements, innerOf, openTags, safeGet } from "./linkPreview.js";
|
||||||
|
|
||||||
const CACHE_MS = 30 * 60 * 1000;
|
const CACHE_MS = 30 * 60 * 1000;
|
||||||
const MAX_FEED_BYTES = 3 * 1024 * 1024;
|
const MAX_FEED_BYTES = 3 * 1024 * 1024;
|
||||||
|
|
@ -34,24 +34,32 @@ function unwrap(text) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The text inside the first <tag>…</tag>, CDATA unwrapped. Tag
|
/* The text inside the first <tag>…</tag>, CDATA unwrapped. Tag
|
||||||
names may carry a namespace prefix (content:encoded). */
|
names may carry a namespace prefix (content:encoded). Scanned with
|
||||||
|
indexOf, not a regex: the feed is someone else's (see "Scanning
|
||||||
|
markup" in linkPreview.js). */
|
||||||
function inner(xml, tag) {
|
function inner(xml, tag) {
|
||||||
const match = xml.match(new RegExp(`<${tag}(?:\\s[^>]*)?>([\\s\\S]*?)</${tag}>`, "i"));
|
const text = innerOf(xml, tag);
|
||||||
return match ? unwrap(match[1]) : null;
|
return text == null ? null : unwrap(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
function attrOf(xml, tag, name, where = () => true) {
|
function attrOf(xml, tag, name, where = () => true) {
|
||||||
for (const match of xml.matchAll(new RegExp(`<${tag}\\b[^>]*>`, "gi"))) {
|
for (const el of openTags(xml, tag, 50)) {
|
||||||
const el = match[0];
|
|
||||||
const value = el.match(new RegExp(`\\b${name}\\s*=\\s*("([^"]*)"|'([^']*)')`, "i"));
|
const value = el.match(new RegExp(`\\b${name}\\s*=\\s*("([^"]*)"|'([^']*)')`, "i"));
|
||||||
if (value && where(el)) return value[2] ?? value[3];
|
if (value && where(el)) return value[2] ?? value[3];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enough of a body or summary to make an excerpt from, so the tag
|
||||||
|
// strip and entity decoding never see more than this.
|
||||||
|
const PLAIN_SCAN = 20_000;
|
||||||
|
|
||||||
function plain(html) {
|
function plain(html) {
|
||||||
if (!html) return null;
|
if (!html) return null;
|
||||||
const text = decodeEntities(html.replace(/<[^>]+>/g, " "));
|
// Tags stripped both before and after decoding: a description is
|
||||||
|
// often HTML written as entities (<p>).
|
||||||
|
const strip = (s) => s.replace(/<[^>]*>/g, " ");
|
||||||
|
const text = decodeEntities(strip(decodeEntities(strip(html.slice(0, PLAIN_SCAN)))));
|
||||||
if (!text) return null;
|
if (!text) return null;
|
||||||
return text.length > EXCERPT_CHARS ? `${text.slice(0, EXCERPT_CHARS).trimEnd()}…` : text;
|
return text.length > EXCERPT_CHARS ? `${text.slice(0, EXCERPT_CHARS).trimEnd()}…` : text;
|
||||||
}
|
}
|
||||||
|
|
@ -74,21 +82,34 @@ function isoDate(raw) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function firstImage(html) {
|
function firstImage(html) {
|
||||||
return html?.match(/<img\b[^>]*\bsrc\s*=\s*["']([^"']+)["']/i)?.[1] ?? null;
|
if (!html) return null;
|
||||||
|
for (const tag of openTags(html, "img", 20)) {
|
||||||
|
const src = tag.match(/\bsrc\s*=\s*["']([^"']+)["']/i)?.[1];
|
||||||
|
if (src) return src;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseFeed(xml, feedUrl) {
|
function parseFeed(xml, feedUrl) {
|
||||||
const isAtom = /<feed\b[^>]*xmlns=["']http:\/\/www\.w3\.org\/2005\/Atom/i.test(xml) && !/<rss\b/i.test(xml);
|
// The root element is near the top; nothing needs the rest for this.
|
||||||
const channelTitle = decodeEntities(inner(xml.replace(/<(item|entry)\b[\s\S]*$/i, ""), "title") ?? "");
|
const top = xml.slice(0, 8192);
|
||||||
const blocks = xml.match(isAtom ? /<entry\b[\s\S]*?<\/entry>/gi : /<item\b[\s\S]*?<\/item>/gi) ?? [];
|
const root = openTags(top, "feed", 1)[0] ?? "";
|
||||||
|
const isAtom = /xmlns=["']http:\/\/www\.w3\.org\/2005\/Atom/i.test(root) && openTags(top, "rss", 1).length === 0;
|
||||||
|
const tag = isAtom ? "entry" : "item";
|
||||||
|
// The channel's own title is the one before the first item.
|
||||||
|
const firstItem = xml.toLowerCase().indexOf(`<${tag}`);
|
||||||
|
const channelTitle = decodeEntities(
|
||||||
|
inner(firstItem === -1 ? xml : xml.slice(0, firstItem), "title")?.slice(0, 1000) ?? "",
|
||||||
|
);
|
||||||
|
const blocks = elements(xml, tag, MAX_ITEMS_PER_FEED);
|
||||||
|
|
||||||
const items = [];
|
const items = [];
|
||||||
for (const block of blocks.slice(0, MAX_ITEMS_PER_FEED)) {
|
for (const block of blocks) {
|
||||||
const link = isAtom
|
const link = isAtom
|
||||||
? attrOf(block, "link", "href", (el) => !/rel\s*=\s*["'](?!alternate)/i.test(el))
|
? attrOf(block, "link", "href", (el) => !/rel\s*=\s*["'](?!alternate)/i.test(el))
|
||||||
: inner(block, "link");
|
: inner(block, "link");
|
||||||
const url = safeUrl(link?.trim(), feedUrl);
|
const url = safeUrl(link?.trim(), feedUrl);
|
||||||
const title = decodeEntities(inner(block, "title") ?? "");
|
const title = decodeEntities(inner(block, "title")?.slice(0, 1000) ?? "");
|
||||||
if (!url || !title) continue;
|
if (!url || !title) continue;
|
||||||
|
|
||||||
const body = inner(block, "content:encoded") ?? inner(block, "content");
|
const body = inner(block, "content:encoded") ?? inner(block, "content");
|
||||||
|
|
@ -123,20 +144,37 @@ async function fetchFeed(url) {
|
||||||
return parseFeed(result.body.toString("utf8"), result.url.toString());
|
return parseFeed(result.body.toString("utf8"), result.url.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* One fetch at a time per feed, shared by everyone who asks while it
|
||||||
|
runs. A failure keeps the last good copy and waits 5 minutes before
|
||||||
|
trying again, rather than retrying on every request. */
|
||||||
|
function refresh(url) {
|
||||||
|
const hit = cache.get(url);
|
||||||
|
if (hit?.pending) return hit.pending;
|
||||||
|
const pending = fetchFeed(url)
|
||||||
|
.then((feed) => {
|
||||||
|
cache.set(url, { at: Date.now(), feed });
|
||||||
|
return feed;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.warn(`feed ${url}: ${err.message}`);
|
||||||
|
const stale = hit?.feed ?? { title: null, items: [] };
|
||||||
|
cache.set(url, { at: Date.now() - CACHE_MS + 5 * 60 * 1000, feed: stale });
|
||||||
|
return stale;
|
||||||
|
});
|
||||||
|
cache.set(url, { ...hit, pending });
|
||||||
|
return pending;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* A fresh copy as it is; a stale one straight away while a refresh
|
||||||
|
runs behind it, so no visitor waits on someone else's server once
|
||||||
|
the feed has been read once. Only the very first read waits. */
|
||||||
async function readFeed(url) {
|
async function readFeed(url) {
|
||||||
const hit = cache.get(url);
|
const hit = cache.get(url);
|
||||||
if (hit && Date.now() - hit.at < CACHE_MS) return hit.feed;
|
if (hit?.feed) {
|
||||||
try {
|
if (Date.now() - hit.at >= CACHE_MS) refresh(url);
|
||||||
const feed = await fetchFeed(url);
|
return hit.feed;
|
||||||
cache.set(url, { at: Date.now(), feed });
|
|
||||||
return feed;
|
|
||||||
} catch (err) {
|
|
||||||
console.warn(`feed ${url}: ${err.message}`);
|
|
||||||
// Serve the last good copy, and don't retry on every request.
|
|
||||||
const stale = hit?.feed ?? { title: null, items: [] };
|
|
||||||
cache.set(url, { at: Date.now() - CACHE_MS + 5 * 60 * 1000, feed: stale });
|
|
||||||
return stale;
|
|
||||||
}
|
}
|
||||||
|
return refresh(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Every listed feed's items, newest first, each tagged with its
|
/* Every listed feed's items, newest first, each tagged with its
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
Binds to localhost only. nginx is the only thing that talks to
|
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
|
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
|
origin, and in development Vite proxies /api so they share one
|
||||||
there too.
|
there too.
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
@ -13,7 +13,10 @@ import { mkdir } from "node:fs/promises";
|
||||||
import { serve } from "@hono/node-server";
|
import { serve } from "@hono/node-server";
|
||||||
import { serveStatic } from "@hono/node-server/serve-static";
|
import { serveStatic } from "@hono/node-server/serve-static";
|
||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
|
import { HTTPException } from "hono/http-exception";
|
||||||
|
import { csrf } from "hono/csrf";
|
||||||
import { logger } from "hono/logger";
|
import { logger } from "hono/logger";
|
||||||
|
import { secureHeaders } from "hono/secure-headers";
|
||||||
|
|
||||||
import { openDatabase, migrate } from "./db.js";
|
import { openDatabase, migrate } from "./db.js";
|
||||||
import { rateLimit } from "./rateLimit.js";
|
import { rateLimit } from "./rateLimit.js";
|
||||||
|
|
@ -32,8 +35,8 @@ import adminEntities from "./routes/admin-entities.js";
|
||||||
import media from "./routes/media.js";
|
import media from "./routes/media.js";
|
||||||
import clips from "./routes/clips.js";
|
import clips from "./routes/clips.js";
|
||||||
import { CLIPS_DIR, startClipWorker } from "./clips.js";
|
import { CLIPS_DIR, startClipWorker } from "./clips.js";
|
||||||
import { UPLOADS_DIR } from "./media.js";
|
import { UPLOADS_DIR, writeMissingThumbs } from "./media.js";
|
||||||
import { startSessionSweeper } from "./auth.js";
|
import { logSafe, startSessionSweeper } from "./auth.js";
|
||||||
import { syncDescriptorsWithSchema } from "./admin-schema-sync.js";
|
import { syncDescriptorsWithSchema } from "./admin-schema-sync.js";
|
||||||
import { ENTITIES } from "./admin-schema.js";
|
import { ENTITIES } from "./admin-schema.js";
|
||||||
|
|
||||||
|
|
@ -50,12 +53,102 @@ syncDescriptorsWithSchema(db, ENTITIES);
|
||||||
console.log(`db ${DB_PATH} (${db.driverName}, schema v${version})`);
|
console.log(`db ${DB_PATH} (${db.driverName}, schema v${version})`);
|
||||||
await mkdir(UPLOADS_DIR, { recursive: true });
|
await mkdir(UPLOADS_DIR, { recursive: true });
|
||||||
console.log(`uploads ${UPLOADS_DIR}`);
|
console.log(`uploads ${UPLOADS_DIR}`);
|
||||||
|
// In the background: pages fall back to the full file until it's done.
|
||||||
|
writeMissingThumbs()
|
||||||
|
.then((made) => made && console.log(`uploads: made ${made} small copies`))
|
||||||
|
.catch((err) => console.warn(`uploads: small copies failed: ${err.message}`));
|
||||||
|
|
||||||
/* ── App ─────────────────────────────────────────────────────── */
|
/* ── App ─────────────────────────────────────────────────────── */
|
||||||
|
|
||||||
const app = new Hono();
|
const app = new Hono();
|
||||||
|
|
||||||
app.use("*", logger());
|
// One log line per admin request, for the record of who did what.
|
||||||
|
// Public traffic is left to nginx's access log: logging every request
|
||||||
|
// here too would double the lines and, under a spike, cost the event
|
||||||
|
// loop a synchronous write each.
|
||||||
|
app.use("/api/admin/*", logger());
|
||||||
|
|
||||||
|
/* Headers for every response. Referrer kept to the origin (YouTube
|
||||||
|
embeds refuse to play without one). No HSTS here: nginx sends it on
|
||||||
|
everything, including the files it serves from disk
|
||||||
|
(docs/security-headers.md).
|
||||||
|
|
||||||
|
The Content-Security-Policy is Report-Only for now: nothing is
|
||||||
|
blocked, and each thing it would have blocked is logged by
|
||||||
|
/api/csp-report (journalctl -u ngu-api). Once a while of real use
|
||||||
|
logs nothing unexpected, switch contentSecurityPolicyReportOnly to
|
||||||
|
contentSecurityPolicy. 'unsafe-inline' scripts cover the page's
|
||||||
|
window.__SITE__ and the theme script in index.html. */
|
||||||
|
const EMBEDS = [
|
||||||
|
"https://www.youtube-nocookie.com",
|
||||||
|
"https://www.youtube.com",
|
||||||
|
"https://www.facebook.com",
|
||||||
|
"https://player.vimeo.com",
|
||||||
|
"https://www.google.com",
|
||||||
|
"https://maps.google.com",
|
||||||
|
"https://*.churchcenter.com",
|
||||||
|
"https://*.churchcenteronline.com",
|
||||||
|
];
|
||||||
|
|
||||||
|
app.use(
|
||||||
|
"*",
|
||||||
|
secureHeaders({
|
||||||
|
referrerPolicy: "strict-origin-when-cross-origin",
|
||||||
|
strictTransportSecurity: false,
|
||||||
|
contentSecurityPolicyReportOnly: {
|
||||||
|
defaultSrc: ["'self'"],
|
||||||
|
scriptSrc: ["'self'", "'unsafe-inline'", "https://js.churchcenter.com"],
|
||||||
|
styleSrc: ["'self'", "'unsafe-inline'"],
|
||||||
|
imgSrc: ["'self'", "data:", "https:"],
|
||||||
|
mediaSrc: ["'self'"],
|
||||||
|
fontSrc: ["'self'"],
|
||||||
|
connectSrc: ["'self'"],
|
||||||
|
frameSrc: EMBEDS,
|
||||||
|
frameAncestors: ["'self'"],
|
||||||
|
baseUri: ["'self'"],
|
||||||
|
formAction: ["'self'"],
|
||||||
|
objectSrc: ["'none'"],
|
||||||
|
reportUri: "/api/csp-report",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
/* What the policy above would have blocked. Browsers post these on
|
||||||
|
their own; a short line per report is plenty to go on. */
|
||||||
|
app.use("/api/csp-report", rateLimit({ windowMs: 60_000, max: 30 }));
|
||||||
|
app.post("/api/csp-report", async (c) => {
|
||||||
|
const text = (await c.req.text()).slice(0, 4000);
|
||||||
|
try {
|
||||||
|
const report = JSON.parse(text)["csp-report"] ?? {};
|
||||||
|
const field = (name) => logSafe(report[name] ?? "?", 150);
|
||||||
|
console.warn(
|
||||||
|
`csp ${field("violated-directive")} blocked ${field("blocked-uri")} on ${field("document-uri")}`,
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
// Not a report; nothing to log.
|
||||||
|
}
|
||||||
|
return c.body(null, 204);
|
||||||
|
});
|
||||||
|
|
||||||
|
/* Refuse a form-style write (text/plain, form or multipart body)
|
||||||
|
that another site sent, including a sibling subdomain, which
|
||||||
|
SameSite=Lax cookies don't stop. Browsers mark their own requests
|
||||||
|
Sec-Fetch-Site: same-origin; older ones fall back to Origin, judged
|
||||||
|
by host because nginx speaks plain http to this service. JSON
|
||||||
|
bodies can't be sent cross-origin without a CORS preflight, which
|
||||||
|
this API never answers. */
|
||||||
|
app.use(
|
||||||
|
"/api/*",
|
||||||
|
csrf({
|
||||||
|
origin: (origin, c) => {
|
||||||
|
try {
|
||||||
|
return new URL(origin).host === c.req.header("host");
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
app.use("*", async (c, next) => {
|
app.use("*", async (c, next) => {
|
||||||
c.set("db", db);
|
c.set("db", db);
|
||||||
|
|
@ -120,6 +213,9 @@ console.log(`clips ${CLIPS_DIR}`);
|
||||||
app.notFound((c) => c.json({ error: "Not found" }, 404));
|
app.notFound((c) => c.json({ error: "Not found" }, 404));
|
||||||
|
|
||||||
app.onError((err, c) => {
|
app.onError((err, c) => {
|
||||||
|
// A deliberate refusal (the CSRF check's 403, say) is an answer,
|
||||||
|
// not a crash: send it as it is and keep it out of the error log.
|
||||||
|
if (err instanceof HTTPException) return err.getResponse();
|
||||||
console.error(err);
|
console.error(err);
|
||||||
// Never leak internals to the browser.
|
// Never leak internals to the browser.
|
||||||
return c.json({ error: "Something went wrong." }, 500);
|
return c.json({ error: "Something went wrong." }, 500);
|
||||||
|
|
@ -139,7 +235,7 @@ const server = serve({ fetch: app.fetch, hostname: HOST, port: PORT }, (info) =>
|
||||||
|
|
||||||
for (const signal of ["SIGTERM", "SIGINT"]) {
|
for (const signal of ["SIGTERM", "SIGINT"]) {
|
||||||
process.on(signal, () => {
|
process.on(signal, () => {
|
||||||
console.log(`${signal} — shutting down`);
|
console.log(`${signal}, shutting down`);
|
||||||
server.close(() => {
|
server.close(() => {
|
||||||
try {
|
try {
|
||||||
db.close();
|
db.close();
|
||||||
|
|
|
||||||
|
|
@ -34,41 +34,33 @@ import net from "node:net";
|
||||||
import { MAX_UPLOAD_BYTES, MediaError } from "./media.js";
|
import { MAX_UPLOAD_BYTES, MediaError } from "./media.js";
|
||||||
|
|
||||||
const TIMEOUT_MS = 8000;
|
const TIMEOUT_MS = 8000;
|
||||||
|
// The whole request, however steadily the bytes trickle in.
|
||||||
|
const TOTAL_TIMEOUT_MS = 15000;
|
||||||
const MAX_REDIRECTS = 4;
|
const MAX_REDIRECTS = 4;
|
||||||
const MAX_HTML_BYTES = 1024 * 1024;
|
const MAX_HTML_BYTES = 1024 * 1024;
|
||||||
const USER_AGENT = "NGU-LinkPreview/1.0 (+https://nextgenerationofunity.org)";
|
const USER_AGENT = "NGU-LinkPreview/1.0 (+https://nextgenerationofunity.org)";
|
||||||
|
|
||||||
/* ── Address checks ────────────────────────────────────────── */
|
/* ── Address checks ────────────────────────────────────────── */
|
||||||
|
|
||||||
function ipv4Blocked(ip) {
|
/* Private, loopback, link-local, shared, benchmark, multicast and
|
||||||
const [a, b] = ip.split(".").map(Number);
|
reserved ranges. BlockList also judges an IPv4-mapped IPv6 address
|
||||||
return (
|
(::ffff:7f00:1, however it's written) by the IPv4 inside it. The
|
||||||
a === 0 ||
|
IPv6 ranges that embed an IPv4 some other way (NAT64, 6to4, the
|
||||||
a === 10 ||
|
old compatible form) are refused outright. */
|
||||||
a === 127 ||
|
const BLOCKED = new net.BlockList();
|
||||||
(a === 100 && b >= 64 && b <= 127) ||
|
for (const [ip, bits] of [
|
||||||
(a === 169 && b === 254) ||
|
["0.0.0.0", 8], ["10.0.0.0", 8], ["100.64.0.0", 10], ["127.0.0.0", 8],
|
||||||
(a === 172 && b >= 16 && b <= 31) ||
|
["169.254.0.0", 16], ["172.16.0.0", 12], ["192.0.0.0", 24], ["192.0.2.0", 24],
|
||||||
(a === 192 && b === 168) ||
|
["192.168.0.0", 16], ["198.18.0.0", 15], ["198.51.100.0", 24], ["203.0.113.0", 24],
|
||||||
(a === 192 && b === 0) ||
|
["224.0.0.0", 3],
|
||||||
(a === 198 && (b === 18 || b === 19)) ||
|
]) BLOCKED.addSubnet(ip, bits, "ipv4");
|
||||||
a >= 224
|
for (const [ip, bits] of [
|
||||||
);
|
["::", 96], ["::1", 128], ["64:ff9b::", 96], ["64:ff9b:1::", 48], ["2002::", 16],
|
||||||
}
|
["fc00::", 7], ["fe80::", 10], ["fec0::", 10], ["ff00::", 8], ["2001:db8::", 32],
|
||||||
|
]) BLOCKED.addSubnet(ip, bits, "ipv6");
|
||||||
|
|
||||||
function ipBlocked(ip) {
|
function ipBlocked(ip) {
|
||||||
if (net.isIPv4(ip)) return ipv4Blocked(ip);
|
return BLOCKED.check(ip, net.isIPv4(ip) ? "ipv4" : "ipv6");
|
||||||
const lower = ip.toLowerCase();
|
|
||||||
// An IPv4 address written as IPv6 is judged as the IPv4 it is.
|
|
||||||
const mapped = lower.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/);
|
|
||||||
if (mapped) return ipv4Blocked(mapped[1]);
|
|
||||||
return (
|
|
||||||
lower === "::" ||
|
|
||||||
lower === "::1" ||
|
|
||||||
/^f[cd]/.test(lower) || // fc00::/7 unique local
|
|
||||||
/^fe[89ab]/.test(lower) || // fe80::/10 link-local
|
|
||||||
/^ff/.test(lower) // multicast
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function vet(raw) {
|
async function vet(raw) {
|
||||||
|
|
@ -157,6 +149,14 @@ function requestOnce({ url, address }, { maxBytes, accept, truncate = false }) {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
req.on("timeout", () => req.destroy(new MediaError(504, "The site took too long to answer.")));
|
req.on("timeout", () => req.destroy(new MediaError(504, "The site took too long to answer.")));
|
||||||
|
// `timeout` above only fires when the socket goes quiet; a server
|
||||||
|
// sending a byte every few seconds would hold the request open
|
||||||
|
// for hours. This caps the whole exchange.
|
||||||
|
const deadline = setTimeout(
|
||||||
|
() => req.destroy(new MediaError(504, "The site took too long to answer.")),
|
||||||
|
TOTAL_TIMEOUT_MS,
|
||||||
|
);
|
||||||
|
req.on("close", () => clearTimeout(deadline));
|
||||||
req.on("error", (err) =>
|
req.on("error", (err) =>
|
||||||
reject(err instanceof MediaError ? err : new MediaError(400, "That site couldn't be reached.")),
|
reject(err instanceof MediaError ? err : new MediaError(400, "That site couldn't be reached.")),
|
||||||
);
|
);
|
||||||
|
|
@ -180,15 +180,82 @@ export async function safeGet(raw, options) {
|
||||||
|
|
||||||
const ENTITIES = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: " " };
|
const ENTITIES = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: " " };
|
||||||
|
|
||||||
|
// A code point past U+10FFFF would make fromCodePoint throw.
|
||||||
|
const codePoint = (n) => String.fromCodePoint(n <= 0x10ffff ? n : 0xfffd);
|
||||||
|
|
||||||
export function decodeEntities(text) {
|
export function decodeEntities(text) {
|
||||||
return text
|
return text
|
||||||
.replace(/&#x([0-9a-f]+);/gi, (_, hex) => String.fromCodePoint(parseInt(hex, 16)))
|
.replace(/&#x([0-9a-f]{1,6});/gi, (_, hex) => codePoint(parseInt(hex, 16)))
|
||||||
.replace(/&#(\d+);/g, (_, dec) => String.fromCodePoint(Number(dec)))
|
.replace(/&#(\d{1,7});/g, (_, dec) => codePoint(Number(dec)))
|
||||||
.replace(/&([a-z]+);/gi, (whole, name) => ENTITIES[name.toLowerCase()] ?? whole)
|
.replace(/&([a-z]+);/gi, (whole, name) => ENTITIES[name.toLowerCase()] ?? whole)
|
||||||
.replace(/\s+/g, " ")
|
.replace(/\s+/g, " ")
|
||||||
.trim();
|
.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ── Scanning markup ───────────────────────────────────────────
|
||||||
|
Pages and feeds come from other people's servers, so nothing here
|
||||||
|
runs a regex over the whole document: a pattern like
|
||||||
|
/<meta[^>]*>/ restarts at every "<meta" and turns a few hundred KB
|
||||||
|
of unclosed tags into seconds of blocked event loop. These walk
|
||||||
|
the text once with indexOf; the regexes left only ever see one tag
|
||||||
|
or one short run of text.
|
||||||
|
───────────────────────────────────────────────────────────── */
|
||||||
|
|
||||||
|
const TAG_END = new Set([">", "/", " ", "\t", "\n", "\r"]);
|
||||||
|
|
||||||
|
/* Where the next <tag (followed by a space, / or >) starts, or -1. */
|
||||||
|
function tagStart(lower, name, from) {
|
||||||
|
for (let i = from; ; ) {
|
||||||
|
const at = lower.indexOf(name, i);
|
||||||
|
if (at === -1 || TAG_END.has(lower[at + name.length] ?? "")) return at;
|
||||||
|
i = at + name.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Each opening <tag ...> in text, up to `limit` of them. */
|
||||||
|
export function openTags(text, tag, limit = 200) {
|
||||||
|
const lower = text.toLowerCase();
|
||||||
|
const name = `<${tag.toLowerCase()}`;
|
||||||
|
const out = [];
|
||||||
|
for (let i = 0; out.length < limit; ) {
|
||||||
|
const start = tagStart(lower, name, i);
|
||||||
|
if (start === -1) break;
|
||||||
|
const end = lower.indexOf(">", start);
|
||||||
|
if (end === -1) break;
|
||||||
|
out.push(text.slice(start, end + 1));
|
||||||
|
i = end + 1;
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Each whole <tag ...>…</tag> in text, up to `limit` of them. */
|
||||||
|
export function elements(text, tag, limit) {
|
||||||
|
const lower = text.toLowerCase();
|
||||||
|
const name = `<${tag.toLowerCase()}`;
|
||||||
|
const close = `</${tag.toLowerCase()}>`;
|
||||||
|
const out = [];
|
||||||
|
for (let i = 0; out.length < limit; ) {
|
||||||
|
const start = tagStart(lower, name, i);
|
||||||
|
if (start === -1) break;
|
||||||
|
const end = lower.indexOf(close, start);
|
||||||
|
if (end === -1) break;
|
||||||
|
out.push(text.slice(start, end + close.length));
|
||||||
|
i = end + close.length;
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* What's between the first <tag ...> and its </tag>, or null. */
|
||||||
|
export function innerOf(text, tag) {
|
||||||
|
const lower = text.toLowerCase();
|
||||||
|
const start = tagStart(lower, `<${tag.toLowerCase()}`, 0);
|
||||||
|
if (start === -1) return null;
|
||||||
|
const open = lower.indexOf(">", start);
|
||||||
|
if (open === -1) return null;
|
||||||
|
const end = lower.indexOf(`</${tag.toLowerCase()}>`, open);
|
||||||
|
return end === -1 ? null : text.slice(open + 1, end);
|
||||||
|
}
|
||||||
|
|
||||||
function attr(tag, name) {
|
function attr(tag, name) {
|
||||||
const match = tag.match(new RegExp(`\\b${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"));
|
const match = tag.match(new RegExp(`\\b${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"));
|
||||||
return match ? (match[1] ?? match[2] ?? match[3] ?? "") : null;
|
return match ? (match[1] ?? match[2] ?? match[3] ?? "") : null;
|
||||||
|
|
@ -196,12 +263,12 @@ function attr(tag, name) {
|
||||||
|
|
||||||
function readMeta(html) {
|
function readMeta(html) {
|
||||||
const meta = {};
|
const meta = {};
|
||||||
for (const tag of html.match(/<meta\b[^>]*>/gi) ?? []) {
|
for (const tag of openTags(html, "meta")) {
|
||||||
const key = (attr(tag, "property") ?? attr(tag, "name") ?? "").toLowerCase();
|
const key = (attr(tag, "property") ?? attr(tag, "name") ?? "").toLowerCase();
|
||||||
const content = attr(tag, "content");
|
const content = attr(tag, "content");
|
||||||
if (key && content != null && !(key in meta)) meta[key] = decodeEntities(content);
|
if (key && content != null && !(key in meta)) meta[key] = decodeEntities(content.slice(0, 2000));
|
||||||
}
|
}
|
||||||
const title = html.match(/<title[^>]*>([\s\S]*?)<\/title>/i)?.[1];
|
const title = innerOf(html, "title")?.slice(0, 1000);
|
||||||
return {
|
return {
|
||||||
title: meta["og:title"] || meta["twitter:title"] || (title ? decodeEntities(title) : null) || null,
|
title: meta["og:title"] || meta["twitter:title"] || (title ? decodeEntities(title) : null) || null,
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,10 @@ export const KEEP_MAX_BYTES = 10 * MB;
|
||||||
|
|
||||||
/* Longest side after processing, in pixels. Wide enough for a
|
/* Longest side after processing, in pixels. Wide enough for a
|
||||||
full-bleed hero on a large screen. */
|
full-bleed hero on a large screen. */
|
||||||
|
// About 60 megapixels (eg. 9000 x 6700): past any camera an editor
|
||||||
|
// uses, and it stops one giant image eating the VPS's memory while
|
||||||
|
// it's decoded. sharp's own default is 268 MP.
|
||||||
|
const MAX_INPUT_PIXELS = 60_000_000;
|
||||||
const MAX_EDGE = 2400;
|
const MAX_EDGE = 2400;
|
||||||
|
|
||||||
const WEBP_QUALITY = 82;
|
const WEBP_QUALITY = 82;
|
||||||
|
|
@ -141,7 +145,7 @@ export async function store(buf, { keepOriginal = false } = {}) {
|
||||||
try {
|
try {
|
||||||
if (convert) {
|
if (convert) {
|
||||||
// animated keeps every frame of a GIF or an animated WebP.
|
// animated keeps every frame of a GIF or an animated WebP.
|
||||||
const { data, info } = await sharp(buf, { animated: true })
|
const { data, info } = await sharp(buf, { animated: true, limitInputPixels: MAX_INPUT_PIXELS })
|
||||||
.rotate()
|
.rotate()
|
||||||
.resize({ width: MAX_EDGE, height: MAX_EDGE, fit: "inside", withoutEnlargement: true })
|
.resize({ width: MAX_EDGE, height: MAX_EDGE, fit: "inside", withoutEnlargement: true })
|
||||||
.webp({ quality: WEBP_QUALITY })
|
.webp({ quality: WEBP_QUALITY })
|
||||||
|
|
@ -152,7 +156,7 @@ export async function store(buf, { keepOriginal = false } = {}) {
|
||||||
// An animated image reports the whole strip's height.
|
// An animated image reports the whole strip's height.
|
||||||
height = info.pageHeight ?? info.height;
|
height = info.pageHeight ?? info.height;
|
||||||
} else if (kind !== "svg") {
|
} else if (kind !== "svg") {
|
||||||
const meta = await sharp(buf).metadata();
|
const meta = await sharp(buf, { limitInputPixels: MAX_INPUT_PIXELS }).metadata();
|
||||||
width = meta.width ?? null;
|
width = meta.width ?? null;
|
||||||
height = meta.pageHeight ?? meta.height ?? null;
|
height = meta.pageHeight ?? meta.height ?? null;
|
||||||
}
|
}
|
||||||
|
|
@ -168,6 +172,7 @@ export async function store(buf, { keepOriginal = false } = {}) {
|
||||||
const tmp = path.join(UPLOADS_DIR, `.${filename}.tmp`);
|
const tmp = path.join(UPLOADS_DIR, `.${filename}.tmp`);
|
||||||
await writeFile(tmp, out);
|
await writeFile(tmp, out);
|
||||||
await rename(tmp, path.join(UPLOADS_DIR, filename));
|
await rename(tmp, path.join(UPLOADS_DIR, filename));
|
||||||
|
if (kind !== "svg") await writeThumb(filename, out);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
filename,
|
filename,
|
||||||
|
|
@ -179,16 +184,72 @@ export async function store(buf, { keepOriginal = false } = {}) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deletes one stored file. A file that's already gone is not an
|
/* ── Small copies ──────────────────────────────────────────────
|
||||||
error: the row is what's being removed. */
|
Beside every raster upload, <name>-640.webp: the same image at most
|
||||||
|
640px on its longer side. Photos and logos shown small (avatars,
|
||||||
|
cards, marks) load it instead of the full file; the page falls back
|
||||||
|
to the full file if it's missing (src/lib/media.ts, mediaThumb).
|
||||||
|
Made when a file is uploaded, and at boot for any upload that
|
||||||
|
doesn't have one yet (files from before this, or copied in by hand).
|
||||||
|
───────────────────────────────────────────────────────────── */
|
||||||
|
|
||||||
|
export const THUMB_EDGE = 640;
|
||||||
|
const THUMB = /-640\.webp$/;
|
||||||
|
|
||||||
|
export const thumbName = (filename) => `${filename.replace(/\.[^.]+$/, "")}-640.webp`;
|
||||||
|
|
||||||
|
async function writeThumb(filename, buf) {
|
||||||
|
const name = thumbName(filename);
|
||||||
|
const tmp = path.join(UPLOADS_DIR, `.${name}.tmp`);
|
||||||
|
try {
|
||||||
|
await sharp(buf, { animated: true, limitInputPixels: MAX_INPUT_PIXELS })
|
||||||
|
.rotate()
|
||||||
|
.resize({ width: THUMB_EDGE, height: THUMB_EDGE, fit: "inside", withoutEnlargement: true })
|
||||||
|
.webp({ quality: WEBP_QUALITY })
|
||||||
|
.toFile(tmp);
|
||||||
|
await rename(tmp, path.join(UPLOADS_DIR, name));
|
||||||
|
} catch (err) {
|
||||||
|
// The full file is what matters; without a copy the page uses it.
|
||||||
|
await unlink(tmp).catch(() => {});
|
||||||
|
console.warn(`media: no small copy of ${filename}: ${err.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Makes the small copy for every raster upload that lacks one.
|
||||||
|
Returns how many it made. */
|
||||||
|
export async function writeMissingThumbs() {
|
||||||
|
let names;
|
||||||
|
try {
|
||||||
|
names = await readdir(UPLOADS_DIR);
|
||||||
|
} catch (err) {
|
||||||
|
if (err.code === "ENOENT") return 0;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
const present = new Set(names);
|
||||||
|
let made = 0;
|
||||||
|
for (const name of names) {
|
||||||
|
if (name.startsWith(".") || THUMB.test(name) || /\.svg$/i.test(name)) continue;
|
||||||
|
if (present.has(thumbName(name))) continue;
|
||||||
|
const buf = await readFile(path.join(UPLOADS_DIR, name)).catch(() => null);
|
||||||
|
if (!buf || !sniff(buf) || sniff(buf) === "svg") continue;
|
||||||
|
await writeThumb(name, buf);
|
||||||
|
made += 1;
|
||||||
|
}
|
||||||
|
return made;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deletes one stored file and its small copy. A file that's already
|
||||||
|
gone is not an error: the row is what's being removed. */
|
||||||
export async function remove(filename) {
|
export async function remove(filename) {
|
||||||
// filename comes from our own table, but it's joined onto a
|
// filename comes from our own table, but it's joined onto a
|
||||||
// directory, so refuse anything that isn't a bare name.
|
// directory, so refuse anything that isn't a bare name.
|
||||||
if (path.basename(filename) !== filename) return;
|
if (path.basename(filename) !== filename) return;
|
||||||
try {
|
for (const name of [filename, thumbName(filename)]) {
|
||||||
await unlink(path.join(UPLOADS_DIR, filename));
|
try {
|
||||||
} catch (err) {
|
await unlink(path.join(UPLOADS_DIR, name));
|
||||||
if (err.code !== "ENOENT") throw err;
|
} catch (err) {
|
||||||
|
if (err.code !== "ENOENT") throw err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -209,7 +270,7 @@ async function describe(filename) {
|
||||||
let height = null;
|
let height = null;
|
||||||
if (kind !== "svg") {
|
if (kind !== "svg") {
|
||||||
try {
|
try {
|
||||||
const meta = await sharp(buf).metadata();
|
const meta = await sharp(buf, { limitInputPixels: MAX_INPUT_PIXELS }).metadata();
|
||||||
width = meta.width ?? null;
|
width = meta.width ?? null;
|
||||||
height = meta.pageHeight ?? meta.height ?? null;
|
height = meta.pageHeight ?? meta.height ?? null;
|
||||||
} catch {
|
} catch {
|
||||||
|
|
@ -248,7 +309,7 @@ export async function registerLooseFiles(db) {
|
||||||
|
|
||||||
let added = 0;
|
let added = 0;
|
||||||
for (const name of names) {
|
for (const name of names) {
|
||||||
if (known.has(name) || name.startsWith(".") || path.basename(name) !== name) continue;
|
if (known.has(name) || name.startsWith(".") || THUMB.test(name) || path.basename(name) !== name) continue;
|
||||||
let row;
|
let row;
|
||||||
try {
|
try {
|
||||||
row = await describe(name);
|
row = await describe(name);
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ CREATE TABLE event_scopes (
|
||||||
-- an every-other-week series is "on", which day
|
-- an every-other-week series is "on", which day
|
||||||
-- of the month a monthly one keeps, and the
|
-- of the month a monthly one keeps, and the
|
||||||
-- weekday used when none is ticked
|
-- 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
|
-- also keeps effective_status right
|
||||||
-- series_count when set, stops it after that many meetings,
|
-- series_count when set, stops it after that many meetings,
|
||||||
-- whichever comes first
|
-- 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,
|
-- 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
|
-- 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
|
-- must never be served lives in person_private, so a careless
|
||||||
-- SELECT * can't leak it. Bios and pages go in content_blocks,
|
-- SELECT * can't leak it. Bios and pages go in content_blocks,
|
||||||
-- socials in links. People sort by sort_name; there is no
|
-- 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 (
|
CREATE TABLE people (
|
||||||
id TEXT PRIMARY KEY, -- slug: 'jane-doe'
|
id TEXT PRIMARY KEY, -- slug: 'jane-doe'
|
||||||
display_name TEXT NOT NULL, -- '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'
|
pronouns TEXT, -- 'she/her'
|
||||||
tagline TEXT, -- fallback when no title applies
|
tagline TEXT, -- fallback when no title applies
|
||||||
photo TEXT, -- filename in public/people/
|
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
|
-- A team belongs to exactly one organization: NGU national has a
|
||||||
-- Board and a Leadership Team, a region or chapter can have its own.
|
-- Board and a Leadership Team, a region or chapter can have its own.
|
||||||
-- UNIQUE (id, org_id) looks redundant against the primary key, and
|
-- 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
|
-- point at, which stops someone filing a person under a team
|
||||||
-- belonging to a different organization.
|
-- belonging to a different organization.
|
||||||
CREATE TABLE teams (
|
CREATE TABLE teams (
|
||||||
|
|
@ -548,7 +548,7 @@ CREATE TABLE timeline_entries (
|
||||||
|
|
||||||
-- Null inherits from the referenced row: an event's starts_on. A
|
-- Null inherits from the referenced row: an event's starts_on. A
|
||||||
-- hand-authored entry has to supply its own, which the descriptor
|
-- 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.
|
-- with neither rather than the table refusing it.
|
||||||
occurred_on TEXT,
|
occurred_on TEXT,
|
||||||
|
|
||||||
|
|
@ -604,9 +604,9 @@ CREATE INDEX timeline_entry_people_person_idx
|
||||||
-- FRONT PAGE
|
-- 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
|
-- 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,
|
-- replaced wholesale on save. Nothing has a foreign key into them,
|
||||||
-- which is what makes that safe.
|
-- 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 at all. A row with both can use either route in.
|
||||||
password_hash TEXT,
|
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.
|
-- SQLite allows any number of NULLs in a unique index.
|
||||||
google_sub TEXT UNIQUE,
|
google_sub TEXT UNIQUE,
|
||||||
|
|
||||||
|
|
@ -935,7 +935,7 @@ SELECT
|
||||||
tm.name AS team_name,
|
tm.name AS team_name,
|
||||||
|
|
||||||
-- Whether the referenced record is itself visible. An entry must not
|
-- 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
|
-- would otherwise leak its title and date onto a public page. Null
|
||||||
-- for a standalone milestone, which answers to nothing but its own
|
-- for a standalone milestone, which answers to nothing but its own
|
||||||
-- is_published.
|
-- 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
|
-- 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
|
-- section, the stats that need no typing, and the Church Center
|
||||||
-- forms sorted into paths. Everything else comes in through the
|
-- forms sorted into paths. Everything else comes in through the
|
||||||
-- admin.
|
-- admin.
|
||||||
|
|
|
||||||
39
server/src/migrations/037_leadership_published_orgs.sql
Normal file
39
server/src/migrations/037_leadership_published_orgs.sql
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
-- 037 LEADERSHIP VIEW: PUBLISHED HOME ORGS ONLY
|
||||||
|
--
|
||||||
|
-- v_org_leadership named a person's primary organization even when
|
||||||
|
-- that organization was unpublished, so a draft org's name could
|
||||||
|
-- show on a public leadership list. It now joins published ones
|
||||||
|
-- only; an unpublished one reads as no primary org.
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
DROP VIEW v_org_leadership;
|
||||||
|
|
||||||
|
CREATE VIEW v_org_leadership AS
|
||||||
|
SELECT
|
||||||
|
a.org_id,
|
||||||
|
a.team_id,
|
||||||
|
t.name AS team_name,
|
||||||
|
t.sort_order AS team_sort_order,
|
||||||
|
a.person_id,
|
||||||
|
a.title,
|
||||||
|
a.role,
|
||||||
|
a.is_owner,
|
||||||
|
a.sort_order,
|
||||||
|
p.display_name,
|
||||||
|
p.sort_name,
|
||||||
|
p.pronouns,
|
||||||
|
p.tagline,
|
||||||
|
p.photo,
|
||||||
|
p.public_email,
|
||||||
|
p.location_label,
|
||||||
|
p.bio,
|
||||||
|
o.id AS primary_org_id,
|
||||||
|
o.name AS primary_org_name
|
||||||
|
FROM affiliations a
|
||||||
|
JOIN people p ON p.id = a.person_id AND p.is_published = 1
|
||||||
|
LEFT JOIN teams t ON t.id = a.team_id
|
||||||
|
LEFT JOIN organizations o ON o.id = p.primary_org_id AND o.is_published = 1
|
||||||
|
WHERE a.is_public = 1
|
||||||
|
AND a.ended_on IS NULL
|
||||||
|
ORDER BY a.org_id, a.is_owner DESC, a.sort_order, p.sort_name;
|
||||||
13
server/src/migrations/038_image_alt_text.sql
Normal file
13
server/src/migrations/038_image_alt_text.sql
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
-- 038 ALT TEXT FOR BLOG COVERS AND SCHEDULE GRAPHICS
|
||||||
|
--
|
||||||
|
-- Both images can carry information (a flyer, a site map, a cover
|
||||||
|
-- photo that sets the scene), so each gets its own description for
|
||||||
|
-- screen readers. Blank means decorative: the image is skipped.
|
||||||
|
--
|
||||||
|
-- blog_posts.cover_alt the cover image's description
|
||||||
|
-- content_block_items.media_alt a schedule entry graphic's
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
ALTER TABLE blog_posts ADD COLUMN cover_alt TEXT;
|
||||||
|
ALTER TABLE content_block_items ADD COLUMN media_alt TEXT;
|
||||||
11
server/src/migrations/039_privacy_contact.sql
Normal file
11
server/src/migrations/039_privacy_contact.sql
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
-- 039 PRIVACY CONTACT
|
||||||
|
--
|
||||||
|
-- The address the Privacy page gives for privacy questions and data
|
||||||
|
-- requests (Panel → Site settings). Null falls back to site.json's
|
||||||
|
-- privacyEmail; blank in both, the page points to its request form
|
||||||
|
-- only. Data requests themselves are feedback rows of type
|
||||||
|
-- 'privacy' (routes/feedback.js), triaged in Admin → Feedback.
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
ALTER TABLE site_settings ADD COLUMN privacy_email TEXT;
|
||||||
12
server/src/migrations/040_drop_event_gradient.sql
Normal file
12
server/src/migrations/040_drop_event_gradient.sql
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
-- 040 NO MORE CARD GRADIENTS
|
||||||
|
--
|
||||||
|
-- An event card is its photo (card_image) under a light veil, or a
|
||||||
|
-- plain card, always with the event's colour as its border. The
|
||||||
|
-- gradient layer went over the photo and hid it, and gradients are
|
||||||
|
-- leaving the design, so the column goes. Any gradient saved on an
|
||||||
|
-- event is dropped with it; the card falls back to its photo or the
|
||||||
|
-- plain surface.
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
ALTER TABLE events DROP COLUMN gradient;
|
||||||
28
server/src/migrations/041_site_colors.sql
Normal file
28
server/src/migrations/041_site_colors.sql
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
-- 041 SITE COLOURS
|
||||||
|
--
|
||||||
|
-- The admin's palette (Panel → Site settings → Colours): one row per
|
||||||
|
-- colour token that differs from the site's own (src/index.css), with
|
||||||
|
-- a light and a dark value. Blank keeps that mode's default. The
|
||||||
|
-- server writes them into every page (server/src/theme.js) and
|
||||||
|
-- refuses a save that would make text hard to read.
|
||||||
|
--
|
||||||
|
-- token one of the tokens in THEME_DEFAULTS (theme.js), which
|
||||||
|
-- the admin's dropdown offers
|
||||||
|
-- light '#rrggbb', or null for the default
|
||||||
|
-- dark '#rrggbb', or null for the default
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
CREATE TABLE site_setting_colors (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
settings_id TEXT NOT NULL REFERENCES site_settings (id) ON DELETE CASCADE,
|
||||||
|
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||||
|
token TEXT NOT NULL CHECK (token IN (
|
||||||
|
'ink', 'body', 'muted', 'link', 'brand', 'action', 'action-hover',
|
||||||
|
'surface', 'tint', 'tint-soft', 'danger', 'danger-tint')),
|
||||||
|
light TEXT CONSTRAINT "A colour must be written #rrggbb, eg. #0f7183."
|
||||||
|
CHECK (light IS NULL OR (length(light) = 7 AND light GLOB '#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]')),
|
||||||
|
dark TEXT CONSTRAINT "A dark colour must be written #rrggbb, eg. #5ccbdc."
|
||||||
|
CHECK (dark IS NULL OR (length(dark) = 7 AND dark GLOB '#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]')),
|
||||||
|
UNIQUE (settings_id, token)
|
||||||
|
) STRICT;
|
||||||
10
server/src/migrations/042_person_awards_index.sql
Normal file
10
server/src/migrations/042_person_awards_index.sql
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
-- 042 AWARD RECIPIENTS BY AWARD
|
||||||
|
--
|
||||||
|
-- person_awards is read by award (an award's page lists its
|
||||||
|
-- recipients, an organization counts them), but its only index
|
||||||
|
-- starts with person_id, so those reads scan the table. Tiny today;
|
||||||
|
-- this keeps it from mattering later.
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
CREATE INDEX person_awards_award_idx ON person_awards (award_id);
|
||||||
10
server/src/migrations/043_blog_contents.sql
Normal file
10
server/src/migrations/043_blog_contents.sql
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
-- 043 A POST'S TABLE OF CONTENTS
|
||||||
|
--
|
||||||
|
-- Blog posts → "Show contents": list the post's headings beside it
|
||||||
|
-- (a fold-out on phones), the one being read lit. Off unless an
|
||||||
|
-- editor turns it on, since a short post doesn't need one.
|
||||||
|
-- ═══════════════════════════════════════════════════════════════
|
||||||
|
|
||||||
|
ALTER TABLE blog_posts ADD COLUMN show_contents INTEGER NOT NULL DEFAULT 0
|
||||||
|
CHECK (show_contents IN (0, 1));
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
site_settings table, 035), where anything set wins and anything
|
site_settings table, 035), where anything set wins and anything
|
||||||
blank falls back to site.json. siteFor(db) does the merge. The
|
blank falls back to site.json. siteFor(db) does the merge. The
|
||||||
pages read the same merged values (renderPage writes them into
|
pages read the same merged values (renderPage writes them into
|
||||||
the HTML as window.__NGU_SITE__, see src/lib/site.ts), so a
|
the HTML as window.__SITE__, see src/lib/site.ts), so a
|
||||||
heading and its search title can't drift.
|
heading and its search title can't drift.
|
||||||
The database: records' names, taglines, first paragraphs and
|
The database: records' names, taglines, first paragraphs and
|
||||||
images. A blank site description falls back to the front page's
|
images. A blank site description falls back to the front page's
|
||||||
|
|
@ -42,6 +42,7 @@ import path from "node:path";
|
||||||
import { fileURLToPath } from "node:url";
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
import { loadBlocks, paragraphs } from "./shape.js";
|
import { loadBlocks, paragraphs } from "./shape.js";
|
||||||
|
import { themeCss } from "./theme.js";
|
||||||
|
|
||||||
const here = path.dirname(fileURLToPath(import.meta.url));
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
|
|
@ -102,12 +103,16 @@ export function siteFor(db) {
|
||||||
...base.robots,
|
...base.robots,
|
||||||
index: row.indexing ? row.indexing === "on" : base.robots?.index !== false,
|
index: row.indexing ? row.indexing === "on" : base.robots?.index !== false,
|
||||||
},
|
},
|
||||||
|
privacyEmail: row.privacy_email || base.privacyEmail || "",
|
||||||
|
// The admin's colours (theme.js): only #rrggbb values and fixed
|
||||||
|
// text, so safe inside <style>.
|
||||||
|
themeCss: themeCss(db),
|
||||||
pages,
|
pages,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* What the browser app reads for headings and titles. */
|
/* What the browser app reads for headings and titles. */
|
||||||
const forBrowser = (site) => ({ title: site.title, pages: site.pages });
|
const forBrowser = (site) => ({ title: site.title, pages: site.pages, privacyEmail: site.privacyEmail });
|
||||||
|
|
||||||
/* robots.txt for this database's setting, as the build writes it. */
|
/* robots.txt for this database's setting, as the build writes it. */
|
||||||
export function robotsTxt(site) {
|
export function robotsTxt(site) {
|
||||||
|
|
@ -125,7 +130,10 @@ export function robotsTxt(site) {
|
||||||
cut on a word near DESCRIPTION_CHARS. */
|
cut on a word near DESCRIPTION_CHARS. */
|
||||||
export function plainText(text) {
|
export function plainText(text) {
|
||||||
if (!text) return null;
|
if (!text) return null;
|
||||||
|
// A description is ~160 characters; reading far past that only
|
||||||
|
// gives the patterns below more to rescan on pathological text.
|
||||||
const flat = String(text)
|
const flat = String(text)
|
||||||
|
.slice(0, 2000)
|
||||||
.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1")
|
.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1")
|
||||||
.replace(/\*\*(.+?)\*\*/g, "$1")
|
.replace(/\*\*(.+?)\*\*/g, "$1")
|
||||||
.replace(/\*(.+?)\*/g, "$1")
|
.replace(/\*(.+?)\*/g, "$1")
|
||||||
|
|
@ -339,8 +347,23 @@ export function metaFor(db, rawPath) {
|
||||||
const meta = defaults(site, db, pathname);
|
const meta = defaults(site, db, pathname);
|
||||||
|
|
||||||
if (pathname === "/") {
|
if (pathname === "/") {
|
||||||
|
// The home page's data, and its first hero photo when the hero is
|
||||||
|
// a slideshow, requested alongside the app's JavaScript instead of
|
||||||
|
// after it has run.
|
||||||
|
const hero = db.prepare(`SELECT hero_backdrop FROM front_page WHERE id = 'home'`).get();
|
||||||
|
const slide =
|
||||||
|
hero?.hero_backdrop === "photos"
|
||||||
|
? db
|
||||||
|
.prepare(`SELECT media FROM front_page_slides WHERE page_id = 'home' ORDER BY sort_order LIMIT 1`)
|
||||||
|
.get()
|
||||||
|
: null;
|
||||||
|
const slideSrc = slide?.media ? (/^(https?:|\/)/.test(slide.media) ? slide.media : `${UPLOADS}/${slide.media}`) : null;
|
||||||
return {
|
return {
|
||||||
...meta,
|
...meta,
|
||||||
|
preload: [
|
||||||
|
{ href: "/api/front-page", as: "fetch" },
|
||||||
|
...(slideSrc ? [{ href: slideSrc, as: "image" }] : []),
|
||||||
|
],
|
||||||
jsonLd: {
|
jsonLd: {
|
||||||
"@context": "https://schema.org",
|
"@context": "https://schema.org",
|
||||||
"@type": "Organization",
|
"@type": "Organization",
|
||||||
|
|
@ -438,9 +461,15 @@ export function renderPage(html, meta) {
|
||||||
site.icons?.icon && `<link rel="icon" href="${escapeHtml(site.icons.icon)}">`,
|
site.icons?.icon && `<link rel="icon" href="${escapeHtml(site.icons.icon)}">`,
|
||||||
site.icons?.apple && `<link rel="apple-touch-icon" href="${escapeHtml(site.icons.apple)}">`,
|
site.icons?.apple && `<link rel="apple-touch-icon" href="${escapeHtml(site.icons.apple)}">`,
|
||||||
meta.jsonLd && `<script type="application/ld+json">${scriptJson(meta.jsonLd)}</script>`,
|
meta.jsonLd && `<script type="application/ld+json">${scriptJson(meta.jsonLd)}</script>`,
|
||||||
|
...(meta.preload ?? []).map((p) =>
|
||||||
|
p.as === "fetch"
|
||||||
|
? `<link rel="preload" href="${escapeHtml(p.href)}" as="fetch" crossorigin>`
|
||||||
|
: `<link rel="preload" href="${escapeHtml(p.href)}" as="image" fetchpriority="high">`,
|
||||||
|
),
|
||||||
// Read by src/lib/site.ts before the app's module runs (a plain
|
// Read by src/lib/site.ts before the app's module runs (a plain
|
||||||
// script in the head runs during parsing; modules wait).
|
// script in the head runs during parsing; modules wait).
|
||||||
`<script>window.__NGU_SITE__ = ${scriptJson(forBrowser(site))}</script>`,
|
`<script>window.__SITE__ = ${scriptJson(forBrowser(site))}</script>`,
|
||||||
|
site.themeCss && `<style id="site-colors">${site.themeCss}</style>`,
|
||||||
].filter(Boolean);
|
].filter(Boolean);
|
||||||
|
|
||||||
// A blocked site (Site settings indexing off, or site.json's
|
// A blocked site (Site settings indexing off, or site.json's
|
||||||
|
|
@ -450,7 +479,8 @@ export function renderPage(html, meta) {
|
||||||
tags.splice(2, 0, `<meta name="robots" content="noindex, nofollow">`);
|
tags.splice(2, 0, `<meta name="robots" content="noindex, nofollow">`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return out.replace(/<\/head>/i, ` ${tags.join("\n ")}\n </head>`);
|
// A function, so a $& or $` in record text isn't read as a pattern.
|
||||||
|
return out.replace(/<\/head>/i, () => ` ${tags.join("\n ")}\n </head>`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Sitemap ───────────────────────────────────────────────── */
|
/* ── Sitemap ───────────────────────────────────────────────── */
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,13 @@
|
||||||
the service restarts and it doesn't survive a second instance,
|
the service restarts and it doesn't survive a second instance,
|
||||||
both of which are fine for one systemd unit on one box.
|
both of which are fine for one systemd unit on one box.
|
||||||
|
|
||||||
The client IP comes from X-Forwarded-For, which nginx sets. That
|
The client IP comes from clientIp() in auth.js (the entry nginx
|
||||||
header is only trustworthy because nothing but nginx can reach
|
adds to X-Forwarded-For). That is only trustworthy because
|
||||||
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";
|
||||||
|
|
||||||
export function rateLimit({ windowMs = 60_000, max = 10 } = {}) {
|
export function rateLimit({ windowMs = 60_000, max = 10 } = {}) {
|
||||||
const hits = new Map(); // ip → { count, resetAt }
|
const hits = new Map(); // ip → { count, resetAt }
|
||||||
|
|
||||||
|
|
@ -22,8 +24,7 @@ export function rateLimit({ windowMs = 60_000, max = 10 } = {}) {
|
||||||
}, windowMs).unref();
|
}, windowMs).unref();
|
||||||
|
|
||||||
return async (c, next) => {
|
return async (c, next) => {
|
||||||
const ip =
|
const ip = clientIp(c) ?? "unknown";
|
||||||
c.req.header("x-forwarded-for")?.split(",")[0].trim() ?? "unknown";
|
|
||||||
|
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
let entry = hits.get(ip);
|
let entry = hits.get(ip);
|
||||||
|
|
@ -47,3 +48,45 @@ export function rateLimit({ windowMs = 60_000, max = 10 } = {}) {
|
||||||
await next();
|
await next();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ── Failures per key ──────────────────────────────────────────
|
||||||
|
For login: count only failed attempts per account, so guessing
|
||||||
|
one person's password from many addresses still stops, and their
|
||||||
|
own successful sign-in clears it. Unknown emails are counted the
|
||||||
|
same way, so the limit says nothing about which accounts exist.
|
||||||
|
ponytail: in-memory like the IP limit (resets on restart, one
|
||||||
|
instance); a spray of random emails is swept each window.
|
||||||
|
───────────────────────────────────────────────────────────── */
|
||||||
|
|
||||||
|
export function failureLimit({ windowMs = 15 * 60_000, max = 5 } = {}) {
|
||||||
|
const failures = new Map(); // key → { count, resetAt }
|
||||||
|
|
||||||
|
setInterval(() => {
|
||||||
|
const now = Date.now();
|
||||||
|
for (const [key, entry] of failures) {
|
||||||
|
if (entry.resetAt <= now) failures.delete(key);
|
||||||
|
}
|
||||||
|
}, windowMs).unref();
|
||||||
|
|
||||||
|
const live = (key) => {
|
||||||
|
const entry = failures.get(key);
|
||||||
|
if (entry && entry.resetAt <= Date.now()) failures.delete(key);
|
||||||
|
return failures.get(key);
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
/** Seconds until the key may try again, or 0. */
|
||||||
|
blockedFor(key) {
|
||||||
|
const entry = live(key);
|
||||||
|
return entry && entry.count >= max ? Math.ceil((entry.resetAt - Date.now()) / 1000) : 0;
|
||||||
|
},
|
||||||
|
fail(key) {
|
||||||
|
const entry = live(key) ?? { count: 0, resetAt: Date.now() + windowMs };
|
||||||
|
entry.count += 1;
|
||||||
|
failures.set(key, entry);
|
||||||
|
},
|
||||||
|
clear(key) {
|
||||||
|
failures.delete(key);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,15 +28,16 @@ import {
|
||||||
updateRow,
|
updateRow,
|
||||||
deleteRow,
|
deleteRow,
|
||||||
} from "../admin-crud.js";
|
} from "../admin-crud.js";
|
||||||
|
import { NO_STORE } from "../shape.js";
|
||||||
|
|
||||||
const entities = new Hono();
|
const entities = new Hono();
|
||||||
|
|
||||||
entities.use("*", requireAuth);
|
entities.use("*", requireAuth);
|
||||||
|
|
||||||
const NO_STORE = { "Cache-Control": "no-store" };
|
|
||||||
|
|
||||||
function entityOr404(c) {
|
function entityOr404(c) {
|
||||||
const entity = ENTITIES[c.req.param("entity")];
|
const name = c.req.param("entity");
|
||||||
|
const entity = Object.hasOwn(ENTITIES, name) ? ENTITIES[name] : null;
|
||||||
if (!entity) throw new HttpError(404, "Unknown entity.");
|
if (!entity) throw new HttpError(404, "Unknown entity.");
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
@ -52,6 +53,16 @@ function entityForWrite(c) {
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* An extension can ask for more than a sign-in to be read
|
||||||
|
(readRole): a person's private details need editor. Blanked on
|
||||||
|
every row sent back, so a write's reply can't leak it either. */
|
||||||
|
function visible(c, entity, row) {
|
||||||
|
for (const ext of entity.extensions ?? []) {
|
||||||
|
if (ext.readRole && !hasRole(c.get("user"), ext.readRole)) row[ext.key] = null;
|
||||||
|
}
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
/* Everything the select inputs need, in one request. Small enough
|
/* Everything the select inputs need, in one request. Small enough
|
||||||
that paging it would cost more than it saves. */
|
that paging it would cost more than it saves. */
|
||||||
entities.get("/options", (c) => {
|
entities.get("/options", (c) => {
|
||||||
|
|
@ -71,12 +82,12 @@ entities.get("/:entity", (c) => {
|
||||||
|
|
||||||
entities.get("/:entity/:id", (c) => {
|
entities.get("/:entity/:id", (c) => {
|
||||||
const entity = entityOr404(c);
|
const entity = entityOr404(c);
|
||||||
return c.json({ row: readRow(c.get("db"), entity, c.req.param("id")) }, 200, NO_STORE);
|
return c.json({ row: visible(c, entity, readRow(c.get("db"), entity, c.req.param("id"))) }, 200, NO_STORE);
|
||||||
});
|
});
|
||||||
|
|
||||||
entities.post("/:entity", requireRole("editor"), async (c) => {
|
entities.post("/:entity", requireRole("editor"), async (c) => {
|
||||||
const entity = entityForWrite(c);
|
const entity = entityForWrite(c);
|
||||||
const row = createRow(c.get("db"), entity, await json(c));
|
const row = visible(c, entity, createRow(c.get("db"), entity, await json(c)));
|
||||||
console.log(`${entity.key} ${row[entity.idColumn]} created by ${c.get("user").email}`);
|
console.log(`${entity.key} ${row[entity.idColumn]} created by ${c.get("user").email}`);
|
||||||
return c.json({ row }, 201, NO_STORE);
|
return c.json({ row }, 201, NO_STORE);
|
||||||
});
|
});
|
||||||
|
|
@ -84,7 +95,7 @@ entities.post("/:entity", requireRole("editor"), async (c) => {
|
||||||
entities.patch("/:entity/:id", requireRole("editor"), async (c) => {
|
entities.patch("/:entity/:id", requireRole("editor"), async (c) => {
|
||||||
const entity = entityForWrite(c);
|
const entity = entityForWrite(c);
|
||||||
const id = c.req.param("id");
|
const id = c.req.param("id");
|
||||||
const row = updateRow(c.get("db"), entity, id, await json(c));
|
const row = visible(c, entity, updateRow(c.get("db"), entity, id, await json(c)));
|
||||||
console.log(`${entity.key} ${id} updated by ${c.get("user").email}`);
|
console.log(`${entity.key} ${id} updated by ${c.get("user").email}`);
|
||||||
return c.json({ row }, 200, NO_STORE);
|
return c.json({ row }, 200, NO_STORE);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,12 @@
|
||||||
|
|
||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
import { requireAuth, requireRole } from "../auth.js";
|
import { requireAuth, requireRole } from "../auth.js";
|
||||||
|
import { NO_STORE } from "../shape.js";
|
||||||
|
|
||||||
const admin = new Hono();
|
const admin = new Hono();
|
||||||
|
|
||||||
admin.use("*", requireAuth);
|
admin.use("*", requireAuth);
|
||||||
|
|
||||||
const NO_STORE = { "Cache-Control": "no-store" };
|
|
||||||
|
|
||||||
const STATUSES = ["new", "read", "actioned", "archived", "spam"];
|
const STATUSES = ["new", "read", "actioned", "archived", "spam"];
|
||||||
const MAX_LIMIT = 200;
|
const MAX_LIMIT = 200;
|
||||||
|
|
@ -23,6 +23,8 @@ const NOTE_LIMIT = 2000;
|
||||||
|
|
||||||
/* ── GET /api/admin/feedback ─────────────────────────────────────
|
/* ── GET /api/admin/feedback ─────────────────────────────────────
|
||||||
?status=new one of STATUSES, or omitted for all
|
?status=new one of STATUSES, or omitted for all
|
||||||
|
?kind=feedback website feedback (every type but 'privacy')
|
||||||
|
?kind=privacy data requests from the Privacy page
|
||||||
?type=broken feedback_type
|
?type=broken feedback_type
|
||||||
?q=retreat substring of the message
|
?q=retreat substring of the message
|
||||||
?before=41 cursor: rows with a lower id than this
|
?before=41 cursor: rows with a lower id than this
|
||||||
|
|
@ -31,11 +33,17 @@ const NOTE_LIMIT = 2000;
|
||||||
|
|
||||||
admin.get("/feedback", (c) => {
|
admin.get("/feedback", (c) => {
|
||||||
const db = c.get("db");
|
const db = c.get("db");
|
||||||
const { status, type, q, before, limit } = c.req.query();
|
const { status, type, kind, q, before, limit } = c.req.query();
|
||||||
|
|
||||||
const where = [];
|
const where = [];
|
||||||
const params = [];
|
const params = [];
|
||||||
|
|
||||||
|
// Data requests and website feedback share the table but are two
|
||||||
|
// queues in the admin (Forms → Website feedback, Data requests).
|
||||||
|
const kindWhere =
|
||||||
|
kind === "privacy" ? "feedback_type = 'privacy'" : kind === "feedback" ? "feedback_type <> 'privacy'" : null;
|
||||||
|
if (kindWhere) where.push(kindWhere);
|
||||||
|
|
||||||
if (STATUSES.includes(status)) {
|
if (STATUSES.includes(status)) {
|
||||||
where.push("status = ?");
|
where.push("status = ?");
|
||||||
params.push(status);
|
params.push(status);
|
||||||
|
|
@ -53,7 +61,7 @@ admin.get("/feedback", (c) => {
|
||||||
params.push(Number(before));
|
params.push(Number(before));
|
||||||
}
|
}
|
||||||
|
|
||||||
const take = Math.min(Number(limit) || 50, MAX_LIMIT);
|
const take = Math.max(1, Math.min(Number(limit) || 50, MAX_LIMIT));
|
||||||
|
|
||||||
const rows = db
|
const rows = db
|
||||||
.prepare(
|
.prepare(
|
||||||
|
|
@ -69,19 +77,27 @@ admin.get("/feedback", (c) => {
|
||||||
const hasMore = rows.length > take;
|
const hasMore = rows.length > take;
|
||||||
const page = hasMore ? rows.slice(0, take) : rows;
|
const page = hasMore ? rows.slice(0, take) : rows;
|
||||||
|
|
||||||
// Counts are unfiltered on purpose: the tabs should show what's
|
// Status counts cover this queue (kind) but ignore the other
|
||||||
// waiting overall, not what's left after the current filter.
|
// filters: the tabs show what's waiting, not what's left after a
|
||||||
|
// search. newByKind is what's new in each queue, for the queue tabs.
|
||||||
const counts = Object.fromEntries(STATUSES.map((s) => [s, 0]));
|
const counts = Object.fromEntries(STATUSES.map((s) => [s, 0]));
|
||||||
for (const row of db
|
for (const row of db
|
||||||
.prepare("SELECT status, COUNT(*) AS n FROM feedback GROUP BY status")
|
.prepare(`SELECT status, COUNT(*) AS n FROM feedback ${kindWhere ? `WHERE ${kindWhere}` : ""} GROUP BY status`)
|
||||||
.all()) {
|
.all()) {
|
||||||
counts[row.status] = row.n;
|
counts[row.status] = row.n;
|
||||||
}
|
}
|
||||||
|
const newByKind = db
|
||||||
|
.prepare(
|
||||||
|
`SELECT SUM(feedback_type <> 'privacy') AS feedback, SUM(feedback_type = 'privacy') AS privacy
|
||||||
|
FROM feedback WHERE status = 'new'`,
|
||||||
|
)
|
||||||
|
.get();
|
||||||
|
|
||||||
return c.json(
|
return c.json(
|
||||||
{
|
{
|
||||||
feedback: page,
|
feedback: page,
|
||||||
counts,
|
counts,
|
||||||
|
newByKind: { feedback: newByKind?.feedback ?? 0, privacy: newByKind?.privacy ?? 0 },
|
||||||
nextCursor: hasMore ? page[page.length - 1].id : null,
|
nextCursor: hasMore ? page[page.length - 1].id : null,
|
||||||
},
|
},
|
||||||
200,
|
200,
|
||||||
|
|
@ -99,7 +115,8 @@ admin.patch("/feedback/:id", requireRole("editor"), async (c) => {
|
||||||
|
|
||||||
let body;
|
let body;
|
||||||
try {
|
try {
|
||||||
body = await c.req.json();
|
// `?? {}`: a body of JSON null parses fine and has no fields.
|
||||||
|
body = (await c.req.json()) ?? {};
|
||||||
} catch {
|
} catch {
|
||||||
return c.json({ error: "Expected a JSON body." }, 400);
|
return c.json({ error: "Expected a JSON body." }, 400);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,9 @@
|
||||||
|
|
||||||
Three deliberate choices:
|
Three deliberate choices:
|
||||||
|
|
||||||
Login is rate limited where it's mounted, and answers wrong
|
Login is rate limited where it's mounted (per IP) and here (per
|
||||||
password and unknown account identically. Telling an attacker
|
email, failures only), and answers wrong password and unknown
|
||||||
|
account identically. Telling an attacker
|
||||||
which addresses exist is free reconnaissance.
|
which addresses exist is free reconnaissance.
|
||||||
|
|
||||||
A failed login still runs a hash. Otherwise the response time
|
A failed login still runs a hash. Otherwise the response time
|
||||||
|
|
@ -32,6 +33,7 @@ import { deleteCookie, getCookie, setCookie } from "hono/cookie";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
SECURE_COOKIE,
|
SECURE_COOKIE,
|
||||||
|
logSafe,
|
||||||
createSession,
|
createSession,
|
||||||
destroySession,
|
destroySession,
|
||||||
currentUser,
|
currentUser,
|
||||||
|
|
@ -39,6 +41,13 @@ import {
|
||||||
verifyPassword,
|
verifyPassword,
|
||||||
} from "../auth.js";
|
} from "../auth.js";
|
||||||
import { GoogleLoginError, finishLogin, googleConfig, startLogin } from "../googleAuth.js";
|
import { GoogleLoginError, finishLogin, googleConfig, startLogin } from "../googleAuth.js";
|
||||||
|
import { failureLimit } from "../rateLimit.js";
|
||||||
|
import { NO_STORE } from "../shape.js";
|
||||||
|
|
||||||
|
// On top of the per-IP limit where /login is mounted: five wrong
|
||||||
|
// passwords for one email in 15 minutes locks that email for the
|
||||||
|
// rest of the window, from anywhere.
|
||||||
|
const loginFailures = failureLimit({ windowMs: 15 * 60_000, max: 5 });
|
||||||
|
|
||||||
const auth = new Hono();
|
const auth = new Hono();
|
||||||
|
|
||||||
|
|
@ -46,12 +55,12 @@ const auth = new Hono();
|
||||||
// so both paths cost the same. Computed once at import.
|
// so both paths cost the same. Computed once at import.
|
||||||
const DUMMY_HASH = hashPassword("this password is never correct");
|
const DUMMY_HASH = hashPassword("this password is never correct");
|
||||||
|
|
||||||
const NO_STORE = { "Cache-Control": "no-store" };
|
|
||||||
|
|
||||||
auth.post("/login", async (c) => {
|
auth.post("/login", async (c) => {
|
||||||
let body;
|
let body;
|
||||||
try {
|
try {
|
||||||
body = await c.req.json();
|
// `?? {}`: a body of JSON null parses fine and has no fields.
|
||||||
|
body = (await c.req.json()) ?? {};
|
||||||
} catch {
|
} catch {
|
||||||
return c.json({ error: "Expected a JSON body." }, 400);
|
return c.json({ error: "Expected a JSON body." }, 400);
|
||||||
}
|
}
|
||||||
|
|
@ -63,6 +72,16 @@ auth.post("/login", async (c) => {
|
||||||
return c.json({ error: "Email and password are required." }, 400);
|
return c.json({ error: "Email and password are required." }, 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const wait = loginFailures.blockedFor(email);
|
||||||
|
if (wait) {
|
||||||
|
console.warn(`login locked for ${logSafe(email)}`);
|
||||||
|
return c.json(
|
||||||
|
{ error: "Too many wrong passwords for this account. Try again in a few minutes." },
|
||||||
|
429,
|
||||||
|
{ "Retry-After": String(wait) },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const db = c.get("db");
|
const db = c.get("db");
|
||||||
|
|
||||||
const user = db
|
const user = db
|
||||||
|
|
@ -75,14 +94,16 @@ auth.post("/login", async (c) => {
|
||||||
|
|
||||||
const ok =
|
const ok =
|
||||||
user && user.is_active === 1
|
user && user.is_active === 1
|
||||||
? verifyPassword(password, user.password_hash)
|
? await verifyPassword(password, user.password_hash)
|
||||||
: (verifyPassword(password, DUMMY_HASH), false);
|
: (await verifyPassword(password, DUMMY_HASH), false);
|
||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
console.warn(`login failed for ${email}`);
|
loginFailures.fail(email);
|
||||||
|
console.warn(`login failed for ${logSafe(email)}`);
|
||||||
return c.json({ error: "That email and password don't match." }, 401);
|
return c.json({ error: "That email and password don't match." }, 401);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loginFailures.clear(email);
|
||||||
createSession(db, c, user.id);
|
createSession(db, c, user.id);
|
||||||
|
|
||||||
db.prepare("UPDATE admin_users SET last_login_at = datetime('now') WHERE id = ?").run(
|
db.prepare("UPDATE admin_users SET last_login_at = datetime('now') WHERE id = ?").run(
|
||||||
|
|
@ -115,12 +136,14 @@ auth.get("/me", (c) => {
|
||||||
// The state and PKCE verifier between the two legs. Scoped to the
|
// The state and PKCE verifier between the two legs. Scoped to the
|
||||||
// Google routes and gone in ten minutes; Lax so it comes back on
|
// Google routes and gone in ten minutes; Lax so it comes back on
|
||||||
// the redirect from Google, which is a top-level navigation.
|
// the redirect from Google, which is a top-level navigation.
|
||||||
const OAUTH_COOKIE = "ngu_oauth";
|
// __Host- (Secure, path /, no Domain) when over https, like the
|
||||||
|
// session cookie, so a sibling subdomain can't plant its own state.
|
||||||
|
const OAUTH_COOKIE = SECURE_COOKIE ? "__Host-site_oauth" : "site_oauth";
|
||||||
const OAUTH_COOKIE_OPTIONS = {
|
const OAUTH_COOKIE_OPTIONS = {
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
secure: SECURE_COOKIE,
|
secure: SECURE_COOKIE,
|
||||||
sameSite: "Lax",
|
sameSite: "Lax",
|
||||||
path: "/api/auth/google",
|
path: "/",
|
||||||
};
|
};
|
||||||
|
|
||||||
// Where to land afterwards: an admin page, never anywhere else.
|
// Where to land afterwards: an admin page, never anywhere else.
|
||||||
|
|
@ -213,7 +236,8 @@ auth.get("/google/callback", async (c) => {
|
||||||
).run(identity.name, user.id);
|
).run(identity.name, user.id);
|
||||||
console.log(`login ${user.email} (google)`);
|
console.log(`login ${user.email} (google)`);
|
||||||
|
|
||||||
return c.redirect(saved.next ?? "/admin/home", 302);
|
// Checked again: the cookie came back from the browser.
|
||||||
|
return c.redirect(safeNext(saved.next), 302);
|
||||||
});
|
});
|
||||||
|
|
||||||
export default auth;
|
export default auth;
|
||||||
|
|
|
||||||
|
|
@ -24,17 +24,11 @@
|
||||||
|
|
||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
|
|
||||||
import { asBool, loadBlocks, loadFeaturedCards, paragraphs } from "../shape.js";
|
import { asBool, json, loadBlocks, loadFeaturedCards, marks, paragraphs } from "../shape.js";
|
||||||
import { readFeeds } from "../feeds.js";
|
import { readFeeds } from "../feeds.js";
|
||||||
|
|
||||||
const blog = new Hono();
|
const blog = new Hono();
|
||||||
|
|
||||||
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";
|
const PAGE_ID = "community";
|
||||||
|
|
||||||
const splitTags = (tags) =>
|
const splitTags = (tags) =>
|
||||||
|
|
@ -104,6 +98,8 @@ blog.get("/blog/:id", (c) => {
|
||||||
title: row.title,
|
title: row.title,
|
||||||
excerpt: row.excerpt,
|
excerpt: row.excerpt,
|
||||||
cover_image: row.cover_image,
|
cover_image: row.cover_image,
|
||||||
|
cover_alt: row.cover_alt,
|
||||||
|
show_contents: row.show_contents === 1,
|
||||||
published_on: row.published_on,
|
published_on: row.published_on,
|
||||||
tags: splitTags(row.tags),
|
tags: splitTags(row.tags),
|
||||||
authors,
|
authors,
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,13 @@ import {
|
||||||
saveToLibrary,
|
saveToLibrary,
|
||||||
toolVersions,
|
toolVersions,
|
||||||
} from "../clips.js";
|
} from "../clips.js";
|
||||||
|
import { NO_STORE } from "../shape.js";
|
||||||
|
|
||||||
const clips = new Hono();
|
const clips = new Hono();
|
||||||
|
|
||||||
clips.use("/clips", requireAuth, requireRole("admin"));
|
clips.use("/clips", requireAuth, requireRole("admin"));
|
||||||
clips.use("/clips/*", requireAuth, requireRole("admin"));
|
clips.use("/clips/*", requireAuth, requireRole("admin"));
|
||||||
|
|
||||||
const NO_STORE = { "Cache-Control": "no-store" };
|
|
||||||
|
|
||||||
const RECENT = 50;
|
const RECENT = 50;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 list + the event scopes
|
||||||
GET /events/:id one event, full body, people
|
GET /events/:id one event, full body, people
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
Organizations are one table, so they're one endpoint. A region
|
Organizations are one table, so they're one endpoint. A region
|
||||||
and a chapter differ by a handful of fields, which arrive under
|
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.
|
list component be written once and pointed at any kind.
|
||||||
|
|
||||||
The lists leave out unlisted records (is_listed = 0); the
|
The lists leave out unlisted records (is_listed = 0); the
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
every event.
|
every event.
|
||||||
|
|
||||||
An event's hosts are a list, in billing order, and each one is
|
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
|
`org_kind` is there for the three organization routes. The
|
||||||
first is the one the colour and logo fell back to, which is why
|
first is the one the colour and logo fell back to, which is why
|
||||||
order is data and not a display choice.
|
order is data and not a display choice.
|
||||||
|
|
@ -54,8 +54,11 @@ import { Hono } from "hono";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
asBool,
|
asBool,
|
||||||
|
json,
|
||||||
loadBlocks,
|
loadBlocks,
|
||||||
loadLinks,
|
loadLinks,
|
||||||
|
loadOwned,
|
||||||
|
marks,
|
||||||
paragraphs,
|
paragraphs,
|
||||||
shapeSeries,
|
shapeSeries,
|
||||||
splitLinks,
|
splitLinks,
|
||||||
|
|
@ -66,14 +69,9 @@ const content = new Hono();
|
||||||
// Content changes weekly at most, and a stale minute costs nobody
|
// Content changes weekly at most, and a stale minute costs nobody
|
||||||
// anything. stale-while-revalidate keeps the page instant while the
|
// anything. stale-while-revalidate keeps the page instant while the
|
||||||
// refresh happens behind it.
|
// refresh happens behind it.
|
||||||
const CACHE = "public, max-age=60, stale-while-revalidate=300";
|
|
||||||
|
|
||||||
const json = (c, body) => c.json(body, 200, { "Cache-Control": CACHE });
|
|
||||||
|
|
||||||
const ORG_KINDS = ["national", "region", "chapter", "partner"];
|
const ORG_KINDS = ["national", "region", "chapter", "partner"];
|
||||||
|
|
||||||
const marks = (n) => Array(n).fill("?").join(",");
|
|
||||||
|
|
||||||
/* ── Loaders ───────────────────────────────────────────────── */
|
/* ── Loaders ───────────────────────────────────────────────── */
|
||||||
|
|
||||||
/* Hosts for a batch of events, keyed by event id, in the order
|
/* Hosts for a batch of events, keyed by event id, in the order
|
||||||
|
|
@ -83,7 +81,7 @@ const marks = (n) => Array(n).fill("?").join(",");
|
||||||
Unpublished hosts are dropped here rather than in the view: the
|
Unpublished hosts are dropped here rather than in the view: the
|
||||||
admin reads the same view and needs to see them. An event whose
|
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
|
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) {
|
function loadHosts(db, ids) {
|
||||||
const byEvent = new Map();
|
const byEvent = new Map();
|
||||||
if (ids.length === 0) return byEvent;
|
if (ids.length === 0) return byEvent;
|
||||||
|
|
@ -147,7 +145,6 @@ function shapeEvent(row, links, cardBlocks, hosts = []) {
|
||||||
org_logo: row.effective_org_logo,
|
org_logo: row.effective_org_logo,
|
||||||
event_logo: row.event_logo,
|
event_logo: row.event_logo,
|
||||||
color: row.effective_color,
|
color: row.effective_color,
|
||||||
gradient: row.gradient,
|
|
||||||
card_image: row.card_image,
|
card_image: row.card_image,
|
||||||
|
|
||||||
hosts: hosts.map(shapeHost),
|
hosts: hosts.map(shapeHost),
|
||||||
|
|
@ -230,8 +227,8 @@ function shapeTeam(row, links, cardBlocks) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* awards.org_id is nullable — an award can predate any decision
|
/* awards.org_id is nullable, an award can predate any decision
|
||||||
about which organization owns it — so `org` genuinely can be
|
about which organization owns it, so `org` genuinely can be
|
||||||
null, and is also null when the awarding org is unpublished. */
|
null, and is also null when the awarding org is unpublished. */
|
||||||
function shapeAward(row) {
|
function shapeAward(row) {
|
||||||
return {
|
return {
|
||||||
|
|
@ -372,7 +369,7 @@ function attachLeadership(db, orgs) {
|
||||||
|
|
||||||
/* Every team this organization has, including ones with nobody
|
/* Every team this organization has, including ones with nobody
|
||||||
currently filed under them. `leadership` already carries team_id
|
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
|
grouping alone would make an empty team invisible rather than
|
||||||
listed, which is the wrong answer for a team that exists. */
|
listed, which is the wrong answer for a team that exists. */
|
||||||
function attachTeams(db, orgs) {
|
function attachTeams(db, orgs) {
|
||||||
|
|
@ -485,7 +482,6 @@ content.get("/events", (c) => {
|
||||||
return json(c, { scopes, events });
|
return json(c, { scopes, events });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/* One event, for its own page. */
|
/* One event, for its own page. */
|
||||||
content.get("/events/:id", (c) => {
|
content.get("/events/:id", (c) => {
|
||||||
const db = c.get("db");
|
const db = c.get("db");
|
||||||
|
|
@ -497,9 +493,7 @@ content.get("/events/:id", (c) => {
|
||||||
|
|
||||||
if (!row) return c.json({ error: "No such event" }, 404);
|
if (!row) return c.json({ error: "No such event" }, 404);
|
||||||
|
|
||||||
const links = loadLinks(db, "event", [id]).get(id) ?? [];
|
const { links, cards, body } = loadOwned(db, "event", id);
|
||||||
const cards = loadBlocks(db, "event", [id], "card").get(id) ?? [];
|
|
||||||
const body = loadBlocks(db, "event", [id], "body").get(id) ?? [];
|
|
||||||
const hosts = loadHosts(db, [id]).get(id) ?? [];
|
const hosts = loadHosts(db, [id]).get(id) ?? [];
|
||||||
|
|
||||||
const people = db
|
const people = db
|
||||||
|
|
@ -542,7 +536,6 @@ content.get("/events/:id", (c) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/* ── Organizations ─────────────────────────────────────────────
|
/* ── Organizations ─────────────────────────────────────────────
|
||||||
GET /organizations every published, listed org
|
GET /organizations every published, listed org
|
||||||
GET /organizations?kind=region one kind
|
GET /organizations?kind=region one kind
|
||||||
|
|
@ -597,7 +590,6 @@ content.get("/organizations", (c) => {
|
||||||
return json(c, { organizations });
|
return json(c, { organizations });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/* One organization's page: region, chapter, partner or NGU. */
|
/* One organization's page: region, chapter, partner or NGU. */
|
||||||
content.get("/organizations/:id", (c) => {
|
content.get("/organizations/:id", (c) => {
|
||||||
const db = c.get("db");
|
const db = c.get("db");
|
||||||
|
|
@ -609,9 +601,7 @@ content.get("/organizations/:id", (c) => {
|
||||||
|
|
||||||
if (!row) return c.json({ error: "No such organization" }, 404);
|
if (!row) return c.json({ error: "No such organization" }, 404);
|
||||||
|
|
||||||
const links = loadLinks(db, "organization", [id]).get(id) ?? [];
|
const { links, cards, body } = loadOwned(db, "organization", id);
|
||||||
const cards = loadBlocks(db, "organization", [id], "card").get(id) ?? [];
|
|
||||||
const body = loadBlocks(db, "organization", [id], "body").get(id) ?? [];
|
|
||||||
|
|
||||||
const organization = shapeOrganization(row, links, cards, body);
|
const organization = shapeOrganization(row, links, cards, body);
|
||||||
const one = [organization];
|
const one = [organization];
|
||||||
|
|
@ -641,7 +631,6 @@ content.get("/organizations/:id", (c) => {
|
||||||
return json(c, { organization });
|
return json(c, { organization });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/* ── Teams ─────────────────────────────────────────────────────
|
/* ── Teams ─────────────────────────────────────────────────────
|
||||||
GET /teams every published, listed team
|
GET /teams every published, listed team
|
||||||
GET /teams?org=mid-atlantic one organization's teams
|
GET /teams?org=mid-atlantic one organization's teams
|
||||||
|
|
@ -677,7 +666,6 @@ content.get("/teams", (c) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
content.get("/teams/:id", (c) => {
|
content.get("/teams/:id", (c) => {
|
||||||
const db = c.get("db");
|
const db = c.get("db");
|
||||||
const id = c.req.param("id");
|
const id = c.req.param("id");
|
||||||
|
|
@ -693,14 +681,11 @@ content.get("/teams/:id", (c) => {
|
||||||
|
|
||||||
if (!row) return c.json({ error: "No such team" }, 404);
|
if (!row) return c.json({ error: "No such team" }, 404);
|
||||||
|
|
||||||
const links = loadLinks(db, "team", [id]).get(id) ?? [];
|
const { links, cards, body } = loadOwned(db, "team", id);
|
||||||
const cards = loadBlocks(db, "team", [id], "card").get(id) ?? [];
|
|
||||||
const body = loadBlocks(db, "team", [id], "body").get(id) ?? [];
|
|
||||||
|
|
||||||
return json(c, { team: { ...shapeTeam(row, links, cards), blocks: body } });
|
return json(c, { team: { ...shapeTeam(row, links, cards), blocks: body } });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/* ── Awards ────────────────────────────────────────────────────
|
/* ── Awards ────────────────────────────────────────────────────
|
||||||
GET /awards every award
|
GET /awards every award
|
||||||
GET /awards?org=ngu awards a given organization gives
|
GET /awards?org=ngu awards a given organization gives
|
||||||
|
|
@ -739,7 +724,6 @@ content.get("/awards", (c) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
content.get("/awards/:id", (c) => {
|
content.get("/awards/:id", (c) => {
|
||||||
const db = c.get("db");
|
const db = c.get("db");
|
||||||
const id = c.req.param("id");
|
const id = c.req.param("id");
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,10 @@
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
|
import { CACHE } from "../shape.js";
|
||||||
|
|
||||||
const directory = new Hono();
|
const directory = new Hono();
|
||||||
|
|
||||||
const CACHE = "public, max-age=60, stale-while-revalidate=300";
|
|
||||||
|
|
||||||
directory.get("/directory", (c) => {
|
directory.get("/directory", (c) => {
|
||||||
const db = c.get("db");
|
const db = c.get("db");
|
||||||
const all = (sql) => db.prepare(sql).all();
|
const all = (sql) => db.prepare(sql).all();
|
||||||
|
|
|
||||||
|
|
@ -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
|
Everything hostile that will ever reach this service arrives
|
||||||
here, so the defences live here rather than being sprinkled
|
here, so the defences live here rather than being sprinkled
|
||||||
|
|
@ -10,13 +10,12 @@
|
||||||
length caps rejected before anything touches the database
|
length caps rejected before anything touches the database
|
||||||
no HTML stored verbatim, escaped at render time
|
no HTML stored verbatim, escaped at render time
|
||||||
|
|
||||||
The write is a single INSERT with positional parameters, so it
|
The write is a single INSERT. No transaction: one statement is
|
||||||
works on node:sqlite and better-sqlite3 alike. No transaction:
|
already atomic.
|
||||||
one statement is already atomic.
|
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
import { createHash, randomBytes } from "node:crypto";
|
import { clientIp, hashIp } from "../auth.js";
|
||||||
|
|
||||||
const feedback = new Hono();
|
const feedback = new Hono();
|
||||||
|
|
||||||
|
|
@ -30,29 +29,10 @@ const LIMITS = {
|
||||||
|
|
||||||
const MIN_MESSAGE = 10;
|
const MIN_MESSAGE = 10;
|
||||||
|
|
||||||
// Must match FEEDBACK_TYPES in src/pages/sections/FeedbackForm.jsx.
|
// Must match FEEDBACK_TYPES and DATA_REQUEST in src/data/feedbackTypes.ts.
|
||||||
// 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.
|
// a renamed option shouldn't lose someone's submission.
|
||||||
const TYPES = ["broken", "confusing", "outdated", "request", "praise", "other"];
|
const TYPES = ["broken", "confusing", "outdated", "request", "praise", "other", "privacy"];
|
||||||
|
|
||||||
/* ── IP hashing ────────────────────────────────────────────────
|
|
||||||
Stored so repeat abuse from one source is visible during
|
|
||||||
triage, hashed so the table never holds an address. Without
|
|
||||||
IP_SALT the salt is regenerated each boot, which makes hashes
|
|
||||||
incomparable across restarts — fine for dev, set it in
|
|
||||||
/etc/ngu/api.env for production.
|
|
||||||
───────────────────────────────────────────────────────────── */
|
|
||||||
|
|
||||||
const IP_SALT = process.env.IP_SALT ?? randomBytes(16).toString("hex");
|
|
||||||
|
|
||||||
if (!process.env.IP_SALT) {
|
|
||||||
console.warn("IP_SALT unset — feedback ip_hash values reset on restart");
|
|
||||||
}
|
|
||||||
|
|
||||||
function hashIp(ip) {
|
|
||||||
if (!ip) return null;
|
|
||||||
return createHash("sha256").update(`${IP_SALT}:${ip}`).digest("hex").slice(0, 32);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Input cleaning ──────────────────────────────────────────── */
|
/* ── Input cleaning ──────────────────────────────────────────── */
|
||||||
|
|
||||||
|
|
@ -72,7 +52,8 @@ function looksLikeEmail(value) {
|
||||||
feedback.post("/", async (c) => {
|
feedback.post("/", async (c) => {
|
||||||
let body;
|
let body;
|
||||||
try {
|
try {
|
||||||
body = await c.req.json();
|
// `?? {}`: a body of JSON null parses fine and has no fields.
|
||||||
|
body = (await c.req.json()) ?? {};
|
||||||
} catch {
|
} catch {
|
||||||
return c.json({ error: "Expected a JSON body." }, 400);
|
return c.json({ error: "Expected a JSON body." }, 400);
|
||||||
}
|
}
|
||||||
|
|
@ -96,6 +77,10 @@ feedback.post("/", async (c) => {
|
||||||
const errors = {};
|
const errors = {};
|
||||||
if (message.length < MIN_MESSAGE) errors.message = "Please write a little more.";
|
if (message.length < MIN_MESSAGE) errors.message = "Please write a little more.";
|
||||||
if (!looksLikeEmail(email)) errors.email = "That email doesn't look right.";
|
if (!looksLikeEmail(email)) errors.email = "That email doesn't look right.";
|
||||||
|
// A data request (Privacy page) has to be answerable.
|
||||||
|
else if (feedbackType === "privacy" && !email) {
|
||||||
|
errors.email = "We need an email address to reply to a data request.";
|
||||||
|
}
|
||||||
|
|
||||||
if (Object.keys(errors).length > 0) {
|
if (Object.keys(errors).length > 0) {
|
||||||
return c.json({ error: "Validation failed", fields: errors }, 422);
|
return c.json({ error: "Validation failed", fields: errors }, 422);
|
||||||
|
|
@ -118,7 +103,7 @@ feedback.post("/", async (c) => {
|
||||||
pagePath || null,
|
pagePath || null,
|
||||||
sectionId || null,
|
sectionId || null,
|
||||||
clean(c.req.header("user-agent"), 500) || null,
|
clean(c.req.header("user-agent"), 500) || null,
|
||||||
hashIp(c.req.header("x-forwarded-for")?.split(",")[0].trim()),
|
hashIp(clientIp(c)),
|
||||||
);
|
);
|
||||||
|
|
||||||
// created_at and status come from column defaults.
|
// created_at and status come from column defaults.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* ═══════════════════════════════════════════════════════════════
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
HISTORY ROUTE — read-only, mounted under /api
|
HISTORY ROUTE: read-only, mounted under /api
|
||||||
|
|
||||||
GET /history every published timeline entry
|
GET /history every published timeline entry
|
||||||
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
queries doesn't grow with the number of entries.
|
queries doesn't grow with the number of entries.
|
||||||
|
|
||||||
· precision that outruns the date. An entry can hold '2012' with
|
· 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
|
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
|
that isn't there, so precision is capped at what the string
|
||||||
actually carries.
|
actually carries.
|
||||||
|
|
@ -31,15 +31,10 @@
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
|
import { json, marks } from "../shape.js";
|
||||||
|
|
||||||
const history = new Hono();
|
const history = new Hono();
|
||||||
|
|
||||||
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. */
|
/* 'YYYY' → year, 'YYYY-MM' → month, 'YYYY-MM-DD' → day. */
|
||||||
function precisionOfString(date) {
|
function precisionOfString(date) {
|
||||||
const parts = String(date).split("-");
|
const parts = String(date).split("-");
|
||||||
|
|
@ -115,7 +110,7 @@ history.get("/history", (c) => {
|
||||||
)
|
)
|
||||||
.all();
|
.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
|
// an entry nobody gave a date to is invisible, and silence is how it
|
||||||
// stays that way.
|
// stays that way.
|
||||||
const undated = db
|
const undated = db
|
||||||
|
|
@ -153,7 +148,7 @@ function loadRosters(db, rows) {
|
||||||
const teamIds = [...new Set(teamEntries.map((row) => row.ref_id))];
|
const teamIds = [...new Set(teamEntries.map((row) => row.ref_id))];
|
||||||
|
|
||||||
// v_org_leadership already decides who counts as current and
|
// 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.
|
// published. Restating those conditions here is how they drift.
|
||||||
const members = db
|
const members = db
|
||||||
.prepare(
|
.prepare(
|
||||||
|
|
|
||||||
|
|
@ -48,14 +48,10 @@
|
||||||
|
|
||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
|
|
||||||
import { asBool, loadFeaturedCards, loadLinks, shapeSeries, splitLinks } from "../shape.js";
|
import { asBool, json, loadFeaturedCards, loadLinks, shapeSeries, splitLinks } from "../shape.js";
|
||||||
|
|
||||||
const home = new Hono();
|
const home = new Hono();
|
||||||
|
|
||||||
const CACHE = "public, max-age=60, stale-while-revalidate=300";
|
|
||||||
|
|
||||||
const json = (c, body) => c.json(body, 200, { "Cache-Control": CACHE });
|
|
||||||
|
|
||||||
const PAGE_ID = "home";
|
const PAGE_ID = "home";
|
||||||
|
|
||||||
const STAT_QUERIES = {
|
const STAT_QUERIES = {
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,12 @@ import {
|
||||||
store,
|
store,
|
||||||
} from "../media.js";
|
} from "../media.js";
|
||||||
import { fetchImage, previewLink } from "../linkPreview.js";
|
import { fetchImage, previewLink } from "../linkPreview.js";
|
||||||
|
import { NO_STORE } from "../shape.js";
|
||||||
|
|
||||||
const media = new Hono();
|
const media = new Hono();
|
||||||
|
|
||||||
media.use("*", requireAuth);
|
media.use("*", requireAuth);
|
||||||
|
|
||||||
const NO_STORE = { "Cache-Control": "no-store" };
|
|
||||||
|
|
||||||
const MAX_LIST = 500;
|
const MAX_LIST = 500;
|
||||||
|
|
||||||
|
|
@ -165,7 +165,7 @@ media.post("/link-preview", requireRole("editor"), async (c) => {
|
||||||
const user = c.get("user");
|
const user = c.get("user");
|
||||||
let url;
|
let url;
|
||||||
try {
|
try {
|
||||||
({ url } = await c.req.json());
|
({ url } = (await c.req.json()) ?? {});
|
||||||
} catch {
|
} catch {
|
||||||
return c.json({ error: "Expected a JSON body." }, 400);
|
return c.json({ error: "Expected a JSON body." }, 400);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ import { fileURLToPath } from "node:url";
|
||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
|
|
||||||
import { metaFor, renderPage, robotsTxt, siteFor, sitemap } from "../pageMeta.js";
|
import { metaFor, renderPage, robotsTxt, siteFor, sitemap } from "../pageMeta.js";
|
||||||
|
import { CACHE, NO_STORE } from "../shape.js";
|
||||||
|
|
||||||
const here = path.dirname(fileURLToPath(import.meta.url));
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
|
|
@ -43,8 +44,6 @@ export const SITE_INDEX = path.resolve(
|
||||||
process.env.SITE_INDEX ?? path.join(here, "../../../dist/index.html"),
|
process.env.SITE_INDEX ?? path.join(here, "../../../dist/index.html"),
|
||||||
);
|
);
|
||||||
|
|
||||||
const CACHE = "public, max-age=60, stale-while-revalidate=300";
|
|
||||||
|
|
||||||
let cached = { mtime: 0, html: null };
|
let cached = { mtime: 0, html: null };
|
||||||
|
|
||||||
function indexHtml() {
|
function indexHtml() {
|
||||||
|
|
@ -118,11 +117,15 @@ pages.get("*", (c, next) => {
|
||||||
`pages: serving ${pathname} without its metadata: ${err.message}` +
|
`pages: serving ${pathname} without its metadata: ${err.message}` +
|
||||||
(err.code === "ENOENT" ? " (set SITE_CONFIG to the deployed site.json)" : ""),
|
(err.code === "ENOENT" ? " (set SITE_CONFIG to the deployed site.json)" : ""),
|
||||||
);
|
);
|
||||||
return c.html(html, 200, { "Cache-Control": "no-store" });
|
return c.html(html, 200, NO_STORE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// no-cache: a browser may keep the page but asks again each time.
|
||||||
|
// HTML names the build's hashed /assets files, and after a deploy
|
||||||
|
// those are gone, so a cached old page would load nothing. Pages
|
||||||
|
// are rebuilt in well under a millisecond.
|
||||||
return c.html(page, meta.status, {
|
return c.html(page, meta.status, {
|
||||||
"Cache-Control": meta.status === 200 ? CACHE : "no-store",
|
"Cache-Control": meta.status === 200 ? "no-cache" : "no-store",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,14 @@
|
||||||
|
|
||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
import { requireAuth, requireRole, ROLES } from "../auth.js";
|
import { requireAuth, requireRole, ROLES } from "../auth.js";
|
||||||
|
import { tx } from "../db.js";
|
||||||
|
import { NO_STORE } from "../shape.js";
|
||||||
|
|
||||||
const panel = new Hono();
|
const panel = new Hono();
|
||||||
|
|
||||||
panel.use("*", requireAuth);
|
panel.use("*", requireAuth);
|
||||||
panel.use("*", requireRole("superadmin"));
|
panel.use("*", requireRole("superadmin"));
|
||||||
|
|
||||||
const NO_STORE = { "Cache-Control": "no-store" };
|
|
||||||
|
|
||||||
/* The counts on the overview. Table name is a literal from this
|
/* The counts on the overview. Table name is a literal from this
|
||||||
list, never anything off the wire. */
|
list, never anything off the wire. */
|
||||||
|
|
@ -116,7 +117,8 @@ panel.patch("/users/:id", async (c) => {
|
||||||
|
|
||||||
let body;
|
let body;
|
||||||
try {
|
try {
|
||||||
body = await c.req.json();
|
// `?? {}`: a body of JSON null parses fine and has no fields.
|
||||||
|
body = (await c.req.json()) ?? {};
|
||||||
} catch {
|
} catch {
|
||||||
return c.json({ error: "Expected a JSON body." }, 400);
|
return c.json({ error: "Expected a JSON body." }, 400);
|
||||||
}
|
}
|
||||||
|
|
@ -154,7 +156,8 @@ panel.patch("/users/:id", async (c) => {
|
||||||
|
|
||||||
if (sets.length === 0) return c.json({ error: "Nothing to change." }, 400);
|
if (sets.length === 0) return c.json({ error: "Nothing to change." }, 400);
|
||||||
|
|
||||||
const tx = db.transaction(() => {
|
// tx(), not db.transaction(): node:sqlite has no transaction().
|
||||||
|
tx(db, () => {
|
||||||
db.prepare(`UPDATE admin_users SET ${sets.join(", ")} WHERE id = ?`).run(
|
db.prepare(`UPDATE admin_users SET ${sets.join(", ")} WHERE id = ?`).run(
|
||||||
...params,
|
...params,
|
||||||
id,
|
id,
|
||||||
|
|
@ -163,7 +166,6 @@ panel.patch("/users/:id", async (c) => {
|
||||||
// matches the row. Make them sign in again.
|
// matches the row. Make them sign in again.
|
||||||
db.prepare("DELETE FROM sessions WHERE user_id = ?").run(id);
|
db.prepare("DELETE FROM sessions WHERE user_id = ?").run(id);
|
||||||
});
|
});
|
||||||
tx();
|
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`account ${target.email} updated by ${me.email}: ${JSON.stringify(body)}`,
|
`account ${target.email} updated by ${me.email}: ${JSON.stringify(body)}`,
|
||||||
|
|
|
||||||
|
|
@ -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 /teams/:id/people current public members of a team
|
||||||
GET /people?ids=a,b,c named people, any order
|
GET /people?ids=a,b,c named people, any order
|
||||||
GET /people/:id one person's page
|
GET /people/:id one person's page
|
||||||
|
|
||||||
The team route reads v_org_leadership, which already decides who
|
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
|
public, person published. Restating those conditions here is how
|
||||||
they drift apart.
|
they drift apart.
|
||||||
|
|
||||||
|
|
@ -21,16 +21,10 @@
|
||||||
|
|
||||||
import { Hono } from "hono";
|
import { Hono } from "hono";
|
||||||
|
|
||||||
import { asBool, loadBlocks, loadLinks, paragraphs, splitLinks } from "../shape.js";
|
import { asBool, json, loadOwned, marks, paragraphs, splitLinks } from "../shape.js";
|
||||||
|
|
||||||
const people = new Hono();
|
const people = new Hono();
|
||||||
|
|
||||||
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. */
|
/* How many slugs one request may name. Keeps the URL sane. */
|
||||||
const MAX_IDS = 50;
|
const MAX_IDS = 50;
|
||||||
|
|
||||||
|
|
@ -55,7 +49,7 @@ function shapePerson(row) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* people.bio is one run of prose with blank lines between
|
/* 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. */
|
content_block rows into text. */
|
||||||
function splitParagraphs(text) {
|
function splitParagraphs(text) {
|
||||||
if (!text) return null;
|
if (!text) return null;
|
||||||
|
|
@ -144,7 +138,7 @@ people.get("/people", (c) => {
|
||||||
the same visibility rules its own page applies: a role needs a
|
the same visibility rules its own page applies: a role needs a
|
||||||
public affiliation and a published organization, an event must
|
public affiliation and a published organization, an event must
|
||||||
be published, an award must be published and the citation
|
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.
|
the seat is still real, it just has no page to link to.
|
||||||
|
|
||||||
Roles are current and past. v_org_leadership only knows
|
Roles are current and past. v_org_leadership only knows
|
||||||
|
|
@ -181,9 +175,7 @@ people.get("/people/:id", (c) => {
|
||||||
|
|
||||||
if (!row) return c.json({ error: "No such person" }, 404);
|
if (!row) return c.json({ error: "No such person" }, 404);
|
||||||
|
|
||||||
const links = loadLinks(db, "person", [id]).get(id) ?? [];
|
const { links, cards, body } = loadOwned(db, "person", id);
|
||||||
const cards = loadBlocks(db, "person", [id], "card").get(id) ?? [];
|
|
||||||
const body = loadBlocks(db, "person", [id], "body").get(id) ?? [];
|
|
||||||
const { actions, socials, website, instagram } = splitLinks(links);
|
const { actions, socials, website, instagram } = splitLinks(links);
|
||||||
|
|
||||||
// Current first, then most recently ended. Within each, the same
|
// Current first, then most recently ended. Within each, the same
|
||||||
|
|
|
||||||
|
|
@ -352,7 +352,6 @@ tx(db, () => {
|
||||||
org_logo: IMAGE,
|
org_logo: IMAGE,
|
||||||
event_logo: IMAGE,
|
event_logo: IMAGE,
|
||||||
color: "#d62976",
|
color: "#d62976",
|
||||||
gradient: "linear-gradient(160deg, rgba(214,41,118,0.10), rgba(19,139,160,0.10))",
|
|
||||||
card_image: IMAGE,
|
card_image: IMAGE,
|
||||||
is_published: 1,
|
is_published: 1,
|
||||||
is_listed: LISTED,
|
is_listed: LISTED,
|
||||||
|
|
@ -463,6 +462,7 @@ tx(db, () => {
|
||||||
cover_image: IMAGE,
|
cover_image: IMAGE,
|
||||||
published_on: db.prepare(`SELECT date('now') AS d`).get().d,
|
published_on: db.prepare(`SELECT date('now') AS d`).get().d,
|
||||||
tags: "Test, Showcase",
|
tags: "Test, Showcase",
|
||||||
|
show_contents: 1,
|
||||||
guest_author: "A Guest Author",
|
guest_author: "A Guest Author",
|
||||||
guest_photo: IMAGE,
|
guest_photo: IMAGE,
|
||||||
is_published: 1,
|
is_published: 1,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
Blocks and links are polymorphic: any organization, event, person
|
Blocks and links are polymorphic: any organization, event, person
|
||||||
or team can own them. Every list endpoint therefore needs the
|
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.
|
in one query each and stitch.
|
||||||
|
|
||||||
The alternative is a query per row, which at a dozen events is
|
The alternative is a query per row, which at a dozen events is
|
||||||
|
|
@ -99,7 +99,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
|
||||||
const itemRows = db
|
const itemRows = db
|
||||||
.prepare(
|
.prepare(
|
||||||
`SELECT i.block_id, i.text, i.detail, i.url,
|
`SELECT i.block_id, i.text, i.detail, i.url,
|
||||||
i.day, i.time, i.location, i.description, i.media, i.map,
|
i.day, i.time, i.location, i.description, i.media, i.media_alt, i.map,
|
||||||
p.id AS person_id, p.display_name AS person_name,
|
p.id AS person_id, p.display_name AS person_name,
|
||||||
p.photo AS person_photo, p.tagline AS person_tagline
|
p.photo AS person_photo, p.tagline AS person_tagline
|
||||||
FROM content_block_items i
|
FROM content_block_items i
|
||||||
|
|
@ -122,6 +122,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
|
||||||
location: row.location,
|
location: row.location,
|
||||||
description: row.description,
|
description: row.description,
|
||||||
media: row.media,
|
media: row.media,
|
||||||
|
media_alt: row.media_alt,
|
||||||
map: row.map,
|
map: row.map,
|
||||||
person: row.person_id
|
person: row.person_id
|
||||||
? {
|
? {
|
||||||
|
|
@ -139,7 +140,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
|
||||||
|
|
||||||
/* ── Card description ──────────────────────────────────────────
|
/* ── Card description ──────────────────────────────────────────
|
||||||
The card slot is paragraphs by convention, so it collapses to
|
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
|
and description[1]. A non-paragraph block in the card slot is
|
||||||
ignored here; put it in the body slot instead.
|
ignored here; put it in the body slot instead.
|
||||||
───────────────────────────────────────────────────────────── */
|
───────────────────────────────────────────────────────────── */
|
||||||
|
|
@ -172,7 +173,7 @@ export function splitLinks(links = []) {
|
||||||
collapse from seven flags to a list of the ticked ones, Sunday
|
collapse from seven flags to a list of the ticked ones, Sunday
|
||||||
first; an empty list means "starts_on's weekday", which the
|
first; an empty list means "starts_on's weekday", which the
|
||||||
client resolves since it already holds starts_on. Occurrences
|
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.
|
against its own today. Shared by /events and /front-page.
|
||||||
───────────────────────────────────────────────────────────── */
|
───────────────────────────────────────────────────────────── */
|
||||||
const SERIES_WEEKDAYS = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
|
const SERIES_WEEKDAYS = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
|
||||||
|
|
@ -300,3 +301,24 @@ export function loadFeaturedCards(db, ownerKind, ownerId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export { asBool };
|
export { asBool };
|
||||||
|
|
||||||
|
/* One record's links, card blocks and body blocks: what every detail
|
||||||
|
page sends beside the record itself. */
|
||||||
|
export function loadOwned(db, ownerKind, id) {
|
||||||
|
return {
|
||||||
|
links: loadLinks(db, ownerKind, [id]).get(id) ?? [],
|
||||||
|
cards: loadBlocks(db, ownerKind, [id], "card").get(id) ?? [],
|
||||||
|
body: loadBlocks(db, ownerKind, [id], "body").get(id) ?? [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Public reads may be cached a minute, and served a little stale
|
||||||
|
while a fresh copy is fetched. json() sends a body with it. */
|
||||||
|
export const CACHE = "public, max-age=60, stale-while-revalidate=300";
|
||||||
|
export const json = (c, body) => c.json(body, 200, { "Cache-Control": CACHE });
|
||||||
|
|
||||||
|
// Admin reads and anything personal: never kept by a browser or proxy.
|
||||||
|
export const NO_STORE = { "Cache-Control": "no-store" };
|
||||||
|
|
||||||
|
// "?,?,?" for an IN (...) list of n values.
|
||||||
|
export const marks = (n) => Array(n).fill("?").join(",");
|
||||||
|
|
|
||||||
122
server/src/theme.js
Normal file
122
server/src/theme.js
Normal file
|
|
@ -0,0 +1,122 @@
|
||||||
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
|
THEME
|
||||||
|
|
||||||
|
The admin's palette (Panel → Site settings → Colours, table
|
||||||
|
site_setting_colors) over the site's own colour tokens.
|
||||||
|
|
||||||
|
The defaults are THEME_DEFAULTS (themeDefaults.js), which the
|
||||||
|
build checks against src/index.css. A blank override keeps the
|
||||||
|
default.
|
||||||
|
|
||||||
|
themeCss() is written into every page's <head> (pageMeta.js).
|
||||||
|
It goes into the same cascade layers as index.css (theme for
|
||||||
|
light, base for dark), after it, so an override replaces exactly
|
||||||
|
the value it names: a light-only change leaves dark mode alone.
|
||||||
|
|
||||||
|
checkTheme() runs when Site settings is saved (the descriptor's
|
||||||
|
`check`, inside the save's transaction), and refuses a palette in
|
||||||
|
which any text would fall under WCAG AA (4.5:1) in either mode, so
|
||||||
|
an admin can't make the site unreadable.
|
||||||
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
import { HttpError } from "./admin-crud.js";
|
||||||
|
import { THEME_DEFAULTS } from "./themeDefaults.js";
|
||||||
|
|
||||||
|
export { THEME_DEFAULTS };
|
||||||
|
|
||||||
|
export const THEME_TOKENS = Object.keys(THEME_DEFAULTS);
|
||||||
|
|
||||||
|
const HEX = /^#[0-9a-f]{6}$/i;
|
||||||
|
const MODES = ["light", "dark"];
|
||||||
|
|
||||||
|
function overrides(db) {
|
||||||
|
const rows = db
|
||||||
|
.prepare(`SELECT token, light, dark FROM site_setting_colors WHERE settings_id = 'site'`)
|
||||||
|
.all();
|
||||||
|
// Checked again here, not only by the table's CHECK: this goes
|
||||||
|
// straight into a <style> element.
|
||||||
|
return rows.filter((row) => Object.hasOwn(THEME_DEFAULTS, row.token));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* { light: { ink: '#…', … }, dark: { … } }, defaults with overrides. */
|
||||||
|
function palette(db) {
|
||||||
|
const out = { light: {}, dark: {} };
|
||||||
|
for (const [token, [light, dark]] of Object.entries(THEME_DEFAULTS)) {
|
||||||
|
out.light[token] = light;
|
||||||
|
out.dark[token] = dark;
|
||||||
|
}
|
||||||
|
for (const row of overrides(db)) {
|
||||||
|
MODES.forEach((mode) => {
|
||||||
|
if (HEX.test(row[mode] ?? "")) out[mode][row.token] = row[mode].toLowerCase();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function themeCss(db) {
|
||||||
|
const rows = overrides(db);
|
||||||
|
const decls = (mode) =>
|
||||||
|
rows
|
||||||
|
.filter((row) => HEX.test(row[mode] ?? ""))
|
||||||
|
.map((row) => `--color-${row.token}:${row[mode].toLowerCase()}`)
|
||||||
|
.join(";");
|
||||||
|
const light = decls("light");
|
||||||
|
const dark = decls("dark");
|
||||||
|
if (!light && !dark) return "";
|
||||||
|
return [
|
||||||
|
light && `@layer theme{:root{${light}}}`,
|
||||||
|
dark &&
|
||||||
|
`@layer base{:root[data-theme="dark"]{${dark}}` +
|
||||||
|
`@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){${dark}}}}`,
|
||||||
|
]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join("");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Contrast ──────────────────────────────────────────────────── */
|
||||||
|
|
||||||
|
function luminance(hex) {
|
||||||
|
const channel = (i) => {
|
||||||
|
const c = parseInt(hex.slice(i, i + 2), 16) / 255;
|
||||||
|
return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
||||||
|
};
|
||||||
|
return 0.2126 * channel(1) + 0.7152 * channel(3) + 0.0722 * channel(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function contrast(a, b) {
|
||||||
|
const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x);
|
||||||
|
return (hi + 0.05) / (lo + 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
const TEXT = ["ink", "body", "muted", "link", "danger"];
|
||||||
|
const BACKGROUNDS = ["surface", "tint", "tint-soft"];
|
||||||
|
|
||||||
|
/* Every pair that has to stay readable: [text, background, minimum]. */
|
||||||
|
function pairs(colors) {
|
||||||
|
const list = [];
|
||||||
|
for (const text of TEXT) {
|
||||||
|
for (const bg of BACKGROUNDS) list.push([text, colors[text], bg, colors[bg], 4.5]);
|
||||||
|
}
|
||||||
|
list.push(["danger", colors.danger, "danger-tint", colors["danger-tint"], 4.5]);
|
||||||
|
list.push(["white text", "#ffffff", "action", colors.action, 4.5]);
|
||||||
|
list.push(["white text", "#ffffff", "action-hover", colors["action-hover"], 4.5]);
|
||||||
|
// Decoration (borders, rules) only needs to be visible.
|
||||||
|
list.push(["brand", colors.brand, "surface", colors.surface, 3]);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function checkTheme(db) {
|
||||||
|
const colors = palette(db);
|
||||||
|
const problems = [];
|
||||||
|
for (const mode of MODES) {
|
||||||
|
for (const [a, aHex, b, bHex, min] of pairs(colors[mode])) {
|
||||||
|
const ratio = contrast(aHex, bHex);
|
||||||
|
if (ratio < min) {
|
||||||
|
problems.push(`${a} on ${b} in ${mode} mode is ${ratio.toFixed(2)}:1, needs ${min}:1`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (problems.length) {
|
||||||
|
throw new HttpError(422, `These colours would be hard to read: ${problems.join("; ")}.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
29
server/src/themeDefaults.js
Normal file
29
server/src/themeDefaults.js
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
|
THEME DEFAULTS
|
||||||
|
|
||||||
|
The site's own colour tokens, light and dark: the one list both
|
||||||
|
the server (theme.js: contrast check, overrides) and the admin
|
||||||
|
(Site settings → Colours: defaults shown) read. No imports, so the
|
||||||
|
browser bundle can take it too.
|
||||||
|
|
||||||
|
src/index.css holds the same values as CSS (@theme and its dark
|
||||||
|
block), since CSS can't import this. The build checks the two
|
||||||
|
agree and stops if they don't (themeDefaultsCheck in
|
||||||
|
vite.config.ts). Change a colour here and there together.
|
||||||
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
// light dark
|
||||||
|
export const THEME_DEFAULTS = {
|
||||||
|
ink: ["#073d4a", "#eaf6f8"],
|
||||||
|
body: ["#26454c", "#cde0e4"],
|
||||||
|
muted: ["#4a6b72", "#9fb9bf"],
|
||||||
|
link: ["#0f7183", "#5ccbdc"],
|
||||||
|
brand: ["#138ba0", "#2aa7bc"],
|
||||||
|
action: ["#0f7183", "#0f7183"],
|
||||||
|
"action-hover": ["#0b5c6a", "#0b5c6a"],
|
||||||
|
surface: ["#ffffff", "#0c1d21"],
|
||||||
|
tint: ["#eef9fb", "#11292e"],
|
||||||
|
"tint-soft": ["#f6fbfc", "#0f2428"],
|
||||||
|
danger: ["#b3261e", "#ff8a80"],
|
||||||
|
"danger-tint": ["#fdf3f2", "#3b1714"],
|
||||||
|
};
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
"title": "Next Generation of Unity",
|
"title": "Next Generation of Unity",
|
||||||
"url": "https://nextgenerationofunity.org",
|
"url": "https://nextgenerationofunity.org",
|
||||||
"description": "",
|
"description": "",
|
||||||
|
"privacyEmail": "",
|
||||||
"robots": {
|
"robots": {
|
||||||
"index": true
|
"index": true
|
||||||
},
|
},
|
||||||
|
|
|
||||||
181
src/App.tsx
181
src/App.tsx
|
|
@ -1,50 +1,86 @@
|
||||||
import { BrowserRouter, Routes, Route, Outlet, Navigate } from "react-router-dom";
|
import {
|
||||||
import { lazy, Suspense } from "react";
|
BrowserRouter,
|
||||||
|
Routes,
|
||||||
|
Route,
|
||||||
|
Outlet,
|
||||||
|
Navigate,
|
||||||
|
} from "react-router-dom"
|
||||||
|
import { lazy, Suspense } from "react"
|
||||||
/*Components*/
|
/*Components*/
|
||||||
import Layout from "./components/Layout.tsx";
|
import Layout from "./components/Layout.tsx"
|
||||||
|
|
||||||
/*Libraries*/
|
/*Libraries*/
|
||||||
import { AuthProvider, RequireAuth } from "./lib/auth.tsx";
|
import { AuthProvider, RequireAuth } from "./lib/auth.tsx"
|
||||||
import RequireRole from "./pages/admin/RequireRole.tsx";
|
import RequireRole from "./pages/admin/RequireRole.tsx"
|
||||||
|
|
||||||
/*Primary Pages*/
|
/*Pages*/
|
||||||
import Home from "./pages/Home.tsx";
|
// Home is the landing page, so it ships in the main bundle. Every
|
||||||
import Retreats from "./pages/Retreats.tsx";
|
// other page, and all of the admin, is fetched when first visited:
|
||||||
import Community from "./pages/Community.tsx";
|
// a visitor to the front page never downloads the admin, the QR
|
||||||
import Leadership from "./pages/Leadership.tsx";
|
// encoder, the calendar or the chapter map. Layout and AdminLayout
|
||||||
import Resources from "./pages/Resources.tsx";
|
// wrap their <Outlet /> in <Suspense>, so the header stays put while
|
||||||
import History from "./pages/History.tsx";
|
// a page loads.
|
||||||
|
import Home from "./pages/Home.tsx"
|
||||||
|
|
||||||
/*Secondary Pages*/
|
/* A page's chunk can be missing when a deploy replaced the build while
|
||||||
import Feedback from "./pages/Feedback.tsx";
|
this tab still ran the old one. Reload once to pick up the new
|
||||||
import Giving from "./pages/Giving.tsx";
|
build; if that doesn't help, let the error surface. */
|
||||||
|
const CHUNK_RELOAD = "site-chunk-reload"
|
||||||
|
const lazyPage = (load) =>
|
||||||
|
lazy(() =>
|
||||||
|
load()
|
||||||
|
.then((page) => {
|
||||||
|
try {
|
||||||
|
sessionStorage.removeItem(CHUNK_RELOAD)
|
||||||
|
} catch {}
|
||||||
|
return page
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
const key = CHUNK_RELOAD
|
||||||
|
let reloaded = false
|
||||||
|
try {
|
||||||
|
reloaded = sessionStorage.getItem(key) === "1"
|
||||||
|
sessionStorage.setItem(key, "1")
|
||||||
|
} catch {}
|
||||||
|
if (!reloaded) {
|
||||||
|
window.location.reload()
|
||||||
|
return new Promise(() => {})
|
||||||
|
}
|
||||||
|
throw err
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
const Retreats = lazyPage(() => import("./pages/Retreats.tsx"))
|
||||||
|
const Community = lazyPage(() => import("./pages/Community.tsx"))
|
||||||
|
const Leadership = lazyPage(() => import("./pages/Leadership.tsx"))
|
||||||
|
const Resources = lazyPage(() => import("./pages/Resources.tsx"))
|
||||||
|
const History = lazyPage(() => import("./pages/History.tsx"))
|
||||||
|
const Feedback = lazyPage(() => import("./pages/Feedback.tsx"))
|
||||||
|
const Giving = lazyPage(() => import("./pages/Giving.tsx"))
|
||||||
|
const QrCodes = lazyPage(() => import("./pages/QrCodes.tsx"))
|
||||||
|
const Privacy = lazyPage(() => import("./pages/Privacy.tsx"))
|
||||||
|
const Terms = lazyPage(() => import("./pages/Terms.tsx"))
|
||||||
|
const NotFound = lazyPage(() => import("./pages/NotFound.tsx"))
|
||||||
|
|
||||||
/*Entity Pages*/
|
/*Entity Pages*/
|
||||||
import EventDetail from './pages/EventDetail.tsx'
|
const EventDetail = lazyPage(() => import("./pages/EventDetail.tsx"))
|
||||||
import OrganizationDetail from './pages/OrganizationDetail.tsx'
|
const OrganizationDetail = lazyPage(
|
||||||
import TeamDetail from './pages/TeamDetail.tsx'
|
() => import("./pages/OrganizationDetail.tsx"),
|
||||||
import AwardDetail from './pages/AwardDetail.tsx'
|
)
|
||||||
import PersonDetail from './pages/PersonDetail.tsx'
|
const TeamDetail = lazyPage(() => import("./pages/TeamDetail.tsx"))
|
||||||
import BlogPost from './pages/BlogPost.tsx'
|
const AwardDetail = lazyPage(() => import("./pages/AwardDetail.tsx"))
|
||||||
|
const PersonDetail = lazyPage(() => import("./pages/PersonDetail.tsx"))
|
||||||
|
const BlogPost = lazyPage(() => import("./pages/BlogPost.tsx"))
|
||||||
|
|
||||||
/*Admin Pages*/
|
/*Admin Pages*/
|
||||||
import AdminLayout from "./pages/admin/AdminLayout.tsx";
|
const AdminLayout = lazyPage(() => import("./pages/admin/AdminLayout.tsx"))
|
||||||
import AdminLogin from "./pages/admin/AdminLogin.tsx";
|
const AdminLogin = lazyPage(() => import("./pages/admin/AdminLogin.tsx"))
|
||||||
import AdminPanel from "./pages/admin/AdminPanel.tsx";
|
const AdminPanel = lazyPage(() => import("./pages/admin/AdminPanel.tsx"))
|
||||||
import AdminHome from "./pages/admin/AdminHome.tsx";
|
const AdminHome = lazyPage(() => import("./pages/admin/AdminHome.tsx"))
|
||||||
import AdminFeedback from "./pages/admin/AdminFeedback.tsx";
|
const AdminFeedback = lazyPage(() => import("./pages/admin/AdminFeedback.tsx"))
|
||||||
import AdminMedia from "./pages/admin/AdminMedia.tsx";
|
const AdminMedia = lazyPage(() => import("./pages/admin/AdminMedia.tsx"))
|
||||||
import AdminClips from "./pages/admin/AdminClips.tsx";
|
const AdminClips = lazyPage(() => import("./pages/admin/AdminClips.tsx"))
|
||||||
import EntityList from "./pages/admin/EntityList.tsx";
|
const EntityList = lazyPage(() => import("./pages/admin/EntityList.tsx"))
|
||||||
import EntityEdit from "./pages/admin/EntityEdit.tsx";
|
const EntityEdit = lazyPage(() => import("./pages/admin/EntityEdit.tsx"))
|
||||||
|
|
||||||
/*Ternary Pages*/
|
|
||||||
import Privacy from "./pages/Privacy.tsx";
|
|
||||||
import Terms from "./pages/Terms.tsx";
|
|
||||||
import NotFound from "./pages/NotFound.tsx";
|
|
||||||
|
|
||||||
// Loaded on demand: it brings the QR encoder, which no other page needs.
|
|
||||||
const QrCodes = lazy(() => import("./pages/QrCodes.tsx"));
|
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
return (
|
return (
|
||||||
|
|
@ -54,46 +90,55 @@ export default function App() {
|
||||||
<Route element={<Layout />}>
|
<Route element={<Layout />}>
|
||||||
<Route index element={<Home />} />
|
<Route index element={<Home />} />
|
||||||
<Route path="retreats" element={<Retreats />} />
|
<Route path="retreats" element={<Retreats />} />
|
||||||
<Route path="/events/:id" element={<EventDetail />} />
|
<Route path="/events/:id" element={<EventDetail />} />
|
||||||
<Route path="community" element={<Community />} />
|
<Route path="community" element={<Community />} />
|
||||||
<Route path="/regions/:id" element={<OrganizationDetail />} />
|
<Route path="/regions/:id" element={<OrganizationDetail />} />
|
||||||
<Route path="/chapters/:id" element={<OrganizationDetail />} />
|
<Route path="/chapters/:id" element={<OrganizationDetail />} />
|
||||||
<Route path="/partners/:id" element={<OrganizationDetail />} />
|
<Route path="/partners/:id" element={<OrganizationDetail />} />
|
||||||
<Route path="/organizations/:id" element={<OrganizationDetail />} />
|
<Route path="/organizations/:id" element={<OrganizationDetail />} />
|
||||||
<Route path="/teams/:id" element={<TeamDetail />} />
|
<Route path="/teams/:id" element={<TeamDetail />} />
|
||||||
<Route path="/awards/:id" element={<AwardDetail />} />
|
<Route path="/awards/:id" element={<AwardDetail />} />
|
||||||
<Route path="/people/:id" element={<PersonDetail />} />
|
<Route path="/people/:id" element={<PersonDetail />} />
|
||||||
<Route path="/blog/:id" element={<BlogPost />} />
|
<Route path="/blog/:id" element={<BlogPost />} />
|
||||||
<Route path="leadership" element={<Leadership />} />
|
<Route path="leadership" element={<Leadership />} />
|
||||||
<Route path="resources" element={<Resources />} />
|
<Route path="resources" element={<Resources />} />
|
||||||
<Route path="history" element={<History />} />
|
<Route path="history" element={<History />} />
|
||||||
<Route path="feedback" element={<Feedback />} />
|
<Route path="feedback" element={<Feedback />} />
|
||||||
<Route path="qr" element={<Suspense fallback={null}><QrCodes /></Suspense>} />
|
<Route path="qr" element={<QrCodes />} />
|
||||||
<Route path="give" element={<Giving />} />
|
<Route path="give" element={<Giving />} />
|
||||||
<Route path="privacy" element={<Privacy />} />
|
<Route path="privacy" element={<Privacy />} />
|
||||||
<Route path="terms" element={<Terms />} />
|
<Route path="terms" element={<Terms />} />
|
||||||
<Route path="*" element={<NotFound />} />
|
<Route path="*" element={<NotFound />} />
|
||||||
</Route>
|
</Route>
|
||||||
<Route element={<AuthProvider><Outlet /></AuthProvider>}>
|
<Route
|
||||||
<Route path="/admin/login" element={<AdminLogin />} />
|
element={
|
||||||
<Route element={<RequireAuth />}>
|
<AuthProvider>
|
||||||
<Route path="/admin" element={<AdminLayout />}>
|
<Suspense fallback={null}>
|
||||||
<Route index element={<Navigate to="/admin/home" replace />} />
|
<Outlet />
|
||||||
<Route path="home" element={<AdminHome />} />
|
</Suspense>
|
||||||
<Route element={<RequireRole role="superadmin" />}>
|
</AuthProvider>
|
||||||
<Route path="panel" element={<AdminPanel />} />
|
}
|
||||||
</Route>
|
>
|
||||||
<Route path="feedback" element={<AdminFeedback />} />
|
<Route path="/admin/login" element={<AdminLogin />} />
|
||||||
<Route path="media" element={<AdminMedia />} />
|
<Route element={<RequireAuth />}>
|
||||||
<Route element={<RequireRole role="admin" />}>
|
<Route path="/admin" element={<AdminLayout />}>
|
||||||
<Route path="clips" element={<AdminClips />} />
|
<Route index element={<Navigate to="/admin/home" replace />} />
|
||||||
</Route>
|
<Route path="home" element={<AdminHome />} />
|
||||||
<Route path=":entity" element={<EntityList />} />
|
<Route element={<RequireRole role="superadmin" />}>
|
||||||
|
<Route path="panel" element={<AdminPanel />} />
|
||||||
|
</Route>
|
||||||
|
<Route path="feedback" element={<AdminFeedback />} />
|
||||||
|
<Route path="data-requests" element={<AdminFeedback kind="privacy" />} />
|
||||||
|
<Route path="media" element={<AdminMedia />} />
|
||||||
|
<Route element={<RequireRole role="admin" />}>
|
||||||
|
<Route path="clips" element={<AdminClips />} />
|
||||||
|
</Route>
|
||||||
|
<Route path=":entity" element={<EntityList />} />
|
||||||
<Route path=":entity/:id" element={<EntityEdit />} />
|
<Route path=":entity/:id" element={<EntityEdit />} />
|
||||||
</Route>
|
</Route>
|
||||||
</Route>
|
</Route>
|
||||||
</Route>
|
</Route>
|
||||||
</Routes>
|
</Routes>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,82 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
||||||
|
|
||||||
<svg
|
|
||||||
width="403.64276mm"
|
|
||||||
height="86.755943mm"
|
|
||||||
viewBox="0 0 403.64273 86.755943"
|
|
||||||
version="1.1"
|
|
||||||
id="svg5"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg">
|
|
||||||
<defs
|
|
||||||
id="defs2" />
|
|
||||||
<g
|
|
||||||
id="layer10"
|
|
||||||
style="display:inline"
|
|
||||||
transform="translate(-344.28592,167.60401)">
|
|
||||||
<g
|
|
||||||
id="g3">
|
|
||||||
<circle
|
|
||||||
style="display:inline;fill:#008da9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.634488;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
id="path205602-8-3-1"
|
|
||||||
cx="403.82111"
|
|
||||||
cy="-121.75806"
|
|
||||||
r="40.889923" />
|
|
||||||
<path
|
|
||||||
id="path1887-1-3-7-7-6-2"
|
|
||||||
style="color:#000000;display:inline;fill:#008da9;fill-opacity:1;stroke:none;stroke-width:2.284;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
d="m 443.45159,-167.57122 c -8.63995,3.71591 -17.05927,7.97953 -25.85742,11.27148 -3.76442,1.391 -7.68514,2.52606 -11.12305,4.64648 -3.58916,2.42042 -5.95825,6.25942 -7.35135,10.29228 -1.23335,3.0863 -2.32136,6.17712 -3.84982,9.11983 -3.67393,-2.17848 -7.69746,-4.08371 -12.04108,-4.24843 -4.09333,-0.39358 -8.26381,0.55262 -11.85512,2.53592 -6.41916,3.13465 -11.92468,7.82515 -18.56868,10.51862 -2.73797,1.21486 -5.51687,2.3331 -8.27926,3.49077 -0.88252,2.47734 0.77854,5.31191 3.20508,6.10351 4.27199,1.7128 8.98018,1.56772 13.49433,1.35771 4.71612,-0.31488 9.32779,-1.47771 13.7933,-2.98449 4.28568,-1.20657 8.61172,-2.23873 13.00143,-3.03728 -2.64145,2.85774 -6.27041,4.39222 -9.272,6.78523 -0.9862,0.76271 -1.85771,1.89939 -1.64657,3.21845 0.1709,1.85512 1.7211,3.08775 2.9593,4.29677 2.6421,2.35246 5.95831,4.07918 9.49722,4.487017 1.35103,0.106385 2.71085,-0.642417 3.25697,-1.900747 1.43582,-2.68121 2.25426,-5.67671 4.35603,-7.93655 1.20099,-1.4152 3.08751,-1.77888 4.83141,-2.01081 3.79664,-0.62592 7.50391,-2.47133 9.93534,-5.50938 1.37471,-1.65305 2.10201,-3.71602 2.52235,-5.79656 0.1379,-0.6722 1.04486,-0.68506 1.58622,-0.85974 1.78218,-0.35339 3.91283,-0.77776 4.83392,-2.54366 0.89776,-1.84635 -0.0715,-4.04503 -1.61189,-5.21854 -2.41639,-1.86664 -5.65021,-3.01579 -8.63111,-2.61499 2.2258,-1.54005 4.74178,-2.58917 7.19752,-3.70372 6.31792,-2.71081 13.11161,-4.94567 18.40937,-9.54069 3.73885,-3.20962 6.79577,-7.24801 8.78271,-11.76096 0.80138,-2.0522 1.44232,-4.33553 0.95805,-6.5376 -0.3398,-1.04637 -1.34059,-2.15906 -2.5332,-1.91992 z" />
|
|
||||||
<path
|
|
||||||
id="path92116-3-2-7-1-4"
|
|
||||||
style="display:inline;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.222835;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
d="m 401.4397,-85.357733 -5.07733,3.7999 c 1.40469,0.28813 3.37038,0.49431 4.1477,0.56482 0,0 13.4726,-8.14749 21.27399,-14.00284 7.80139,-5.855347 13.28514,-13.045137 15.64699,-18.030857 4.23462,-8.93904 5.76755,-17.18121 4.93866,-21.94278 -2.3532,12.13055 -6.84548,20.1394 -8.91525,22.66728 -2.77658,3.39114 -7.3818,10.79482 -14.1263,15.035397 -8.02485,5.04559 -16.87157,10.25674 -17.88846,11.90908 z" />
|
|
||||||
<path
|
|
||||||
fill="#519259"
|
|
||||||
d="m 401.25566,-85.224563 c 2.11431,-7.90893 7.29014,-19.728807 13.53049,-25.077287 3.15174,-2.74769 6.75532,-5.34691 11.45401,-7.64618 4.36158,-2.05194 6.70709,-3.73973 9.19688,-6.81027 3.40267,-3.94053 5.90574,-7.35199 6.96383,-10.47421 0.22347,8.84634 -6.48806,19.37766 -9.02864,23.54668 -6.2265,9.41606 -10.0147,12.608287 -17.50625,17.196147 -4.38236,2.60687 -9.65678,5.68615 -14.61032,9.26512 z"
|
|
||||||
fill-opacity="1"
|
|
||||||
fill-rule="nonzero"
|
|
||||||
id="path184-6-7-6-9-3-2"
|
|
||||||
style="display:inline;fill:#358a0d;fill-opacity:1;stroke:none;stroke-width:0.625031;stroke-opacity:1" />
|
|
||||||
<path
|
|
||||||
style="color:#000000;display:inline;fill:#ffffff;stroke:none;stroke-width:2.284;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
d="m 358.52422,-123.11955 c 3.13369,-1.59928 7.04147,-4.49077 10.29591,-6.33595 3.25443,-1.84519 6.30899,-3.58417 9.61426,-4.20523 2.65302,-0.4889 6.37319,-0.18817 9.07211,0.58357 2.69896,0.77175 5.57299,2.70484 7.16593,3.40762 1.59295,0.70275 2.24655,0.19006 2.82855,-0.77494 0.582,-0.96504 2.81839,-6.05064 3.84362,-8.9293 1.02519,-2.87864 2.26409,-5.72337 4.14553,-7.76121 1.88144,-2.03782 2.31893,-2.07776 4.06202,-3.15865 1.74307,-1.08086 10.24244,-3.71628 14.53403,-5.61581 4.29158,-1.89953 8.11957,-3.58996 12.24067,-5.48028 4.12109,-1.89033 6.08861,-2.79441 7.30709,-3.29554 0.273,0.73801 -0.2034,3.06663 -1.16031,5.22317 -0.95691,2.15654 -2.9569,5.04357 -4.86279,7.26365 -1.90589,2.22009 -4.28775,4.10342 -6.82223,5.66812 -2.53448,1.56467 -4.53981,2.45823 -7.60439,3.71266 -3.06457,1.25446 -11.88915,4.7102 -14.64698,7.12005 -2.75786,2.40984 -4.18313,6.63212 -3.64772,7.60115 0.5354,0.96902 2.51391,-1.48598 3.81084,-2.34867 1.29694,-0.8627 1.95172,-1.05814 3.14897,-1.09198 1.17765,-0.0172 2.77532,0.40067 3.29849,0.63293 1.48441,0.659 3.97438,2.00122 3.54176,3.36038 -0.16368,0.51434 -0.19462,0.56904 -3.05611,1.25841 -2.86151,0.68935 -3.48508,1.29579 -3.81533,3.74861 -0.22097,1.47094 -1.44719,3.88743 -3.13317,5.28015 -1.68596,1.39274 -4.55099,2.93627 -8.41717,3.35482 -3.86617,0.41855 -6.17544,3.97192 -6.93256,5.37259 -0.75713,1.40064 -2.66104,5.90506 -2.99685,6.15238 -0.3358,0.24732 -2.76998,-0.36582 -3.79458,-0.82517 -1.02463,-0.45935 -2.612,-1.39111 -3.63624,-2.16132 -1.02425,-0.7702 -3.457,-2.975 -3.0018,-3.64018 0.45519,-0.66516 1.56543,-1.35445 2.73515,-2.12254 1.16972,-0.76811 3.86984,-2.33631 5.3456,-3.59002 1.47576,-1.25372 2.7334,-2.47754 3.4042,-3.48323 0.67079,-1.00567 0.9358,-2.14286 -0.28206,-2.7388 -1.21786,-0.59597 -1.84092,-0.39835 -4.4486,0.0225 -2.60769,0.42097 -4.8218,1.10142 -8.46858,1.9005 -3.64678,0.79905 -7.82786,2.49393 -10.97221,3.07304 -3.14439,0.5791 -4.3363,0.83756 -8.5197,0.95691 -4.1834,0.11935 -7.15938,-0.35864 -8.95468,-0.91763 -1.7953,-0.55899 -2.64147,-1.55556 -2.60415,-2.17667 3.90737,-1.58574 7.9469,-3.2841 11.38348,-5.04009 z"
|
|
||||||
id="path1887-1-3-7-7-6" />
|
|
||||||
<path
|
|
||||||
fill="#519259"
|
|
||||||
d="m 412.95849,-81.884143 c 4.58067,-1.05723 7.7275,-1.9948 13.67931,-5.91343 5.95181,-3.91863 10.62995,-9.54813 13.02992,-14.097387 2.39997,-4.54926 4.34384,-10.28218 4.83384,-15.81643 0.49,-5.53425 0.14775,-11.25197 -2.10696,-17.66367 0.15927,9.10203 -2.7414,15.06092 -4.17879,18.80503 -1.43739,3.74411 -4.80196,9.50687 -8.2717,13.57264 -3.46184,4.223207 -7.82036,7.647487 -12.67981,10.383567 -5.38026,3.05578 -13.21504,8.4585 -16.7484,11.61577 4.01135,0.4226 9.12694,-0.10316 12.44259,-0.88609 z"
|
|
||||||
fill-opacity="1"
|
|
||||||
fill-rule="nonzero"
|
|
||||||
id="path182-2-6-6-7-2-2"
|
|
||||||
style="display:inline;fill:#358a0d;fill-opacity:1;stroke:none;stroke-width:0.717458;stroke-opacity:1" />
|
|
||||||
</g>
|
|
||||||
<g
|
|
||||||
id="g40616-9"
|
|
||||||
transform="translate(13.096206,-216.39844)"
|
|
||||||
style="display:inline">
|
|
||||||
<g
|
|
||||||
id="g2-4">
|
|
||||||
<text
|
|
||||||
xml:space="preserve"
|
|
||||||
style="font-size:34.109px;line-height:1.25;font-family:Impact;-inkscape-font-specification:Impact;letter-spacing:0px;word-spacing:0px;display:inline;stroke-width:0.852729"
|
|
||||||
x="451.59149"
|
|
||||||
y="89.758339"
|
|
||||||
id="text156858-3-8"><tspan
|
|
||||||
id="tspan156856-8-82"
|
|
||||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:34.109px;font-family:Poppins;-inkscape-font-specification:'Poppins, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#008da9;fill-opacity:1;stroke-width:0.852729"
|
|
||||||
x="451.59149"
|
|
||||||
y="89.758339">Next Generation</tspan></text>
|
|
||||||
<text
|
|
||||||
xml:space="preserve"
|
|
||||||
style="font-size:33.8136px;line-height:1.25;font-family:Impact;-inkscape-font-specification:Impact;letter-spacing:0px;word-spacing:0px;display:inline;stroke-width:0.845345"
|
|
||||||
x="469.26224"
|
|
||||||
y="119.08144"
|
|
||||||
id="text156858-3-1-4"><tspan
|
|
||||||
id="tspan156856-8-8-5"
|
|
||||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:33.8136px;font-family:Poppins;-inkscape-font-specification:'Poppins, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#008da9;fill-opacity:1;stroke-width:0.845345"
|
|
||||||
x="469.26224"
|
|
||||||
y="119.08144">of Unity</tspan></text>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 8.4 KiB |
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { ArrowRight } from "@phosphor-icons/react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
|
||||||
/* ═══════════════════════════════════════════════════════════════
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
|
|
@ -13,18 +14,7 @@ export default function ArrowLink({ to, label, color, size = "h-9 w-9" }) {
|
||||||
className={`${size} shrink-0 rounded-full flex items-center justify-center transition-transform duration-200 hover:scale-110`}
|
className={`${size} shrink-0 rounded-full flex items-center justify-center transition-transform duration-200 hover:scale-110`}
|
||||||
style={{ border: `1px solid ${color}`, color }}
|
style={{ border: `1px solid ${color}`, color }}
|
||||||
>
|
>
|
||||||
<svg
|
<ArrowRight className="h-4 w-4" weight="bold" aria-hidden="true" />
|
||||||
viewBox="0 0 24 24"
|
|
||||||
className="h-4 w-4"
|
|
||||||
fill="none"
|
|
||||||
stroke="currentColor"
|
|
||||||
strokeWidth="2.5"
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
aria-hidden="true"
|
|
||||||
>
|
|
||||||
<path d="M5 12h14M13 6l6 6-6 6" />
|
|
||||||
</svg>
|
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
|
import { X } from "@phosphor-icons/react";
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { SITE_BANNER } from "../data/bannerConfig.ts";
|
import { SITE_BANNER } from "../data/bannerConfig.ts";
|
||||||
|
|
||||||
export default function Banner() {
|
export default function Banner() {
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const storageKey = `ngu-banner-dismissed:${SITE_BANNER.id}`;
|
const storageKey = `site-banner-dismissed:${SITE_BANNER.id}`;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!SITE_BANNER.enabled) return;
|
if (!SITE_BANNER.enabled) return;
|
||||||
|
|
@ -12,7 +13,7 @@ export default function Banner() {
|
||||||
try {
|
try {
|
||||||
if (!localStorage.getItem(storageKey)) setVisible(true);
|
if (!localStorage.getItem(storageKey)) setVisible(true);
|
||||||
} catch {
|
} catch {
|
||||||
setVisible(true); // storage blocked — show it anyway
|
setVisible(true); // storage blocked, show it anyway
|
||||||
}
|
}
|
||||||
}, [storageKey]);
|
}, [storageKey]);
|
||||||
|
|
||||||
|
|
@ -54,9 +55,7 @@ export default function Banner() {
|
||||||
aria-label="Dismiss announcement"
|
aria-label="Dismiss announcement"
|
||||||
className="absolute right-3 top-1/2 -translate-y-1/2 p-1.5 rounded-md text-white/50 hover:text-white hover:bg-white/10 transition-colors"
|
className="absolute right-3 top-1/2 -translate-y-1/2 p-1.5 rounded-md text-white/50 hover:text-white hover:bg-white/10 transition-colors"
|
||||||
>
|
>
|
||||||
<svg className="w-4 h-4" viewBox="0 0 20 20" fill="currentColor">
|
<X className="w-4 h-4" weight="bold" aria-hidden="true" />
|
||||||
<path d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z" />
|
|
||||||
</svg>
|
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
24
src/components/ComingSoon.tsx
Normal file
24
src/components/ComingSoon.tsx
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
|
COMING SOON
|
||||||
|
|
||||||
|
What a page section shows before it has content, instead of a
|
||||||
|
heading over nothing: that it's being put together, and where to
|
||||||
|
ask in the meantime. Swap it for the real content when there is
|
||||||
|
some.
|
||||||
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
const CONTACT = 'info@nextgenerationofunity.org'
|
||||||
|
|
||||||
|
export default function ComingSoon({ what }: { what: string }) {
|
||||||
|
return (
|
||||||
|
<div className="mx-auto max-w-6xl px-6">
|
||||||
|
<p className="max-w-xl rounded-2xl border border-dashed border-brand/30 bg-surface/60 p-6 text-body">
|
||||||
|
We’re putting {what} together. In the meantime, ask us at{' '}
|
||||||
|
<a href={`mailto:${CONTACT}`} className="font-semibold text-link underline underline-offset-2">
|
||||||
|
{CONTACT}
|
||||||
|
</a>
|
||||||
|
.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -33,17 +33,19 @@
|
||||||
visible even if the renderer hasn't caught up with it.
|
visible even if the renderer hasn't caught up with it.
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
import { blockMedia } from '../lib/media.ts'
|
import { mediaUrl } from '../lib/media.ts'
|
||||||
import type { ContentBlock } from '../lib/useContent.ts'
|
import type { ContentBlock } from '../lib/useContent.ts'
|
||||||
import { Anchor, Inline, Paragraphs } from './InlineText.tsx'
|
import { Anchor, Inline, Paragraphs } from './InlineText.tsx'
|
||||||
import VideoPlayer from './VideoPlayer.tsx'
|
import VideoPlayer from './VideoPlayer.tsx'
|
||||||
import ScheduleBlock from './ScheduleBlock.tsx'
|
import ScheduleBlock from './ScheduleBlock.tsx'
|
||||||
|
import { accentText, BRAND } from '../lib/color.ts'
|
||||||
|
import { headingAnchors } from '../lib/contents.ts'
|
||||||
|
|
||||||
const BODY = '#4a6b72'
|
const BODY = 'var(--color-muted)'
|
||||||
|
|
||||||
export default function ContentBlocks({
|
export default function ContentBlocks({
|
||||||
blocks,
|
blocks,
|
||||||
accent = '#138ba0',
|
accent = BRAND,
|
||||||
className = '',
|
className = '',
|
||||||
}: {
|
}: {
|
||||||
blocks?: ContentBlock[] | null
|
blocks?: ContentBlock[] | null
|
||||||
|
|
@ -51,11 +53,14 @@ export default function ContentBlocks({
|
||||||
className?: string
|
className?: string
|
||||||
}) {
|
}) {
|
||||||
if (!blocks?.length) return null
|
if (!blocks?.length) return null
|
||||||
|
// Headings get ids so a post's contents (PostContents) and a shared
|
||||||
|
// link (#getting-there) can point at them.
|
||||||
|
const { idAt } = headingAnchors(blocks)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`space-y-6 ${className}`}>
|
<div className={`space-y-6 ${className}`}>
|
||||||
{blocks.map((block, index) => (
|
{blocks.map((block, index) => (
|
||||||
<Block key={block.id ?? index} block={block} accent={accent} />
|
<Block key={block.id ?? index} block={block} accent={accent} anchor={idAt.get(index)} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
@ -70,20 +75,23 @@ function Caption({ text }: { text?: string | null }) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Block({ block, accent }: { block: ContentBlock; accent: string }) {
|
// Clear of the fixed header when jumped to.
|
||||||
|
const ANCHOR_MARGIN = { scrollMarginTop: 'calc(var(--header-h, 5rem) + 1rem)' }
|
||||||
|
|
||||||
|
function Block({ block, accent, anchor }: { block: ContentBlock; accent: string; anchor?: string }) {
|
||||||
const text = block.text ?? ''
|
const text = block.text ?? ''
|
||||||
|
|
||||||
switch (block.type) {
|
switch (block.type) {
|
||||||
case 'heading':
|
case 'heading':
|
||||||
return (
|
return (
|
||||||
<h3 className="text-2xl font-bold" style={{ color: accent }}>
|
<h3 id={anchor} className="text-2xl font-bold" style={{ color: accentText(accent), ...ANCHOR_MARGIN }}>
|
||||||
{text}
|
{text}
|
||||||
</h3>
|
</h3>
|
||||||
)
|
)
|
||||||
|
|
||||||
case 'subheading':
|
case 'subheading':
|
||||||
return (
|
return (
|
||||||
<h4 className="text-lg font-semibold" style={{ color: accent }}>
|
<h4 id={anchor} className="text-lg font-semibold" style={{ color: accentText(accent), ...ANCHOR_MARGIN }}>
|
||||||
{text}
|
{text}
|
||||||
</h4>
|
</h4>
|
||||||
)
|
)
|
||||||
|
|
@ -93,12 +101,12 @@ function Block({ block, accent }: { block: ContentBlock; accent: string }) {
|
||||||
<ul className="space-y-2">
|
<ul className="space-y-2">
|
||||||
{(block.items ?? []).map((item, index) => (
|
{(block.items ?? []).map((item, index) => (
|
||||||
<li key={index} className="flex gap-3">
|
<li key={index} className="flex gap-3">
|
||||||
<span aria-hidden="true" style={{ color: accent }}>
|
<span aria-hidden="true" style={{ color: accentText(accent) }}>
|
||||||
•
|
•
|
||||||
</span>
|
</span>
|
||||||
<span style={{ color: BODY }}>
|
<span style={{ color: BODY }}>
|
||||||
{item.url ? (
|
{item.url ? (
|
||||||
<Anchor href={item.url} className="underline" style={{ color: accent }}>
|
<Anchor href={item.url} className="underline" style={{ color: accentText(accent) }}>
|
||||||
{item.text}
|
{item.text}
|
||||||
</Anchor>
|
</Anchor>
|
||||||
) : (
|
) : (
|
||||||
|
|
@ -120,8 +128,8 @@ function Block({ block, accent }: { block: ContentBlock; accent: string }) {
|
||||||
<Anchor
|
<Anchor
|
||||||
key={index}
|
key={index}
|
||||||
href={item.url as string}
|
href={item.url as string}
|
||||||
className="rounded-full border px-4 py-1.5 text-sm font-medium transition-colors hover:bg-[#eef9fb]"
|
className="rounded-full border px-4 py-1.5 text-sm font-medium transition-colors hover:bg-tint"
|
||||||
style={{ borderColor: accent, color: accent }}
|
style={{ borderColor: accent, color: accentText(accent) }}
|
||||||
>
|
>
|
||||||
{item.text}
|
{item.text}
|
||||||
</Anchor>
|
</Anchor>
|
||||||
|
|
@ -150,7 +158,7 @@ function Block({ block, accent }: { block: ContentBlock; accent: string }) {
|
||||||
<Inline text={text} accent={accent} />
|
<Inline text={text} accent={accent} />
|
||||||
</blockquote>
|
</blockquote>
|
||||||
{block.cite && (
|
{block.cite && (
|
||||||
<figcaption className="mt-2 text-sm font-semibold not-italic" style={{ color: accent }}>
|
<figcaption className="mt-2 text-sm font-semibold not-italic" style={{ color: accentText(accent) }}>
|
||||||
{block.cite}
|
{block.cite}
|
||||||
</figcaption>
|
</figcaption>
|
||||||
)}
|
)}
|
||||||
|
|
@ -162,14 +170,14 @@ function Block({ block, accent }: { block: ContentBlock; accent: string }) {
|
||||||
return (
|
return (
|
||||||
<aside
|
<aside
|
||||||
className="space-y-3 rounded-2xl border-l-4 px-6 py-5 leading-relaxed"
|
className="space-y-3 rounded-2xl border-l-4 px-6 py-5 leading-relaxed"
|
||||||
style={{ borderColor: accent, background: `color-mix(in srgb, ${accent} 8%, white)`, color: '#26454c' }}
|
style={{ borderColor: accent, background: `color-mix(in srgb, ${accent} 8%, var(--color-surface))`, color: 'var(--color-body)' }}
|
||||||
>
|
>
|
||||||
<Paragraphs text={text} accent={accent} />
|
<Paragraphs text={text} accent={accent} />
|
||||||
</aside>
|
</aside>
|
||||||
)
|
)
|
||||||
|
|
||||||
case 'image': {
|
case 'image': {
|
||||||
const src = blockMedia(block.media)
|
const src = mediaUrl(block.media)
|
||||||
if (!src) return null
|
if (!src) return null
|
||||||
const img = (
|
const img = (
|
||||||
<img
|
<img
|
||||||
|
|
@ -195,7 +203,7 @@ function Block({ block, accent }: { block: ContentBlock; accent: string }) {
|
||||||
return (
|
return (
|
||||||
<figure>
|
<figure>
|
||||||
<div className="overflow-hidden rounded-lg">
|
<div className="overflow-hidden rounded-lg">
|
||||||
<VideoPlayer url={block.href} still={blockMedia(block.media)} title={text || null} />
|
<VideoPlayer url={block.href} still={mediaUrl(block.media)} title={text || null} />
|
||||||
</div>
|
</div>
|
||||||
<Caption text={text} />
|
<Caption text={text} />
|
||||||
</figure>
|
</figure>
|
||||||
|
|
@ -213,7 +221,7 @@ function Block({ block, accent }: { block: ContentBlock; accent: string }) {
|
||||||
if (!text) return null
|
if (!text) return null
|
||||||
return block.href ? (
|
return block.href ? (
|
||||||
<p className="leading-relaxed" style={{ color: BODY }}>
|
<p className="leading-relaxed" style={{ color: BODY }}>
|
||||||
<Anchor href={block.href} className="underline" style={{ color: accent }}>
|
<Anchor href={block.href} className="underline" style={{ color: accentText(accent) }}>
|
||||||
{text}
|
{text}
|
||||||
</Anchor>
|
</Anchor>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
NGU's dove, lifted from the original home page. The path and its
|
NGU's dove, lifted from the original home page. The path and its
|
||||||
two transforms are the drawing as exported, untouched; only the
|
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
|
and hidden from screen readers since it's decoration wherever
|
||||||
it appears.
|
it appears.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,13 @@
|
||||||
panel instead, since cropping a logo to 16:9 cuts it off.
|
panel instead, since cropping a logo to 16:9 cuts it off.
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
import { useState } from 'react'
|
|
||||||
|
|
||||||
import HomeLink from '../pages/sections/home/HomeLink.tsx'
|
import HomeLink from '../pages/sections/home/HomeLink.tsx'
|
||||||
import VideoPlayer from './VideoPlayer.tsx'
|
import VideoPlayer from './VideoPlayer.tsx'
|
||||||
import { refHref } from '../lib/hrefs.ts'
|
import { refHref } from '../lib/hrefs.ts'
|
||||||
import { logoForKind } from '../lib/media.ts'
|
import { mediaUrl } from '../lib/media.ts'
|
||||||
import type { FeaturedCard } from '../lib/useFrontPage.ts'
|
import type { FeaturedCard } from '../lib/useFrontPage.ts'
|
||||||
|
import { useSmallImage } from '../lib/useSmallImage.ts'
|
||||||
|
|
||||||
/* Image kinds that are photographs, drawn edge to edge. Anything
|
/* Image kinds that are photographs, drawn edge to edge. Anything
|
||||||
else is a logo, drawn whole. */
|
else is a logo, drawn whole. */
|
||||||
|
|
@ -38,37 +38,36 @@ function hrefFor(card: FeaturedCard): string | null {
|
||||||
}
|
}
|
||||||
|
|
||||||
function Picture({ card }: { card: FeaturedCard }) {
|
function Picture({ card }: { card: FeaturedCard }) {
|
||||||
const [failed, setFailed] = useState(false)
|
const img = useSmallImage(card.image ? mediaUrl(card.image.file) : null)
|
||||||
const src = card.image ? logoForKind(card.image.kind, card.image.file) : null
|
|
||||||
const photo = card.image ? PHOTO_KINDS.has(card.image.kind) : false
|
const photo = card.image ? PHOTO_KINDS.has(card.image.kind) : false
|
||||||
|
|
||||||
if (!src || failed) {
|
if (img.failed) {
|
||||||
return <div className="aspect-video w-full bg-gradient-to-br from-[#eef9fb] to-[#d9f0f3]" />
|
return <div className="aspect-video w-full bg-tint" />
|
||||||
}
|
}
|
||||||
|
|
||||||
return photo ? (
|
return photo ? (
|
||||||
<img
|
<img
|
||||||
src={src}
|
src={img.src}
|
||||||
alt=""
|
alt=""
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
onError={() => setFailed(true)}
|
onError={img.onError}
|
||||||
className="aspect-video w-full object-cover"
|
className="aspect-video w-full object-cover"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex aspect-video w-full items-center justify-center bg-[#eef9fb] p-8">
|
<div className="flex aspect-video w-full items-center justify-center bg-tint p-8">
|
||||||
<img
|
<img
|
||||||
src={src}
|
src={img.src}
|
||||||
alt=""
|
alt=""
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
onError={() => setFailed(true)}
|
onError={img.onError}
|
||||||
className="max-h-full max-w-full object-contain"
|
className="logo-plate max-h-full max-w-full object-contain"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function VideoPicture({ card }: { card: FeaturedCard }) {
|
function VideoPicture({ card }: { card: FeaturedCard }) {
|
||||||
const own = card.image ? logoForKind(card.image.kind, card.image.file) : null
|
const own = card.image ? mediaUrl(card.image.file) : null
|
||||||
return <VideoPlayer url={card.url} still={own} title={card.title} />
|
return <VideoPlayer url={card.url} still={own} title={card.title} />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,10 +77,10 @@ function Card({ card }: { card: FeaturedCard }) {
|
||||||
const text = (
|
const text = (
|
||||||
<div className="flex flex-1 flex-col p-6">
|
<div className="flex flex-1 flex-col p-6">
|
||||||
{card.eyebrow && (
|
{card.eyebrow && (
|
||||||
<p className="text-xs font-bold uppercase tracking-[0.2em] text-[#138ba0]">{card.eyebrow}</p>
|
<p className="text-sm font-semibold text-link">{card.eyebrow}</p>
|
||||||
)}
|
)}
|
||||||
{card.title && (
|
{card.title && (
|
||||||
<h3 className="mt-2 font-display text-xl font-extrabold leading-snug text-[#073d4a]">
|
<h3 className="mt-2 font-display text-xl font-extrabold leading-snug text-ink">
|
||||||
{href ? (
|
{href ? (
|
||||||
// Stretched over the whole card, so the picture and the
|
// Stretched over the whole card, so the picture and the
|
||||||
// blurb are part of the click without nesting links.
|
// blurb are part of the click without nesting links.
|
||||||
|
|
@ -96,12 +95,12 @@ function Card({ card }: { card: FeaturedCard }) {
|
||||||
)}
|
)}
|
||||||
</h3>
|
</h3>
|
||||||
)}
|
)}
|
||||||
{card.blurb && <p className="mt-2 leading-relaxed text-[#4a6b72]">{card.blurb}</p>}
|
{card.blurb && <p className="mt-2 leading-relaxed text-muted">{card.blurb}</p>}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li className="relative flex flex-col overflow-hidden rounded-2xl border border-[#138ba0]/15 bg-white shadow-sm transition-shadow hover:shadow-lg">
|
<li className="relative flex flex-col overflow-hidden rounded-2xl border border-brand/15 bg-surface shadow-sm transition-shadow hover:shadow-lg">
|
||||||
{card.kind === 'video' ? (
|
{card.kind === 'video' ? (
|
||||||
// Above the stretched link, which a video card doesn't have
|
// Above the stretched link, which a video card doesn't have
|
||||||
// anyway, so the play button always gets the click.
|
// anyway, so the play button always gets the click.
|
||||||
|
|
@ -118,7 +117,7 @@ function Card({ card }: { card: FeaturedCard }) {
|
||||||
|
|
||||||
export default function FeaturedCards({ cards }: { cards: FeaturedCard[] }) {
|
export default function FeaturedCards({ cards }: { cards: FeaturedCard[] }) {
|
||||||
return (
|
return (
|
||||||
<ul className="grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
|
<ul className="grid gap-6 sm:grid-cols-2 lg:grid-cols-3 lg:[&>li:first-child]:col-span-2">
|
||||||
{cards.map((card, index) => (
|
{cards.map((card, index) => (
|
||||||
<Card key={`${card.kind}-${card.ref?.id ?? card.url}-${index}`} card={card} />
|
<Card key={`${card.kind}-${card.ref?.id ?? card.url}-${index}`} card={card} />
|
||||||
))}
|
))}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { PAGE_LINKS, PAGE_SECTIONS, NAV_ACTIONS } from "../navConfig.ts";
|
import { PAGE_LINKS, PAGE_SECTIONS, NAV_ACTIONS } from "../navConfig.ts";
|
||||||
import nguLogo from "../assets/logos/NGU_Logo.svg";
|
import siteLogo from "../assets/logos/NGU_Logo.svg";
|
||||||
import PlatformIcon from "./PlatformIcon.tsx";
|
import PlatformIcon from "./PlatformIcon.tsx";
|
||||||
|
|
||||||
const Social_Links = [
|
const Social_Links = [
|
||||||
|
|
@ -40,13 +40,13 @@ const Footer_Links = [
|
||||||
];
|
];
|
||||||
|
|
||||||
const footerLinkClass =
|
const footerLinkClass =
|
||||||
"text-white/40 hover:text-[#aac992] text-sm transition-colors";
|
"text-white/65 hover:text-[#aac992] text-sm transition-colors";
|
||||||
|
|
||||||
const pageLinkClass =
|
const pageLinkClass =
|
||||||
"text-white/80 hover:text-[#aac992] text-sm font-semibold transition-colors";
|
"text-white/80 hover:text-[#aac992] text-sm font-semibold transition-colors";
|
||||||
|
|
||||||
const sectionLinkClass =
|
const sectionLinkClass =
|
||||||
"text-white/45 hover:text-[#aac992] text-sm transition-colors";
|
"text-white/65 hover:text-[#aac992] text-sm transition-colors";
|
||||||
|
|
||||||
const headingClass = "text-white/90 text-sm font-semibold mb-4";
|
const headingClass = "text-white/90 text-sm font-semibold mb-4";
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@ export default function Footer() {
|
||||||
width below them. */}
|
width below them. */}
|
||||||
<div className="md:col-span-9 text-center md:text-left">
|
<div className="md:col-span-9 text-center md:text-left">
|
||||||
<Link to="/" className="inline-block">
|
<Link to="/" className="inline-block">
|
||||||
<img src={nguLogo} alt="Next Generation of Unity" className="h-14 w-auto" />
|
<img src={siteLogo} alt="Next Generation of Unity" className="h-14 w-auto" />
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<address className="mt-5 not-italic text-sm leading-relaxed text-white/60">
|
<address className="mt-5 not-italic text-sm leading-relaxed text-white/60">
|
||||||
|
|
@ -67,7 +67,7 @@ export default function Footer() {
|
||||||
<br />
|
<br />
|
||||||
{Organization_Details.cityLine}
|
{Organization_Details.cityLine}
|
||||||
<br />
|
<br />
|
||||||
<span className="text-white/40">({Organization_Details.addressNote})</span>
|
<span className="text-white/65">({Organization_Details.addressNote})</span>
|
||||||
</address>
|
</address>
|
||||||
<p className="mt-3 max-w-xl text-sm leading-relaxed text-white/60">
|
<p className="mt-3 max-w-xl text-sm leading-relaxed text-white/60">
|
||||||
{Organization_Details.nonprofit} Tax ID: {Organization_Details.taxId}.
|
{Organization_Details.nonprofit} Tax ID: {Organization_Details.taxId}.
|
||||||
|
|
@ -111,9 +111,9 @@ export default function Footer() {
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="inline-block mt-8 px-6 py-2.5 rounded-full text-sm font-bold text-white whitespace-nowrap transition-all duration-200 hover:scale-105"
|
className="inline-block mt-8 px-6 py-2.5 rounded-full text-sm font-bold text-white whitespace-nowrap transition-all duration-200 hover:scale-105"
|
||||||
style={{ background: "linear-gradient(135deg, #008fa8, #88b668)" }}
|
style={{ background: "var(--color-action)" }}
|
||||||
>
|
>
|
||||||
Support Us
|
{giveAction.label}
|
||||||
</a>
|
</a>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -161,7 +161,7 @@ export default function Footer() {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="border-t border-white/10 pt-8 flex flex-col md:flex-row items-center justify-between gap-4">
|
<div className="border-t border-white/10 pt-8 flex flex-col md:flex-row items-center justify-between gap-4">
|
||||||
<p className="text-white/40 text-sm">© 2026 Next Generation of Unity. All rights reserved.</p>
|
<p className="text-white/65 text-sm">© 2026 Next Generation of Unity. All rights reserved.</p>
|
||||||
<div className="flex gap-6">
|
<div className="flex gap-6">
|
||||||
{Footer_Links.map((link) => (
|
{Footer_Links.map((link) => (
|
||||||
<Link key={link.label} to={link.to} className={footerLinkClass}>
|
<Link key={link.label} to={link.to} className={footerLinkClass}>
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
import { Fragment, type CSSProperties, type ReactNode } from 'react'
|
import { Fragment, type CSSProperties, type ReactNode } from 'react'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
|
import { accentText } from '../lib/color.ts'
|
||||||
|
|
||||||
const TOKEN = /\*\*(.+?)\*\*|\*(.+?)\*|\[([^\]]+)\]\(([^)\s]+)\)/g
|
const TOKEN = /\*\*(.+?)\*\*|\*(.+?)\*|\[([^\]]+)\]\(([^)\s]+)\)/g
|
||||||
const SAFE_URL = /^(\/(?!\/)|#|https?:\/\/|mailto:|tel:)/i
|
const SAFE_URL = /^(\/(?!\/)|#|https?:\/\/|mailto:|tel:)/i
|
||||||
|
|
@ -39,6 +40,15 @@ export function Anchor({
|
||||||
className?: string
|
className?: string
|
||||||
style?: CSSProperties
|
style?: CSSProperties
|
||||||
}) {
|
}) {
|
||||||
|
// A stored link with some other scheme (javascript:, data:) draws
|
||||||
|
// as plain text rather than a link.
|
||||||
|
if (isExternalUrl(href) && !SAFE_URL.test(href)) {
|
||||||
|
return (
|
||||||
|
<span className={className} style={style}>
|
||||||
|
{children}
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
if (isExternalUrl(href)) {
|
if (isExternalUrl(href)) {
|
||||||
const app = /^(mailto|tel):/i.test(href)
|
const app = /^(mailto|tel):/i.test(href)
|
||||||
return (
|
return (
|
||||||
|
|
@ -79,7 +89,7 @@ function line(text: string, accent: string, key: string): ReactNode[] {
|
||||||
else if (italic != null) out.push(<em key={k}>{italic}</em>)
|
else if (italic != null) out.push(<em key={k}>{italic}</em>)
|
||||||
else if (label != null && SAFE_URL.test(url)) {
|
else if (label != null && SAFE_URL.test(url)) {
|
||||||
out.push(
|
out.push(
|
||||||
<Anchor key={k} href={url} className="underline underline-offset-2" style={{ color: accent }}>
|
<Anchor key={k} href={url} className="underline underline-offset-2" style={{ color: accentText(accent) }}>
|
||||||
{label}
|
{label}
|
||||||
</Anchor>,
|
</Anchor>,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
import { useState, useEffect, useRef } from "react";
|
import { X, List } from "@phosphor-icons/react";
|
||||||
|
import { Suspense, useState, useEffect, useRef } from "react";
|
||||||
import { NavLink, Link, Outlet, useLocation } from "react-router-dom";
|
import { NavLink, Link, Outlet, useLocation } from "react-router-dom";
|
||||||
import { PAGE_LINKS, PAGE_SECTIONS, NAV_ACTIONS } from "../navConfig.ts";
|
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 siteLogo from "../assets/logos/NGU_Logo.svg";
|
||||||
import Footer from "./Footer.tsx";
|
import Footer from "./Footer.tsx";
|
||||||
|
import PrivacyNotice from "./PrivacyNotice.tsx";
|
||||||
|
import ThemeToggle from "./ThemeToggle.tsx";
|
||||||
|
import { scrollBehavior } from "../lib/motion.ts";
|
||||||
|
|
||||||
/* ── Right-side nav actions ──────────────────────────────── */
|
/* ── Right-side nav actions ──────────────────────────────── */
|
||||||
|
|
||||||
|
|
@ -25,7 +29,7 @@ const ACTION_VARIANTS: Record<
|
||||||
},
|
},
|
||||||
fancy: {
|
fancy: {
|
||||||
className: "font-bold text-white hover:scale-105",
|
className: "font-bold text-white hover:scale-105",
|
||||||
style: { background: "linear-gradient(135deg, #008fa8, #88b668)" },
|
style: { background: "var(--color-action)" },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -44,7 +48,7 @@ function NavAction({
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
}) {
|
}) {
|
||||||
const v = ACTION_VARIANTS[item.variant] ?? ACTION_VARIANTS.ghost;
|
const v = ACTION_VARIANTS[item.variant] ?? ACTION_VARIANTS.ghost;
|
||||||
const className = `inline-block whitespace-nowrap rounded-full transition-all duration-200 ${ACTION_SIZES[size]} ${v.className}`;
|
const className = `inline-block whitespace-nowrap rounded-full transition-all duration-200 active:scale-[0.98] ${ACTION_SIZES[size]} ${v.className}`;
|
||||||
|
|
||||||
return item.external ? (
|
return item.external ? (
|
||||||
<a
|
<a
|
||||||
|
|
@ -71,8 +75,13 @@ const navActions = NAV_ACTIONS as NavActionItem[];
|
||||||
export default function Layout() {
|
export default function Layout() {
|
||||||
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
|
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
|
||||||
const [activeSection, setActiveSection] = useState<string | null>(null);
|
const [activeSection, setActiveSection] = useState<string | null>(null);
|
||||||
const [headerHeight, setHeaderHeight] = useState(72);
|
// Measured below; this first guess (nav, plus the section strip on
|
||||||
|
// pages that have one) keeps the content from jumping when it lands.
|
||||||
|
const [headerHeight, setHeaderHeight] = useState(() =>
|
||||||
|
72 + ((PAGE_SECTIONS[window.location.pathname] ?? []).length ? 36 : 0),
|
||||||
|
);
|
||||||
const headerRef = useRef<HTMLElement>(null);
|
const headerRef = useRef<HTMLElement>(null);
|
||||||
|
const closeMenuRef = useRef<HTMLButtonElement>(null);
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
const sections = PAGE_SECTIONS[location.pathname] ?? [];
|
const sections = PAGE_SECTIONS[location.pathname] ?? [];
|
||||||
|
|
@ -84,6 +93,16 @@ export default function Layout() {
|
||||||
setActiveSection(null);
|
setActiveSection(null);
|
||||||
}, [location.pathname]);
|
}, [location.pathname]);
|
||||||
|
|
||||||
|
// The open menu is modal: focus starts on its close button, Escape
|
||||||
|
// shuts it, and everything behind it is inert (below).
|
||||||
|
useEffect(() => {
|
||||||
|
if (!mobileMenuOpen) return;
|
||||||
|
closeMenuRef.current?.focus();
|
||||||
|
const onKey = (e: KeyboardEvent) => e.key === "Escape" && setMobileMenuOpen(false);
|
||||||
|
window.addEventListener("keydown", onKey);
|
||||||
|
return () => window.removeEventListener("keydown", onKey);
|
||||||
|
}, [mobileMenuOpen]);
|
||||||
|
|
||||||
// The header grows and shrinks: the banner can be dismissed and the
|
// The header grows and shrinks: the banner can be dismissed and the
|
||||||
// subnav only exists on some pages. Measure it instead of guessing,
|
// subnav only exists on some pages. Measure it instead of guessing,
|
||||||
// so the spacer below always matches.
|
// so the spacer below always matches.
|
||||||
|
|
@ -104,7 +123,7 @@ export default function Layout() {
|
||||||
if (location.hash) {
|
if (location.hash) {
|
||||||
const el = document.querySelector(location.hash);
|
const el = document.querySelector(location.hash);
|
||||||
if (el) {
|
if (el) {
|
||||||
el.scrollIntoView({ behavior: "smooth" });
|
el.scrollIntoView({ behavior: scrollBehavior() });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -139,18 +158,31 @@ export default function Layout() {
|
||||||
}, [location.pathname, headerHeight]);
|
}, [location.pathname, headerHeight]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen overflow-x-hidden">
|
// overflow-x-clip, not -hidden: hidden makes this div a scroll
|
||||||
|
// container, and then nothing inside it can be position: sticky
|
||||||
|
// (a blog post's contents column scrolled away with the page).
|
||||||
|
<div
|
||||||
|
className="min-h-screen overflow-x-clip"
|
||||||
|
style={{ "--header-h": `${headerHeight}px` } as React.CSSProperties}
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
href="#main"
|
||||||
|
className="sr-only focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-[70] focus:rounded-full focus:bg-surface focus:px-4 focus:py-2 focus:font-semibold focus:text-ink"
|
||||||
|
>
|
||||||
|
Skip to content
|
||||||
|
</a>
|
||||||
|
|
||||||
{/* ── NAV ─────────────────────────────────────────────── */}
|
{/* ── NAV ─────────────────────────────────────────────── */}
|
||||||
<header
|
<header
|
||||||
ref={headerRef}
|
ref={headerRef}
|
||||||
className="fixed top-0 left-0 right-0 z-50 backdrop-blur-md"
|
className="fixed top-0 left-0 right-0 z-50 backdrop-blur-md"
|
||||||
|
inert={mobileMenuOpen}
|
||||||
>
|
>
|
||||||
|
|
||||||
{/* Tier 0 — site-wide announcement */}
|
{/* Tier 0, site-wide announcement */}
|
||||||
<Banner />
|
<Banner />
|
||||||
|
|
||||||
{/* Tier 1 — site navigation */}
|
{/* Tier 1, site navigation */}
|
||||||
<nav
|
<nav
|
||||||
className="flex items-center justify-between px-6 py-4"
|
className="flex items-center justify-between px-6 py-4"
|
||||||
aria-label="Site"
|
aria-label="Site"
|
||||||
|
|
@ -158,10 +190,10 @@ export default function Layout() {
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-8">
|
<div className="flex items-center gap-8">
|
||||||
<Link to="/" aria-label="Next Generation of Unity home" className="inline-block">
|
<Link to="/" aria-label="Next Generation of Unity home" className="inline-block">
|
||||||
<img src={nguLogo} alt="Next Generation of Unity" className="h-10 w-auto" />
|
<img src={siteLogo} alt="Next Generation of Unity" className="h-10 w-auto" />
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<div className="hidden md:flex items-center gap-6">
|
<div className="hidden lg:flex items-center gap-6">
|
||||||
{PAGE_LINKS.map((page) => (
|
{PAGE_LINKS.map((page) => (
|
||||||
<NavLink
|
<NavLink
|
||||||
key={page.path}
|
key={page.path}
|
||||||
|
|
@ -182,26 +214,26 @@ export default function Layout() {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
<div className="hidden md:flex items-center gap-3">
|
<div className="hidden lg:flex items-center gap-3">
|
||||||
{navActions.map((item) => (
|
{navActions.map((item) => (
|
||||||
<NavAction key={item.label} item={item} />
|
<NavAction key={item.label} item={item} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<ThemeToggle className="text-white/80 hover:bg-white/10 hover:text-white" />
|
||||||
|
|
||||||
<button
|
<button
|
||||||
className="md:hidden text-white p-2"
|
className="lg:hidden text-white p-2"
|
||||||
aria-label="Open menu"
|
aria-label="Open menu"
|
||||||
aria-expanded={mobileMenuOpen}
|
aria-expanded={mobileMenuOpen}
|
||||||
onClick={() => setMobileMenuOpen(!mobileMenuOpen)}
|
onClick={() => setMobileMenuOpen(!mobileMenuOpen)}
|
||||||
>
|
>
|
||||||
<div className="w-6 h-0.5 bg-white mb-1.5 transition-all" />
|
<List size={26} weight="bold" aria-hidden="true" />
|
||||||
<div className="w-6 h-0.5 bg-white mb-1.5" />
|
|
||||||
<div className="w-6 h-0.5 bg-white" />
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
{/* Tier 2 — sections of the current page */}
|
{/* Tier 2, sections of the current page */}
|
||||||
{sections.length > 0 && (
|
{sections.length > 0 && (
|
||||||
<nav
|
<nav
|
||||||
className="hidden md:flex items-center px-6 py-2"
|
className="hidden md:flex items-center px-6 py-2"
|
||||||
|
|
@ -211,7 +243,7 @@ export default function Layout() {
|
||||||
borderBottom: "1px solid rgba(45,200,224,0.15)",
|
borderBottom: "1px solid rgba(45,200,224,0.15)",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span className="text-xs text-white/45">{activePage?.label}</span>
|
<span className="text-xs text-white/65">{activePage?.label}</span>
|
||||||
|
|
||||||
{/* Separates the page label from its sections */}
|
{/* Separates the page label from its sections */}
|
||||||
<span
|
<span
|
||||||
|
|
@ -244,25 +276,34 @@ export default function Layout() {
|
||||||
<div aria-hidden style={{ height: headerHeight }} />
|
<div aria-hidden style={{ height: headerHeight }} />
|
||||||
|
|
||||||
{/* Page content */}
|
{/* Page content */}
|
||||||
<main>
|
<main id="main" tabIndex={-1} className="outline-none" inert={mobileMenuOpen}>
|
||||||
<Outlet />
|
<Suspense fallback={null}>
|
||||||
|
<Outlet />
|
||||||
|
</Suspense>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
{/*Site Footer applied to every page*/}
|
{/*Site Footer applied to every page*/}
|
||||||
<Footer />
|
<div inert={mobileMenuOpen}>
|
||||||
|
<Footer />
|
||||||
|
<PrivacyNotice />
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Mobile menu */}
|
{/* Mobile menu */}
|
||||||
{mobileMenuOpen && (
|
{mobileMenuOpen && (
|
||||||
<div
|
<div
|
||||||
className="fixed inset-0 z-40 flex flex-col items-center justify-center overflow-y-auto py-16"
|
className="fixed inset-0 z-[60] flex flex-col items-center justify-center overflow-y-auto py-16"
|
||||||
style={{ background: "rgba(7,61,74,0.97)" }}
|
style={{ background: "rgba(7,61,74,0.97)" }}
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-label="Menu"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
|
ref={closeMenuRef}
|
||||||
className="absolute top-5 right-6 text-white text-3xl"
|
className="absolute top-5 right-6 text-white text-3xl"
|
||||||
aria-label="Close menu"
|
aria-label="Close menu"
|
||||||
onClick={() => setMobileMenuOpen(false)}
|
onClick={() => setMobileMenuOpen(false)}
|
||||||
>
|
>
|
||||||
×
|
<X size={28} weight="bold" aria-hidden="true" />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div className="w-64">
|
<div className="w-64">
|
||||||
|
|
@ -277,7 +318,7 @@ export default function Layout() {
|
||||||
end={page.path === "/"}
|
end={page.path === "/"}
|
||||||
className={({ isActive }) =>
|
className={({ isActive }) =>
|
||||||
`block text-2xl font-bold py-3 transition-colors ${
|
`block text-2xl font-bold py-3 transition-colors ${
|
||||||
isActive ? "text-[#aac992]" : "text-white hover:text-[#10d48a]"
|
isActive ? "text-[#aac992]" : "text-white hover:text-[#9fe7d0]"
|
||||||
}`
|
}`
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|
@ -294,7 +335,7 @@ export default function Layout() {
|
||||||
<a
|
<a
|
||||||
key={section.hash}
|
key={section.hash}
|
||||||
href={section.hash}
|
href={section.hash}
|
||||||
className="text-white/80 text-lg py-2 hover:text-[#10d48a] transition-colors"
|
className="text-white/80 text-lg py-2 hover:text-[#9fe7d0] transition-colors"
|
||||||
onClick={() => setMobileMenuOpen(false)}
|
onClick={() => setMobileMenuOpen(false)}
|
||||||
>
|
>
|
||||||
{section.label}
|
{section.label}
|
||||||
|
|
|
||||||
46
src/components/LegalText.tsx
Normal file
46
src/components/LegalText.tsx
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
|
LEGAL TEXT
|
||||||
|
|
||||||
|
The Privacy and Terms pages: a list of headed parts, each a few
|
||||||
|
paragraphs or a bullet list, in a readable column. The words live
|
||||||
|
in the page files; this only lays them out the same way.
|
||||||
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
import type { ReactNode } from 'react'
|
||||||
|
|
||||||
|
export type LegalPart = {
|
||||||
|
/** Anchor for linking to one part, eg. 'cookies'. */
|
||||||
|
id: string
|
||||||
|
heading: string
|
||||||
|
body: ReactNode[]
|
||||||
|
list?: ReactNode[]
|
||||||
|
/** After the list. */
|
||||||
|
after?: ReactNode[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function LegalText({ parts }: { parts: LegalPart[] }) {
|
||||||
|
return (
|
||||||
|
<div className="mx-auto max-w-3xl space-y-10 px-6 leading-relaxed text-body">
|
||||||
|
{parts.map((part) => (
|
||||||
|
<section key={part.id} id={part.id} style={{ scrollMarginTop: '6rem' }}>
|
||||||
|
<h3 className="text-xl font-bold text-ink">{part.heading}</h3>
|
||||||
|
<div className="mt-3 space-y-3">
|
||||||
|
{part.body.map((paragraph, i) => (
|
||||||
|
<p key={i}>{paragraph}</p>
|
||||||
|
))}
|
||||||
|
{part.list && (
|
||||||
|
<ul className="list-disc space-y-2 pl-6">
|
||||||
|
{part.list.map((item, i) => (
|
||||||
|
<li key={i}>{item}</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
|
{part.after?.map((paragraph, i) => (
|
||||||
|
<p key={i}>{paragraph}</p>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
30
src/components/Logo.tsx
Normal file
30
src/components/Logo.tsx
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
|
LOGO
|
||||||
|
|
||||||
|
An <img> for a logo or mark that may not exist: no src, or a file
|
||||||
|
that 404s, and it draws `fallback` instead (initials, a colour dot,
|
||||||
|
or nothing). `src` is already resolved (mediaUrl in media.ts). An
|
||||||
|
upload loads its 640px copy first (useSmallImage). Decorative by
|
||||||
|
default (alt ""), since a logo sits next to the name it stands for.
|
||||||
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
import type { ReactNode } from 'react'
|
||||||
|
|
||||||
|
import { useSmallImage } from '../lib/useSmallImage.ts'
|
||||||
|
|
||||||
|
export default function Logo({
|
||||||
|
src,
|
||||||
|
alt = '',
|
||||||
|
className,
|
||||||
|
fallback = null,
|
||||||
|
}: {
|
||||||
|
src?: string | null
|
||||||
|
alt?: string
|
||||||
|
className?: string
|
||||||
|
fallback?: ReactNode
|
||||||
|
}) {
|
||||||
|
const img = useSmallImage(src)
|
||||||
|
if (img.failed) return <>{fallback}</>
|
||||||
|
// logo-plate: a light backing in dark mode, for marks drawn for white.
|
||||||
|
return <img src={img.src} alt={alt} loading="lazy" className={`logo-plate ${className ?? ""}`} onError={img.onError} />
|
||||||
|
}
|
||||||
39
src/components/OrgLogo.tsx
Normal file
39
src/components/OrgLogo.tsx
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
|
ORG LOGO
|
||||||
|
|
||||||
|
An organization's logo, or its initials in a square in its colour
|
||||||
|
when there's no file or it fails to load. Decorative: the name is
|
||||||
|
always right beside it. Used by the organization lists and the
|
||||||
|
chapter map.
|
||||||
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
import Logo from './Logo.tsx'
|
||||||
|
import { accentText } from '../lib/color.ts'
|
||||||
|
import { mediaUrl } from '../lib/media.ts'
|
||||||
|
import { initialsFor } from '../lib/organizations.ts'
|
||||||
|
|
||||||
|
export default function OrgLogo({
|
||||||
|
org,
|
||||||
|
color,
|
||||||
|
size = 'h-14 w-14',
|
||||||
|
}: {
|
||||||
|
org: { logo?: string | null; name: string }
|
||||||
|
color: string
|
||||||
|
size?: string
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<Logo
|
||||||
|
src={mediaUrl(org.logo)}
|
||||||
|
className={`${size} object-contain rounded-xl shrink-0`}
|
||||||
|
fallback={
|
||||||
|
<span
|
||||||
|
className={`${size} rounded-xl shrink-0 flex items-center justify-center font-extrabold`}
|
||||||
|
style={{ border: `1px solid ${color}`, color: accentText(color) }}
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
{initialsFor(org.name)}
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -4,10 +4,10 @@
|
||||||
sections with a thin accent banner between them, alternating
|
sections with a thin accent banner between them, alternating
|
||||||
backgrounds, and a left-aligned heading with a blurb and rule.
|
backgrounds, and a left-aligned heading with a blurb and rule.
|
||||||
|
|
||||||
Whatever goes inside a section is passed as `content` — the shell
|
Whatever goes inside a section is passed as `content`, the shell
|
||||||
doesn't care what it is.
|
doesn't care what it is.
|
||||||
|
|
||||||
No <main> and no footer here — Layout provides both, so a page
|
No <main> and no footer here, Layout provides both, so a page
|
||||||
using this shell drops straight into the router's Outlet.
|
using this shell drops straight into the router's Outlet.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
@ -20,8 +20,8 @@
|
||||||
|
|
||||||
title: "Local Chapters",
|
title: "Local Chapters",
|
||||||
blurb: "Optional line under the section heading.",
|
blurb: "Optional line under the section heading.",
|
||||||
accent: "#138ba0", // heading, banner, rule
|
accent: BRAND, // heading, banner, rule
|
||||||
background: "#eef9fb",
|
background: "var(--color-tint)",
|
||||||
actions: <SomeButton />, // optional, right of the heading
|
actions: <SomeButton />, // optional, right of the heading
|
||||||
content: <YourStuff />,
|
content: <YourStuff />,
|
||||||
},
|
},
|
||||||
|
|
@ -32,8 +32,8 @@
|
||||||
import { useEffect, type ReactNode } from "react";
|
import { useEffect, type ReactNode } from "react";
|
||||||
|
|
||||||
import { documentTitle } from "../lib/site.ts";
|
import { documentTitle } from "../lib/site.ts";
|
||||||
|
import { accentText, BRAND } from '../lib/color.ts'
|
||||||
|
|
||||||
const TEAL = "#138ba0";
|
|
||||||
|
|
||||||
export type ShellSection = {
|
export type ShellSection = {
|
||||||
id: string;
|
id: string;
|
||||||
|
|
@ -58,7 +58,7 @@ export function Section({ section }: { section: ShellSection }) {
|
||||||
blurb,
|
blurb,
|
||||||
accent,
|
accent,
|
||||||
background,
|
background,
|
||||||
// Optional action bar for this section's heading row — a view
|
// Optional action bar for this section's heading row, a view
|
||||||
// toggle, a filter, a link. Whatever the section needs; the
|
// toggle, a filter, a link. Whatever the section needs; the
|
||||||
// shell just gives it a place to sit.
|
// shell just gives it a place to sit.
|
||||||
actions,
|
actions,
|
||||||
|
|
@ -69,20 +69,21 @@ export function Section({ section }: { section: ShellSection }) {
|
||||||
<section
|
<section
|
||||||
id={id}
|
id={id}
|
||||||
className="py-20"
|
className="py-20"
|
||||||
style={{ background, scrollMarginTop: "5rem" }}
|
// Clear of the fixed header, whatever it holds today (Layout
|
||||||
|
// sets --header-h from its measured height).
|
||||||
|
style={{ background, scrollMarginTop: "calc(var(--header-h, 5rem) + 1rem)" }}
|
||||||
>
|
>
|
||||||
{/* Heading — left aligned, optional actions on the right */}
|
{/* Heading, left aligned, optional actions on the right */}
|
||||||
<div className="max-w-6xl mx-auto px-6 mb-10">
|
<div className="max-w-6xl mx-auto px-6 mb-10">
|
||||||
<div className="flex flex-wrap items-end justify-between gap-4">
|
<div className="flex flex-wrap items-end justify-between gap-4">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-4xl md:text-5xl font-800" style={{ color: accent }}>
|
<h2 className="text-3xl md:text-4xl font-extrabold" style={{ color: accentText(accent) }}>
|
||||||
{title}
|
{title}
|
||||||
</h2>
|
</h2>
|
||||||
{blurb && <p className="mt-2 text-[#4a6b72] max-w-xl">{blurb}</p>}
|
{blurb && <p className="mt-2 text-muted max-w-xl">{blurb}</p>}
|
||||||
</div>
|
</div>
|
||||||
{actions}
|
{actions}
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-6 h-px w-full" style={{ background: accent, opacity: 0.35 }} />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{content}
|
{content}
|
||||||
|
|
@ -101,12 +102,12 @@ export default function PageShell({ title, intro, sections }: PageShellProps) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* Page header */}
|
{/* Page header */}
|
||||||
<div className="pt-24 pb-12 px-6" style={{ background: "#eef9fb" }}>
|
<div className="pt-24 pb-12 px-6" style={{ background: "var(--color-tint)" }}>
|
||||||
<div className="max-w-6xl mx-auto">
|
<div className="max-w-6xl mx-auto">
|
||||||
<h1 className="text-5xl md:text-6xl font-800" style={{ color: TEAL }}>
|
<h1 className="text-5xl md:text-6xl font-extrabold" style={{ color: accentText(BRAND) }}>
|
||||||
{title}
|
{title}
|
||||||
</h1>
|
</h1>
|
||||||
{intro && <p className="mt-3 text-lg text-[#4a6b72] max-w-2xl">{intro}</p>}
|
{intro && <p className="mt-3 text-lg text-muted max-w-2xl">{intro}</p>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
PAGE STATE
|
PAGE STATE
|
||||||
|
|
||||||
The three ways a detail page can fail to be a detail page. All
|
The three ways a detail page can fail to be a detail page. All
|
||||||
four of them need the same thing, and it should be the same thing
|
four of them need the same thing, and it should be the same thing:
|
||||||
— a visitor who hits a dead retreat link and a dead chapter link
|
a visitor who hits a dead retreat link and a dead chapter link
|
||||||
shouldn't get two different pages.
|
shouldn't get two different pages.
|
||||||
|
|
||||||
Rendered inside PageShell so the chrome doesn't flicker in and
|
Rendered inside PageShell so the chrome doesn't flicker in and
|
||||||
|
|
@ -16,9 +16,9 @@
|
||||||
|
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
import PageShell from './PageShell.tsx'
|
import PageShell from './PageShell.tsx'
|
||||||
|
import { accentText, BRAND } from '../lib/color.ts'
|
||||||
|
|
||||||
const TEAL = '#138ba0'
|
const BODY = 'var(--color-muted)'
|
||||||
const BODY = '#4a6b72'
|
|
||||||
|
|
||||||
export default function PageState({
|
export default function PageState({
|
||||||
loading,
|
loading,
|
||||||
|
|
@ -51,8 +51,8 @@ export default function PageState({
|
||||||
</p>
|
</p>
|
||||||
<Link
|
<Link
|
||||||
to={backTo}
|
to={backTo}
|
||||||
className="mt-4 inline-block rounded-full border px-4 py-1.5 text-sm font-medium transition-colors hover:bg-[#eef9fb]"
|
className="mt-4 inline-block rounded-full border px-4 py-1.5 text-sm font-medium transition-colors hover:bg-tint"
|
||||||
style={{ borderColor: TEAL, color: TEAL }}
|
style={{ borderColor: BRAND, color: accentText(BRAND) }}
|
||||||
>
|
>
|
||||||
{backLabel}
|
{backLabel}
|
||||||
</Link>
|
</Link>
|
||||||
|
|
@ -62,12 +62,12 @@ export default function PageState({
|
||||||
title = 'Something went wrong'
|
title = 'Something went wrong'
|
||||||
content = (
|
content = (
|
||||||
<div className="max-w-6xl mx-auto px-6">
|
<div className="max-w-6xl mx-auto px-6">
|
||||||
<p style={{ color: '#b3261e' }}>Couldn’t load this {noun}. {error}</p>
|
<p className="text-danger">Couldn’t load this {noun}. {error}</p>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={onRetry}
|
onClick={onRetry}
|
||||||
className="mt-3 rounded-full border px-4 py-1.5 text-sm font-medium transition-colors hover:bg-[#eef9fb]"
|
className="mt-3 rounded-full border px-4 py-1.5 text-sm font-medium transition-colors hover:bg-tint"
|
||||||
style={{ borderColor: TEAL, color: TEAL }}
|
style={{ borderColor: BRAND, color: accentText(BRAND) }}
|
||||||
>
|
>
|
||||||
Try again
|
Try again
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -76,16 +76,22 @@ export default function PageState({
|
||||||
} else {
|
} else {
|
||||||
title = 'Loading…'
|
title = 'Loading…'
|
||||||
content = (
|
content = (
|
||||||
<p className="max-w-6xl mx-auto px-6" style={{ color: BODY }} role="status">
|
<div className="max-w-6xl mx-auto px-6" role="status">
|
||||||
Loading this {noun}…
|
<span className="sr-only">Loading this {noun}…</span>
|
||||||
</p>
|
<div aria-hidden="true" className="space-y-4">
|
||||||
|
<div className="skeleton !min-h-0 h-8 w-2/3 !rounded-xl" />
|
||||||
|
<div className="skeleton !min-h-0 h-4 w-full !rounded-lg" />
|
||||||
|
<div className="skeleton !min-h-0 h-4 w-5/6 !rounded-lg" />
|
||||||
|
<div className="skeleton !min-h-0 mt-8 aspect-video w-full max-w-3xl" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageShell
|
<PageShell
|
||||||
title={title}
|
title={title}
|
||||||
sections={[{ id: 'status', title: '', accent: TEAL, background: '#ffffff', content }]}
|
sections={[{ id: 'status', title: '', accent: BRAND, background: 'var(--color-surface)', content }]}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/* PeopleTiles — polaroid-style people list.
|
/* PeopleTiles, polaroid-style people list.
|
||||||
Everything is scoped under .pl and driven by custom properties, so a section
|
Everything is scoped under .pl and driven by custom properties, so a section
|
||||||
can retune it inline: <PeopleTiles style={{ "--pl-base-w": "150px" }} /> */
|
can retune it inline: <PeopleTiles style={{ "--pl-base-w": "150px" }} /> */
|
||||||
|
|
||||||
|
|
@ -13,12 +13,12 @@
|
||||||
--pl-radius: 3px;
|
--pl-radius: 3px;
|
||||||
|
|
||||||
/* color */
|
/* color */
|
||||||
--pl-accent: #138ba0;
|
--pl-accent: #0f7183;
|
||||||
--pl-frame-bg: #fff;
|
--pl-frame-bg: var(--color-surface);
|
||||||
--pl-frame-edge: rgba(15, 23, 42, 0.1);
|
--pl-frame-edge: color-mix(in srgb, var(--color-muted) 20%, transparent);
|
||||||
--pl-photo-bg: #e7edef;
|
--pl-photo-bg: color-mix(in srgb, var(--color-muted) 15%, var(--color-surface));
|
||||||
--pl-ink: #16262b;
|
--pl-ink: var(--color-ink);
|
||||||
--pl-muted: #4a6b72;
|
--pl-muted: var(--color-muted);
|
||||||
--pl-rule: rgba(45, 200, 224, 0.3);
|
--pl-rule: rgba(45, 200, 224, 0.3);
|
||||||
--pl-shadow: 0 1px 1px rgba(15, 23, 42, 0.06), 0 10px 18px -14px rgba(15, 23, 42, 0.5);
|
--pl-shadow: 0 1px 1px rgba(15, 23, 42, 0.06), 0 10px 18px -14px rgba(15, 23, 42, 0.5);
|
||||||
|
|
||||||
|
|
@ -249,7 +249,7 @@
|
||||||
padding: 1rem 1.1rem;
|
padding: 1rem 1.1rem;
|
||||||
border-left: 3px solid var(--pl-accent);
|
border-left: 3px solid var(--pl-accent);
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
background: color-mix(in srgb, var(--pl-accent) 7%, #fff);
|
background: color-mix(in srgb, var(--pl-accent) 7%, var(--color-surface));
|
||||||
max-width: 68ch;
|
max-width: 68ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -278,7 +278,7 @@
|
||||||
height: 1.75rem;
|
height: 1.75rem;
|
||||||
border: 1px solid var(--pl-frame-edge);
|
border: 1px solid var(--pl-frame-edge);
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
background: #fff;
|
background: var(--color-surface);
|
||||||
color: var(--pl-muted);
|
color: var(--pl-muted);
|
||||||
font-size: 1.1rem;
|
font-size: 1.1rem;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
|
|
@ -309,7 +309,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.pl__fact a {
|
.pl__fact a {
|
||||||
color: var(--pl-accent);
|
color: color-mix(in srgb, var(--pl-accent) var(--accent-text-mix), #fff);
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
text-underline-offset: 2px;
|
text-underline-offset: 2px;
|
||||||
}
|
}
|
||||||
|
|
@ -326,7 +326,7 @@
|
||||||
margin-top: 0.75rem;
|
margin-top: 0.75rem;
|
||||||
font-size: 0.9375rem;
|
font-size: 0.9375rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: var(--pl-accent);
|
color: color-mix(in srgb, var(--pl-accent) var(--accent-text-mix), #fff);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { ArrowRight, CaretDown, X } from "@phosphor-icons/react";
|
||||||
import {
|
import {
|
||||||
useEffect,
|
useEffect,
|
||||||
useId,
|
useId,
|
||||||
|
|
@ -12,10 +13,12 @@ import { Link } from "react-router-dom";
|
||||||
|
|
||||||
import { get } from "../lib/api.ts";
|
import { get } from "../lib/api.ts";
|
||||||
import { isBadId, personHref } from "../lib/hrefs.ts";
|
import { isBadId, personHref } from "../lib/hrefs.ts";
|
||||||
|
import { mediaUrl, initials } from "../lib/media.ts";
|
||||||
|
import { useSmallImage } from "../lib/useSmallImage.ts";
|
||||||
import "./PeopleTiles.css";
|
import "./PeopleTiles.css";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PeopleTiles — a horizontal, polaroid-style people list.
|
* PeopleTiles, a horizontal, polaroid-style people list.
|
||||||
*
|
*
|
||||||
* Supply data any of four ways:
|
* Supply data any of four ways:
|
||||||
*
|
*
|
||||||
|
|
@ -32,7 +35,7 @@ import "./PeopleTiles.css";
|
||||||
* is_owner flag.
|
* is_owner flag.
|
||||||
*
|
*
|
||||||
* With `peopleslug`, the person is fetched by id and any other key
|
* With `peopleslug`, the person is fetched by id and any other key
|
||||||
* on the entry overrides what came back — so a title can be given
|
* on the entry overrides what came back, so a title can be given
|
||||||
* per placement, and is blank when it isn't. A slug entry can sit
|
* per placement, and is blank when it isn't. A slug entry can sit
|
||||||
* beside a fully-written person in the same array.
|
* beside a fully-written person in the same array.
|
||||||
*
|
*
|
||||||
|
|
@ -41,7 +44,7 @@ import "./PeopleTiles.css";
|
||||||
* md photo + name + title
|
* md photo + name + title
|
||||||
* lg photo + name + title, and a chevron on anyone who has
|
* lg photo + name + title, and a chevron on anyone who has
|
||||||
* something to expand: pronouns, home organization, location,
|
* something to expand: pronouns, home organization, location,
|
||||||
* public email or a bio. Not bio alone — the details panel is
|
* public email or a bio. Not bio alone, the details panel is
|
||||||
* worth opening before anyone has written prose.
|
* worth opening before anyone has written prose.
|
||||||
*
|
*
|
||||||
* Field names follow the API (is_owner, location_label), so a row
|
* Field names follow the API (is_owner, location_label), so a row
|
||||||
|
|
@ -50,8 +53,8 @@ import "./PeopleTiles.css";
|
||||||
* Profiles
|
* Profiles
|
||||||
* A person with a string id is taken to be a people row and links
|
* A person with a string id is taken to be a people row and links
|
||||||
* to /people/:id. A tile with nothing to expand is that link; an
|
* to /people/:id. A tile with nothing to expand is that link; an
|
||||||
* expandable one stays the button that opens its panel — a link
|
* expandable one stays the button that opens its panel, a link
|
||||||
* can't sit inside a button — and the panel carries the link
|
* can't sit inside a button, and the panel carries the link
|
||||||
* instead. A hand-written entry with no id links nowhere.
|
* instead. A hand-written entry with no id links nowhere.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -135,7 +138,7 @@ const SIZE_FEATURES: Record<PeopleTilesSize, { title: boolean; details: boolean
|
||||||
|
|
||||||
/* ── Data ──────────────────────────────────────────────────────
|
/* ── Data ──────────────────────────────────────────────────────
|
||||||
Fetching lives here rather than in every section, but the view
|
Fetching lives here rather than in every section, but the view
|
||||||
below stays pure — it only ever sees resolved groups, whatever
|
below stays pure, it only ever sees resolved groups, whatever
|
||||||
produced them.
|
produced them.
|
||||||
───────────────────────────────────────────────────────────── */
|
───────────────────────────────────────────────────────────── */
|
||||||
|
|
||||||
|
|
@ -289,7 +292,7 @@ function collectSlugs(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The fetched record is the base; anything else on the entry wins,
|
/* The fetched record is the base; anything else on the entry wins,
|
||||||
including an explicit null — that's how a title is deliberately
|
including an explicit null, that's how a title is deliberately
|
||||||
left blank rather than inherited. */
|
left blank rather than inherited. */
|
||||||
function resolveAll(
|
function resolveAll(
|
||||||
list: PersonInput[],
|
list: PersonInput[],
|
||||||
|
|
@ -547,7 +550,7 @@ function Tile({
|
||||||
const content = (
|
const content = (
|
||||||
<span className="pl__frame">
|
<span className="pl__frame">
|
||||||
<span className="pl__photo">
|
<span className="pl__photo">
|
||||||
<Photo src={photoSrc(person.photo)} name={person.name} />
|
<Photo src={mediaUrl(person.photo)} name={person.name} />
|
||||||
</span>
|
</span>
|
||||||
<span className="pl__caption">
|
<span className="pl__caption">
|
||||||
<span className="pl__name">{person.name}</span>
|
<span className="pl__name">{person.name}</span>
|
||||||
|
|
@ -587,13 +590,9 @@ function Tile({
|
||||||
}
|
}
|
||||||
|
|
||||||
function Photo({ src, name }: { src?: string | null; name: string }) {
|
function Photo({ src, name }: { src?: string | null; name: string }) {
|
||||||
const [failed, setFailed] = useState(false);
|
const img = useSmallImage(src);
|
||||||
|
|
||||||
useEffect(() => {
|
if (img.failed) {
|
||||||
setFailed(false);
|
|
||||||
}, [src]);
|
|
||||||
|
|
||||||
if (!src || failed) {
|
|
||||||
return (
|
return (
|
||||||
<span className="pl__initials" aria-hidden="true">
|
<span className="pl__initials" aria-hidden="true">
|
||||||
{initials(name)}
|
{initials(name)}
|
||||||
|
|
@ -604,11 +603,11 @@ function Photo({ src, name }: { src?: string | null; name: string }) {
|
||||||
return (
|
return (
|
||||||
<img
|
<img
|
||||||
className="pl__img"
|
className="pl__img"
|
||||||
src={src}
|
src={img.src}
|
||||||
alt=""
|
alt=""
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
decoding="async"
|
decoding="async"
|
||||||
onError={() => setFailed(true)}
|
onError={img.onError}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -645,7 +644,7 @@ function DetailPanel({
|
||||||
</div>
|
</div>
|
||||||
<button type="button" className="pl__close" onClick={onClose}>
|
<button type="button" className="pl__close" onClick={onClose}>
|
||||||
<span className="pl__sr">Close details</span>
|
<span className="pl__sr">Close details</span>
|
||||||
<span aria-hidden="true">×</span>
|
<X size={18} weight="bold" aria-hidden="true" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -694,7 +693,7 @@ function DetailPanel({
|
||||||
|
|
||||||
{profile && (
|
{profile && (
|
||||||
<Link to={profile} className="pl__profile">
|
<Link to={profile} className="pl__profile">
|
||||||
View full profile →
|
View full profile <ArrowRight size="1em" weight="bold" className="inline align-[-0.125em]" aria-hidden="true" />
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -703,16 +702,7 @@ function DetailPanel({
|
||||||
|
|
||||||
function Chevron() {
|
function Chevron() {
|
||||||
return (
|
return (
|
||||||
<svg viewBox="0 0 16 16" width="12" height="12" focusable="false">
|
<CaretDown size={12} weight="bold" aria-hidden="true" />
|
||||||
<path
|
|
||||||
d="M4 6.5 8 10.5 12 6.5"
|
|
||||||
fill="none"
|
|
||||||
stroke="currentColor"
|
|
||||||
strokeWidth="2"
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -740,7 +730,7 @@ function findByKey(groups: PeopleGroup[], key: string | null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The seat they hold here, or what they're called when there is no
|
/* The seat they hold here, or what they're called when there is no
|
||||||
seat — the same fallback content.js applies to leadership rows. */
|
seat, the same fallback content.js applies to leadership rows. */
|
||||||
function titleOf(person: Person): string | null {
|
function titleOf(person: Person): string | null {
|
||||||
return person.title || person.tagline || null;
|
return person.title || person.tagline || null;
|
||||||
}
|
}
|
||||||
|
|
@ -760,23 +750,7 @@ function hasDetails(person: Person): boolean {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Database rows carry a bare filename; a hand-written entry may
|
|
||||||
give a path or a full URL. Both should work. */
|
|
||||||
function photoSrc(photo?: string | null): string | null {
|
|
||||||
if (!photo) return null;
|
|
||||||
if (/^(https?:|\/|data:)/.test(photo)) return photo;
|
|
||||||
return `/people/${photo}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function initials(name = ""): string {
|
|
||||||
return name
|
|
||||||
.trim()
|
|
||||||
.split(/\s+/)
|
|
||||||
.slice(0, 2)
|
|
||||||
.map((word) => word[0] || "")
|
|
||||||
.join("")
|
|
||||||
.toUpperCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
function resolveOrg(org: Person["org"]) {
|
function resolveOrg(org: Person["org"]) {
|
||||||
if (!org) return null;
|
if (!org) return null;
|
||||||
|
|
|
||||||
93
src/components/PostContents.tsx
Normal file
93
src/components/PostContents.tsx
Normal file
|
|
@ -0,0 +1,93 @@
|
||||||
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
|
POST CONTENTS
|
||||||
|
|
||||||
|
A post's table of contents, from its headings (lib/contents.ts).
|
||||||
|
On a wide screen it's a sticky column beside the post, the
|
||||||
|
heading you're reading lit; below lg it's a fold-out at the top.
|
||||||
|
Which heading is lit comes from an IntersectionObserver, not a
|
||||||
|
scroll listener: the last heading to cross the band just under
|
||||||
|
the fixed header.
|
||||||
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
|
import type { ContentsEntry } from '../lib/contents.ts'
|
||||||
|
import { scrollBehavior } from '../lib/motion.ts'
|
||||||
|
|
||||||
|
function useLit(entries: ContentsEntry[]) {
|
||||||
|
const [lit, setLit] = useState<string | null>(entries[0]?.id ?? null)
|
||||||
|
const ids = entries.map((entry) => entry.id).join('|')
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const els = ids
|
||||||
|
.split('|')
|
||||||
|
.map((id) => document.getElementById(id))
|
||||||
|
.filter((el): el is HTMLElement => Boolean(el))
|
||||||
|
if (els.length === 0) return
|
||||||
|
// The band: from just under the header to 60% up the screen.
|
||||||
|
const header = parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--header-h')) || 80
|
||||||
|
const observer = new IntersectionObserver(
|
||||||
|
(records) => {
|
||||||
|
const crossing = records.filter((r) => r.isIntersecting).map((r) => r.target.id)
|
||||||
|
if (crossing.length) setLit(crossing[0])
|
||||||
|
},
|
||||||
|
{ rootMargin: `-${header + 16}px 0px -60% 0px` },
|
||||||
|
)
|
||||||
|
els.forEach((el) => observer.observe(el))
|
||||||
|
return () => observer.disconnect()
|
||||||
|
}, [ids])
|
||||||
|
|
||||||
|
return lit
|
||||||
|
}
|
||||||
|
|
||||||
|
function jump(event: React.MouseEvent<HTMLAnchorElement>, id: string) {
|
||||||
|
event.preventDefault()
|
||||||
|
document.getElementById(id)?.scrollIntoView({ behavior: scrollBehavior(), block: 'start' })
|
||||||
|
history.replaceState(null, '', `#${id}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
function List({ entries, lit }: { entries: ContentsEntry[]; lit: string | null }) {
|
||||||
|
return (
|
||||||
|
<ol className="space-y-1 text-sm">
|
||||||
|
{entries.map((entry) => (
|
||||||
|
<li key={entry.id} className={entry.level === 2 ? 'pl-4' : ''}>
|
||||||
|
<a
|
||||||
|
href={`#${entry.id}`}
|
||||||
|
onClick={(event) => jump(event, entry.id)}
|
||||||
|
aria-current={entry.id === lit ? 'location' : undefined}
|
||||||
|
className={
|
||||||
|
'block rounded-lg border-l-2 px-3 py-1.5 transition-colors ' +
|
||||||
|
(entry.id === lit
|
||||||
|
? 'border-link bg-tint font-semibold text-link'
|
||||||
|
: 'border-transparent text-muted hover:text-link')
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{entry.text}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ol>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function PostContents({ entries }: { entries: ContentsEntry[] }) {
|
||||||
|
const lit = useLit(entries)
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<details className="rounded-2xl border border-brand/20 bg-tint-soft p-4 lg:hidden">
|
||||||
|
<summary className="cursor-pointer font-semibold text-ink">On this page</summary>
|
||||||
|
<div className="mt-3">
|
||||||
|
<List entries={entries} lit={lit} />
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
<nav
|
||||||
|
aria-label="On this page"
|
||||||
|
className="sticky hidden self-start lg:block"
|
||||||
|
style={{ top: 'calc(var(--header-h, 5rem) + 1.5rem)' }}
|
||||||
|
>
|
||||||
|
<p className="mb-2 px-3 text-sm font-semibold text-ink">On this page</p>
|
||||||
|
<List entries={entries} lit={lit} />
|
||||||
|
</nav>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
63
src/components/PrivacyNotice.tsx
Normal file
63
src/components/PrivacyNotice.tsx
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
|
PRIVACY NOTICE
|
||||||
|
|
||||||
|
A small note on a first visit, until closed: the site sets no
|
||||||
|
tracking cookies, and videos and maps from other companies wait
|
||||||
|
for a click (VideoPlayer, HeroStage, ScheduleBlock). Because
|
||||||
|
nothing loads before that, a notice is enough, rather than a
|
||||||
|
consent banner that blocks the page. If an embed ever loads on
|
||||||
|
its own, or analytics are added, this has to become a real
|
||||||
|
consent choice.
|
||||||
|
|
||||||
|
Closed is remembered in this browser; blocked storage just
|
||||||
|
means it shows again next time.
|
||||||
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
import { Link } from 'react-router-dom'
|
||||||
|
|
||||||
|
const STORAGE_KEY = 'site-privacy-notice-closed'
|
||||||
|
|
||||||
|
export default function PrivacyNotice() {
|
||||||
|
const [visible, setVisible] = useState(false)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
try {
|
||||||
|
if (!localStorage.getItem(STORAGE_KEY)) setVisible(true)
|
||||||
|
} catch {
|
||||||
|
setVisible(true)
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const close = () => {
|
||||||
|
setVisible(false)
|
||||||
|
try {
|
||||||
|
localStorage.setItem(STORAGE_KEY, '1')
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!visible) return null
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
role="region"
|
||||||
|
aria-label="Privacy notice"
|
||||||
|
className="fixed bottom-4 left-4 right-4 z-40 mx-auto max-w-md rounded-2xl border border-brand/20 bg-surface p-4 text-sm text-body shadow-xl sm:right-auto"
|
||||||
|
>
|
||||||
|
<p>
|
||||||
|
No tracking cookies here. Videos and maps come from YouTube, Facebook or Google only when you press
|
||||||
|
play or show them, and those services may set their own cookies then.{' '}
|
||||||
|
<Link to="/privacy#cookies" className="font-semibold text-link underline underline-offset-2">
|
||||||
|
Privacy Policy
|
||||||
|
</Link>
|
||||||
|
</p>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={close}
|
||||||
|
className="mt-3 rounded-full bg-action px-4 py-1.5 font-semibold text-white hover:bg-action-hover"
|
||||||
|
>
|
||||||
|
Got it
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -24,11 +24,13 @@ import { useId, useState, type KeyboardEvent } from 'react'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
|
|
||||||
import { personHref } from '../lib/hrefs.ts'
|
import { personHref } from '../lib/hrefs.ts'
|
||||||
import { blockMedia, initials, personPhoto } from '../lib/media.ts'
|
import { mediaUrl, initials } from '../lib/media.ts'
|
||||||
import type { ContentBlockItem } from '../lib/useContent.ts'
|
import type { ContentBlockItem } from '../lib/useContent.ts'
|
||||||
import { Anchor, Paragraphs } from './InlineText.tsx'
|
import { Anchor, Paragraphs } from './InlineText.tsx'
|
||||||
|
import { withAlpha, accentText, readableOn } from '../lib/color.ts'
|
||||||
|
import { useSmallImage } from '../lib/useSmallImage.ts'
|
||||||
|
|
||||||
const BODY = '#4a6b72'
|
const BODY = 'var(--color-muted)'
|
||||||
const WEEKDAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
|
const WEEKDAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
|
||||||
|
|
||||||
type Day = { name: string; entries: ContentBlockItem[] }
|
type Day = { name: string; entries: ContentBlockItem[] }
|
||||||
|
|
@ -64,14 +66,13 @@ const mapLink = (place: string) =>
|
||||||
`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(place)}`
|
`https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(place)}`
|
||||||
|
|
||||||
function Avatar({ person, size }: { person: NonNullable<ContentBlockItem['person']>; size: string }) {
|
function Avatar({ person, size }: { person: NonNullable<ContentBlockItem['person']>; size: string }) {
|
||||||
const [failed, setFailed] = useState(false)
|
const img = useSmallImage(mediaUrl(person.photo))
|
||||||
const src = personPhoto(person.photo)
|
return !img.failed ? (
|
||||||
return src && !failed ? (
|
<img src={img.src} alt="" onError={img.onError} className={`${size} shrink-0 rounded-full object-cover`} />
|
||||||
<img src={src} alt="" onError={() => setFailed(true)} className={`${size} shrink-0 rounded-full object-cover`} />
|
|
||||||
) : (
|
) : (
|
||||||
<span
|
<span
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
className={`${size} flex shrink-0 items-center justify-center rounded-full bg-[#eef9fb] text-xs font-bold text-[#138ba0]`}
|
className={`${size} flex shrink-0 items-center justify-center rounded-full bg-tint text-xs font-bold text-link`}
|
||||||
>
|
>
|
||||||
{initials(person.name)}
|
{initials(person.name)}
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -80,13 +81,15 @@ function Avatar({ person, size }: { person: NonNullable<ContentBlockItem['person
|
||||||
|
|
||||||
function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
|
function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
|
// Google's map loads only when asked for (Privacy page).
|
||||||
|
const [showMap, setShowMap] = useState(false)
|
||||||
const panelId = useId()
|
const panelId = useId()
|
||||||
const graphic = blockMedia(entry.media)
|
const graphic = mediaUrl(entry.media)
|
||||||
const place = entry.map?.trim()
|
const place = entry.map?.trim()
|
||||||
const more = Boolean(entry.description || graphic || place || entry.person)
|
const more = Boolean(entry.description || graphic || place || entry.person)
|
||||||
|
|
||||||
const title = entry.url ? (
|
const title = entry.url ? (
|
||||||
<Anchor href={entry.url} className="underline-offset-2 hover:underline" style={{ color: accent }}>
|
<Anchor href={entry.url} className="underline-offset-2 hover:underline" style={{ color: accentText(accent) }}>
|
||||||
{entry.text}
|
{entry.text}
|
||||||
</Anchor>
|
</Anchor>
|
||||||
) : (
|
) : (
|
||||||
|
|
@ -94,14 +97,14 @@ function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li className="border-b border-[#138ba0]/10 last:border-b-0">
|
<li className="border-b border-brand/10 last:border-b-0">
|
||||||
<div className="flex gap-4 py-4 sm:gap-6">
|
<div className="flex gap-4 py-4 sm:gap-6">
|
||||||
<p className="w-24 shrink-0 pt-0.5 text-sm font-semibold sm:w-32" style={{ color: accent }}>
|
<p className="w-24 shrink-0 pt-0.5 text-sm font-semibold sm:w-32" style={{ color: accentText(accent) }}>
|
||||||
{entry.time}
|
{entry.time}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
<p className="font-semibold text-[#26454c]">{title}</p>
|
<p className="font-semibold text-body">{title}</p>
|
||||||
{(entry.location || entry.person) && (
|
{(entry.location || entry.person) && (
|
||||||
<p className="mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-sm" style={{ color: BODY }}>
|
<p className="mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-sm" style={{ color: BODY }}>
|
||||||
{entry.location && <span>{entry.location}</span>}
|
{entry.location && <span>{entry.location}</span>}
|
||||||
|
|
@ -127,8 +130,8 @@ function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
|
||||||
aria-expanded={open}
|
aria-expanded={open}
|
||||||
aria-controls={panelId}
|
aria-controls={panelId}
|
||||||
aria-label={open ? `Less about ${entry.text}` : `More about ${entry.text}`}
|
aria-label={open ? `Less about ${entry.text}` : `More about ${entry.text}`}
|
||||||
className="h-8 w-8 shrink-0 rounded-full border text-sm transition-colors hover:bg-[#eef9fb]"
|
className="h-8 w-8 shrink-0 rounded-full border text-sm transition-colors hover:bg-tint"
|
||||||
style={{ borderColor: `${accent}55`, color: accent }}
|
style={{ borderColor: `${withAlpha(accent, 33)}`, color: accentText(accent) }}
|
||||||
>
|
>
|
||||||
<span aria-hidden="true" className={`inline-block transition-transform ${open ? 'rotate-180' : ''}`}>
|
<span aria-hidden="true" className={`inline-block transition-transform ${open ? 'rotate-180' : ''}`}>
|
||||||
▾
|
▾
|
||||||
|
|
@ -138,7 +141,7 @@ function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{more && open && (
|
{more && open && (
|
||||||
<div id={panelId} className="mb-5 space-y-5 rounded-2xl bg-[#f6fbfc] p-5 sm:ml-38">
|
<div id={panelId} className="mb-5 space-y-5 rounded-2xl bg-tint-soft p-5 sm:ml-38">
|
||||||
{entry.person && (
|
{entry.person && (
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
<Avatar person={entry.person} size="h-16 w-16" />
|
<Avatar person={entry.person} size="h-16 w-16" />
|
||||||
|
|
@ -146,7 +149,7 @@ function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
|
||||||
<Link
|
<Link
|
||||||
to={personHref(entry.person.id)}
|
to={personHref(entry.person.id)}
|
||||||
className="font-semibold hover:underline"
|
className="font-semibold hover:underline"
|
||||||
style={{ color: accent }}
|
style={{ color: accentText(accent) }}
|
||||||
>
|
>
|
||||||
{entry.person.name}
|
{entry.person.name}
|
||||||
</Link>
|
</Link>
|
||||||
|
|
@ -165,23 +168,35 @@ function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{graphic && <img src={graphic} alt="" loading="lazy" className="w-full rounded-lg" />}
|
{graphic && <img src={graphic} alt={entry.media_alt ?? ""} loading="lazy" className="w-full rounded-lg" />}
|
||||||
|
|
||||||
{place && (
|
{place && (
|
||||||
<div>
|
<div>
|
||||||
<iframe
|
{showMap ? (
|
||||||
src={mapEmbed(place)}
|
<iframe
|
||||||
title={`Map: ${place}`}
|
src={mapEmbed(place)}
|
||||||
loading="lazy"
|
title={`Map: ${place}`}
|
||||||
referrerPolicy="no-referrer-when-downgrade"
|
loading="lazy"
|
||||||
className="aspect-video w-full rounded-lg border-0"
|
referrerPolicy="no-referrer-when-downgrade"
|
||||||
/>
|
className="aspect-video w-full rounded-lg border-0"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => setShowMap(true)}
|
||||||
|
className="flex aspect-video w-full flex-col items-center justify-center gap-1 rounded-lg border border-dashed text-sm"
|
||||||
|
style={{ borderColor: `${withAlpha(accent, 33)}`, color: BODY }}
|
||||||
|
>
|
||||||
|
<span className="font-semibold">Show map</span>
|
||||||
|
<span className="text-xs">{place}, from Google Maps</span>
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
<a
|
<a
|
||||||
href={mapLink(place)}
|
href={mapLink(place)}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noreferrer"
|
rel="noreferrer"
|
||||||
className="mt-2 inline-block text-sm underline"
|
className="mt-2 inline-block text-sm underline"
|
||||||
style={{ color: accent }}
|
style={{ color: accentText(accent) }}
|
||||||
>
|
>
|
||||||
Open in Google Maps
|
Open in Google Maps
|
||||||
</a>
|
</a>
|
||||||
|
|
@ -209,11 +224,17 @@ export default function ScheduleBlock({
|
||||||
if (days.length === 0) return null
|
if (days.length === 0) return null
|
||||||
const current = days[Math.min(active, days.length - 1)]
|
const current = days[Math.min(active, days.length - 1)]
|
||||||
|
|
||||||
|
// Arrows move one tab and wrap; Home and End jump to the ends.
|
||||||
const onKey = (e: KeyboardEvent<HTMLButtonElement>) => {
|
const onKey = (e: KeyboardEvent<HTMLButtonElement>) => {
|
||||||
const step = e.key === 'ArrowRight' ? 1 : e.key === 'ArrowLeft' ? -1 : 0
|
const last = days.length - 1
|
||||||
if (!step) return
|
const next =
|
||||||
|
e.key === 'ArrowRight' ? (active + 1) % days.length
|
||||||
|
: e.key === 'ArrowLeft' ? (active + last) % days.length
|
||||||
|
: e.key === 'Home' ? 0
|
||||||
|
: e.key === 'End' ? last
|
||||||
|
: null
|
||||||
|
if (next === null) return
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
const next = (active + step + days.length) % days.length
|
|
||||||
setActive(next)
|
setActive(next)
|
||||||
document.getElementById(`${baseId}-tab-${next}`)?.focus()
|
document.getElementById(`${baseId}-tab-${next}`)?.focus()
|
||||||
}
|
}
|
||||||
|
|
@ -244,8 +265,8 @@ export default function ScheduleBlock({
|
||||||
className="rounded-full border px-5 py-2 text-sm font-semibold transition-colors"
|
className="rounded-full border px-5 py-2 text-sm font-semibold transition-colors"
|
||||||
style={
|
style={
|
||||||
selected
|
selected
|
||||||
? { background: accent, borderColor: accent, color: '#ffffff' }
|
? { background: accent, borderColor: accent, color: readableOn(accent) }
|
||||||
: { borderColor: `${accent}55`, color: accent }
|
: { borderColor: `${withAlpha(accent, 33)}`, color: accentText(accent) }
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{day.name || 'Schedule'}
|
{day.name || 'Schedule'}
|
||||||
|
|
@ -259,7 +280,7 @@ export default function ScheduleBlock({
|
||||||
id={`${baseId}-panel`}
|
id={`${baseId}-panel`}
|
||||||
role={days.length > 1 ? 'tabpanel' : undefined}
|
role={days.length > 1 ? 'tabpanel' : undefined}
|
||||||
aria-labelledby={days.length > 1 ? `${baseId}-tab-${days.indexOf(current)}` : undefined}
|
aria-labelledby={days.length > 1 ? `${baseId}-tab-${days.indexOf(current)}` : undefined}
|
||||||
className="rounded-2xl border border-[#138ba0]/15 bg-white px-5"
|
className="rounded-2xl border border-brand/15 bg-surface px-5"
|
||||||
>
|
>
|
||||||
{current.entries.map((entry, index) => (
|
{current.entries.map((entry, index) => (
|
||||||
<Entry key={`${current.name}-${index}`} entry={entry} accent={accent} />
|
<Entry key={`${current.name}-${index}`} entry={entry} accent={accent} />
|
||||||
|
|
|
||||||
69
src/components/ThemeToggle.tsx
Normal file
69
src/components/ThemeToggle.tsx
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
|
THEME TOGGLE
|
||||||
|
|
||||||
|
Light or dark. The theme lives on <html data-theme>, which
|
||||||
|
index.html sets before the first paint (from this browser's
|
||||||
|
choice, else the system setting) so a dark visitor never sees a
|
||||||
|
white flash. Pressing this makes an explicit choice and remembers
|
||||||
|
it; until then the site follows the system, including a change
|
||||||
|
made while the page is open. Colours come from the tokens in
|
||||||
|
index.css.
|
||||||
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
import { Sun, Moon } from '@phosphor-icons/react'
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
|
type Theme = 'light' | 'dark'
|
||||||
|
|
||||||
|
export const THEME_STORAGE_KEY = 'site-theme'
|
||||||
|
|
||||||
|
const current = (): Theme =>
|
||||||
|
document.documentElement.dataset.theme === 'dark' ? 'dark' : 'light'
|
||||||
|
|
||||||
|
function chosen(): Theme | null {
|
||||||
|
try {
|
||||||
|
const value = localStorage.getItem(THEME_STORAGE_KEY)
|
||||||
|
return value === 'dark' || value === 'light' ? value : null
|
||||||
|
} catch {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function ThemeToggle({ className = '' }: { className?: string }) {
|
||||||
|
const [theme, setTheme] = useState<Theme>(current)
|
||||||
|
|
||||||
|
// No choice made: follow the system as it changes.
|
||||||
|
useEffect(() => {
|
||||||
|
const media = window.matchMedia('(prefers-color-scheme: dark)')
|
||||||
|
const follow = () => {
|
||||||
|
if (chosen()) return
|
||||||
|
const next: Theme = media.matches ? 'dark' : 'light'
|
||||||
|
document.documentElement.dataset.theme = next
|
||||||
|
setTheme(next)
|
||||||
|
}
|
||||||
|
media.addEventListener('change', follow)
|
||||||
|
return () => media.removeEventListener('change', follow)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const toggle = () => {
|
||||||
|
const next: Theme = theme === 'dark' ? 'light' : 'dark'
|
||||||
|
document.documentElement.dataset.theme = next
|
||||||
|
setTheme(next)
|
||||||
|
try {
|
||||||
|
localStorage.setItem(THEME_STORAGE_KEY, next)
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
const dark = theme === 'dark'
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={toggle}
|
||||||
|
aria-label={dark ? 'Switch to light mode' : 'Switch to dark mode'}
|
||||||
|
title={dark ? 'Light mode' : 'Dark mode'}
|
||||||
|
className={`flex h-9 w-9 items-center justify-center rounded-full transition-colors ${className}`}
|
||||||
|
>
|
||||||
|
{dark ? <Sun size={20} weight="bold" aria-hidden="true" /> : <Moon size={20} weight="bold" aria-hidden="true" />}
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -11,12 +11,13 @@
|
||||||
goes somewhere: the still becomes a link to it.
|
goes somewhere: the still becomes a link to it.
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
import { Play } from '@phosphor-icons/react'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
|
|
||||||
import HomeLink from '../pages/sections/home/HomeLink.tsx'
|
import HomeLink from '../pages/sections/home/HomeLink.tsx'
|
||||||
import { playingSource, videoSource, videoThumbnail } from '../lib/embeds.ts'
|
import { playingSource, videoSource, videoThumbnail } from '../lib/embeds.ts'
|
||||||
|
import { BRAND } from '../lib/color.ts'
|
||||||
|
|
||||||
const ACCENT = '#138ba0'
|
|
||||||
|
|
||||||
export default function VideoPlayer({
|
export default function VideoPlayer({
|
||||||
url,
|
url,
|
||||||
|
|
@ -55,16 +56,14 @@ export default function VideoPlayer({
|
||||||
{image ? (
|
{image ? (
|
||||||
<img src={image} alt="" loading="lazy" className={`aspect-video w-full object-cover ${className}`} />
|
<img src={image} alt="" loading="lazy" className={`aspect-video w-full object-cover ${className}`} />
|
||||||
) : (
|
) : (
|
||||||
<div className={`aspect-video w-full bg-gradient-to-br from-[#073d4a] to-[#04262e] ${className}`} />
|
<div className={`aspect-video w-full bg-[#073d4a] ${className}`} />
|
||||||
)}
|
)}
|
||||||
<span
|
<span
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
className="absolute inset-0 flex items-center justify-center bg-black/10 transition-colors group-hover:bg-black/25"
|
className="absolute inset-0 flex items-center justify-center bg-black/10 transition-colors group-hover:bg-black/25"
|
||||||
>
|
>
|
||||||
<span className="flex h-16 w-16 items-center justify-center rounded-full bg-white/90 shadow-lg transition-transform group-hover:scale-110">
|
<span className="flex h-16 w-16 items-center justify-center rounded-full bg-white/90 shadow-lg transition-transform group-hover:scale-110">
|
||||||
<svg viewBox="0 0 24 24" className="ml-1 h-7 w-7" fill={ACCENT}>
|
<Play className="ml-1 h-7 w-7" weight="fill" style={{ color: BRAND }} aria-hidden="true" />
|
||||||
<path d="M8 5v14l11-7z" />
|
|
||||||
</svg>
|
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,8 @@ export type MediaItem = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const button =
|
const button =
|
||||||
"rounded-full border border-[#138ba0] px-3 py-1 text-sm font-medium text-[#138ba0] " +
|
"rounded-full border border-brand px-3 py-1 text-sm font-medium text-link " +
|
||||||
"transition-colors hover:bg-[#eef9fb] disabled:cursor-default disabled:opacity-50";
|
"transition-colors hover:bg-tint disabled:cursor-default disabled:opacity-50";
|
||||||
|
|
||||||
/* A light checkerboard, so a white logo on a transparent background
|
/* A light checkerboard, so a white logo on a transparent background
|
||||||
is still visible in its thumbnail. */
|
is still visible in its thumbnail. */
|
||||||
|
|
@ -166,25 +166,25 @@ export function UploadButton({
|
||||||
className="hidden"
|
className="hidden"
|
||||||
onChange={(e) => send(e.target.files)}
|
onChange={(e) => send(e.target.files)}
|
||||||
/>
|
/>
|
||||||
<label htmlFor={keepId} className="flex items-center gap-1.5 text-xs text-[#4a6b72]">
|
<label htmlFor={keepId} className="flex items-center gap-1.5 text-xs text-muted">
|
||||||
<input
|
<input
|
||||||
id={keepId}
|
id={keepId}
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={keepOriginal}
|
checked={keepOriginal}
|
||||||
onChange={(e) => setKeepOriginal(e.target.checked)}
|
onChange={(e) => setKeepOriginal(e.target.checked)}
|
||||||
className="h-3.5 w-3.5 rounded border-[#4a6b72]/40 text-[#138ba0]"
|
className="h-3.5 w-3.5 rounded border-muted/40 text-link"
|
||||||
/>
|
/>
|
||||||
Keep original
|
Keep original
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
{error && <p className="mt-1 text-xs text-[#b3261e]">{error}</p>}
|
{error && <p className="mt-1 text-xs text-danger">{error}</p>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const UPLOAD_HELP =
|
export const UPLOAD_HELP =
|
||||||
"Photos are shrunk to 2400px and saved as WebP, which also removes their location data. " +
|
"Photos are shrunk to 2400px and saved as WebP, which also removes their location data. " +
|
||||||
"Keep original stores the file exactly as it is (up to 10 MB). SVGs are always kept as they are.";
|
"Keep original stores the file exactly as it is (up to 10 MB), including any location a phone saved in a photo; shrinking removes it. SVGs are always kept as they are.";
|
||||||
|
|
||||||
/* ── Grid ────────────────────────────────────────────────────── */
|
/* ── Grid ────────────────────────────────────────────────────── */
|
||||||
|
|
||||||
|
|
@ -200,7 +200,7 @@ export function MediaGrid({
|
||||||
renderActions?: (item: MediaItem) => ReactNode;
|
renderActions?: (item: MediaItem) => ReactNode;
|
||||||
}) {
|
}) {
|
||||||
if (items.length === 0) {
|
if (items.length === 0) {
|
||||||
return <p className="text-sm text-[#4a6b72]">Nothing here yet.</p>;
|
return <p className="text-sm text-muted">Nothing here yet.</p>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -214,7 +214,7 @@ export function MediaGrid({
|
||||||
// A still of the first frame; metadata only, not the file.
|
// A still of the first frame; metadata only, not the file.
|
||||||
<video src={item.url} preload="metadata" muted className="h-full w-full bg-black object-contain" />
|
<video src={item.url} preload="metadata" muted className="h-full w-full bg-black object-contain" />
|
||||||
) : item.content_type.startsWith("audio/") ? (
|
) : item.content_type.startsWith("audio/") ? (
|
||||||
<div className="flex h-full w-full items-center justify-center bg-[#eef9fb] text-3xl" aria-hidden="true">
|
<div className="flex h-full w-full items-center justify-center bg-tint text-3xl" aria-hidden="true">
|
||||||
♪
|
♪
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
|
@ -226,18 +226,18 @@ export function MediaGrid({
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<p className="mt-1.5 truncate text-xs font-medium text-[#26454c]" title={item.original_name}>
|
<p className="mt-1.5 truncate text-xs font-medium text-body" title={item.original_name}>
|
||||||
{item.original_name}
|
{item.original_name}
|
||||||
</p>
|
</p>
|
||||||
<p className="text-xs text-[#4a6b72]/80">{mediaSize(item)}</p>
|
<p className="text-xs text-muted/80">{mediaSize(item)}</p>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li
|
<li
|
||||||
key={item.id}
|
key={item.id}
|
||||||
className={`rounded-xl border bg-white p-2 ${
|
className={`rounded-xl border bg-surface p-2 ${
|
||||||
isSelected ? "border-[#138ba0] ring-2 ring-[#138ba0]/30" : "border-[#4a6b72]/20"
|
isSelected ? "border-brand ring-2 ring-brand/30" : "border-muted/20"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{onPick ? (
|
{onPick ? (
|
||||||
|
|
@ -292,27 +292,27 @@ export function MediaPicker({
|
||||||
className="w-[min(56rem,calc(100vw-2rem))] rounded-2xl p-0 backdrop:bg-[#0f2f36]/40"
|
className="w-[min(56rem,calc(100vw-2rem))] rounded-2xl p-0 backdrop:bg-[#0f2f36]/40"
|
||||||
>
|
>
|
||||||
<div className="flex max-h-[85vh] flex-col">
|
<div className="flex max-h-[85vh] flex-col">
|
||||||
<div className="flex flex-wrap items-center gap-3 border-b border-[#138ba0]/15 px-5 py-4">
|
<div className="flex flex-wrap items-center gap-3 border-b border-brand/15 px-5 py-4">
|
||||||
<h2 className="text-lg font-semibold text-[#138ba0]">Choose an image</h2>
|
<h2 className="text-lg font-semibold text-link">Choose an image</h2>
|
||||||
<input
|
<input
|
||||||
type="search"
|
type="search"
|
||||||
value={query}
|
value={query}
|
||||||
onChange={(e) => setQuery(e.target.value)}
|
onChange={(e) => setQuery(e.target.value)}
|
||||||
placeholder="Search by file name"
|
placeholder="Search by file name"
|
||||||
className="ml-auto w-56 rounded-lg border border-[#4a6b72]/25 px-3 py-1.5 text-sm outline-none focus:border-[#138ba0]"
|
className="ml-auto w-56 rounded-lg border border-muted/25 px-3 py-1.5 text-sm outline-none focus:border-brand"
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => dialogRef.current?.close()}
|
onClick={() => dialogRef.current?.close()}
|
||||||
aria-label="Close"
|
aria-label="Close"
|
||||||
className="h-8 w-8 rounded-full text-[#4a6b72] hover:bg-[#eef9fb]"
|
className="h-8 w-8 rounded-full text-muted hover:bg-tint"
|
||||||
>
|
>
|
||||||
✕
|
✕
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{roleCanWrite(user) && (
|
{roleCanWrite(user) && (
|
||||||
<div className="border-b border-[#138ba0]/10 px-5 py-3">
|
<div className="border-b border-brand/10 px-5 py-3">
|
||||||
<UploadButton
|
<UploadButton
|
||||||
label="Upload new"
|
label="Upload new"
|
||||||
onUploaded={(item) => {
|
onUploaded={(item) => {
|
||||||
|
|
@ -321,15 +321,15 @@ export function MediaPicker({
|
||||||
dialogRef.current?.close();
|
dialogRef.current?.close();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<p className="mt-1 text-xs text-[#4a6b72]">{UPLOAD_HELP}</p>
|
<p className="mt-1 text-xs text-muted">{UPLOAD_HELP}</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="overflow-y-auto px-5 py-4">
|
<div className="overflow-y-auto px-5 py-4">
|
||||||
{error ? (
|
{error ? (
|
||||||
<p className="text-sm text-[#b3261e]">{error}</p>
|
<p className="text-sm text-danger">{error}</p>
|
||||||
) : items === null ? (
|
) : items === null ? (
|
||||||
<p className="text-sm text-[#4a6b72]">Loading…</p>
|
<p className="text-sm text-muted">Loading…</p>
|
||||||
) : (
|
) : (
|
||||||
<MediaGrid
|
<MediaGrid
|
||||||
items={items}
|
items={items}
|
||||||
|
|
@ -375,13 +375,13 @@ export function ImageInput({
|
||||||
return (
|
return (
|
||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
<div
|
<div
|
||||||
className="flex h-20 w-20 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-[#4a6b72]/20"
|
className="flex h-20 w-20 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-muted/20"
|
||||||
style={CHECKER}
|
style={CHECKER}
|
||||||
>
|
>
|
||||||
{src && !broken ? (
|
{src && !broken ? (
|
||||||
<img src={src} alt="" className="h-full w-full object-contain" onError={() => setBroken(true)} />
|
<img src={src} alt="" className="h-full w-full object-contain" onError={() => setBroken(true)} />
|
||||||
) : (
|
) : (
|
||||||
<span className="px-1 text-center text-[10px] text-[#4a6b72]/70">
|
<span className="px-1 text-center text-[10px] text-muted/70">
|
||||||
{src ? "Not found" : "No image"}
|
{src ? "Not found" : "No image"}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
|
@ -406,7 +406,7 @@ export function ImageInput({
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => onChange("")}
|
onClick={() => onChange("")}
|
||||||
className="px-2 py-1 text-sm text-[#4a6b72] hover:text-[#b3261e]"
|
className="px-2 py-1 text-sm text-muted hover:text-danger"
|
||||||
>
|
>
|
||||||
Clear
|
Clear
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -498,7 +498,7 @@ export function LinkPreviewInput({
|
||||||
{busy ? "Fetching…" : "Fetch preview"}
|
{busy ? "Fetching…" : "Fetch preview"}
|
||||||
</button>
|
</button>
|
||||||
{note && (
|
{note && (
|
||||||
<span className={`text-xs ${note.tone === "ok" ? "text-[#138ba0]" : "text-[#b3261e]"}`}>
|
<span className={`text-xs ${note.tone === "ok" ? "text-link" : "text-danger"}`}>
|
||||||
{note.text}
|
{note.text}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
import { scrollBehavior } from "../../lib/motion.ts";
|
||||||
|
|
||||||
export type EditorSection = {
|
export type EditorSection = {
|
||||||
id: string;
|
id: string;
|
||||||
|
|
@ -63,7 +64,7 @@ function useActiveSection(sections: EditorSection[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function jump(id: string) {
|
function jump(id: string) {
|
||||||
document.getElementById(id)?.scrollIntoView({ behavior: "smooth", block: "start" });
|
document.getElementById(id)?.scrollIntoView({ behavior: scrollBehavior(), block: "start" });
|
||||||
}
|
}
|
||||||
|
|
||||||
function Label({ section }: { section: EditorSection }) {
|
function Label({ section }: { section: EditorSection }) {
|
||||||
|
|
@ -71,10 +72,10 @@ function Label({ section }: { section: EditorSection }) {
|
||||||
<>
|
<>
|
||||||
<span className="truncate">{section.label}</span>
|
<span className="truncate">{section.label}</span>
|
||||||
{section.count != null && (
|
{section.count != null && (
|
||||||
<span className="text-xs text-[#4a6b72]/70">({section.count})</span>
|
<span className="text-xs text-muted/70">({section.count})</span>
|
||||||
)}
|
)}
|
||||||
{section.hasError && (
|
{section.hasError && (
|
||||||
<span aria-label="needs attention" className="h-1.5 w-1.5 shrink-0 rounded-full bg-[#b3261e]" />
|
<span aria-label="needs attention" className="h-1.5 w-1.5 shrink-0 rounded-full bg-danger" />
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
@ -87,10 +88,10 @@ export function SectionNav({ sections }: { sections: EditorSection[] }) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav aria-label="Sections" className="hidden max-h-[calc(100vh-8rem)] overflow-y-auto lg:block">
|
<nav aria-label="Sections" className="hidden max-h-[calc(100vh-8rem)] overflow-y-auto lg:block">
|
||||||
<p className="mb-2 px-3 text-xs font-semibold uppercase tracking-wider text-[#4a6b72]/70">
|
<p className="mb-2 px-3 text-xs font-semibold uppercase tracking-wider text-muted/70">
|
||||||
On this page
|
On this page
|
||||||
</p>
|
</p>
|
||||||
<ul className="space-y-0.5 border-l border-[#138ba0]/15">
|
<ul className="space-y-0.5 border-l border-brand/15">
|
||||||
{sections.map((section) => {
|
{sections.map((section) => {
|
||||||
const lit = section.id === active;
|
const lit = section.id === active;
|
||||||
return (
|
return (
|
||||||
|
|
@ -101,8 +102,8 @@ export function SectionNav({ sections }: { sections: EditorSection[] }) {
|
||||||
aria-current={lit ? "location" : undefined}
|
aria-current={lit ? "location" : undefined}
|
||||||
className={`-ml-px flex w-full items-center gap-1.5 border-l-2 px-3 py-1.5 text-left text-sm transition-colors ${
|
className={`-ml-px flex w-full items-center gap-1.5 border-l-2 px-3 py-1.5 text-left text-sm transition-colors ${
|
||||||
lit
|
lit
|
||||||
? "border-[#138ba0] font-semibold text-[#138ba0]"
|
? "border-brand font-semibold text-link"
|
||||||
: "border-transparent text-[#4a6b72] hover:border-[#138ba0]/40 hover:text-[#138ba0]"
|
: "border-transparent text-muted hover:border-brand/40 hover:text-link"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<Label section={section} />
|
<Label section={section} />
|
||||||
|
|
@ -120,13 +121,13 @@ export function SectionJump({ sections }: { sections: EditorSection[] }) {
|
||||||
const active = useActiveSection(sections);
|
const active = useActiveSection(sections);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="sticky top-0 z-20 -mx-6 mt-4 mb-2 border-b border-[#138ba0]/15 bg-[#f6fbfc]/95 px-6 py-2 backdrop-blur lg:hidden">
|
<div className="sticky top-0 z-20 -mx-6 mt-4 mb-2 border-b border-brand/15 bg-tint-soft/95 px-6 py-2 backdrop-blur lg:hidden">
|
||||||
<label className="flex items-center gap-3 text-sm text-[#4a6b72]">
|
<label className="flex items-center gap-3 text-sm text-muted">
|
||||||
<span className="shrink-0">Jump to</span>
|
<span className="shrink-0">Jump to</span>
|
||||||
<select
|
<select
|
||||||
value={active ?? ""}
|
value={active ?? ""}
|
||||||
onChange={(e) => jump(e.target.value)}
|
onChange={(e) => jump(e.target.value)}
|
||||||
className="w-full rounded-lg border border-[#4a6b72]/25 bg-white px-3 py-1.5 text-sm text-[#26454c] outline-none focus:border-[#138ba0]"
|
className="w-full rounded-lg border border-muted/25 bg-surface px-3 py-1.5 text-sm text-body outline-none focus:border-brand"
|
||||||
>
|
>
|
||||||
{sections.map((section) => (
|
{sections.map((section) => (
|
||||||
<option key={section.id} value={section.id}>
|
<option key={section.id} value={section.id}>
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@
|
||||||
able to read and copy.
|
able to read and copy.
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
import { ArrowUp, ArrowDown, CaretRight } from "@phosphor-icons/react";
|
||||||
import { useRef, useState } from "react";
|
import { useRef, useState } from "react";
|
||||||
|
|
||||||
import ContentBlocks from "../ContentBlocks.tsx";
|
import ContentBlocks from "../ContentBlocks.tsx";
|
||||||
|
|
@ -104,27 +105,35 @@ const PREVIEWS = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const input =
|
const input =
|
||||||
"w-full rounded-lg border border-[#4a6b72]/25 bg-white px-3 py-2 text-sm text-[#26454c] " +
|
"w-full rounded-lg border border-muted/25 bg-surface px-3 py-2 text-sm text-body " +
|
||||||
"outline-none transition-colors focus:border-[#138ba0] focus:ring-2 focus:ring-[#138ba0]/25";
|
"outline-none transition-colors focus:border-brand focus:ring-2 focus:ring-brand/25";
|
||||||
|
|
||||||
/* Same box, but lit by the real input nested inside it. */
|
/* Same box, but lit by the real input nested inside it. */
|
||||||
const inputShell =
|
const inputShell =
|
||||||
"flex w-full items-center rounded-lg border border-[#4a6b72]/25 bg-white px-3 py-2 text-sm " +
|
"flex w-full items-center rounded-lg border border-muted/25 bg-surface px-3 py-2 text-sm " +
|
||||||
"text-[#26454c] transition-colors focus-within:border-[#138ba0] focus-within:ring-2 " +
|
"text-body transition-colors focus-within:border-brand focus-within:ring-2 " +
|
||||||
"focus-within:ring-[#138ba0]/25";
|
"focus-within:ring-brand/25";
|
||||||
|
|
||||||
const inputError = "border-[#b3261e] focus:border-[#b3261e] focus:ring-[#b3261e]/20";
|
const inputError = "border-danger focus:border-danger focus:ring-danger/20";
|
||||||
const shellError =
|
const shellError =
|
||||||
"border-[#b3261e] focus-within:border-[#b3261e] focus-within:ring-[#b3261e]/20";
|
"border-danger focus-within:border-danger focus-within:ring-danger/20";
|
||||||
|
|
||||||
/* Reads as settled fact rather than as an empty box someone forgot
|
/* Reads as settled fact rather than as an empty box someone forgot
|
||||||
to fill in. */
|
to fill in. */
|
||||||
const inputLocked =
|
const inputLocked =
|
||||||
"w-full rounded-lg border border-[#4a6b72]/20 bg-[#f6fbfc] px-3 py-2 text-sm " +
|
"w-full rounded-lg border border-muted/20 bg-tint-soft px-3 py-2 text-sm " +
|
||||||
"text-[#4a6b72] outline-none cursor-default focus:border-[#4a6b72]/40";
|
"text-muted outline-none cursor-default focus:border-muted/40";
|
||||||
|
|
||||||
/* ── Dotted paths ────────────────────────────────────────────── */
|
/* ── Dotted paths ────────────────────────────────────────────── */
|
||||||
|
|
||||||
|
/* What an empty colour field shows in its swatch and placeholder:
|
||||||
|
the field's own default (a value, or one worked out from the row),
|
||||||
|
else the brand teal. */
|
||||||
|
function colorPlaceholder(field, row): string {
|
||||||
|
const own = typeof field.placeholder === "function" ? field.placeholder(row) : field.placeholder;
|
||||||
|
return own || "#138ba0";
|
||||||
|
}
|
||||||
|
|
||||||
export function getPath(object, path) {
|
export function getPath(object, path) {
|
||||||
// An entity with no slug has no heading path either, and a missing
|
// An entity with no slug has no heading path either, and a missing
|
||||||
// path should read as "no value" rather than throwing on .split.
|
// path should read as "no value" rather than throwing on .split.
|
||||||
|
|
@ -226,21 +235,21 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={field.full ? "sm:col-span-2" : ""}>
|
<div className={field.full ? "sm:col-span-2" : ""}>
|
||||||
<label htmlFor={id} className="block text-sm font-medium text-[#26454c]">
|
<label htmlFor={id} className="block text-sm font-medium text-body">
|
||||||
{typeof field.label === "function" ? field.label(row) : field.label}
|
{typeof field.label === "function" ? field.label(row) : field.label}
|
||||||
{field.required && !locked && <span className="ml-1 text-[#b3261e]">*</span>}
|
{field.required && !locked && <span className="ml-1 text-danger">*</span>}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div className="mt-1.5">
|
<div className="mt-1.5">
|
||||||
{widget === "checkbox" ? (
|
{widget === "checkbox" ? (
|
||||||
<label className="flex items-center gap-2 text-sm text-[#4a6b72]">
|
<label className="flex items-center gap-2 text-sm text-muted">
|
||||||
<input
|
<input
|
||||||
id={id}
|
id={id}
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={value === 1 || value === true}
|
checked={value === 1 || value === true}
|
||||||
disabled={locked}
|
disabled={locked}
|
||||||
onChange={(e) => onChange(e.target.checked ? 1 : 0)}
|
onChange={(e) => onChange(e.target.checked ? 1 : 0)}
|
||||||
className="h-4 w-4 rounded border-[#4a6b72]/40 text-[#138ba0] focus:ring-[#138ba0]/40 disabled:opacity-50"
|
className="h-4 w-4 rounded border-muted/40 text-link focus:ring-brand/40 disabled:opacity-50"
|
||||||
/>
|
/>
|
||||||
{helpText(field, row) ?? "Yes"}
|
{helpText(field, row) ?? "Yes"}
|
||||||
</label>
|
</label>
|
||||||
|
|
@ -274,15 +283,15 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<input
|
<input
|
||||||
type="color"
|
type="color"
|
||||||
value={/^#[0-9a-f]{6}$/i.test(value ?? "") ? value : "#138ba0"}
|
value={/^#[0-9a-f]{6}$/i.test(value ?? "") ? value : colorPlaceholder(field, row)}
|
||||||
disabled={locked}
|
disabled={locked}
|
||||||
onChange={(e) => onChange(e.target.value)}
|
onChange={(e) => onChange(e.target.value)}
|
||||||
className="h-9 w-12 shrink-0 rounded border border-[#4a6b72]/25 bg-white disabled:opacity-50"
|
className="h-9 w-12 shrink-0 rounded border border-muted/25 bg-surface disabled:opacity-50"
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
{...common}
|
{...common}
|
||||||
readOnly={locked}
|
readOnly={locked}
|
||||||
placeholder="#138ba0"
|
placeholder={colorPlaceholder(field, row)}
|
||||||
className={locked ? inputLocked : common.className}
|
className={locked ? inputLocked : common.className}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -318,7 +327,7 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
|
||||||
<span
|
<span
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
className={`shrink-0 select-none ${
|
className={`shrink-0 select-none ${
|
||||||
field.prefixPending ? "text-[#4a6b72]/45" : "text-[#4a6b72]"
|
field.prefixPending ? "text-muted/45" : "text-muted"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{field.prefix}
|
{field.prefix}
|
||||||
|
|
@ -329,7 +338,7 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
|
||||||
value={value ?? ""}
|
value={value ?? ""}
|
||||||
onChange={(e) => onChange(e.target.value)}
|
onChange={(e) => onChange(e.target.value)}
|
||||||
placeholder={field.placeholder}
|
placeholder={field.placeholder}
|
||||||
className="w-full border-0 bg-transparent p-0 text-[#26454c] outline-none placeholder:text-[#4a6b72]/45"
|
className="w-full border-0 bg-transparent p-0 text-body outline-none placeholder:text-muted/45"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
|
@ -347,15 +356,15 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error ? (
|
{error ? (
|
||||||
<p className="mt-1 text-xs text-[#b3261e]">{error}</p>
|
<p className="mt-1 text-xs text-danger">{error}</p>
|
||||||
) : orphaned && !locked ? (
|
) : orphaned && !locked ? (
|
||||||
<p className="mt-1 text-xs text-[#b3261e]">
|
<p className="mt-1 text-xs text-danger">
|
||||||
This points at something that has been deleted. Pick a replacement before saving.
|
This points at something that has been deleted. Pick a replacement before saving.
|
||||||
</p>
|
</p>
|
||||||
) : (
|
) : (
|
||||||
helpText(field, row) &&
|
helpText(field, row) &&
|
||||||
widget !== "checkbox" && (
|
widget !== "checkbox" && (
|
||||||
<p className="mt-1 text-xs text-[#4a6b72]">{helpText(field, row)}</p>
|
<p className="mt-1 text-xs text-muted">{helpText(field, row)}</p>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -467,25 +476,25 @@ export function Repeater({
|
||||||
return (
|
return (
|
||||||
<section className={className}>
|
<section className={className}>
|
||||||
<div className="flex flex-wrap items-center gap-3">
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
<h3 className="text-base font-semibold text-[#26454c]">
|
<h3 className="text-base font-semibold text-body">
|
||||||
{spec.label}
|
{spec.label}
|
||||||
{list.length > 0 && (
|
{list.length > 0 && (
|
||||||
<span className="ml-2 text-sm font-normal text-[#4a6b72]/80">{list.length}</span>
|
<span className="ml-2 text-sm font-normal text-muted/80">{list.length}</span>
|
||||||
)}
|
)}
|
||||||
</h3>
|
</h3>
|
||||||
{list.length > 1 && (
|
{list.length > 1 && (
|
||||||
<div className="flex gap-3 text-xs text-[#4a6b72]">
|
<div className="flex gap-3 text-xs text-muted">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => setOpen(new Set(list.map((_, i) => i)))}
|
onClick={() => setOpen(new Set(list.map((_, i) => i)))}
|
||||||
className="hover:text-[#138ba0] hover:underline"
|
className="hover:text-link hover:underline"
|
||||||
>
|
>
|
||||||
Expand all
|
Expand all
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => setOpen(new Set())}
|
onClick={() => setOpen(new Set())}
|
||||||
className="hover:text-[#138ba0] hover:underline"
|
className="hover:text-link hover:underline"
|
||||||
>
|
>
|
||||||
Collapse all
|
Collapse all
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -494,15 +503,15 @@ export function Repeater({
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={add}
|
onClick={add}
|
||||||
className="ml-auto rounded-full border border-[#138ba0] px-3 py-1 text-sm font-medium text-[#138ba0] transition-colors hover:bg-[#eef9fb]"
|
className="ml-auto rounded-full border border-brand px-3 py-1 text-sm font-medium text-link transition-colors hover:bg-tint"
|
||||||
>
|
>
|
||||||
{spec.addLabel ?? "Add"}
|
{spec.addLabel ?? "Add"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{spec.note && <p className="mt-1 text-sm text-[#4a6b72]">{spec.note}</p>}
|
{spec.note && <p className="mt-1 text-sm text-muted">{spec.note}</p>}
|
||||||
|
|
||||||
{list.length === 0 && <p className="mt-2 text-sm text-[#4a6b72]">None yet.</p>}
|
{list.length === 0 && <p className="mt-2 text-sm text-muted">None yet.</p>}
|
||||||
|
|
||||||
<div className="mt-3 space-y-3">
|
<div className="mt-3 space-y-3">
|
||||||
{list.map((row, index) => {
|
{list.map((row, index) => {
|
||||||
|
|
@ -533,10 +542,10 @@ export function Repeater({
|
||||||
endDrag();
|
endDrag();
|
||||||
}}
|
}}
|
||||||
className={
|
className={
|
||||||
`rounded-xl border bg-[#f6fbfc] ${expanded ? "p-4" : "px-4 py-2.5"} transition-colors ` +
|
`rounded-xl border bg-tint-soft ${expanded ? "p-4" : "px-4 py-2.5"} transition-colors ` +
|
||||||
(over
|
(over
|
||||||
? "border-[#138ba0] ring-2 ring-[#138ba0]/25 "
|
? "border-brand ring-2 ring-brand/25 "
|
||||||
: "border-[#4a6b72]/20 ") +
|
: "border-muted/20 ") +
|
||||||
(dragging ? "opacity-50" : "")
|
(dragging ? "opacity-50" : "")
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|
@ -556,7 +565,7 @@ export function Repeater({
|
||||||
onDragEnd={endDrag}
|
onDragEnd={endDrag}
|
||||||
title="Drag to reorder"
|
title="Drag to reorder"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
className="cursor-grab select-none px-1 text-[#4a6b72]/60 active:cursor-grabbing"
|
className="cursor-grab select-none px-1 text-muted/60 active:cursor-grabbing"
|
||||||
>
|
>
|
||||||
⠿
|
⠿
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -565,21 +574,21 @@ export function Repeater({
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => toggle(index)}
|
onClick={() => toggle(index)}
|
||||||
aria-expanded={expanded}
|
aria-expanded={expanded}
|
||||||
className="flex min-w-0 flex-1 items-center gap-2 text-left text-sm font-medium text-[#26454c] hover:text-[#138ba0]"
|
className="flex min-w-0 flex-1 items-center gap-2 text-left text-sm font-medium text-body hover:text-link"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
className={`inline-block text-xs text-[#4a6b72] transition-transform ${
|
className={`inline-block text-xs text-muted transition-transform ${
|
||||||
expanded ? "rotate-90" : ""
|
expanded ? "rotate-90" : ""
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
▶
|
<CaretRight size={14} weight="bold" aria-hidden="true" />
|
||||||
</span>
|
</span>
|
||||||
<span className="truncate">
|
<span className="truncate">
|
||||||
{spec.title ? spec.title(row, options) : `#${index + 1}`}
|
{spec.title ? spec.title(row, options) : `#${index + 1}`}
|
||||||
</span>
|
</span>
|
||||||
{!expanded && hasError(index) && (
|
{!expanded && hasError(index) && (
|
||||||
<span className="text-xs text-[#b3261e]">needs attention</span>
|
<span className="text-xs text-danger">needs attention</span>
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|
@ -589,14 +598,14 @@ export function Repeater({
|
||||||
onClick={() => move(index, -1)}
|
onClick={() => move(index, -1)}
|
||||||
disabled={index === 0}
|
disabled={index === 0}
|
||||||
>
|
>
|
||||||
↑
|
<ArrowUp size={14} weight="bold" aria-hidden="true" />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<IconButton
|
<IconButton
|
||||||
label="Move down"
|
label="Move down"
|
||||||
onClick={() => move(index, 1)}
|
onClick={() => move(index, 1)}
|
||||||
disabled={index === list.length - 1}
|
disabled={index === list.length - 1}
|
||||||
>
|
>
|
||||||
↓
|
<ArrowDown size={14} weight="bold" aria-hidden="true" />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<IconButton
|
<IconButton
|
||||||
label="Insert a new one below"
|
label="Insert a new one below"
|
||||||
|
|
@ -642,7 +651,7 @@ export function Repeater({
|
||||||
{(spec.children ?? [])
|
{(spec.children ?? [])
|
||||||
.filter((nested) => fieldShown(nested, row, parentRow))
|
.filter((nested) => fieldShown(nested, row, parentRow))
|
||||||
.map((nested) => (
|
.map((nested) => (
|
||||||
<div key={nested.key} className="mt-4 border-t border-[#4a6b72]/15 pt-4">
|
<div key={nested.key} className="mt-4 border-t border-muted/15 pt-4">
|
||||||
<Repeater
|
<Repeater
|
||||||
spec={nested}
|
spec={nested}
|
||||||
rows={row[nested.key]}
|
rows={row[nested.key]}
|
||||||
|
|
@ -657,8 +666,8 @@ export function Repeater({
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{spec.preview && PREVIEWS[spec.preview] && (
|
{spec.preview && PREVIEWS[spec.preview] && (
|
||||||
<div className="mt-4 rounded-lg border border-dashed border-[#138ba0]/30 bg-white p-4">
|
<div className="mt-4 rounded-lg border border-dashed border-brand/30 bg-surface p-4">
|
||||||
<p className="mb-3 text-xs font-semibold uppercase tracking-wider text-[#4a6b72]/70">
|
<p className="mb-3 text-xs font-semibold uppercase tracking-wider text-muted/70">
|
||||||
Preview
|
Preview
|
||||||
</p>
|
</p>
|
||||||
{PREVIEWS[spec.preview](row, options)}
|
{PREVIEWS[spec.preview](row, options)}
|
||||||
|
|
@ -685,10 +694,10 @@ function IconButton({ label, onClick, danger = false, disabled = false, children
|
||||||
className={
|
className={
|
||||||
"h-7 w-7 rounded-full border text-sm leading-none transition-colors " +
|
"h-7 w-7 rounded-full border text-sm leading-none transition-colors " +
|
||||||
(disabled
|
(disabled
|
||||||
? "cursor-default border-[#4a6b72]/20 text-[#4a6b72]/40"
|
? "cursor-default border-muted/20 text-muted/40"
|
||||||
: danger
|
: danger
|
||||||
? "border-[#b3261e]/30 text-[#b3261e] hover:bg-[#fdf3f2]"
|
? "border-danger/30 text-danger hover:bg-danger-tint"
|
||||||
: "border-[#4a6b72]/30 text-[#4a6b72] hover:bg-white")
|
: "border-muted/30 text-muted hover:bg-surface")
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// Site-wide announcement banner. Set `enabled: false` to hide it entirely.
|
// Site-wide announcement banner. Set `enabled: false` to hide it entirely.
|
||||||
// Bump `id` whenever the message changes — that re-shows the banner to
|
// Bump `id` whenever the message changes, that re-shows the banner to
|
||||||
// people who dismissed the previous one.
|
// people who dismissed the previous one.
|
||||||
|
|
||||||
export const SITE_BANNER = {
|
export const SITE_BANNER = {
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,11 @@
|
||||||
|
|
||||||
Used by the public form (to render the tiles) and the admin
|
Used by the public form (to render the tiles) and the admin
|
||||||
triage view (to label them). The ids must match TYPES in
|
triage view (to label them). The ids must match TYPES in
|
||||||
server/src/routes/feedback.js — that list stays separate because
|
server/src/routes/feedback.js, which decides what's storable;
|
||||||
the server isn't in this workspace, and it's the thing that
|
keep the two in step.
|
||||||
decides what's storable.
|
|
||||||
|
DATA_REQUEST is kept out of the tiles: the Privacy page's form
|
||||||
|
sends it (FeedbackForm's fixedType), with an email required.
|
||||||
|
|
||||||
'general' isn't offered anywhere; it's the server's fallback for
|
'general' isn't offered anywhere; it's the server's fallback for
|
||||||
a type it doesn't recognise, so old rows still read sensibly.
|
a type it doesn't recognise, so old rows still read sensibly.
|
||||||
|
|
@ -44,7 +46,13 @@ export const FEEDBACK_TYPES = [
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const BY_ID = new Map(FEEDBACK_TYPES.map((t) => [t.id, t.label]));
|
export const DATA_REQUEST = {
|
||||||
|
id: "privacy",
|
||||||
|
label: "Privacy or data request",
|
||||||
|
hint: "A question about your data, or a request to see or delete it",
|
||||||
|
};
|
||||||
|
|
||||||
|
const BY_ID = new Map([...FEEDBACK_TYPES, DATA_REQUEST].map((t) => [t.id, t.label]));
|
||||||
|
|
||||||
export function feedbackTypeLabel(id) {
|
export function feedbackTypeLabel(id) {
|
||||||
return BY_ID.get(id) ?? (id === "general" ? "Unsorted" : id);
|
return BY_ID.get(id) ?? (id === "general" ? "Unsorted" : id);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
* Decade headers for the history page.
|
* Decade headers for the history page.
|
||||||
*
|
*
|
||||||
* Not in the database on purpose. There are four of them, they change
|
* Not in the database on purpose. There are four of them, they change
|
||||||
* about never, and they're editorial voice rather than record — the same
|
* about never, and they're editorial voice rather than record, the same
|
||||||
* reasoning that keeps the map grid config in code. A table for four
|
* reasoning that keeps the map grid config in code. A table for four
|
||||||
* rows that nobody edits is a migration and an admin page for nothing.
|
* rows that nobody edits is a migration and an admin page for nothing.
|
||||||
*
|
*
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
* date is ever revised.
|
* date is ever revised.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { DecadeMeta } from '../lib/timeline'
|
import type { DecadeMeta } from '../lib/timeline.ts'
|
||||||
|
|
||||||
export const HISTORY_DECADES: DecadeMeta[] = [
|
export const HISTORY_DECADES: DecadeMeta[] = [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
Pure layout. Where each tile sits, what it's called, and how to
|
Pure layout. Where each tile sits, what it's called, and how to
|
||||||
work out which tile a chapter belongs to. None of this is in the
|
work out which tile a chapter belongs to. None of this is in the
|
||||||
database because none of it changes — Rhode Island will not be
|
database because none of it changes, Rhode Island will not be
|
||||||
moving, and no admin form should offer to move it.
|
moving, and no admin form should offer to move it.
|
||||||
|
|
||||||
What IS in the database is which regions cover which areas, and
|
What IS in the database is which regions cover which areas, and
|
||||||
|
|
@ -13,8 +13,6 @@
|
||||||
as regions with no tile.
|
as regions with no tile.
|
||||||
═══════════════════════════════════════════════════════════════ */
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
export const GRID_COLS = 13;
|
|
||||||
export const GRID_ROWS = 7;
|
|
||||||
|
|
||||||
/* ── States ────────────────────────────────────────────────────
|
/* ── States ────────────────────────────────────────────────────
|
||||||
[column, row], both 1-based. A tile grid rather than true
|
[column, row], both 1-based. A tile grid rather than true
|
||||||
|
|
@ -86,8 +84,8 @@ export const AREAS = Object.freeze([
|
||||||
export const AREA_BY_CODE = Object.fromEntries(AREAS.map((a) => [a.code, a]));
|
export const AREA_BY_CODE = Object.fromEntries(AREAS.map((a) => [a.code, a]));
|
||||||
|
|
||||||
/* ── Which tile a chapter sits on ──────────────────────────────
|
/* ── Which tile a chapter sits on ──────────────────────────────
|
||||||
The database stores a real address — state_code for US, and a
|
The database stores a real address, state_code for US, and a
|
||||||
country code otherwise — rather than a tile name. This is the
|
country code otherwise, rather than a tile name. This is the
|
||||||
one place that translates between the two, so adding a Mexico
|
one place that translates between the two, so adding a Mexico
|
||||||
band later means a line here and nothing in SQL.
|
band later means a line here and nothing in SQL.
|
||||||
|
|
||||||
|
|
@ -115,7 +113,7 @@ export function areaForChapter(chapter) {
|
||||||
A region with share 1 and no edge fills the tile. A shared
|
A region with share 1 and no edge fills the tile. A shared
|
||||||
tile has one row per region, each declaring its own slice, so
|
tile has one row per region, each declaring its own slice, so
|
||||||
California is two entries of 0.5 rather than a primary plus a
|
California is two entries of 0.5 rather than a primary plus a
|
||||||
remainder — no arithmetic, and the renderer doesn't need to
|
remainder, no arithmetic, and the renderer doesn't need to
|
||||||
know which region "really" owns it.
|
know which region "really" owns it.
|
||||||
|
|
||||||
regionAreas [{ region_id, area_code, share, edge, note }]
|
regionAreas [{ region_id, area_code, share, edge, note }]
|
||||||
|
|
@ -165,10 +163,3 @@ export function countChaptersByArea(chapters: any[] = []) {
|
||||||
from the row rather than being looked up in a splits table and
|
from the row rather than being looked up in a splits table and
|
||||||
branched on whether this region is the primary.
|
branched on whether this region is the primary.
|
||||||
───────────────────────────────────────────────────────────── */
|
───────────────────────────────────────────────────────────── */
|
||||||
export function areasLabel(regionId, regionAreas: any[] = []) {
|
|
||||||
return regionAreas
|
|
||||||
.filter((row) => row.region_id === regionId && row.area_code !== "CANADA")
|
|
||||||
.map((row) => (row.note ? `${row.area_code} (${row.note})` : row.area_code))
|
|
||||||
.sort()
|
|
||||||
.join(", ");
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,299 +0,0 @@
|
||||||
/**
|
|
||||||
* PLACEHOLDER DATA — delete this file once `GET /api/history` lands.
|
|
||||||
*
|
|
||||||
* Shaped exactly like the aggregation route's payload, so swapping it out
|
|
||||||
* is a two-line change in History.tsx.
|
|
||||||
*
|
|
||||||
* Note what is and isn't here. Entries that point at a record carry a
|
|
||||||
* `ref` and little else: no venue, no host name, no copy that also lives
|
|
||||||
* in `events`. The few that do carry a title are overriding it on
|
|
||||||
* purpose. Titles and blurbs below are invented scaffolding, not real NGU
|
|
||||||
* history — replace them before anyone sees this.
|
|
||||||
*
|
|
||||||
* Decade headers are not here — they live in historyDecades.ts and stay
|
|
||||||
* in code even after the API lands.
|
|
||||||
*
|
|
||||||
* Upcoming items are not flagged. `partitionByDate` decides what's
|
|
||||||
* upcoming by comparing dates to the wall clock, so nothing here needs
|
|
||||||
* editing as dates pass.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import type { TimelineItem } from '../lib/timeline'
|
|
||||||
|
|
||||||
export const MOCK_ITEMS: TimelineItem[] = [
|
|
||||||
// ——— Upcoming (relative to the wall clock, not a flag) ———
|
|
||||||
{
|
|
||||||
id: 'tl-0001',
|
|
||||||
date: '2027-06',
|
|
||||||
precision: 'month',
|
|
||||||
kind: 'event',
|
|
||||||
title: 'Summer Conference 2027',
|
|
||||||
meta: 'Unity Village, MO',
|
|
||||||
ref: { kind: 'event', id: 'summer-2027' },
|
|
||||||
logo: { file: 'summer-conference.svg', kind: 'event' },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0002',
|
|
||||||
date: '2026-11-14',
|
|
||||||
precision: 'day',
|
|
||||||
kind: 'event',
|
|
||||||
title: 'Fall Regional Rally',
|
|
||||||
meta: 'Southeast',
|
|
||||||
ref: { kind: 'event', id: 'fall-rally-2026' },
|
|
||||||
logo: { file: 'regional-rally.svg', kind: 'event' },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0003',
|
|
||||||
date: '2026-10-03',
|
|
||||||
precision: 'day',
|
|
||||||
kind: 'event',
|
|
||||||
title: 'Chapter Leads Intensive',
|
|
||||||
meta: 'Online',
|
|
||||||
ref: { kind: 'event', id: 'leads-intensive-2026' },
|
|
||||||
},
|
|
||||||
|
|
||||||
// ——— 2020s ———
|
|
||||||
{
|
|
||||||
id: 'tl-0010',
|
|
||||||
date: '2026-03',
|
|
||||||
precision: 'month',
|
|
||||||
kind: 'organization',
|
|
||||||
title: 'Twentieth chapter chartered',
|
|
||||||
blurb:
|
|
||||||
'The first new charter in the region since 2017, started by three people who met at a rally two summers earlier.',
|
|
||||||
featured: true,
|
|
||||||
ref: { kind: 'organization', id: 'boise', orgKind: 'chapter' },
|
|
||||||
logo: { file: 'boise.svg', kind: 'organization' },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0011',
|
|
||||||
date: '2026-04-17',
|
|
||||||
precision: 'day',
|
|
||||||
kind: 'event',
|
|
||||||
title: 'Spring Regional Rally',
|
|
||||||
ref: { kind: 'event', id: 'spring-rally-2026' },
|
|
||||||
logo: { file: 'regional-rally.svg', kind: 'event' },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0012',
|
|
||||||
date: '2026-01',
|
|
||||||
precision: 'month',
|
|
||||||
kind: 'people',
|
|
||||||
title: 'New leadership team seated',
|
|
||||||
blurb: 'A four-person exec on a two-year term, the first under the 2024 bylaws.',
|
|
||||||
ref: { kind: 'team', id: 'ngu-leadership' },
|
|
||||||
team: { id: 'ngu-leadership', name: 'Leadership Team', orgId: 'ngu', orgName: 'NGU National' },
|
|
||||||
people: [
|
|
||||||
{ id: 'jane-doe', name: 'Jane Doe', title: 'Chair', photo: 'jane-doe.jpg' },
|
|
||||||
{ id: 'sam-ruiz', name: 'Sam Ruiz', title: 'Vice Chair', photo: 'sam-ruiz.jpg' },
|
|
||||||
{ id: 'ada-mensah', name: 'Ada Mensah', title: 'Secretary' },
|
|
||||||
{ id: 'tom-baird', name: 'Tom Baird', title: 'Treasurer', photo: 'tom-baird.jpg' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0013',
|
|
||||||
date: '2025-12-28',
|
|
||||||
precision: 'day',
|
|
||||||
kind: 'event',
|
|
||||||
title: 'Winter Gathering',
|
|
||||||
ref: { kind: 'event', id: 'winter-gathering-2025' },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0014',
|
|
||||||
date: '2025-07-19',
|
|
||||||
precision: 'day',
|
|
||||||
kind: 'award',
|
|
||||||
title: 'Service Award',
|
|
||||||
meta: 'Presented to the Southeast chapter leads',
|
|
||||||
ref: { kind: 'award', id: 'service' },
|
|
||||||
logo: { file: 'service-award.svg', kind: 'award' },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0015',
|
|
||||||
date: '2025-07-17',
|
|
||||||
precision: 'day',
|
|
||||||
kind: 'event',
|
|
||||||
title: 'Summer Conference',
|
|
||||||
meta: 'Three days, 140 attendees',
|
|
||||||
ref: { kind: 'event', id: 'summer-2025' },
|
|
||||||
logo: { file: 'summer-conference.svg', kind: 'event' },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0016',
|
|
||||||
date: '2025',
|
|
||||||
precision: 'year',
|
|
||||||
kind: 'milestone',
|
|
||||||
title: 'Photo archive digitized',
|
|
||||||
blurb: 'Roughly 4,000 images from 2003 onward, scanned by volunteers.',
|
|
||||||
href: 'https://archive.nextgenerationofunity.org',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0017',
|
|
||||||
date: '2024-09',
|
|
||||||
precision: 'month',
|
|
||||||
kind: 'milestone',
|
|
||||||
title: 'Bylaws rewritten',
|
|
||||||
blurb:
|
|
||||||
'Term limits, a defined handoff window, and the first written process for chartering a chapter.',
|
|
||||||
featured: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0018',
|
|
||||||
date: '2024-07-11',
|
|
||||||
precision: 'day',
|
|
||||||
kind: 'event',
|
|
||||||
title: 'Summer Conference',
|
|
||||||
ref: { kind: 'event', id: 'summer-2024' },
|
|
||||||
logo: { file: 'summer-conference.svg', kind: 'event' },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0019',
|
|
||||||
date: '2024-07-13',
|
|
||||||
precision: 'day',
|
|
||||||
kind: 'award',
|
|
||||||
title: 'Emerging Leader Award',
|
|
||||||
meta: 'First year the award was given',
|
|
||||||
ref: { kind: 'award', id: 'emerging-leader' },
|
|
||||||
logo: { file: 'emerging-leader.svg', kind: 'award' },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0020',
|
|
||||||
date: '2022-06',
|
|
||||||
precision: 'month',
|
|
||||||
kind: 'event',
|
|
||||||
title: 'First in-person rally since 2019',
|
|
||||||
blurb: 'Sixty-one people, most of whom had only ever met on a video call.',
|
|
||||||
featured: true,
|
|
||||||
ref: { kind: 'event', id: 'return-rally-2022' },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0021',
|
|
||||||
date: '2021-08',
|
|
||||||
precision: 'month',
|
|
||||||
kind: 'event',
|
|
||||||
title: 'Online Summer Intensive',
|
|
||||||
meta: 'Six sessions across two weeks',
|
|
||||||
ref: { kind: 'event', id: 'online-intensive-2021' },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0022',
|
|
||||||
date: '2020-03',
|
|
||||||
precision: 'month',
|
|
||||||
kind: 'milestone',
|
|
||||||
title: 'All gatherings suspended',
|
|
||||||
blurb: 'Weekly online rooms started the following week and ran for 118 weeks.',
|
|
||||||
},
|
|
||||||
|
|
||||||
// ——— 2010s ———
|
|
||||||
{
|
|
||||||
id: 'tl-0030',
|
|
||||||
date: '2018-05',
|
|
||||||
precision: 'month',
|
|
||||||
kind: 'organization',
|
|
||||||
title: 'Eighth region recognized',
|
|
||||||
featured: true,
|
|
||||||
ref: { kind: 'organization', id: 'northwest', orgKind: 'region' },
|
|
||||||
logo: { file: 'northwest.svg', kind: 'organization' },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0031',
|
|
||||||
date: '2018-07-20',
|
|
||||||
precision: 'day',
|
|
||||||
kind: 'event',
|
|
||||||
title: 'Summer Conference',
|
|
||||||
ref: { kind: 'event', id: 'summer-2018' },
|
|
||||||
logo: { file: 'summer-conference.svg', kind: 'event' },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0032',
|
|
||||||
date: '2016-02',
|
|
||||||
precision: 'month',
|
|
||||||
kind: 'people',
|
|
||||||
title: 'Retreat Team formed',
|
|
||||||
blurb:
|
|
||||||
'Programming had been whoever volunteered. This made it a standing team with a handoff.',
|
|
||||||
ref: { kind: 'team', id: 'ngu-retreat-team' },
|
|
||||||
team: { id: 'ngu-retreat-team', name: 'Retreat Team', orgId: 'ngu', orgName: 'NGU National' },
|
|
||||||
people: [
|
|
||||||
{ id: 'marcus-hale', name: 'Marcus Hale', title: 'Founding lead', photo: 'marcus-hale.jpg' },
|
|
||||||
{ id: 'priya-nair', name: 'Priya Nair', photo: 'priya-nair.jpg' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0033',
|
|
||||||
date: '2015-07',
|
|
||||||
precision: 'month',
|
|
||||||
kind: 'award',
|
|
||||||
title: 'First Service Award presented',
|
|
||||||
blurb: 'Created to name the work that had been going unnamed for a decade.',
|
|
||||||
featured: true,
|
|
||||||
ref: { kind: 'award', id: 'service' },
|
|
||||||
logo: { file: 'service-award.svg', kind: 'award' },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0034',
|
|
||||||
date: '2015-02',
|
|
||||||
precision: 'month',
|
|
||||||
kind: 'milestone',
|
|
||||||
title: 'Shared calendar goes live',
|
|
||||||
blurb: 'Regions stop scheduling on top of each other.',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0035',
|
|
||||||
date: '2012-06',
|
|
||||||
precision: 'month',
|
|
||||||
kind: 'event',
|
|
||||||
title: 'Summer Conference',
|
|
||||||
meta: 'The year attendance first passed 100',
|
|
||||||
ref: { kind: 'event', id: 'summer-2012' },
|
|
||||||
logo: { file: 'summer-conference.svg', kind: 'event' },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0036',
|
|
||||||
date: '2012',
|
|
||||||
precision: 'year',
|
|
||||||
kind: 'milestone',
|
|
||||||
title: 'Adopted the name Next Generation of Unity',
|
|
||||||
},
|
|
||||||
|
|
||||||
// ——— 2000s ———
|
|
||||||
{
|
|
||||||
id: 'tl-0040',
|
|
||||||
date: '2009',
|
|
||||||
precision: 'year',
|
|
||||||
kind: 'milestone',
|
|
||||||
title: 'Four regions drawn on a map for the first time',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0041',
|
|
||||||
date: '2005-08',
|
|
||||||
precision: 'month',
|
|
||||||
kind: 'milestone',
|
|
||||||
title: 'The gathering becomes annual',
|
|
||||||
blurb: 'Before this it happened when someone had the energy to organize it.',
|
|
||||||
featured: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'tl-0042',
|
|
||||||
date: '2002-08',
|
|
||||||
precision: 'month',
|
|
||||||
kind: 'event',
|
|
||||||
title: 'First young adult retreat',
|
|
||||||
meta: 'Nineteen attendees',
|
|
||||||
blurb:
|
|
||||||
'Organized over six weeks at a borrowed retreat center. Everything else on this page follows from it.',
|
|
||||||
featured: true,
|
|
||||||
ref: { kind: 'event', id: 'first-retreat-2002' },
|
|
||||||
},
|
|
||||||
|
|
||||||
// ——— Pre-program ———
|
|
||||||
{
|
|
||||||
id: 'tl-0050',
|
|
||||||
date: '1997',
|
|
||||||
precision: 'year',
|
|
||||||
kind: 'milestone',
|
|
||||||
title: 'Regional youth programs running independently',
|
|
||||||
blurb:
|
|
||||||
'Not NGU, and not connected to each other — but the people who started NGU came out of these.',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
28
src/data/pathIcons.ts
Normal file
28
src/data/pathIcons.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
/* ═══════════════════════════════════════════════════════════════
|
||||||
|
PATH ICONS
|
||||||
|
|
||||||
|
The icons a "Find your way in" path can show (Front page →
|
||||||
|
Connect Nav → Icon), as [key, label]. The admin's dropdown lists
|
||||||
|
the labels; Pathfinder.tsx draws the Phosphor icon for each key.
|
||||||
|
Adding one is a line here and one in ICONS in Pathfinder.tsx.
|
||||||
|
|
||||||
|
A path saved before this list existed may hold an emoji instead
|
||||||
|
of a key; Pathfinder shows that as it is.
|
||||||
|
═══════════════════════════════════════════════════════════════ */
|
||||||
|
|
||||||
|
export const PATH_ICONS: [string, string][] = [
|
||||||
|
['heart', 'Heart'],
|
||||||
|
['hands', 'Helping hand'],
|
||||||
|
['people', 'People'],
|
||||||
|
['calendar', 'Calendar'],
|
||||||
|
['tent', 'Retreat (tent)'],
|
||||||
|
['map', 'Map pin'],
|
||||||
|
['home', 'Home'],
|
||||||
|
['book', 'Book'],
|
||||||
|
['learn', 'Graduation cap'],
|
||||||
|
['chat', 'Speech bubble'],
|
||||||
|
['music', 'Music'],
|
||||||
|
['compass', 'Compass'],
|
||||||
|
['sparkle', 'Sparkle'],
|
||||||
|
['star', 'Star'],
|
||||||
|
]
|
||||||
169
src/index.css
169
src/index.css
|
|
@ -1,13 +1,94 @@
|
||||||
@import '@fontsource/montserrat/400.css';
|
@import '@fontsource/montserrat/400.css';
|
||||||
@import '@fontsource/montserrat/600.css';
|
@import '@fontsource/montserrat/600.css';
|
||||||
|
@import '@fontsource/montserrat/700.css';
|
||||||
@import '@fontsource/poppins/400.css';
|
@import '@fontsource/poppins/400.css';
|
||||||
@import '@fontsource/poppins/600.css';
|
@import '@fontsource/poppins/600.css';
|
||||||
|
@import '@fontsource/poppins/700.css';
|
||||||
|
@import '@fontsource/poppins/800.css';
|
||||||
|
|
||||||
@import 'tailwindcss';
|
@import 'tailwindcss';
|
||||||
|
|
||||||
@theme {
|
@theme {
|
||||||
--font-display: 'Poppins', sans-serif;
|
--font-display: 'Poppins', sans-serif;
|
||||||
--font-body: 'Montserrat', sans-serif;
|
--font-body: 'Montserrat', sans-serif;
|
||||||
|
|
||||||
|
/* ── Colour tokens ─────────────────────────────────────────────
|
||||||
|
Named for what they do, not what they look like, because dark
|
||||||
|
mode (below) swaps the values. Use them as utilities
|
||||||
|
(text-muted, bg-surface, border-brand/20) or, in a style prop,
|
||||||
|
as var(--color-muted). Every text colour passes WCAG AA (4.5:1)
|
||||||
|
on surface, tint and tint-soft in both modes.
|
||||||
|
|
||||||
|
A colour that must stay the same in both modes (white text on
|
||||||
|
a dark band, a platform's own colour) stays a literal. Colours
|
||||||
|
that arrive as data (page accents, event and region colours) go
|
||||||
|
through withAlpha() and accentText() in src/lib/color.ts. */
|
||||||
|
--color-ink: #073d4a; /* headings */
|
||||||
|
--color-body: #26454c; /* body text */
|
||||||
|
--color-muted: #4a6b72; /* secondary text, quiet borders */
|
||||||
|
--color-link: #0f7183; /* links and teal text */
|
||||||
|
--color-brand: #138ba0; /* decoration: borders, rings, rules */
|
||||||
|
--color-action: #0f7183; /* button fills, under white text */
|
||||||
|
--color-action-hover: #0b5c6a;
|
||||||
|
--color-surface: #ffffff; /* page and cards */
|
||||||
|
--color-tint: #eef9fb; /* tinted sections and panels */
|
||||||
|
--color-tint-soft: #f6fbfc; /* hover rows, faint panels */
|
||||||
|
--color-danger: #b3261e;
|
||||||
|
--color-danger-tint: #fdf3f2;
|
||||||
|
|
||||||
|
/* Tailwind's shadows, tinted with the site's deep ink instead of
|
||||||
|
black, so a card's shadow belongs to the page. */
|
||||||
|
--shadow-2xs: 0 1px rgb(4 38 46 / 0.05);
|
||||||
|
--shadow-xs: 0 1px 2px 0 rgb(4 38 46 / 0.05);
|
||||||
|
--shadow-sm: 0 1px 3px 0 rgb(4 38 46 / 0.1), 0 1px 2px -1px rgb(4 38 46 / 0.1);
|
||||||
|
--shadow-md: 0 4px 6px -1px rgb(4 38 46 / 0.1), 0 2px 4px -2px rgb(4 38 46 / 0.1);
|
||||||
|
--shadow-lg: 0 10px 15px -3px rgb(4 38 46 / 0.12), 0 4px 6px -4px rgb(4 38 46 / 0.1);
|
||||||
|
--shadow-xl: 0 20px 25px -5px rgb(4 38 46 / 0.12), 0 8px 10px -6px rgb(4 38 46 / 0.1);
|
||||||
|
--shadow-2xl: 0 25px 50px -12px rgb(4 38 46 / 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* How much of an accent colour its text keeps (src/lib/color.ts,
|
||||||
|
accentText): all of it on light, half (the rest white) on dark. */
|
||||||
|
:root {
|
||||||
|
--accent-text-mix: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dark mode: the visitor's system setting, unless the header toggle
|
||||||
|
chose (data-theme on <html>, set before first paint in index.html
|
||||||
|
and by ThemeToggle). */
|
||||||
|
@custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));
|
||||||
|
|
||||||
|
@layer base {
|
||||||
|
:root[data-theme="dark"] {
|
||||||
|
--color-ink: #eaf6f8;
|
||||||
|
--color-body: #cde0e4;
|
||||||
|
--color-muted: #9fb9bf;
|
||||||
|
--color-link: #5ccbdc;
|
||||||
|
--color-brand: #2aa7bc;
|
||||||
|
--color-surface: #0c1d21;
|
||||||
|
--color-tint: #11292e;
|
||||||
|
--color-tint-soft: #0f2428;
|
||||||
|
--color-danger: #ff8a80;
|
||||||
|
--color-danger-tint: #3b1714;
|
||||||
|
--accent-text-mix: 50%;
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root:not([data-theme="light"]) {
|
||||||
|
--color-ink: #eaf6f8;
|
||||||
|
--color-body: #cde0e4;
|
||||||
|
--color-muted: #9fb9bf;
|
||||||
|
--color-link: #5ccbdc;
|
||||||
|
--color-brand: #2aa7bc;
|
||||||
|
--color-surface: #0c1d21;
|
||||||
|
--color-tint: #11292e;
|
||||||
|
--color-tint-soft: #0f2428;
|
||||||
|
--color-danger: #ff8a80;
|
||||||
|
--color-danger-tint: #3b1714;
|
||||||
|
--accent-text-mix: 50%;
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
|
|
@ -18,10 +99,32 @@ html {
|
||||||
scroll-behavior: smooth;
|
scroll-behavior: smooth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* One visible focus ring for keyboard users, wherever a component
|
||||||
|
doesn't draw its own. */
|
||||||
|
:focus-visible {
|
||||||
|
outline: 2px solid var(--color-link);
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Visitors who ask for less motion get no smooth scrolling, slides
|
||||||
|
or hover zooms. */
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
html {
|
||||||
|
scroll-behavior: auto;
|
||||||
|
}
|
||||||
|
*,
|
||||||
|
*::before,
|
||||||
|
*::after {
|
||||||
|
animation-duration: 0.01ms !important;
|
||||||
|
animation-iteration-count: 1 !important;
|
||||||
|
transition-duration: 0.01ms !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: 'Montserrat', sans-serif;
|
font-family: 'Montserrat', sans-serif;
|
||||||
background-color: #ffffff;
|
background-color: var(--color-surface);
|
||||||
color: #073d4a;
|
color: var(--color-ink);
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,38 +133,42 @@ h1, h2, h3, h4, h5, h6 {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Gradient utilities */
|
/* A logo on a dark page: many are drawn for white paper (dark marks,
|
||||||
.grad-brand {
|
transparent background) and would vanish. .logo-plate gives them
|
||||||
background: linear-gradient(135deg, #073d4a 0%, #138ba0 45%, #10d48a 100%);
|
a small light backing in dark mode only. */
|
||||||
|
:root[data-theme="dark"] .logo-plate {
|
||||||
|
background: #eef9fb;
|
||||||
|
border-radius: 0.75rem;
|
||||||
|
padding: 0.25rem;
|
||||||
|
}
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root:not([data-theme="light"]) .logo-plate {
|
||||||
|
background: #eef9fb;
|
||||||
|
border-radius: 0.75rem;
|
||||||
|
padding: 0.25rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.grad-brand-light {
|
/* Church Center's giving modal (Giving.tsx) is a transparent iframe
|
||||||
background: linear-gradient(135deg, #0a5260 0%, #17aac4 50%, #00e676 100%);
|
over the whole page, drawn for light pages. On a dark page the
|
||||||
|
browser sees the iframe's scheme differ from ours and paints its
|
||||||
|
background opaque, so the page behind goes solid white. Telling it
|
||||||
|
the iframe is light keeps the backdrop see-through. */
|
||||||
|
iframe[src*="churchcenter"] {
|
||||||
|
color-scheme: light;
|
||||||
}
|
}
|
||||||
|
|
||||||
.grad-dark {
|
/* Corners, one rule for the site: actions (buttons, pills, chips)
|
||||||
background: linear-gradient(135deg, #042f3a 0%, #073d4a 60%, #0a5260 100%);
|
are rounded-full; cards and panels are rounded-3xl when large and
|
||||||
}
|
rounded-2xl when small; media and logos inside a card are
|
||||||
|
rounded-xl. PeopleTiles' 2-3px photo frame is its own deliberate
|
||||||
.grad-hero-text {
|
exception. */
|
||||||
background: linear-gradient(90deg, #88b668 0%, #008fa8 100%);
|
|
||||||
-webkit-background-clip: text;
|
|
||||||
-webkit-text-fill-color: transparent;
|
|
||||||
background-clip: text;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Scrollbar hide */
|
/* Scrollbar hide */
|
||||||
::-webkit-scrollbar { width: 6px; }
|
::-webkit-scrollbar { width: 6px; }
|
||||||
::-webkit-scrollbar-track { background: transparent; }
|
::-webkit-scrollbar-track { background: transparent; }
|
||||||
::-webkit-scrollbar-thumb { background: rgba(19, 139, 160, 0.4); border-radius: 3px; }
|
::-webkit-scrollbar-thumb { background: rgba(19, 139, 160, 0.4); border-radius: 3px; }
|
||||||
|
|
||||||
/* Float animation */
|
|
||||||
@keyframes float {
|
|
||||||
0%, 100% { transform: translateY(0px); }
|
|
||||||
50% { transform: translateY(-12px); }
|
|
||||||
}
|
|
||||||
|
|
||||||
.float-anim { display: inline-block; animation: float 4s ease-in-out infinite; will-change: transform;}
|
|
||||||
|
|
||||||
|
|
||||||
.ig-icon { fill: currentColor; transition: fill 200ms ease; }
|
.ig-icon { fill: currentColor; transition: fill 200ms ease; }
|
||||||
|
|
@ -81,13 +188,13 @@ h1, h2, h3, h4, h5, h6 {
|
||||||
gap: 0.25rem 1.5rem;
|
gap: 0.25rem 1.5rem;
|
||||||
grid-template-columns: 2fr 1fr;
|
grid-template-columns: 2fr 1fr;
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"ngu image"
|
"org image"
|
||||||
"info image"
|
"info image"
|
||||||
"desc desc";
|
"desc desc";
|
||||||
}
|
}
|
||||||
|
|
||||||
.ev-ngu {
|
.ev-org {
|
||||||
grid-area: ngu;
|
grid-area: org;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ev-info {
|
.ev-info {
|
||||||
|
|
@ -110,7 +217,7 @@ h1, h2, h3, h4, h5, h6 {
|
||||||
.ev-grid {
|
.ev-grid {
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
"ngu"
|
"org"
|
||||||
"info"
|
"info"
|
||||||
"desc";
|
"desc";
|
||||||
}
|
}
|
||||||
|
|
@ -135,9 +242,9 @@ h1, h2, h3, h4, h5, h6 {
|
||||||
min-height: 22rem;
|
min-height: 22rem;
|
||||||
background: linear-gradient(
|
background: linear-gradient(
|
||||||
100deg,
|
100deg,
|
||||||
rgba(0, 0, 0, 0.04) 30%,
|
color-mix(in srgb, var(--color-muted) 8%, transparent) 30%,
|
||||||
rgba(0, 0, 0, 0.08) 50%,
|
color-mix(in srgb, var(--color-muted) 16%, transparent) 50%,
|
||||||
rgba(0, 0, 0, 0.04) 70%
|
color-mix(in srgb, var(--color-muted) 8%, transparent) 70%
|
||||||
);
|
);
|
||||||
background-size: 200% 100%;
|
background-size: 200% 100%;
|
||||||
animation: skeleton-shimmer 1.4s ease-in-out infinite;
|
animation: skeleton-shimmer 1.4s ease-in-out infinite;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
54
src/lib/adminSchema/awards.ts
Normal file
54
src/lib/adminSchema/awards.ts
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
import { mediaUrl } from "../media.ts";
|
||||||
|
import { PUBLISH_FIELDS } from "./shared.ts";
|
||||||
|
|
||||||
|
/* ── Awards ──────────────────────────────────────────────────── */
|
||||||
|
|
||||||
|
export const awards = {
|
||||||
|
key: "awards",
|
||||||
|
label: "Awards",
|
||||||
|
singular: "award",
|
||||||
|
idLabel: "URL ID",
|
||||||
|
slugFrom: "name",
|
||||||
|
|
||||||
|
list: {
|
||||||
|
columns: [
|
||||||
|
{ key: "name", label: "Name", primary: true },
|
||||||
|
{ key: "org_id", label: "Awarded by" },
|
||||||
|
{ key: "description", label: "Description" },
|
||||||
|
{ key: "is_published", label: "Live", widget: "bool" },
|
||||||
|
{ key: "is_listed", label: "Listed", widget: "bool" },
|
||||||
|
],
|
||||||
|
filters: [
|
||||||
|
{ key: "org_id", label: "Awarded by", optionsFrom: "organizations" },
|
||||||
|
{ key: "is_published", label: "Published", options: [["1", "Live"], ["0", "Hidden"]] },
|
||||||
|
{ key: "is_listed", label: "Listed", options: [["1", "Listed"], ["0", "Link only"]] },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
groups: [
|
||||||
|
{
|
||||||
|
legend: "Identity",
|
||||||
|
note:
|
||||||
|
"An award exists whether or not anyone has received it. " +
|
||||||
|
"Who received it is edited on the person.",
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
path: "org_id",
|
||||||
|
label: "Awarded by",
|
||||||
|
widget: "select",
|
||||||
|
optionsFrom: "organizations",
|
||||||
|
blankLabel: "- unattributed -",
|
||||||
|
help: "The organization that gives this award",
|
||||||
|
},
|
||||||
|
{ path: "name", label: "Name", required: true },
|
||||||
|
{ path: "description", label: "Description", widget: "textarea", full: true },
|
||||||
|
{ path: "logo", label: "Logo", widget: "image", resolve: mediaUrl, full: true },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
legend: "Publishing",
|
||||||
|
note: "An unpublished award is a draft: off the site, and a 404 at its own page.",
|
||||||
|
fields: PUBLISH_FIELDS,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
190
src/lib/adminSchema/blog.ts
Normal file
190
src/lib/adminSchema/blog.ts
Normal file
|
|
@ -0,0 +1,190 @@
|
||||||
|
import { preview } from "../text.ts";
|
||||||
|
import { mediaUrl } from "../media.ts";
|
||||||
|
import { PUBLISHED_FIELD, LISTED_FIELD, FEATURED_KINDS, featuredCardsChild, blocksChild } from "./shared.ts";
|
||||||
|
|
||||||
|
/* ── Blog (031_blog.sql) ─────────────────────────────────────────
|
||||||
|
Posts at /blog/:id, and the Community page's blog section. The
|
||||||
|
section's community posts reuse the featured cards, limited to
|
||||||
|
links: a pinned Substack post is a link card, and Fetch preview
|
||||||
|
fills it from the post. */
|
||||||
|
|
||||||
|
/* A post's body is the content blocks without the card/body choice:
|
||||||
|
a post only has a body. */
|
||||||
|
const blogBlocksChild = {
|
||||||
|
...blocksChild,
|
||||||
|
label: "Post body",
|
||||||
|
note: "The post, top to bottom. The first paragraph doubles as the excerpt when that's left blank.",
|
||||||
|
fields: blocksChild.fields.filter((field) => field.path !== "slot"),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const blogPosts = {
|
||||||
|
key: "blog_posts",
|
||||||
|
label: "Blog posts",
|
||||||
|
singular: "blog post",
|
||||||
|
idLabel: "URL ID",
|
||||||
|
slugFrom: "title",
|
||||||
|
|
||||||
|
list: {
|
||||||
|
columns: [
|
||||||
|
{ key: "title", label: "Title", primary: true },
|
||||||
|
{ key: "published_on", label: "Date" },
|
||||||
|
{ key: "tags", label: "Tags" },
|
||||||
|
{ key: "is_published", label: "Live", widget: "bool" },
|
||||||
|
{ key: "is_listed", label: "Listed", widget: "bool" },
|
||||||
|
],
|
||||||
|
filters: [
|
||||||
|
{ key: "is_published", label: "Published", options: [["1", "Live"], ["0", "Draft"]] },
|
||||||
|
{ key: "is_listed", label: "Listed", options: [["1", "Listed"], ["0", "Link only"]] },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
groups: [
|
||||||
|
{
|
||||||
|
legend: "Post",
|
||||||
|
fields: [
|
||||||
|
{ path: "title", label: "Title", required: true, full: true },
|
||||||
|
{ path: "published_on", label: "Date", widget: "date", help: "Newest first on the Community page" },
|
||||||
|
{ path: "tags", label: "Tags", help: "Comma separated, eg. Reflection, Event recap" },
|
||||||
|
{
|
||||||
|
path: "excerpt",
|
||||||
|
label: "Excerpt",
|
||||||
|
widget: "textarea",
|
||||||
|
full: true,
|
||||||
|
help: "A sentence or two for the card. Default: the body's first paragraph.",
|
||||||
|
},
|
||||||
|
{ path: "cover_image", label: "Cover image", widget: "image", resolve: mediaUrl, full: true },
|
||||||
|
{
|
||||||
|
path: "show_contents",
|
||||||
|
label: "Show contents",
|
||||||
|
widget: "checkbox",
|
||||||
|
help: "Lists the post's headings beside it, the one being read lit (a fold-out on phones). Worth it for a long post with two or more headings.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "cover_alt",
|
||||||
|
label: "Cover description",
|
||||||
|
full: true,
|
||||||
|
help: "For screen readers: what the cover shows. Default: skipped as decoration.",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
legend: "Guest author",
|
||||||
|
note: "For a writer with no People record. People who wrote it go under Authors below; both can be set.",
|
||||||
|
fields: [
|
||||||
|
{ path: "guest_author", label: "Name" },
|
||||||
|
{ path: "guest_photo", label: "Photo", widget: "image", resolve: mediaUrl, full: true },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
legend: "Publishing",
|
||||||
|
note: "A new post is a draft until Published is ticked. Unlisted posts keep their page and can still be pinned.",
|
||||||
|
fields: [PUBLISHED_FIELD, LISTED_FIELD],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: "authors",
|
||||||
|
label: "Authors",
|
||||||
|
note: "Shown as person tiles at the end of the post, in this order.",
|
||||||
|
addLabel: "Add author",
|
||||||
|
title: (row, options) =>
|
||||||
|
options?.people?.find((p) => p.id === row.person_id)?.label ?? "New author",
|
||||||
|
blank: { person_id: "" },
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
path: "person_id",
|
||||||
|
label: "Person",
|
||||||
|
widget: "select",
|
||||||
|
optionsFrom: "people",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
blogBlocksChild,
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const communityPage = {
|
||||||
|
key: "community_page",
|
||||||
|
label: "Community blog section",
|
||||||
|
singular: "community blog section",
|
||||||
|
idLabel: "Page",
|
||||||
|
singleton: "community",
|
||||||
|
|
||||||
|
list: { columns: [], filters: [] },
|
||||||
|
|
||||||
|
groups: [
|
||||||
|
{
|
||||||
|
legend: "Section",
|
||||||
|
note: "The first section of the Community page.",
|
||||||
|
fields: [
|
||||||
|
{ path: "blog_title", label: "Heading", help: "Default: Community Blog" },
|
||||||
|
{ path: "blog_blurb", label: "Blurb", widget: "textarea", full: true },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
legend: "Our posts",
|
||||||
|
note: "Pinned posts first, then the newest published, listed posts, up to the number of slots.",
|
||||||
|
fields: [
|
||||||
|
{ path: "internal_title", label: "Heading", help: "Default: From NGU" },
|
||||||
|
{ path: "internal_slots", label: "Slots", widget: "number", help: "0 to 12. Default: 3" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
legend: "Community posts",
|
||||||
|
note: "Pinned cards first, then the newest items from the feeds below, up to the number of slots.",
|
||||||
|
fields: [
|
||||||
|
{ path: "external_title", label: "Heading", help: "Default: From our community" },
|
||||||
|
{ path: "external_slots", label: "Slots", widget: "number", help: "0 to 12. Default: 3" },
|
||||||
|
{ path: "external_url", label: "Button link", help: "eg. https://ngu.substack.com", full: true },
|
||||||
|
{ path: "external_label", label: "Button text", help: "Default: Read more on Substack" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: "pinned_posts",
|
||||||
|
label: "Pinned posts (ours)",
|
||||||
|
note: "Always shown, before the newest.",
|
||||||
|
addLabel: "Pin a post",
|
||||||
|
title: (row, options) =>
|
||||||
|
options?.blog_posts?.find((p) => p.id === row.post_id)?.label ?? "New pin",
|
||||||
|
blank: { post_id: "" },
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
path: "post_id",
|
||||||
|
label: "Post",
|
||||||
|
widget: "select",
|
||||||
|
optionsFrom: "blog_posts",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...featuredCardsChild,
|
||||||
|
label: "Pinned community posts",
|
||||||
|
note: "Always shown, before the feeds' newest. Paste a post's link and press Fetch preview.",
|
||||||
|
addLabel: "Pin a post",
|
||||||
|
blank: { kind: "", url: "", title: "" },
|
||||||
|
fields: featuredCardsChild.fields.map((field) =>
|
||||||
|
field.path === "kind"
|
||||||
|
? { ...field, options: FEATURED_KINDS.filter(([kind]) => kind !== "record") }
|
||||||
|
: field,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "feeds",
|
||||||
|
label: "Feeds",
|
||||||
|
note: "RSS or Atom feeds whose newest posts fill the community slots. Read about every 30 minutes.",
|
||||||
|
addLabel: "Add feed",
|
||||||
|
title: (row) => row.label || row.url || "New feed",
|
||||||
|
blank: { url: "", label: "" },
|
||||||
|
fields: [
|
||||||
|
{ path: "url", label: "Feed URL", required: true, full: true, help: "eg. https://ngu.substack.com/feed" },
|
||||||
|
{ path: "label", label: "Source name", help: "Shown on its cards. Default: the feed's own title" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
203
src/lib/adminSchema/events.ts
Normal file
203
src/lib/adminSchema/events.ts
Normal file
|
|
@ -0,0 +1,203 @@
|
||||||
|
import { mediaUrl } from "../media.ts";
|
||||||
|
import { PLACE_FIELDS, PUBLISHED_FIELD, LISTED_FIELD, timelineGroup, timelineDetailGroup, linksChild, hostsChild, blocksChild } from "./shared.ts";
|
||||||
|
|
||||||
|
/* ── Events ──────────────────────────────────────────────────── */
|
||||||
|
|
||||||
|
/* The panel the Series checkbox opens. Starts and Ends above stay
|
||||||
|
the series' bounds (the first meeting and the last day it can
|
||||||
|
meet), so nothing here repeats them. */
|
||||||
|
const SERIES_WEEKDAYS = [
|
||||||
|
["sun", "Sunday"],
|
||||||
|
["mon", "Monday"],
|
||||||
|
["tue", "Tuesday"],
|
||||||
|
["wed", "Wednesday"],
|
||||||
|
["thu", "Thursday"],
|
||||||
|
["fri", "Friday"],
|
||||||
|
["sat", "Saturday"],
|
||||||
|
];
|
||||||
|
|
||||||
|
const seriesGroup = {
|
||||||
|
legend: "Series",
|
||||||
|
when: { path: "is_series", value: 1 },
|
||||||
|
note:
|
||||||
|
"Starts is the first meeting and anchors the schedule; Ends, if set, is the last " +
|
||||||
|
"day it can meet. The weekdays only apply to a weekly series; with none ticked it " +
|
||||||
|
"meets on the start date's day. Leave Date label blank and the site describes " +
|
||||||
|
"the schedule itself.",
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
path: "series_frequency",
|
||||||
|
label: "Repeats",
|
||||||
|
widget: "select",
|
||||||
|
options: [
|
||||||
|
["weekly", "Weekly, on the days ticked below"],
|
||||||
|
["monthly_date", "Monthly, on the day of the start date (eg. the 13th)"],
|
||||||
|
["monthly_weekday", "Monthly, on the weekday of the start date (eg. 2nd Tuesday)"],
|
||||||
|
],
|
||||||
|
blankLabel: "Default: weekly",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "series_interval",
|
||||||
|
label: "Every",
|
||||||
|
widget: "number",
|
||||||
|
help: "1 for every week or month, 2 for every other, and so on",
|
||||||
|
},
|
||||||
|
{ path: "series_start_time", label: "Start time", widget: "time" },
|
||||||
|
{ path: "series_end_time", label: "End time", widget: "time" },
|
||||||
|
{
|
||||||
|
path: "series_count",
|
||||||
|
label: "Number of meetings",
|
||||||
|
widget: "number",
|
||||||
|
help: "Stops after this many. Blank to run until Ends, or indefinitely",
|
||||||
|
},
|
||||||
|
...SERIES_WEEKDAYS.map(([day, name]) => ({
|
||||||
|
path: `series_${day}`,
|
||||||
|
label: name,
|
||||||
|
widget: "checkbox",
|
||||||
|
help: `Meets on ${name}s`,
|
||||||
|
})),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const events = {
|
||||||
|
key: "events",
|
||||||
|
label: "Events",
|
||||||
|
singular: "event",
|
||||||
|
idLabel: "URL ID",
|
||||||
|
slugFrom: "title",
|
||||||
|
|
||||||
|
list: {
|
||||||
|
columns: [
|
||||||
|
{ key: "title", label: "Title", primary: true },
|
||||||
|
{ key: "scope_id", label: "Scope" },
|
||||||
|
{ key: "event_type", label: "Type" },
|
||||||
|
{ key: "date_label", label: "Dates" },
|
||||||
|
{ key: "status", label: "Status" },
|
||||||
|
{ key: "is_published", label: "Live", widget: "bool" },
|
||||||
|
{ key: "is_listed", label: "Listed", widget: "bool" },
|
||||||
|
],
|
||||||
|
filters: [
|
||||||
|
{ key: "scope_id", label: "Scope", optionsFrom: "event_scopes" },
|
||||||
|
{
|
||||||
|
key: "event_type",
|
||||||
|
label: "Type",
|
||||||
|
options: ["retreat", "class", "workshop", "meeting", "other"],
|
||||||
|
},
|
||||||
|
{ key: "status", label: "Status", options: ["upcoming", "past", "cancelled"] },
|
||||||
|
{ key: "is_published", label: "Published", options: [["1", "Live"], ["0", "Hidden"]] },
|
||||||
|
{ key: "is_listed", label: "Listed", options: [["1", "Listed"], ["0", "Link only"]] },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
groups: [
|
||||||
|
{
|
||||||
|
legend: "Identity",
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
path: "scope_id",
|
||||||
|
label: "Scope",
|
||||||
|
widget: "select",
|
||||||
|
optionsFrom: "event_scopes",
|
||||||
|
required: true,
|
||||||
|
help: "Whose gathering this is.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "event_type",
|
||||||
|
label: "Type",
|
||||||
|
widget: "select",
|
||||||
|
options: ["retreat", "class", "workshop", "meeting", "other"],
|
||||||
|
required: true,
|
||||||
|
help: "What kind of gathering. Independent of the scope",
|
||||||
|
},
|
||||||
|
{ path: "title", label: "Title", required: true },
|
||||||
|
{ path: "theme", label: "Theme" },
|
||||||
|
{ path: "tagline", label: "Tagline", full: true },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
legend: "When",
|
||||||
|
fields: [
|
||||||
|
{ path: "starts_on", label: "Starts", widget: "date" },
|
||||||
|
{ path: "ends_on", label: "Ends", widget: "date" },
|
||||||
|
{
|
||||||
|
path: "date_label",
|
||||||
|
label: "Date label",
|
||||||
|
help: "Text override of what the card shows (eg. March/April 2026)",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "status",
|
||||||
|
label: "Status",
|
||||||
|
widget: "select",
|
||||||
|
options: ["upcoming", "past", "cancelled"],
|
||||||
|
blankLabel: "Default: derive from end date",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "is_series",
|
||||||
|
label: "Series",
|
||||||
|
widget: "checkbox",
|
||||||
|
help: "Repeats on a schedule, such as a weekly class, a monthly meeting",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
seriesGroup,
|
||||||
|
{ legend: "Where", fields: PLACE_FIELDS },
|
||||||
|
{
|
||||||
|
legend: "Appearance",
|
||||||
|
fields: [
|
||||||
|
{ path: "event_logo", label: "Event logo", widget: "image", resolve: mediaUrl, full: true },
|
||||||
|
{ path: "org_logo", label: "Org logo override", widget: "image", resolve: mediaUrl, full: true },
|
||||||
|
{ path: "color", label: "Colour", widget: "color" },
|
||||||
|
{
|
||||||
|
path: "card_image",
|
||||||
|
label: "Card background",
|
||||||
|
widget: "image",
|
||||||
|
resolve: mediaUrl,
|
||||||
|
full: true,
|
||||||
|
help: "A photo behind the event's card, faded so the text stays readable.",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
timelineGroup("event"),
|
||||||
|
timelineDetailGroup("event"),
|
||||||
|
{ legend: "Publishing", fields: [PUBLISHED_FIELD, LISTED_FIELD] },
|
||||||
|
],
|
||||||
|
|
||||||
|
children: [
|
||||||
|
hostsChild,
|
||||||
|
{
|
||||||
|
key: "event_people",
|
||||||
|
label: "People at this event",
|
||||||
|
addLabel: "Add person",
|
||||||
|
title: (row, options) =>
|
||||||
|
options?.people?.find((p) => p.id === row.person_id)?.label ?? "New person",
|
||||||
|
blank: { person_id: "", role: "speaker", is_public: 1 },
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
path: "person_id",
|
||||||
|
label: "Person",
|
||||||
|
widget: "select",
|
||||||
|
optionsFrom: "people",
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "role",
|
||||||
|
label: "Role",
|
||||||
|
widget: "select",
|
||||||
|
options: [
|
||||||
|
"speaker",
|
||||||
|
"leader",
|
||||||
|
"facilitator",
|
||||||
|
"host",
|
||||||
|
"musician",
|
||||||
|
"volunteer",
|
||||||
|
"attendee",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{ path: "title", label: "Title", help: "eg. Keynote Speaker" },
|
||||||
|
{ path: "is_public", label: "Show on the site", widget: "checkbox" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
linksChild,
|
||||||
|
blocksChild,
|
||||||
|
],
|
||||||
|
};
|
||||||
251
src/lib/adminSchema/frontPage.ts
Normal file
251
src/lib/adminSchema/frontPage.ts
Normal file
|
|
@ -0,0 +1,251 @@
|
||||||
|
import { mediaUrl } from "../media.ts";
|
||||||
|
import { featuredCardsChild } from "./shared.ts";
|
||||||
|
import { PATH_ICONS } from "../../data/pathIcons.ts";
|
||||||
|
|
||||||
|
/* ── Front page ──────────────────────────────────────────────────
|
||||||
|
|
||||||
|
One record (see the singleton note in server/src/admin-schema.js).
|
||||||
|
The groups are the hero; the collections below are the rest of
|
||||||
|
the page. Photos, the livestream and the featured video are
|
||||||
|
editable whatever the mode, so each can be ready before the
|
||||||
|
switch is flipped.
|
||||||
|
|
||||||
|
Section keys and stat sources are the CHECK lists on
|
||||||
|
front_page_sections and front_page_stats. The labels here are what the admin reads; the values are
|
||||||
|
what the page and the API key on. */
|
||||||
|
|
||||||
|
const FRONT_PAGE_SECTIONS = [
|
||||||
|
["countdown", "Event Countdown"],
|
||||||
|
["retreats", "Events Carousel (National Retreats)"],
|
||||||
|
["calendar", "Event Calendar"],
|
||||||
|
["stats", "Stats"],
|
||||||
|
["timeline", "Featured Timeline"],
|
||||||
|
["connect", "Connect Nav"],
|
||||||
|
["featured", "Featured Content"],
|
||||||
|
];
|
||||||
|
|
||||||
|
const STAT_SOURCES = [
|
||||||
|
["manual", "Print Value Field"],
|
||||||
|
["years_since", "Years Since Value"],
|
||||||
|
["regions", "Count: regions"],
|
||||||
|
["chapters", "Count: chapters"],
|
||||||
|
["partners", "Count: partners"],
|
||||||
|
["events_held", "Count: past events"],
|
||||||
|
["retreats_held", "Count: past retreats"],
|
||||||
|
["people", "Count: people in database"],
|
||||||
|
["awards_given", "Count: public awards given"],
|
||||||
|
];
|
||||||
|
|
||||||
|
export const frontPage = {
|
||||||
|
key: "front_page",
|
||||||
|
label: "Front page",
|
||||||
|
singular: "front page",
|
||||||
|
idLabel: "Page",
|
||||||
|
singleton: "home",
|
||||||
|
|
||||||
|
list: { columns: [], filters: [] },
|
||||||
|
|
||||||
|
groups: [
|
||||||
|
{
|
||||||
|
legend: "Hero - Primary Section",
|
||||||
|
note: "The first thing a visitor sees. Blank buttons don't render.",
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
path: "hero_backdrop",
|
||||||
|
label: "Background",
|
||||||
|
widget: "select",
|
||||||
|
options: [
|
||||||
|
["brand", "Brand: animated colour and the dove"],
|
||||||
|
["photos", "Photos: cycles through the photos below"],
|
||||||
|
],
|
||||||
|
blankLabel: "Default: brand",
|
||||||
|
help: "Photos with none added shows the brand background",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "hero_feature",
|
||||||
|
label: "Feature",
|
||||||
|
widget: "select",
|
||||||
|
options: [
|
||||||
|
["none", "Nothing: No additional overlay"],
|
||||||
|
["livestream", "Livestream: the stream, with a LIVE badge"],
|
||||||
|
["video", "Featured video: click to play"],
|
||||||
|
["event", "Featured event: an event's card"],
|
||||||
|
],
|
||||||
|
blankLabel: "Default: nothing",
|
||||||
|
help: "Switch to Livestream when you go live, and back when you're done",
|
||||||
|
},
|
||||||
|
{ path: "eyebrow", label: "Eyebrow", help: "Small line above the headline" },
|
||||||
|
{ path: "headline", label: "Headline", full: true },
|
||||||
|
{ path: "subhead", label: "Subhead", widget: "textarea", full: true },
|
||||||
|
{ path: "primary_label", label: "Main button label" },
|
||||||
|
{ path: "primary_url", label: "Main button link", help: "/page, #section-id or a full URL" },
|
||||||
|
{ path: "secondary_label", label: "Second button label" },
|
||||||
|
{ path: "secondary_url", label: "Second button link" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
legend: "Photos, livestream, video and event",
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
path: "slide_seconds",
|
||||||
|
label: "Seconds per photo",
|
||||||
|
widget: "number",
|
||||||
|
help: "Photos Background. Set from 3 to 60 seconds",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "livestream_url",
|
||||||
|
label: "Livestream link",
|
||||||
|
full: true,
|
||||||
|
help: "A YouTube, Facebook or Vimeo link, or any embed URL",
|
||||||
|
},
|
||||||
|
{ path: "livestream_title", label: "Livestream title", full: true },
|
||||||
|
{
|
||||||
|
path: "video_url",
|
||||||
|
label: "Featured video",
|
||||||
|
full: true,
|
||||||
|
help:
|
||||||
|
"A YouTube, Vimeo or Facebook link, or a video file: a filename in " +
|
||||||
|
"the uploads folder, or a link ending in .mp4 or .webm",
|
||||||
|
},
|
||||||
|
{ path: "video_title", label: "Video title", full: true, help: "Shown after \"Featured video\" above the headline" },
|
||||||
|
{
|
||||||
|
path: "hero_event_id",
|
||||||
|
label: "Featured event",
|
||||||
|
widget: "select",
|
||||||
|
optionsFrom: "events",
|
||||||
|
blankLabel: "Default: the countdown's event",
|
||||||
|
full: true,
|
||||||
|
help: "For the Featured event feature. A pinned event that's over falls back to the countdown's",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
legend: "Countdown",
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
path: "countdown_event_id",
|
||||||
|
label: "Count down to",
|
||||||
|
widget: "select",
|
||||||
|
optionsFrom: "events",
|
||||||
|
blankLabel: "Default: the next upcoming event",
|
||||||
|
help: "Leave blank almost always. A pinned event that's over falls back to the next one",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "countdown_scope_id",
|
||||||
|
label: "Only this scope",
|
||||||
|
widget: "select",
|
||||||
|
optionsFrom: "event_scopes",
|
||||||
|
blankLabel: "Default: any scope",
|
||||||
|
help: "Narrows the next upcoming event. Ignored when an event is pinned above",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "countdown_event_type",
|
||||||
|
label: "Only this type",
|
||||||
|
widget: "select",
|
||||||
|
options: [
|
||||||
|
["retreat", "Retreat"],
|
||||||
|
["class", "Class"],
|
||||||
|
["workshop", "Workshop"],
|
||||||
|
["meeting", "Meeting"],
|
||||||
|
["other", "Other"],
|
||||||
|
],
|
||||||
|
blankLabel: "Default: any type",
|
||||||
|
help: "Combines with the scope: National + Retreat counts down to the next national retreat",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: "sections",
|
||||||
|
label: "Page sections",
|
||||||
|
note: "Drag to reorder. Each section can appear once; leave one out to drop it.",
|
||||||
|
addLabel: "Add section",
|
||||||
|
title: (row) =>
|
||||||
|
FRONT_PAGE_SECTIONS.find(([key]) => key === row.section)?.[1] ?? "New section",
|
||||||
|
blank: { section: "", title: "", blurb: "" },
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
path: "section",
|
||||||
|
label: "Section",
|
||||||
|
widget: "select",
|
||||||
|
options: FRONT_PAGE_SECTIONS,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{ path: "title", label: "Heading", help: "Heading Override" },
|
||||||
|
{ path: "blurb", label: "Blurb", full: true },
|
||||||
|
{ path: "is_hidden", label: "Hidden", widget: "checkbox", help: "Hide for now" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "slides",
|
||||||
|
label: "Hero photos",
|
||||||
|
note: "Shown in Photos mode, in this order.",
|
||||||
|
addLabel: "Add photo",
|
||||||
|
title: (row) => row.caption || row.media || "New photo",
|
||||||
|
blank: { media: "", alt: "", caption: "" },
|
||||||
|
fields: [
|
||||||
|
{ path: "media", label: "Photo", required: true, widget: "image", resolve: mediaUrl, full: true },
|
||||||
|
{ path: "alt", label: "Description", help: "For screen readers" },
|
||||||
|
{ path: "caption", label: "Caption", full: true },
|
||||||
|
{ path: "link_url", label: "Link", help: "Optional; makes the caption a link" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "stats",
|
||||||
|
label: "Numbers",
|
||||||
|
note: "Counts update themselves. A typed-in number with no value is left out.",
|
||||||
|
addLabel: "Add number",
|
||||||
|
title: (row) => row.label || "New number",
|
||||||
|
blank: { label: "", source: "", value: "" },
|
||||||
|
fields: [
|
||||||
|
{ path: "label", label: "Label", required: true },
|
||||||
|
{
|
||||||
|
path: "source",
|
||||||
|
label: "Number Source",
|
||||||
|
widget: "select",
|
||||||
|
options: STAT_SOURCES,
|
||||||
|
blankLabel: "Default: Print Value",
|
||||||
|
},
|
||||||
|
{ path: "value", label: "Value", help: "The number thats printed" },
|
||||||
|
{ path: "suffix", label: "Suffix", help: "+, k, % …" },
|
||||||
|
{ path: "note", label: "Note", full: true },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
featuredCardsChild,
|
||||||
|
{
|
||||||
|
key: "paths",
|
||||||
|
label: "Connect Nav",
|
||||||
|
note: "Each path is a choice a visitor can pick; its actions appear when they do.",
|
||||||
|
addLabel: "Add path",
|
||||||
|
title: (row) => row.label || "New path",
|
||||||
|
blank: { label: "", icon: "", blurb: "" },
|
||||||
|
fields: [
|
||||||
|
{ path: "label", label: "Label", required: true, help: "eg. Attend, Serve…" },
|
||||||
|
{
|
||||||
|
path: "icon",
|
||||||
|
label: "Icon",
|
||||||
|
widget: "select",
|
||||||
|
options: PATH_ICONS,
|
||||||
|
blankLabel: "Default: a dot",
|
||||||
|
},
|
||||||
|
{ path: "blurb", label: "Blurb", full: true },
|
||||||
|
],
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
key: "actions",
|
||||||
|
label: "Actions",
|
||||||
|
addLabel: "Add action",
|
||||||
|
title: (row) => row.label || "New action",
|
||||||
|
blank: { label: "", url: "" },
|
||||||
|
fields: [
|
||||||
|
{ path: "label", label: "Label", required: true },
|
||||||
|
{ path: "url", label: "Link", required: true },
|
||||||
|
{ path: "description", label: "Description", full: true },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue