From 43797f38bca735c23ab0ca167a8c035df71acf62 Mon Sep 17 00:00:00 2001 From: Zaldimmar Date: Wed, 30 Sep 2026 23:37:35 -0500 Subject: [PATCH 001/128] Cleanup of old-data fixes; an editor for the Organization page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nothing before these changes was ever public, so the fixes kept for older data go: the /leadership redirect (MOVED in routes/pages.js), index.html's move of "ngu-" browser keys to "site-", the boot-time sorting of images from before folders (media.js), and emoji path icons (a path with no named icon shows a dot; migration 055 turns the baseline's seeded emoji into their names). Pages → Organization page (migration 055): a singleton with the Mission, Vision & Values blocks, the Leadership blocks (a People block per team, in order) with a heading and blurb, and Volunteering (title, blurb, links). content_blocks gains the two owner kinds; GET /organization-page serves it. Co-Authored-By: Claude Opus 5.5 --- docs/media-uploads.md | 10 -- index.html | 10 -- server/src/admin-schema.js | 2 + server/src/admin-schema/organizationPage.js | 43 ++++++ server/src/index.js | 7 +- server/src/media.js | 83 +---------- .../src/migrations/055_organization_page.sql | 134 ++++++++++++++++++ server/src/routes/organizationPage.js | 43 ++++++ server/src/routes/pages.js | 14 -- src/data/pathIcons.ts | 4 +- src/lib/adminSchema.ts | 2 + src/lib/adminSchema/organizationPage.ts | 71 ++++++++++ src/pages/admin/adminNav.ts | 5 + src/pages/sections/home/Pathfinder.tsx | 7 +- 14 files changed, 308 insertions(+), 127 deletions(-) create mode 100644 server/src/admin-schema/organizationPage.js create mode 100644 server/src/migrations/055_organization_page.sql create mode 100644 server/src/routes/organizationPage.js create mode 100644 src/lib/adminSchema/organizationPage.ts diff --git a/docs/media-uploads.md b/docs/media-uploads.md index bb2bfe3..a0e025e 100644 --- a/docs/media-uploads.md +++ b/docs/media-uploads.md @@ -38,16 +38,6 @@ Each image's `-640.webp` small copy sits beside it. Video and audio clips (Tools → Video clips) stay in the root. The Media page and every image picker have a tab per folder; a picker opens on its field's folder, and uploads there. - -**Images from before folders** (a bare name in the root) are sorted -once, when the server first starts with this version: a logo or icon -field names it → `logos/`; saved as a preview → `thumbnails/`; anything -else → `images/`. Every record that names it is rewritten to the new -path in one transaction, after the files move (if that fails, the files -move back). The journal says `uploads: moved N image(s) into folders`. -Back up the database and uploads before that first start; nothing is -needed after. - nginx needs no change: `location /uploads/` already serves the folders. ## Files copied in by hand diff --git a/index.html b/index.html index c84d3d0..50ffe59 100644 --- a/index.html +++ b/index.html @@ -13,16 +13,6 @@ and the accessibility choices, for the same reason. --> diff --git a/server/src/routes/content.js b/server/src/routes/content.js index 6d65d0e..bbe9bb7 100644 --- a/server/src/routes/content.js +++ b/server/src/routes/content.js @@ -463,7 +463,7 @@ content.get("/events", (c) => { // Optional filters, each narrowing the list (src/lib/eventData.ts): // ?scope=national ?host= ?status=upcoming - // ?type=class,workshop + // ?type=class,workshop ?from=&to= (a date window) ?past=12 const where = [`is_published = 1`, `is_listed = 1`]; const params = []; const scope = c.req.query("scope"); @@ -477,11 +477,38 @@ content.get("/events", (c) => { if (status) where.push(`effective_status = ?`), params.push(status); const types = (c.req.query("type") ?? "").split(",").filter(Boolean).slice(0, 20); if (types.length) where.push(`event_type IN (${marks(types.length)})`), params.push(...types); + // ?from=2026-10-01&to=2026-11-07: only events with a day in that + // window (the calendar's six weeks), plus the undated ones it + // counts. Either end may be left off. A series with no end date + // runs on, so it stays in every window after its start. + const day = (name) => { + const value = c.req.query(name); + return /^\d{4}-\d{2}-\d{2}$/.test(value ?? "") ? value : null; + }; + const from = day("from"); + const to = day("to"); + if (from || to) { + const dated = []; + if (to) dated.push(`starts_on <= ?`), params.push(to); + if (from) { + dated.push(`COALESCE(ends_on, CASE WHEN is_series = 1 THEN '9999-12-31' ELSE starts_on END) >= ?`); + params.push(from); + } + where.push(`(starts_on IS NULL OR (${dated.join(" AND ")}))`); + } - const rows = db + let rows = db .prepare(`SELECT * FROM v_events WHERE ${where.join(" AND ")} ORDER BY ${EVENT_ORDER}`) .all(...params); + // ?past=12: only the 12 most recent past events (a carousel's way + // back), before their links, cards and hosts are loaded. + const past = Number.parseInt(c.req.query("past") ?? "", 10); + if (past >= 0) { + let keep = rows.filter((row) => row.effective_status === "past").length - past; + rows = rows.filter((row) => row.effective_status !== "past" || keep-- <= 0); + } + const ids = rows.map((row) => row.id); const links = loadLinks(db, "event", ids); const cards = loadBlocks(db, "event", ids, "card"); diff --git a/src/components/AccessibilityPanel.tsx b/src/components/AccessibilityPanel.tsx index faf5ecc..9f25f16 100644 --- a/src/components/AccessibilityPanel.tsx +++ b/src/components/AccessibilityPanel.tsx @@ -2,28 +2,42 @@ ACCESSIBILITY PANEL A button fixed to the bottom right of every public page, opening - two switches that change how the whole site reads: + two switches and a choice that change how the whole site reads: Dyslexia-friendly font every typeface becomes OpenDyslexic (self-hosted, index.css) - Reading mode the design steps back: no background - circles, motion or shadows, one column, - larger text and plain underlined links, - the same content throughout + Reading mode the page as plain text: one column of + ink on white, no colors, pictures, + cards or motion; a picture's + description stays in its place + Color blind mode the palette swapped so its colors stay + apart for that type of color blindness, + or grays (color.ts, VISIONS) - Each is a data attribute on (data-font, data-reading) that - index.css styles, saved in this browser (site-font, site-reading) - and set again before the first paint by index.html, so a page - never flashes the other look. Blocked storage just means the - choice lasts until the tab closes. + Each is a data attribute on (data-font, data-reading, + data-vision) that index.css styles, saved in this browser + (site-font, site-reading, site-vision) and set again before the + first paint by index.html, so a page never flashes the other + look. A color blind mode reloads the page, since colors set from + code and data are swapped as they load. Blocked storage just + means the choice lasts until the tab closes. - The panel closes on Escape, on the button again, or a click + Reading and color blind modes belong to the public pages, which + are the only ones with this panel: it sets them when they mount + and clears them when the admin takes over (index.html leaves them + off there too), since the admin edits the colors and layout they + would hide. The font follows the visitor everywhere. + + The panel opens on its first switch, comes after its button in + the Tab order, closes on Escape, on the button again, or a click anywhere else, and gives focus back to the button. ═══════════════════════════════════════════════════════════════ */ import { PersonArmsSpread, X } from '@phosphor-icons/react' import { useEffect, useId, useRef, useState } from 'react' +import { VISIONS } from '../lib/color.ts' + /* A setting: its attribute, storage key, the value that turns it on, and its words. */ const SETTINGS = [ @@ -39,35 +53,89 @@ const SETTINGS = [ key: 'site-reading', on: 'on', label: 'Reading mode', - help: 'A plain, single column with larger text and no motion.', + help: 'The page as plain text: one column, larger type, no colors, pictures or motion.', }, ] as const type Setting = (typeof SETTINGS)[number] -const isOn = (setting: Setting) => document.documentElement.dataset[setting.attribute] === setting.on - -function apply(setting: Setting, on: boolean) { - const root = document.documentElement - if (on) root.dataset[setting.attribute] = setting.on - else delete root.dataset[setting.attribute] +/* The saved choice, or the page's own where storage is blocked. */ +function saved(attribute: string, key: string): string | null { try { - if (on) localStorage.setItem(setting.key, setting.on) - else localStorage.removeItem(setting.key) + return localStorage.getItem(key) + } catch { + return document.documentElement.dataset[attribute] ?? null + } +} + +const isOn = (setting: Setting) => saved(setting.attribute, setting.key) === setting.on +const PUBLIC_ONLY = [ + { attribute: 'reading', key: 'site-reading' }, + { attribute: 'vision', key: 'site-vision' }, +] + +/* Sets (or, given null, clears) an attribute and its saved copy. */ +function apply(attribute: string, key: string, value: string | null) { + const root = document.documentElement + if (value) root.dataset[attribute] = value + else delete root.dataset[attribute] + try { + if (value) localStorage.setItem(key, value) + else localStorage.removeItem(key) } catch { // Storage blocked: the choice holds for this page view. } } +/* Reading mode hides pictures, video and maps; their descriptions + (alt, title, aria-label) go on the parent as data-reading-alt, + which index.css shows in their place. An attribute rather than a + new element, so React's own nodes are left alone. */ +const DESCRIBED = 'main img[alt]:not([alt=""]), main iframe[title], main video[aria-label]' + +function describeMedia() { + for (const el of document.querySelectorAll(DESCRIBED)) { + const words = el.getAttribute('alt') ?? el.getAttribute('title') ?? el.getAttribute('aria-label') + const kind = el.tagName === 'IMG' ? 'Image' : 'Video' + el.parentElement?.setAttribute('data-reading-alt', `${kind}: ${words}`) + } +} + +function useMediaDescriptions(on: boolean) { + useEffect(() => { + if (!on) return undefined + describeMedia() + const observer = new MutationObserver(describeMedia) + observer.observe(document.body, { childList: true, subtree: true }) + return () => observer.disconnect() + }, [on]) +} + export default function AccessibilityPanel() { const [open, setOpen] = useState(false) const [state, setState] = useState(() => Object.fromEntries(SETTINGS.map((s) => [s.key, isOn(s)]))) + const [vision, setVision] = useState(() => saved('vision', 'site-vision') ?? '') const rootRef = useRef(null) const buttonRef = useRef(null) + const firstRef = useRef(null) const panelId = useId() + useMediaDescriptions(state['site-reading']) + + useEffect(() => { + const root = document.documentElement + for (const { attribute, key } of PUBLIC_ONLY) { + const value = saved(attribute, key) + if (value) root.dataset[attribute] = value + } + return () => { + for (const { attribute } of PUBLIC_ONLY) delete root.dataset[attribute] + } + }, []) + useEffect(() => { if (!open) return undefined + firstRef.current?.focus() const close = () => { setOpen(false) buttonRef.current?.focus() @@ -88,18 +156,38 @@ export default function AccessibilityPanel() { const toggle = (setting: Setting) => { const next = !state[setting.key] - apply(setting, next) + apply(setting.attribute, setting.key, next ? setting.on : null) setState((current) => ({ ...current, [setting.key]: next })) } + const chooseVision = (value: string) => { + setVision(value) + apply('vision', 'site-vision', value || null) + window.location.reload() + } + return (
+ + + {/* After the button in the page, so Tab goes from it into the + panel; drawn above it. */} {open && (

Accessibility

@@ -117,25 +205,31 @@ export default function AccessibilityPanel() {
    - {SETTINGS.map((setting) => { + {SETTINGS.map((setting, i) => { const on = state[setting.key] const labelId = `${panelId}-${setting.attribute}` + const helpId = `${labelId}-help` return (
  • @@ -143,26 +237,35 @@ export default function AccessibilityPanel() { {setting.label} - {setting.help} + + {setting.help} +
  • ) })}
+ +
)} - -
) } diff --git a/src/components/Banner.tsx b/src/components/Banner.tsx index a0be933..a8fb404 100644 --- a/src/components/Banner.tsx +++ b/src/components/Banner.tsx @@ -25,7 +25,7 @@ export default function Banner() { if (!visible) return null; const linkClass = - "underline underline-offset-4 decoration-[#9cc47c] hover:text-white transition-colors"; + "underline underline-offset-4 decoration-[var(--green-2)] hover:text-white transition-colors"; return (
+

{text}

) case 'subheading': return ( -

+

{text}

) @@ -248,8 +245,9 @@ function Block({ block, accent, anchor }: { block: ContentBlock; accent: string; const width = Math.max(...rows.map((row) => row.length)) return ( // Wide tables scroll sideways inside their box on a phone - // rather than squeezing every column to a word. -
+ // rather than squeezing every column to a word. Focusable, so + // the arrow keys scroll it too (Safari won't on its own). +
diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index a291b87..4ec43b4 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -28,14 +28,14 @@ const Footer_Links = [ ]; const footerLinkClass = - "text-white/65 hover:text-[#9cc47c] text-sm transition-colors"; + "text-white/65 hover:text-[var(--green-2)] text-sm transition-colors"; // inline-block with a little height of its own, so a finger can hit it. const pageLinkClass = - "inline-block py-1 text-white/80 hover:text-[#9cc47c] text-sm font-semibold transition-colors"; + "inline-block py-1 text-white/80 hover:text-[var(--green-2)] text-sm font-semibold transition-colors"; const sectionLinkClass = - "inline-block py-1 text-white/65 hover:text-[#9cc47c] text-sm transition-colors"; + "inline-block py-1 text-white/65 hover:text-[var(--green-2)] text-sm transition-colors"; const headingClass = "text-white/90 text-sm font-semibold mb-4"; diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx index e98b6b2..8bbb625 100644 --- a/src/components/Layout.tsx +++ b/src/components/Layout.tsx @@ -10,7 +10,7 @@ import PrivacyNotice from "./PrivacyNotice.tsx"; import PageBackdrop from "./PageBackdrop.tsx"; import AccessibilityPanel from "./AccessibilityPanel.tsx"; import ThemeToggle from "./ThemeToggle.tsx"; -import { scrollBehavior } from "../lib/motion.ts"; +import { jumpTo } from "../lib/focus.ts"; /* ── Right-side nav actions ──────────────────────────────── */ @@ -82,7 +82,12 @@ export default function Layout() { const [headerHeight, setHeaderHeight] = useState(72); const headerRef = useRef(null); const closeMenuRef = useRef(null); + const openMenuRef = useRef(null); + // The desktop dropdown Escape has shut, until the pointer or focus + // leaves it (hover and focus would otherwise hold it open). + const [dismissed, setDismissed] = useState(null); const location = useLocation(); + const lastPath = useRef(location.pathname); const sectionsOf = useNavSections(); @@ -98,7 +103,13 @@ export default function Layout() { closeMenuRef.current?.focus(); const onKey = (e: KeyboardEvent) => e.key === "Escape" && setMobileMenuOpen(false); window.addEventListener("keydown", onKey); - return () => window.removeEventListener("keydown", onKey); + return () => { + window.removeEventListener("keydown", onKey); + // Closed with Escape or Close, focus fell to the page with the + // menu: give it back to the menu button. A link that changed + // the page has already sent it to the new page (below). + if (document.activeElement === document.body) openMenuRef.current?.focus(); + }; }, [mobileMenuOpen]); // The header grows and shrinks: the banner can be dismissed, and @@ -115,27 +126,36 @@ export default function Layout() { return () => ro.disconnect(); }, []); + // On the root, so anything can read it: index.css keeps focused + // and jumped-to things clear of the header with it + // (scroll-padding-top), and PostContents offsets by it. + useEffect(() => { + const root = document.documentElement; + root.style.setProperty("--header-h", `${headerHeight}px`); + // The admin has no fixed header: nothing to stay clear of there. + return () => { + root.style.removeProperty("--header-h"); + }; + }, [headerHeight]); + // Router does not scroll on navigation. Go to top on a new page, // or to the anchor if the URL carries one (handles deep links too). + // A new page also takes focus to its content, as a page load would, + // so a screen reader starts there and Tab doesn't begin from a + // link that may be gone. useEffect(() => { - if (location.hash) { - const el = document.querySelector(location.hash); - if (el) { - el.scrollIntoView({ behavior: scrollBehavior() }); - return; - } - } + const newPage = lastPath.current !== location.pathname; + lastPath.current = location.pathname; + if (location.hash && jumpTo(decodeURIComponent(location.hash.slice(1)))) return; window.scrollTo({ top: 0 }); + if (newPage) document.getElementById("main")?.focus({ preventScroll: true }); }, [location.pathname, location.hash, location.key]); return ( // 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). -
+
{ const pageSections = page.path === "/" ? [] : sectionsOf(page.path); return ( -
+
{ + if (e.key !== "Escape" || pageSections.length === 0) return; + setDismissed(page.path); + e.currentTarget.querySelector("a")?.focus(); + }} + onMouseLeave={() => setDismissed(null)} + onBlur={(e) => { + if (!e.currentTarget.contains(e.relatedTarget as Node)) setDismissed(null); + }} + > `block text-base font-bold pb-1 border-b-2 transition-colors duration-200 ${ isActive - ? "text-white border-[#9cc47c]" + ? "text-white border-[var(--green-2)]" : "text-white/75 hover:text-white border-transparent" }` } @@ -194,10 +226,14 @@ export default function Layout() { // (:focus-visible): a click leaves focus on the // link, which held the menu open after the // pointer had gone. -
+
    {pageSections.map((section) => (
  • @@ -228,6 +264,7 @@ export default function Layout() {