From a67ca983948520c4e17dbda1bc0135f54f0a7666 Mon Sep 17 00:00:00 2001 From: Zaldimmar Date: Sun, 27 Sep 2026 23:18:32 -0500 Subject: [PATCH 1/4] Move the NGU logos to src/assets/logos and load event logos from uploads The site's own logos now live in src/assets/logos. Event logos are no longer bundled: the event cards resolve them through media.ts like every other image, and a bare event-logo filename now means one in the uploads directory (fall-retreat-logo.svg has been moved there by hand). Organization logos on the cards resolve from org-logos. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 2 +- server/src/pageMeta.js | 2 +- src/assets/Fall Logo.svg | 1 - src/assets/event-logos/fall-retreat-logo.svg | 1 - src/assets/event-logos/ngu-logo-white-bg.svg | 82 -------------------- src/assets/{ => logos}/NGU_Logo.svg | 0 src/assets/{ => logos}/NGU_Logo_WhiteBG.svg | 0 src/components/Footer.tsx | 2 +- src/components/Layout.tsx | 2 +- src/lib/media.ts | 7 +- src/pages/admin/AdminLayout.tsx | 2 +- src/pages/sections/EventList-Cards.tsx | 33 +++----- 12 files changed, 21 insertions(+), 113 deletions(-) delete mode 100644 src/assets/Fall Logo.svg delete mode 100644 src/assets/event-logos/fall-retreat-logo.svg delete mode 100644 src/assets/event-logos/ngu-logo-white-bg.svg rename src/assets/{ => logos}/NGU_Logo.svg (100%) rename src/assets/{ => logos}/NGU_Logo_WhiteBG.svg (100%) diff --git a/CLAUDE.md b/CLAUDE.md index acb20d0..1332872 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -57,7 +57,7 @@ In dev, Vite proxies `/api` to the target set in `vite.config.ts`, so the API mu - `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. - `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. -- Logos: org logos in `public/org-logos/` (served at `/org-logos/`), event logos in `public/event-logos/`. The `` component hides itself on load error. +- Logos: org logos in `public/org-logos/` (served at `/org-logos/`); event logos are uploads (`/uploads/`, a bare filename resolves there). The site's own NGU logos are bundled from `src/assets/logos/`. Image paths resolve through `src/lib/media.ts`. The `` component hides itself on load error. ## 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. diff --git a/server/src/pageMeta.js b/server/src/pageMeta.js index 69555fb..f47f28d 100644 --- a/server/src/pageMeta.js +++ b/server/src/pageMeta.js @@ -48,7 +48,7 @@ const DESCRIPTION_CHARS = 160; /* Where a bare filename lives, per kind. Mirrors src/lib/media.ts. */ const DIRS = { person: "/people", - eventLogo: "/event-logos", + eventLogo: "/uploads", eventBackground: "/event-backgrounds", organization: "/org-logos", team: "/team-logos", diff --git a/src/assets/Fall Logo.svg b/src/assets/Fall Logo.svg deleted file mode 100644 index 33f133f..0000000 --- a/src/assets/Fall Logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/event-logos/fall-retreat-logo.svg b/src/assets/event-logos/fall-retreat-logo.svg deleted file mode 100644 index 33f133f..0000000 --- a/src/assets/event-logos/fall-retreat-logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/assets/event-logos/ngu-logo-white-bg.svg b/src/assets/event-logos/ngu-logo-white-bg.svg deleted file mode 100644 index 3202fa3..0000000 --- a/src/assets/event-logos/ngu-logo-white-bg.svg +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - Next Generation - of Unity - - - - diff --git a/src/assets/NGU_Logo.svg b/src/assets/logos/NGU_Logo.svg similarity index 100% rename from src/assets/NGU_Logo.svg rename to src/assets/logos/NGU_Logo.svg diff --git a/src/assets/NGU_Logo_WhiteBG.svg b/src/assets/logos/NGU_Logo_WhiteBG.svg similarity index 100% rename from src/assets/NGU_Logo_WhiteBG.svg rename to src/assets/logos/NGU_Logo_WhiteBG.svg diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index 21974ea..d06455e 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -1,6 +1,6 @@ import { Link } from "react-router-dom"; import { PAGE_LINKS, PAGE_SECTIONS, NAV_ACTIONS } from "../navConfig.ts"; -import nguLogo from "../assets/NGU_Logo.svg"; +import nguLogo from "../assets/logos/NGU_Logo.svg"; import PlatformIcon from "./PlatformIcon.tsx"; const Social_Links = [ diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx index 6b999a7..d04bf59 100644 --- a/src/components/Layout.tsx +++ b/src/components/Layout.tsx @@ -2,7 +2,7 @@ import { useState, useEffect, useRef } from "react"; import { NavLink, Link, Outlet, useLocation } from "react-router-dom"; import { PAGE_LINKS, PAGE_SECTIONS, NAV_ACTIONS } from "../navConfig.ts"; import Banner from "./Banner.jsx"; -import nguLogo from "../assets/NGU_Logo.svg"; +import nguLogo from "../assets/logos/NGU_Logo.svg"; import Footer from "./Footer.tsx"; /* ── Right-side nav actions ──────────────────────────────── */ diff --git a/src/lib/media.ts b/src/lib/media.ts index 35b35f0..f7da6a9 100644 --- a/src/lib/media.ts +++ b/src/lib/media.ts @@ -7,7 +7,7 @@ edit rather than a grep. ⚠ Only two of these directories are confirmed by the admin help - text: people/ and event-logos/. The other three are a guess at + text: people/. Event logos are uploads. The other three are a guess at your convention. Check public/ and fix them here — nothing else references the paths. @@ -30,7 +30,10 @@ function inDir(dir: string) { } export const personPhoto = inDir('/people') // confirmed -export const eventLogo = inDir('/event-logos') // confirmed +// Event logos are uploads. A bare filename is one copied into the +// uploads directory by hand (fall-retreat-logo.svg was); anything +// uploaded through the admin is already /uploads/… +export const eventLogo = inDir('/uploads') export const eventBackground = inDir('/event-backgrounds') export const orgLogo = inDir('/org-logos') // ⚠ guess export const teamLogo = inDir('/team-logos') // ⚠ guess diff --git a/src/pages/admin/AdminLayout.tsx b/src/pages/admin/AdminLayout.tsx index e68b59b..2a98f84 100644 --- a/src/pages/admin/AdminLayout.tsx +++ b/src/pages/admin/AdminLayout.tsx @@ -27,7 +27,7 @@ import { AdminTitleContext } from "../../lib/adminTitle.tsx"; import { AdminWidthContext } from "../../lib/adminWidth.tsx"; import { SITE_VERSION } from "../../lib/version.ts"; import { ROLE_LABELS, isSuper } from "../../lib/roles.ts"; -import nguLogo from "../../assets/NGU_Logo.svg"; +import nguLogo from "../../assets/logos/NGU_Logo.svg"; import { ADMIN_HOME, AREA_TITLES, diff --git a/src/pages/sections/EventList-Cards.tsx b/src/pages/sections/EventList-Cards.tsx index 238ab43..9fd8fd5 100644 --- a/src/pages/sections/EventList-Cards.tsx +++ b/src/pages/sections/EventList-Cards.tsx @@ -5,7 +5,7 @@ import { eventHref } from "../../lib/hrefs.ts"; import { EVENT_TYPES, eventTypeLabel } from "../../lib/eventTypes.ts"; import { seriesLabel } from "../../lib/eventSeries.ts"; import PlatformIcon from "../../components/PlatformIcon.tsx"; -import { eventBackground, isAbsoluteMedia } from "../../lib/media.ts"; +import { eventBackground, eventLogo as eventLogoSrc, orgLogo as orgLogoSrc } from "../../lib/media.ts"; /* ═══════════════════════════════════════════════════════════════ EVENT LIST — CARDS @@ -27,28 +27,17 @@ import { eventBackground, isAbsoluteMedia } from "../../lib/media.ts"; nothing but retreats shows no control at all. ═══════════════════════════════════════════════════════════════ */ -const LOGO_FILES = import.meta.glob("../../assets/event-logos/*.svg", { - eager: true, - import: "default", -}); - -const LOGOS = Object.fromEntries( - Object.entries(LOGO_FILES).map(([path, src]) => [path.split("/").pop(), src]) -); - -/* A bundled logo by filename, or an upload or URL as it is. */ -const logoSrc = file => - (file && LOGOS[file]) || (isAbsoluteMedia(file) ? file : null); /* Last resort only. The API already falls back to the host organization's logo when an event doesn't name its own, so this fires only for an event with no host at all. */ const DEFAULT_ORG_LOGO = null; -/* An that removes itself if the file 404s. */ -function Logo({ file, alt = "", className }) { +/* An that removes itself if the file 404s. `src` is already + resolved by media.ts: an event logo from the uploads directory, an + organization's from org-logos, anything with a path or URL as is. */ +function Logo({ src, alt = "", className }) { const [failed, setFailed] = useState(false); - const src = logoSrc(file); if (!src || failed) return null; return ( - +
{typeBadge}

@@ -234,7 +223,7 @@ export function Card({ )}

@@ -245,7 +234,7 @@ export function Card({ <>
- + {typeBadge}

@@ -263,7 +252,7 @@ export function Card({

From 9075cfb90812f0ecadddf86e7c2465297b67b529 Mon Sep 17 00:00:00 2001 From: Zaldimmar Date: Sun, 27 Sep 2026 23:18:32 -0500 Subject: [PATCH 2/4] Show schedule maps in satellite view Co-Authored-By: Claude Opus 5.5 --- src/components/ScheduleBlock.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ScheduleBlock.tsx b/src/components/ScheduleBlock.tsx index 05b6b10..d15e2d0 100644 --- a/src/components/ScheduleBlock.tsx +++ b/src/components/ScheduleBlock.tsx @@ -59,7 +59,7 @@ function todayIndex(days: Day[]): number { } const mapEmbed = (place: string) => - `https://maps.google.com/maps?q=${encodeURIComponent(place)}&output=embed` + `https://maps.google.com/maps?q=${encodeURIComponent(place)}&output=embed&maptype=satellite` const mapLink = (place: string) => `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(place)}` From 9eeb13c5ecee6c21cf2421942fc4779869c11c39 Mon Sep 17 00:00:00 2001 From: Zaldimmar Date: Sun, 27 Sep 2026 23:20:55 -0500 Subject: [PATCH 3/4] QR tool: choose the centre, type any link, pick the colours The centre can be nothing, the NGU dove, or any SVG dropped into src/assets/qr, embedded in the code so downloads carry it. "A link I type" takes a site path (sent to the live site), a full http(s) address, or a bare domain. The code, background and dove colours can be changed, with a warning under 4:1 contrast or for an inverted code, which many scanners can't read. Co-Authored-By: Claude Opus 5.5 --- site.json | 2 +- src/components/QrCode.tsx | 81 +++++++--- src/pages/QrCodes.tsx | 2 +- src/pages/admin/adminNav.ts | 2 +- src/pages/sections/QrCodeMaker.tsx | 243 ++++++++++++++++++++++++++--- 5 files changed, 279 insertions(+), 51 deletions(-) diff --git a/site.json b/site.json index a0fc0c3..786515f 100644 --- a/site.json +++ b/site.json @@ -39,7 +39,7 @@ }, "/qr": { "title": "QR Codes", - "description": "Codes for flyers, slides and signs, pointing at any page on the site." + "description": "Codes for flyers, slides and signs, pointing at any page on the site or any link, in your choice of colours." }, "/give": { "title": "Giving", diff --git a/src/components/QrCode.tsx b/src/components/QrCode.tsx index e5f92d1..8ae64bf 100644 --- a/src/components/QrCode.tsx +++ b/src/components/QrCode.tsx @@ -1,16 +1,25 @@ /* ═══════════════════════════════════════════════════════════════ QR CODE - A QR code as an , sized by its container. With `dove`, the - NGU dove sits on a white badge over the centre; the code switches - to high error correction so the modules under the badge are - recovered when it's scanned (see lib/qr.ts). The badge covers - under 6% of the code, well inside what 'H' repairs, and never - reaches the three corner finder patterns. + A QR code as an , sized by its container. - Everything is drawn in the SVG itself (no CSS, no external - references), so the element serialises to a file that looks the - same outside the page. `ref` reaches the for exactly that. + `centre` puts something on a badge over the middle: the NGU dove, + or an image (an SVG from src/assets/qr, passed as a data: URL). + With anything there, the code switches to high error correction + so the modules under the badge are recovered when it's scanned + (see lib/qr.ts). The badge covers under 6% of the code, well + inside what 'H' repairs, and never reaches the three corner + finder patterns. + + `ink` is the modules and the badge's outline, `paper` the + background and the badge. A code should stay dark on light with + strong contrast to scan reliably; QrCodeMaker warns when it + doesn't, this just draws what it's given. + + Everything is drawn in the SVG itself (no CSS, and an image is + embedded rather than linked), so the element serialises to a + file that looks the same outside the page. `ref` reaches the + for exactly that. ═══════════════════════════════════════════════════════════════ */ import { useMemo, type Ref } from 'react' @@ -23,8 +32,9 @@ import { qrMatrix, qrPath } from '../lib/qr.ts' const MARGIN = 4 /* Dark enough to scan as black; the site's deep teal. */ -const INK = '#04262e' -const TEAL = '#138ba0' +export const QR_INK = '#04262e' +export const QR_PAPER = '#ffffff' +export const QR_DOVE = '#138ba0' /* Badge side as a share of the code's width. */ const BADGE = 0.24 @@ -32,21 +42,28 @@ const BADGE = 0.24 /* DoveMark's own viewBox is 72.87 × 48.57. */ const DOVE_ASPECT = 72.867699 / 48.568241 +export type QrCentre = { kind: 'dove'; color?: string } | { kind: 'image'; src: string } | null + export default function QrCode({ value, - dove = false, + centre = null, + ink = QR_INK, + paper = QR_PAPER, label, ref, className, }: { value: string - dove?: boolean + centre?: QrCentre + ink?: string + paper?: string /** Accessible name for the image, e.g. "QR code for /retreats". */ label: string ref?: Ref className?: string }) { - const matrix = useMemo(() => qrMatrix(value, dove ? 'H' : 'M'), [value, dove]) + const level = centre ? 'H' : 'M' + const matrix = useMemo(() => qrMatrix(value, level), [value, level]) const path = useMemo(() => qrPath(matrix, MARGIN), [matrix]) const total = matrix.size + MARGIN * 2 @@ -54,6 +71,7 @@ export default function QrCode({ const badgeAt = (total - badge) / 2 const doveWidth = badge * 0.78 const doveHeight = doveWidth / DOVE_ASPECT + const imageSize = badge * 0.8 return ( - - + + - {dove && ( + {centre && ( - + {centre.kind === 'dove' ? ( + + ) : ( + + )} )} diff --git a/src/pages/QrCodes.tsx b/src/pages/QrCodes.tsx index fa798f2..b092121 100644 --- a/src/pages/QrCodes.tsx +++ b/src/pages/QrCodes.tsx @@ -19,7 +19,7 @@ const SECTIONS = [ id: 'make', title: 'Make a QR code', blurb: - 'Pick a page from the main navigation, or any event, organization, team, award, person or blog post on the site. The code always points at the live site.', + 'Pick a page from the main navigation, any event, organization, team, award, person or blog post, or type any link. Site pages always point at the live site. Choose what sits in the centre and the colours; a warning shows if the code might not scan.', accent: '#138ba0', background: '#eef9fb', content: ( diff --git a/src/pages/admin/adminNav.ts b/src/pages/admin/adminNav.ts index 40f7dc5..2d311af 100644 --- a/src/pages/admin/adminNav.ts +++ b/src/pages/admin/adminNav.ts @@ -135,7 +135,7 @@ export const TOOLS_NAV = { { to: "/qr", label: "QR code generator", - blurb: "Codes for flyers, slides and signs, pointing at any page on the site.", + blurb: "Codes for flyers, slides and signs: any page or link, in your choice of colours.", }, ], }; diff --git a/src/pages/sections/QrCodeMaker.tsx b/src/pages/sections/QrCodeMaker.tsx index 4db3dcb..1db9613 100644 --- a/src/pages/sections/QrCodeMaker.tsx +++ b/src/pages/sections/QrCodeMaker.tsx @@ -1,12 +1,23 @@ /* ═══════════════════════════════════════════════════════════════ QR CODE MAKER - Pick a page, get a QR code for it on the live site. + Pick a page, or type a link, and get a QR code for it. - What main navigation, or one kind of record + What main navigation, one kind of record, or a link + typed in Which the page or record itself Section for a main page with a subnav, optionally one of its #sections + Centre nothing, the NGU dove, or any SVG in + src/assets/qr (drop a file there and it's offered; + it's embedded in the code, so downloads carry it) + Colours the code, its background, and the dove. A warning + appears when the pair is unlikely to scan: too + little contrast, or a light code on a dark ground + + A typed link can be a site path (/retreats, which goes to the live + site like every other choice), a full http(s) address, or a bare + domain, which gets https:// in front. The main pages come from navConfig.ts, the same list the header draws; records come from GET /directory, which lists only what's @@ -22,7 +33,7 @@ import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react' -import QrCode from '../../components/QrCode.tsx' +import QrCode, { QR_DOVE, QR_INK, QR_PAPER, type QrCentre } from '../../components/QrCode.tsx' import { NAV_ACTIONS, PAGE_LINKS, PAGE_SECTIONS } from '../../navConfig.ts' import { awardHref, blogHref, eventHref, orgHref, personHref, teamHref } from '../../lib/hrefs.ts' import { siteUrl } from '../../lib/site.ts' @@ -35,7 +46,7 @@ const MUTED = '#4a6b72' anything bigger should use the SVG. */ const PNG_SIZE = 1024 -type Kind = 'pages' | 'events' | 'organizations' | 'teams' | 'awards' | 'people' | 'blog_posts' +type Kind = 'pages' | 'events' | 'organizations' | 'teams' | 'awards' | 'people' | 'blog_posts' | 'custom' const KINDS: Array<[Kind, string]> = [ ['pages', 'Main navigation'], @@ -45,8 +56,81 @@ const KINDS: Array<[Kind, string]> = [ ['awards', 'Awards'], ['people', 'People'], ['blog_posts', 'Blog posts'], + ['custom', 'A link I type'], ] +/* The centres on offer: the dove, then every SVG in src/assets/qr, + named after its file ("ngu-circle.svg" → "Ngu circle"). Read as + text and turned into data: URLs so they sit inside the code's own + SVG. */ +const CENTRE_FILES = import.meta.glob('../../assets/qr/*.svg', { + eager: true, + query: '?raw', + import: 'default', +}) + +type CentreOption = { id: string; label: string; centre: (dove: string) => QrCentre } + +const toDataUrl = (svg: string) => + `data:image/svg+xml;base64,${btoa(String.fromCharCode(...new TextEncoder().encode(svg)))}` + +const CENTRES: CentreOption[] = [ + { id: 'none', label: 'Nothing', centre: () => null }, + { id: 'dove', label: 'NGU dove', centre: (color) => ({ kind: 'dove', color }) }, + ...Object.entries(CENTRE_FILES) + .sort(([a], [b]) => a.localeCompare(b)) + .map(([path, svg]) => { + const name = path.split('/').pop()!.replace(/\.svg$/i, '') + const label = name.replace(/[-_]+/g, ' ').replace(/^./, (c) => c.toUpperCase()) + const src = toDataUrl(svg) + return { id: `file:${name}`, label, centre: () => ({ kind: 'image', src }) as QrCentre } + }), +] + +/* ── Contrast ────────────────────────────────────────────────── + WCAG relative luminance and contrast ratio. Below MIN_CONTRAST + some phone cameras struggle; a code lighter than its background + is "inverted", which many scanners don't read at all. */ +const MIN_CONTRAST = 4 + +function luminance(hex: string): number { + const m = hex.replace('#', '').match(/^([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i) + if (!m) return 0 + const [r, g, b] = m.slice(1).map((h) => { + const c = parseInt(h, 16) / 255 + return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4 + }) + return 0.2126 * r + 0.7152 * g + 0.0722 * b +} + +function scanWarning(ink: string, paper: string): string | null { + const a = luminance(ink) + const b = luminance(paper) + if (a > b) return 'The code is lighter than its background. Many scanners can’t read an inverted code.' + const ratio = (b + 0.05) / (a + 0.05) + if (ratio < MIN_CONTRAST) { + return `Low contrast (${ratio.toFixed(1)}:1). Use a darker code or a lighter background so it scans reliably.` + } + return null +} + +/* What a typed link means: a site path goes to the live site, a + full address is used as it is, a bare domain gets https://. + Anything else isn't a link. */ +function typedUrl(raw: string): string | null { + const value = raw.trim() + if (!value) return null + if (value.startsWith('/') && !value.startsWith('//')) return siteUrl(value) + const withScheme = /^[a-z][a-z0-9+.-]*:/i.test(value) ? value : /^[^\s/]+\.[^\s/]+/.test(value) ? `https://${value}` : null + if (!withScheme) return null + try { + const url = new URL(withScheme) + return url.protocol === 'http:' || url.protocol === 'https:' ? url.href : null + } catch { + return null + } +} + /* Organizations are grouped by kind in the dropdown, in this order. */ const ORG_GROUPS: Array<[string, string]> = [ ['national', 'NGU'], @@ -109,12 +193,22 @@ function groupsFor(kind: Kind, directory: Directory | null): Group[] { return [{ choices: directory.people.map((p) => ({ path: personHref(p.id), label: p.name })) }] case 'blog_posts': return [{ choices: directory.blog_posts.map((b) => ({ path: blogHref(b.id), label: b.name })) }] + case 'custom': + return [] } } -/* "/regions/northwest#events" → "regions-northwest-events". */ -function fileStem(path: string): string { - const stem = path.replace(/^\//, '').replace(/[^a-z0-9]+/gi, '-').replace(/^-|-$/g, '') +/* "/regions/northwest#events" → "regions-northwest-events"; a typed + link keeps its host too: "example-org-page". */ +function fileStem(target: string): string { + let name = target + try { + const url = new URL(target) + name = `${url.hostname.replace(/^www\./, '')}${url.pathname}${url.hash}` + } catch { + /* a site path */ + } + const stem = name.replace(/^\//, '').replace(/[^a-z0-9]+/gi, '-').replace(/^-|-$/g, '') return `ngu-qr-${stem || 'home'}` } @@ -163,7 +257,11 @@ export default function QrCodeMaker() { const [kind, setKind] = useState('pages') const [path, setPath] = useState('/') const [section, setSection] = useState('') - const [dove, setDove] = useState(true) + const [custom, setCustom] = useState('') + const [centreId, setCentreId] = useState('dove') + const [ink, setInk] = useState(QR_INK) + const [paper, setPaper] = useState(QR_PAPER) + const [doveColor, setDoveColor] = useState(QR_DOVE) const [copied, setCopied] = useState(false) const svgRef = useRef(null) @@ -181,8 +279,13 @@ export default function QrCodeMaker() { const sections = kind === 'pages' ? (PAGE_SECTIONS[path] ?? []) : [] const selected = choices.find((c) => c.path === path) ?? null - const target = selected ? `${selected.path}${section}` : null - const url = target ? siteUrl(target) : null + const typed = kind === 'custom' ? typedUrl(custom) : null + const target = kind === 'custom' ? typed : selected ? `${selected.path}${section}` : null + const url = kind === 'custom' ? typed : target ? siteUrl(target) : null + + const centreOption = CENTRES.find((c) => c.id === centreId) ?? CENTRES[0] + const centre = centreOption.centre(doveColor) + const warning = scanWarning(ink, paper) useEffect(() => setCopied(false), [url]) @@ -198,7 +301,7 @@ export default function QrCodeMaker() { } } - const needsDirectory = kind !== 'pages' + const needsDirectory = kind !== 'pages' && kind !== 'custom' return (
@@ -211,7 +314,27 @@ export default function QrCodeMaker() { ))} - {needsDirectory && loading && !directory ? ( + {kind === 'custom' ? ( +
+ + setCustom(e.target.value)} + placeholder="https://… or /retreats" + className={`mt-2 ${inputClass}`} + /> +

+ {custom.trim() && !typed + ? 'That isn’t a web address. Use https://…, a domain, or a site path like /retreats.' + : 'A full address, a domain (example.org), or a path on this site (/retreats).'} +

+
+ ) : needsDirectory && loading && !directory ? (

Loading the list…

) : needsDirectory && error ? (

Couldn't load the list of pages. {error}

@@ -258,15 +381,43 @@ export default function QrCodeMaker() { )} - + + +
+ Colours +
+ + + {centreOption.id === 'dove' && ( + + )} + {(ink !== QR_INK || paper !== QR_PAPER || doveColor !== QR_DOVE) && ( + + )} +
+ {warning && ( +

+ {warning} +

+ )} +
{url && (
@@ -295,7 +446,9 @@ export default function QrCodeMaker() { @@ -333,6 +486,52 @@ function DownloadButton({ onClick, children }: { onClick: () => void; children: ) } +const inputClass = + 'w-full rounded-xl border border-[#4a6b72]/25 bg-white px-4 py-3 text-[#26454c] ' + + 'outline-none transition-colors focus:border-[#138ba0] focus:ring-2 focus:ring-[#138ba0]/25' + +/* A colour well with its hex beside it, both editable. */ +function ColourInput({ + id, + label, + value, + onChange, +}: { + id: string + label: string + value: string + onChange: (value: string) => void +}) { + const [text, setText] = useState(value) + useEffect(() => setText(value), [value]) + return ( +
+ +
+ onChange(e.target.value)} + className="h-9 w-11 cursor-pointer rounded border border-[#4a6b72]/25 bg-white" + /> + { + setText(e.target.value) + if (/^#[0-9a-f]{6}$/i.test(e.target.value)) onChange(e.target.value.toLowerCase()) + }} + className="w-24 rounded-lg border border-[#4a6b72]/25 bg-white px-2 py-1.5 font-mono text-sm text-[#26454c] outline-none focus:border-[#138ba0]" + /> +
+
+ ) +} + const selectClass = 'w-full appearance-none rounded-xl border border-[#4a6b72]/25 bg-white px-4 py-3 pr-10 text-[#26454c] ' + 'outline-none transition-colors focus:border-[#138ba0] focus:ring-2 focus:ring-[#138ba0]/25' From dad3803cccb647b1c910f09ff2b38556e10255e6 Mon Sep 17 00:00:00 2001 From: Zaldimmar Date: Sun, 27 Sep 2026 23:29:54 -0500 Subject: [PATCH 4/4] Resolve every record image from the uploads folder A bare image filename, whatever it belongs to (organization and event logos, people photos, team and award logos, backgrounds, hero photos, block images), now resolves to /uploads/, in media.ts and for link previews in pageMeta.js. The per-kind public/ folders were guesses that don't exist. Only the site's own chosen assets, the NGU logos in the nav, footer and admin, stay bundled from src/assets/logos. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 2 +- server/src/pageMeta.js | 23 +++----- src/lib/adminSchema.ts | 2 +- src/lib/embeds.ts | 2 +- src/lib/media.ts | 78 ++++++++++++++------------ src/pages/sections/EventList-Cards.tsx | 4 +- 6 files changed, 55 insertions(+), 56 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 1332872..375dde6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -57,7 +57,7 @@ In dev, Vite proxies `/api` to the target set in `vite.config.ts`, so the API mu - `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. - `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. -- Logos: org logos in `public/org-logos/` (served at `/org-logos/`); event logos are uploads (`/uploads/`, a bare filename resolves there). The site's own NGU logos are bundled from `src/assets/logos/`. Image paths resolve through `src/lib/media.ts`. The `` component hides itself on load error. +- Images: every record image (logos, photos, backgrounds, block images) is an upload. A bare filename resolves to `/uploads/` (`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 `` component hides itself on load error. ## 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. diff --git a/server/src/pageMeta.js b/server/src/pageMeta.js index f47f28d..c76dc45 100644 --- a/server/src/pageMeta.js +++ b/server/src/pageMeta.js @@ -27,8 +27,8 @@ /admin noindex Image paths resolve like src/lib/media.ts does: a bare filename - lives in that record kind's public/ directory, anything starting - with / or a scheme is used as it is. Keep DIRS in step with it. + is in the uploads directory, anything starting with / or a scheme + is used as it is. An SVG isn't used as a preview image (the big sites won't show one), so it falls back to the site default. ═══════════════════════════════════════════════════════════════ */ @@ -45,16 +45,9 @@ export const SITE_CONFIG = path.resolve(process.env.SITE_CONFIG ?? path.join(her const DESCRIPTION_CHARS = 160; -/* Where a bare filename lives, per kind. Mirrors src/lib/media.ts. */ -const DIRS = { - person: "/people", - eventLogo: "/uploads", - eventBackground: "/event-backgrounds", - organization: "/org-logos", - team: "/team-logos", - award: "/award-logos", - blog: "/blog", -}; +/* Where a bare filename lives: record images are uploads, whatever + kind they are. Mirrors src/lib/media.ts. */ +const UPLOADS = "/uploads"; /* ── site.json, reread when it changes ─────────────────────── */ @@ -94,9 +87,9 @@ const first = (...values) => values.find((v) => v != null && String(v).trim() != function imageUrl(site, file, kind) { if (!file || /\.svg(\?|#|$)/i.test(file)) return null; - // A bare filename is in that kind's directory, or at the site's - // root for the site's own default (kind null). - const pathOrUrl = /^(https?:|\/)/.test(file) ? file : kind ? `${DIRS[kind]}/${file}` : `/${file}`; + // A record's bare filename is an upload; the site's own default + // image (kind null) is a path from the site's root. + const pathOrUrl = /^(https?:|\/)/.test(file) ? file : kind ? `${UPLOADS}/${file}` : `/${file}`; return /^https?:/.test(pathOrUrl) ? pathOrUrl : `${origin(site)}${pathOrUrl}`; } diff --git a/src/lib/adminSchema.ts b/src/lib/adminSchema.ts index 94d227b..224dbd9 100644 --- a/src/lib/adminSchema.ts +++ b/src/lib/adminSchema.ts @@ -1305,7 +1305,7 @@ const frontPage = { full: true, help: "A YouTube, Vimeo or Facebook link, or a video file: a filename in " + - "/front-page/ or a link ending in .mp4 or .webm", + "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" }, { diff --git a/src/lib/embeds.ts b/src/lib/embeds.ts index afc68c1..435560c 100644 --- a/src/lib/embeds.ts +++ b/src/lib/embeds.ts @@ -15,7 +15,7 @@ so the visitor presses play. A featured video can also be a file rather than a link: a - filename in public/front-page/, a /path, or an https URL ending + filename in the uploads directory, a /path, or an https URL ending in a video extension. videoSource() says which, so the hero can hand a file to