Finish the audit leftovers

- One mediaUrl in media.ts instead of 12 identical aliases and a
  kind map; orgPath builds on hrefs.ts's orgHref
- One Logo component (hides itself or shows a fallback when the file
  is missing) for event cards, org lists and chapter marks
- useHistory is a thin wrapper over useRecord
- adminSchema.ts split into adminSchema/, one file per entity plus
  shared.ts; the registry is unchanged (checked by loading both)
- JS smooth scrolls respect reduced motion (lib/motion.ts)
- Content-Security-Policy in Report-Only, with /api/csp-report logging
  what it would block

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-28 22:49:07 -05:00
parent c74ad746f5
commit e4a9c96f7e
42 changed files with 1968 additions and 2043 deletions

View file

@ -5,7 +5,8 @@ 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, eventLogo as eventLogoSrc, orgLogo as orgLogoSrc } from "../../lib/media.ts";
import { mediaUrl } from "../../lib/media.ts";
import Logo from "../../components/Logo.tsx";
import { accentText, withAlpha, readableOn } from '../../lib/color.ts'
/* ═══════════════════════════════════════════════════════════════
@ -34,22 +35,6 @@ import { accentText, withAlpha, readableOn } from '../../lib/color.ts'
fires only for an event with no host at all. */
const DEFAULT_ORG_LOGO = null;
/* An <img> that removes itself if the file 404s. `src` is already
resolved by media.ts: a bare filename from the uploads directory,
anything with a path or URL as it is. */
function Logo({ src, alt = "", className }) {
const [failed, setFailed] = useState(false);
if (!src || failed) return null;
return (
<img
src={src}
alt={alt}
className={className}
onError={() => setFailed(true)}
/>
);
}
const TEAL = "#0f7183"; // last-resort card color
const INK = "var(--color-ink)"; // button text: the card colour is only a border
const CARD_BG = "var(--color-surface)"; // sits under every card, photo or not
@ -64,7 +49,7 @@ const CARD_IMAGE_VEIL =
has one, then the plain surface. */
function cardBackground(ev) {
const layers: string[] = [];
const image = eventBackground(ev.card_image);
const image = mediaUrl(ev.card_image);
if (image) {
layers.push(CARD_IMAGE_VEIL, `url(${JSON.stringify(image)}) center / cover no-repeat`);
}
@ -155,8 +140,8 @@ export function Card({
}) {
const past = ev.status === "past";
const color = ev.color || defaultColor;
const orgLogo = orgLogoSrc(ev.org_logo) || DEFAULT_ORG_LOGO;
const eventLogo = eventLogoSrc(ev.event_logo);
const orgLogo = mediaUrl(ev.org_logo) || DEFAULT_ORG_LOGO;
const eventLogo = mediaUrl(ev.event_logo);
const schedule = seriesLabel(ev.series, ev.starts_on);
const links = ev.links ?? [];
const igHandle = ev.instagram || null;