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:
parent
c74ad746f5
commit
e4a9c96f7e
42 changed files with 1968 additions and 2043 deletions
|
|
@ -33,7 +33,7 @@
|
|||
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 { Anchor, Inline, Paragraphs } from './InlineText.tsx'
|
||||
import VideoPlayer from './VideoPlayer.tsx'
|
||||
|
|
@ -170,7 +170,7 @@ function Block({ block, accent }: { block: ContentBlock; accent: string }) {
|
|||
)
|
||||
|
||||
case 'image': {
|
||||
const src = blockMedia(block.media)
|
||||
const src = mediaUrl(block.media)
|
||||
if (!src) return null
|
||||
const img = (
|
||||
<img
|
||||
|
|
@ -196,7 +196,7 @@ function Block({ block, accent }: { block: ContentBlock; accent: string }) {
|
|||
return (
|
||||
<figure>
|
||||
<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>
|
||||
<Caption text={text} />
|
||||
</figure>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import { useState } from 'react'
|
|||
import HomeLink from '../pages/sections/home/HomeLink.tsx'
|
||||
import VideoPlayer from './VideoPlayer.tsx'
|
||||
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'
|
||||
|
||||
/* Image kinds that are photographs, drawn edge to edge. Anything
|
||||
|
|
@ -39,7 +39,7 @@ function hrefFor(card: FeaturedCard): string | null {
|
|||
|
||||
function Picture({ card }: { card: FeaturedCard }) {
|
||||
const [failed, setFailed] = useState(false)
|
||||
const src = card.image ? logoForKind(card.image.kind, card.image.file) : null
|
||||
const src = card.image ? mediaUrl(card.image.file) : null
|
||||
const photo = card.image ? PHOTO_KINDS.has(card.image.kind) : false
|
||||
|
||||
if (!src || failed) {
|
||||
|
|
@ -68,7 +68,7 @@ function Picture({ 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} />
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import nguLogo from "../assets/logos/NGU_Logo.svg";
|
|||
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 ──────────────────────────────── */
|
||||
|
||||
|
|
@ -117,7 +118,7 @@ export default function Layout() {
|
|||
if (location.hash) {
|
||||
const el = document.querySelector(location.hash);
|
||||
if (el) {
|
||||
el.scrollIntoView({ behavior: "smooth" });
|
||||
el.scrollIntoView({ behavior: scrollBehavior() });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
27
src/components/Logo.tsx
Normal file
27
src/components/Logo.tsx
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
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).
|
||||
Decorative by default (alt ""), since a logo sits next to the
|
||||
name it stands for.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { useState, type ReactNode } from 'react'
|
||||
|
||||
export default function Logo({
|
||||
src,
|
||||
alt = '',
|
||||
className,
|
||||
fallback = null,
|
||||
}: {
|
||||
src?: string | null
|
||||
alt?: string
|
||||
className?: string
|
||||
fallback?: ReactNode
|
||||
}) {
|
||||
const [failed, setFailed] = useState(false)
|
||||
if (!src || failed) return <>{fallback}</>
|
||||
return <img src={src} alt={alt} loading="lazy" className={className} onError={() => setFailed(true)} />
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ import { Link } from "react-router-dom";
|
|||
|
||||
import { get } from "../lib/api.ts";
|
||||
import { isBadId, personHref } from "../lib/hrefs.ts";
|
||||
import { initials, personPhoto } from "../lib/media.ts";
|
||||
import { mediaUrl, initials } from "../lib/media.ts";
|
||||
import "./PeopleTiles.css";
|
||||
|
||||
/**
|
||||
|
|
@ -548,7 +548,7 @@ function Tile({
|
|||
const content = (
|
||||
<span className="pl__frame">
|
||||
<span className="pl__photo">
|
||||
<Photo src={personPhoto(person.photo)} name={person.name} />
|
||||
<Photo src={mediaUrl(person.photo)} name={person.name} />
|
||||
</span>
|
||||
<span className="pl__caption">
|
||||
<span className="pl__name">{person.name}</span>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import { useId, useState, type KeyboardEvent } from 'react'
|
|||
import { Link } from 'react-router-dom'
|
||||
|
||||
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 { Anchor, Paragraphs } from './InlineText.tsx'
|
||||
import { withAlpha, accentText, readableOn } from '../lib/color.ts'
|
||||
|
|
@ -66,7 +66,7 @@ const mapLink = (place: string) =>
|
|||
|
||||
function Avatar({ person, size }: { person: NonNullable<ContentBlockItem['person']>; size: string }) {
|
||||
const [failed, setFailed] = useState(false)
|
||||
const src = personPhoto(person.photo)
|
||||
const src = mediaUrl(person.photo)
|
||||
return src && !failed ? (
|
||||
<img src={src} alt="" onError={() => setFailed(true)} className={`${size} shrink-0 rounded-full object-cover`} />
|
||||
) : (
|
||||
|
|
@ -84,7 +84,7 @@ function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
|
|||
// Google's map loads only when asked for (Privacy page).
|
||||
const [showMap, setShowMap] = useState(false)
|
||||
const panelId = useId()
|
||||
const graphic = blockMedia(entry.media)
|
||||
const graphic = mediaUrl(entry.media)
|
||||
const place = entry.map?.trim()
|
||||
const more = Boolean(entry.description || graphic || place || entry.person)
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { scrollBehavior } from "../../lib/motion.ts";
|
||||
|
||||
export type EditorSection = {
|
||||
id: string;
|
||||
|
|
@ -63,7 +64,7 @@ function useActiveSection(sections: EditorSection[]) {
|
|||
}
|
||||
|
||||
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 }) {
|
||||
|
|
|
|||
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,
|
||||
},
|
||||
],
|
||||
};
|
||||
184
src/lib/adminSchema/blog.ts
Normal file
184
src/lib/adminSchema/blog.ts
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
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: "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,
|
||||
],
|
||||
};
|
||||
244
src/lib/adminSchema/frontPage.ts
Normal file
244
src/lib/adminSchema/frontPage.ts
Normal file
|
|
@ -0,0 +1,244 @@
|
|||
import { mediaUrl } from "../media.ts";
|
||||
import { featuredCardsChild } from "./shared.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.icon, row.label].filter(Boolean).join(" ") || "New path",
|
||||
blank: { label: "", icon: "", blurb: "" },
|
||||
fields: [
|
||||
{ path: "label", label: "Label", required: true, help: "eg. Attend, Serve…" },
|
||||
{ path: "icon", label: "Icon", help: "Emoji" },
|
||||
{ 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 },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
107
src/lib/adminSchema/organizations.ts
Normal file
107
src/lib/adminSchema/organizations.ts
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
import { mediaUrl } from "../media.ts";
|
||||
import { PLACE_FIELDS, PUBLISH_FIELDS, timelineGroup, timelineDetailGroup, linksChild, blocksChild } from "./shared.ts";
|
||||
|
||||
/* ── Organizations ───────────────────────────────────────────── */
|
||||
|
||||
export const organizations = {
|
||||
key: "organizations",
|
||||
label: "Organizations",
|
||||
singular: "organization",
|
||||
idLabel: "URL ID",
|
||||
slugFrom: "name",
|
||||
|
||||
list: {
|
||||
columns: [
|
||||
{ key: "name", label: "Name", primary: true },
|
||||
{ key: "kind", label: "Kind" },
|
||||
{ key: "locality", label: "City" },
|
||||
{ key: "state_code", label: "State" },
|
||||
{ key: "is_published", label: "Live", widget: "bool" },
|
||||
{ key: "is_listed", label: "Listed", widget: "bool" },
|
||||
],
|
||||
filters: [
|
||||
{ key: "kind", label: "Kind", options: ["national", "region", "chapter", "partner"] },
|
||||
{ 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: "kind",
|
||||
label: "Kind",
|
||||
widget: "select",
|
||||
options: ["national", "region", "chapter", "partner"],
|
||||
required: true,
|
||||
help: "Changing this swaps which extra fields apply",
|
||||
},
|
||||
{ path: "name", label: "Name", required: true },
|
||||
{ path: "short_name", label: "Short name" },
|
||||
{ path: "tagline", label: "Tagline", full: true },
|
||||
{ path: "color", label: "Colour", widget: "color" },
|
||||
{ path: "logo", label: "Logo", widget: "image", resolve: mediaUrl, full: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Region",
|
||||
when: { path: "kind", value: "region" },
|
||||
fields: [
|
||||
{
|
||||
path: "region.scope",
|
||||
label: "Scope",
|
||||
widget: "select",
|
||||
options: ["domestic", "international", "virtual"],
|
||||
required: true,
|
||||
},
|
||||
{ path: "region.map_note", label: "Map note", full: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Chapter",
|
||||
when: { path: "kind", value: "chapter" },
|
||||
fields: [
|
||||
{
|
||||
path: "chapter.region_id",
|
||||
label: "Region",
|
||||
widget: "select",
|
||||
optionsFrom: "regions",
|
||||
blankLabel: "Default: none",
|
||||
},
|
||||
{ path: "chapter.meets", label: "Meets", help: "2nd Sundays, 6:00pm" },
|
||||
{ path: "chapter.started", label: "Started", help: "Since 2021" },
|
||||
],
|
||||
},
|
||||
{ legend: "Place", fields: PLACE_FIELDS },
|
||||
timelineGroup("organization"),
|
||||
timelineDetailGroup("organization"),
|
||||
{ legend: "Publishing", fields: PUBLISH_FIELDS },
|
||||
],
|
||||
|
||||
children: [
|
||||
{
|
||||
key: "region_areas",
|
||||
label: "Map areas",
|
||||
when: { path: "kind", value: "region" },
|
||||
addLabel: "Add area",
|
||||
title: (row) => row.area_code || "New area",
|
||||
blank: { area_code: "", share: 1 },
|
||||
fields: [
|
||||
{ path: "area_code", label: "Area code", required: true, help: "Two letter state code or Country name" },
|
||||
{ path: "share", label: "Share", widget: "number", help: "1 for the whole tile, 0.5 for half" },
|
||||
{
|
||||
path: "edge",
|
||||
label: "Edge",
|
||||
widget: "select",
|
||||
options: ["top", "bottom"],
|
||||
blankLabel: "Default: whole tile",
|
||||
},
|
||||
{ path: "note", label: "Note", help: "details to explain why it's half or other note" },
|
||||
],
|
||||
},
|
||||
linksChild,
|
||||
blocksChild,
|
||||
],
|
||||
};
|
||||
148
src/lib/adminSchema/people.ts
Normal file
148
src/lib/adminSchema/people.ts
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
import { mediaUrl } from "../media.ts";
|
||||
import { PUBLISHED_FIELD, LISTED_FIELD, AFFILIATION_ROLE_FIELDS, linksChild, blocksChild } from "./shared.ts";
|
||||
|
||||
/* ── People ──────────────────────────────────────────────────── */
|
||||
|
||||
export const people = {
|
||||
key: "people",
|
||||
label: "People",
|
||||
singular: "person",
|
||||
idLabel: "URL ID",
|
||||
slugFrom: "display_name",
|
||||
|
||||
list: {
|
||||
columns: [
|
||||
{ key: "display_name", label: "Name", primary: true },
|
||||
{ key: "tagline", label: "Tagline" },
|
||||
{ key: "locality", label: "City" },
|
||||
{ key: "is_published", label: "Live", widget: "bool" },
|
||||
{ key: "is_listed", label: "Listed", widget: "bool" },
|
||||
],
|
||||
filters: [
|
||||
{ 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: "display_name", label: "Display name", required: true },
|
||||
{ path: "sort_name", label: "Sort name", help: "Doe, Jane" },
|
||||
{ path: "pronouns", label: "Pronouns" },
|
||||
{ path: "tagline", label: "Tagline", full: true },
|
||||
{ path: "photo", label: "Photo", widget: "image", resolve: mediaUrl, full: true },
|
||||
{
|
||||
path: "primary_org_id",
|
||||
label: "Home organization",
|
||||
widget: "select",
|
||||
optionsFrom: "organizations",
|
||||
blankLabel: "Default: none",
|
||||
help: "Optional. Shown above their bio",
|
||||
},
|
||||
{
|
||||
path: "bio",
|
||||
label: "Bio",
|
||||
widget: "textarea",
|
||||
full: true,
|
||||
help: "Leave a blank line between paragraphs",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Public contact",
|
||||
fields: [
|
||||
{ path: "public_email", label: "Email", help: "Printed on the site" },
|
||||
{ path: "public_phone", label: "Phone" },
|
||||
{ path: "locality", label: "City" },
|
||||
{ path: "state_code", label: "State" },
|
||||
{ path: "country", label: "Country" },
|
||||
{ path: "location_label", label: "Display location" },
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Private",
|
||||
note: "Never sent to the public site. Only admins see this.",
|
||||
fields: [
|
||||
{ path: "private.birth_date", label: "Birth date", widget: "date" },
|
||||
{ path: "private.private_email", label: "Email" },
|
||||
{ path: "private.private_phone", label: "Phone" },
|
||||
{ path: "private.address", label: "Address", full: true },
|
||||
{ path: "private.notes", label: "Notes", widget: "textarea", full: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Publishing",
|
||||
note: "Unpublished people are invisible everywhere.",
|
||||
fields: [PUBLISHED_FIELD, LISTED_FIELD],
|
||||
},
|
||||
],
|
||||
|
||||
children: [
|
||||
{
|
||||
key: "affiliations",
|
||||
label: "Roles and organizations",
|
||||
addLabel: "Add role",
|
||||
note:
|
||||
"Where someone appears within a team is set on that team's page, " +
|
||||
"not by the order of this list.",
|
||||
title: (row, options) =>
|
||||
[row.title, options?.organizations?.find((o) => o.id === row.org_id)?.label]
|
||||
.filter(Boolean)
|
||||
.join(" · ") || "New role",
|
||||
blank: { org_id: "", role: "member", is_public: 1, is_owner: 0 },
|
||||
fields: [
|
||||
{
|
||||
path: "org_id",
|
||||
label: "Organization",
|
||||
widget: "select",
|
||||
optionsFrom: "organizations",
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
path: "team_id",
|
||||
label: "Team",
|
||||
widget: "select",
|
||||
optionsFrom: "teams",
|
||||
blankLabel: "Default: none",
|
||||
// A team belongs to an org; offering one from another
|
||||
// org would fail the composite foreign key on save.
|
||||
filterBy: (option, row) => option.org_id === row.org_id,
|
||||
help: "Only teams of the chosen organization",
|
||||
},
|
||||
...AFFILIATION_ROLE_FIELDS,
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "person_awards",
|
||||
label: "Awards",
|
||||
addLabel: "Add award",
|
||||
title: (row, options) =>
|
||||
options?.awards?.find((a) => a.id === row.award_id)?.label ?? "New award",
|
||||
blank: { award_id: "", is_public: 1 },
|
||||
fields: [
|
||||
{
|
||||
path: "award_id",
|
||||
label: "Award",
|
||||
widget: "select",
|
||||
optionsFrom: "awards",
|
||||
required: true,
|
||||
help: "Labelled with the organization that gives it",
|
||||
},
|
||||
{
|
||||
path: "event_id",
|
||||
label: "Presented at",
|
||||
widget: "select",
|
||||
optionsFrom: "events",
|
||||
blankLabel: "Default: none",
|
||||
},
|
||||
{ path: "awarded_on", label: "Date", widget: "date" },
|
||||
{ path: "citation", label: "Citation", widget: "textarea", full: true },
|
||||
{ path: "is_public", label: "Public", widget: "checkbox" },
|
||||
],
|
||||
},
|
||||
linksChild,
|
||||
blocksChild,
|
||||
],
|
||||
};
|
||||
446
src/lib/adminSchema/shared.ts
Normal file
446
src/lib/adminSchema/shared.ts
Normal file
|
|
@ -0,0 +1,446 @@
|
|||
/* Field sets, groups and child collections shared by several entity
|
||||
manifests (adminSchema.ts has the overview). */
|
||||
|
||||
import { preview } from "../text.ts";
|
||||
import { PLATFORMS } from "../platforms.ts";
|
||||
import { FORMATTING_HELP } from "../../components/InlineText.tsx";
|
||||
import { mediaUrl } from "../media.ts";
|
||||
|
||||
export const PLACE_FIELDS = [
|
||||
{ path: "venue", label: "Venue" },
|
||||
{ path: "address", label: "Address", full: true },
|
||||
{ path: "locality", label: "City" },
|
||||
{ path: "state_code", label: "State", help: "Two letters, US only" },
|
||||
{ path: "country", label: "Country", help: "Defaults to US" },
|
||||
{ path: "location_label", label: "Display location", help: "Overrides the line built from city and state" },
|
||||
{ path: "latitude", label: "Latitude", widget: "number" },
|
||||
{ path: "longitude", label: "Longitude", widget: "number" },
|
||||
{ path: "is_online", label: "Online", widget: "checkbox" },
|
||||
];
|
||||
|
||||
export const PUBLISHED_FIELD = { path: "is_published", label: "Published", widget: "checkbox" };
|
||||
|
||||
/* Only means anything on a published record. Unticked, its own page
|
||||
still works but the site's lists, counts and the QR page leave it
|
||||
out. See 027_listed.sql for exactly which. */
|
||||
export const LISTED_FIELD = {
|
||||
path: "is_listed",
|
||||
label: "Listed",
|
||||
widget: "checkbox",
|
||||
help: "Unticked: only reachable by its link",
|
||||
};
|
||||
|
||||
/* For entities whose lists the site orders by hand. Events sort by
|
||||
date and people by sort_name, so they take the first two alone. */
|
||||
export const PUBLISH_FIELDS = [
|
||||
PUBLISHED_FIELD,
|
||||
LISTED_FIELD,
|
||||
{ path: "sort_order", label: "Sort order", widget: "number" },
|
||||
];
|
||||
|
||||
/* The parts of an affiliation that read the same from either end:
|
||||
the person's list of roles, and the team's list of members. */
|
||||
export const AFFILIATION_ROLE_FIELDS = [
|
||||
{ path: "title", label: "Title", help: "eg. Board Chair, Team Lead" },
|
||||
{
|
||||
path: "role",
|
||||
label: "Role",
|
||||
widget: "select",
|
||||
options: ["lead", "board", "staff", "volunteer", "member"],
|
||||
},
|
||||
{ path: "is_owner", label: "Owner", widget: "checkbox", help: "Listed first (can be more than one)" },
|
||||
{ path: "started_on", label: "Started", widget: "date" },
|
||||
{ path: "ended_on", label: "Ended", widget: "date", help: "Blank means current" },
|
||||
{ path: "is_public", label: "Public", widget: "checkbox" },
|
||||
];
|
||||
|
||||
/* The timeline panel that appears on an event or organization once the
|
||||
box is ticked. Paths are prefixed with the extension key, exactly as
|
||||
'region.scope' and 'private.notes' are.
|
||||
|
||||
Everything here is an override. Left blank, the history page falls
|
||||
back to the record's own title, date and logo through v_timeline,
|
||||
which is the point of referencing rather than copying. */
|
||||
export const timelineExtensionFields = (noun) => [
|
||||
{
|
||||
path: "timeline.occurred_on",
|
||||
label: "Date on the timeline",
|
||||
help: `Blank uses the ${noun}'s own date. Partial dates are fine: 2012, 2012-06`,
|
||||
},
|
||||
{
|
||||
path: "timeline.precision",
|
||||
label: "Date precision",
|
||||
widget: "select",
|
||||
options: ["year", "month", "day"],
|
||||
help: "How much of the date to trust. 'year' files it under 'Elsewhere in 2012'",
|
||||
},
|
||||
{
|
||||
path: "timeline.title",
|
||||
label: "Title override",
|
||||
full: true,
|
||||
help: `Blank uses the ${noun}'s name`,
|
||||
},
|
||||
{
|
||||
path: "timeline.blurb",
|
||||
label: "Blurb override",
|
||||
widget: "textarea",
|
||||
full: true,
|
||||
help: `Blank uses the ${noun}'s tagline`,
|
||||
},
|
||||
{ path: "timeline.meta", label: "Secondary line", help: "Region, venue, recipient" },
|
||||
{
|
||||
path: "timeline.link_url",
|
||||
label: "Link override",
|
||||
help: `Blank links to the ${noun}'s own page`,
|
||||
},
|
||||
{
|
||||
path: "timeline.is_featured",
|
||||
label: "Featured",
|
||||
widget: "checkbox",
|
||||
help: "Shown large, above the month list for its year",
|
||||
},
|
||||
{ path: "timeline.is_published", label: "Visible on the history page", widget: "checkbox" },
|
||||
{ path: "timeline.sort_order", label: "Sort order", widget: "number" },
|
||||
];
|
||||
|
||||
/* The checkbox itself, plus the panel it gates. One entry in `groups`. */
|
||||
export const timelineGroup = (noun) => ({
|
||||
legend: "Timeline",
|
||||
note:
|
||||
`Adds this ${noun} to the history page. Nothing is copied, the entry ` +
|
||||
`reads this record, so editing it here updates the timeline too.`,
|
||||
fields: [
|
||||
{
|
||||
path: "in_timeline",
|
||||
label: "On the timeline",
|
||||
widget: "checkbox",
|
||||
help: "Show this on the history page",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
export const timelineDetailGroup = (noun) => ({
|
||||
legend: "Timeline entry",
|
||||
when: { path: "in_timeline", value: 1 },
|
||||
note: "Every field here is optional. Blank means \u201cuse the record's own value\u201d.",
|
||||
fields: timelineExtensionFields(noun),
|
||||
});
|
||||
|
||||
/* Featured cards (030_featured_cards.sql), a front page collection
|
||||
now and the Community blog's next, so it's written once. Fields
|
||||
show by kind; switching kind clears the ones that stop applying
|
||||
(see `when` in fields.tsx). */
|
||||
export const FEATURED_KINDS = [
|
||||
["record", "A page on this site (event, org, person…)"],
|
||||
["link", "A link (article, post, any URL)"],
|
||||
["video", "A video (YouTube, Vimeo, Facebook)"],
|
||||
];
|
||||
|
||||
export const featuredCardsChild = {
|
||||
key: "featured_cards",
|
||||
label: "Featured cards",
|
||||
note: "Shown by the Featured Content section, in this order.",
|
||||
addLabel: "Add card",
|
||||
title: (row, options) =>
|
||||
row.title ||
|
||||
options?.record_refs?.find((o) => o.kind === row.ref_kind && o.id === row.ref_id)?.label ||
|
||||
row.url ||
|
||||
"New card",
|
||||
blank: { kind: "", ref_kind: "", ref_id: "", url: "", title: "" },
|
||||
fields: [
|
||||
{
|
||||
path: "kind",
|
||||
label: "Card type",
|
||||
widget: "select",
|
||||
options: FEATURED_KINDS,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
path: "ref_kind",
|
||||
label: "Record type",
|
||||
widget: "select",
|
||||
options: ["event", "organization", "person", "team", "award"],
|
||||
required: true,
|
||||
when: { path: "kind", value: "record" },
|
||||
},
|
||||
{
|
||||
path: "ref_id",
|
||||
label: "Record",
|
||||
widget: "select",
|
||||
optionsFrom: "record_refs",
|
||||
filterBy: (option, row) => option.kind === row.ref_kind,
|
||||
required: true,
|
||||
when: { path: "kind", value: "record" },
|
||||
help: "Its title, picture and link fill the card. Anything typed below overrides them.",
|
||||
},
|
||||
{
|
||||
path: "url",
|
||||
label: "URL",
|
||||
widget: "linkPreview",
|
||||
previewWhen: { path: "kind", value: "link" },
|
||||
required: true,
|
||||
full: true,
|
||||
when: { path: "kind", value: ["link", "video"] },
|
||||
},
|
||||
{ path: "eyebrow", label: "Label", help: "Small text above the title, eg. Article, Watch" },
|
||||
{ path: "title", label: "Title" },
|
||||
{ path: "blurb", label: "Blurb", widget: "textarea", full: true },
|
||||
{
|
||||
path: "image",
|
||||
label: "Image",
|
||||
widget: "image",
|
||||
resolve: mediaUrl,
|
||||
full: true,
|
||||
help: "Default: the record's own picture, or for a YouTube video, its thumbnail.",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/* The two collections every entity carries. */
|
||||
export const linksChild = {
|
||||
key: "links",
|
||||
label: "Links and socials",
|
||||
addLabel: "Add link",
|
||||
title: (row) => row.label || row.url || "New link",
|
||||
blank: { kind: "action", label: "", url: "", is_primary: 0 },
|
||||
fields: [
|
||||
{
|
||||
path: "kind",
|
||||
label: "Kind",
|
||||
widget: "select",
|
||||
options: ["action", "social", "website", "email"],
|
||||
},
|
||||
{
|
||||
path: "platform",
|
||||
label: "Platform",
|
||||
widget: "select",
|
||||
options: PLATFORMS.map((platform) => [platform.id, platform.label]),
|
||||
blankLabel: "Default: no icon",
|
||||
help: "Shows the platform's icon on the button.",
|
||||
},
|
||||
{ path: "label", label: "Label", required: true },
|
||||
{ path: "url", label: "URL", required: true, full: true },
|
||||
{ path: "is_primary", label: "Primary", widget: "checkbox" },
|
||||
],
|
||||
};
|
||||
|
||||
/* Hosts. One row is one host, ordered, and each is either an
|
||||
organization or a person, never both, which the CHECK on
|
||||
event_hosts enforces and this form can only ask nicely about.
|
||||
|
||||
The first row supplies the logo and colour when the event sets
|
||||
neither, so the order here is data rather than a display choice.
|
||||
A person supplies neither: there is no colour on a person and a
|
||||
headshot is not a logo, so a person-hosted event with no colour
|
||||
of its own falls through to the section default. */
|
||||
export const hostsChild = {
|
||||
key: "event_hosts",
|
||||
label: "Hosts",
|
||||
addLabel: "Add host",
|
||||
title: (row, options) =>
|
||||
options?.organizations?.find((o) => o.id === row.org_id)?.label ??
|
||||
options?.people?.find((p) => p.id === row.person_id)?.label ??
|
||||
"New host",
|
||||
blank: { org_id: "", person_id: "" },
|
||||
fields: [
|
||||
{
|
||||
path: "org_id",
|
||||
label: "Organization",
|
||||
widget: "select",
|
||||
optionsFrom: "organizations",
|
||||
blankLabel: "Default: none",
|
||||
help: "Host Organization"
|
||||
},
|
||||
{
|
||||
path: "person_id",
|
||||
label: "Person",
|
||||
widget: "select",
|
||||
optionsFrom: "people",
|
||||
blankLabel: "Default: none",
|
||||
help: "Use if the host is an individual, choose between person and org host, not both.",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/* Content blocks. The type decides which fields appear (`when`),
|
||||
what the text box is for (`help` as a function), and whether the
|
||||
block has items; the preview under each open block is the site's
|
||||
own renderer. Types and what they read: ContentBlocks.tsx. */
|
||||
export const BLOCK_TYPES = [
|
||||
["paragraph", "Paragraph", "Body text. Formatting: " + FORMATTING_HELP],
|
||||
["heading", "Heading", "A section heading."],
|
||||
["subheading", "Subheading", "A smaller heading under a heading."],
|
||||
["callout", "Callout", "A note or announcement in a tinted box. Formatting: " + FORMATTING_HELP],
|
||||
["quote", "Quote", "A quotation, with who said it. Formatting: " + FORMATTING_HELP],
|
||||
["list", "List", "Bulleted items, each optionally linked, with an optional detail."],
|
||||
["links", "Link buttons", "A row of outlined buttons, one per item."],
|
||||
["button", "Button", "One filled call-to-action button, eg. Register, Donate."],
|
||||
["image", "Image", "A picture, with alt text and an optional caption and link."],
|
||||
["video", "Video", "A YouTube, Vimeo or Facebook video, or a video file, played in place."],
|
||||
["schedule", "Schedule", "Entries in one tab per day, each folding out for more. The text is an optional intro."],
|
||||
["divider", "Divider", "A thin line between parts."],
|
||||
];
|
||||
|
||||
/* An item field that only a schedule's entries have. */
|
||||
export const SCHEDULE_ENTRY = { scope: "parent", path: "type", value: "schedule" };
|
||||
|
||||
export const blockTypeLabel = (type) => BLOCK_TYPES.find(([value]) => value === type)?.[1] ?? type;
|
||||
|
||||
export const TEXT_TYPES = ["paragraph", "heading", "subheading", "callout", "quote", "button", "image", "video", "schedule"];
|
||||
|
||||
export const TEXT_HELP = {
|
||||
paragraph: FORMATTING_HELP,
|
||||
callout: FORMATTING_HELP,
|
||||
quote: FORMATTING_HELP,
|
||||
button: "The button's label, eg. Register now",
|
||||
image: "Caption shown under the image. Optional.",
|
||||
video: "Caption shown under the video. Optional.",
|
||||
schedule: "Optional intro above the tabs. " + FORMATTING_HELP,
|
||||
};
|
||||
|
||||
export const TEXT_LABEL = { button: "Label", image: "Caption", video: "Caption", schedule: "Intro" };
|
||||
|
||||
export const HREF_HELP = {
|
||||
paragraph: "Optional. Makes the whole paragraph one link. For a link inside the text, use [text](url).",
|
||||
button: "Where the button goes, eg. /give or https://…",
|
||||
image: "Optional. Makes the image a link.",
|
||||
video: "The video's page, eg. https://www.youtube.com/watch?v=…, or a video file",
|
||||
};
|
||||
|
||||
export const blocksChild = {
|
||||
key: "content_blocks",
|
||||
label: "Content blocks",
|
||||
addLabel: "Add block",
|
||||
preview: "contentBlock",
|
||||
title: (row) => {
|
||||
const label = blockTypeLabel(row.type) || "Block";
|
||||
const text = preview(row.text || row.href || row.media || "", 40);
|
||||
return text ? `${label}: ${text}` : label;
|
||||
},
|
||||
blank: { slot: "body", type: "paragraph", text: "" },
|
||||
fields: [
|
||||
{
|
||||
path: "slot",
|
||||
label: "Shown in",
|
||||
widget: "select",
|
||||
options: [
|
||||
["body", "The page"],
|
||||
["card", "The card (paragraphs only)"],
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "type",
|
||||
label: "Type",
|
||||
widget: "select",
|
||||
options: BLOCK_TYPES.map(([value, label]) => [value, label]),
|
||||
help: (row) => BLOCK_TYPES.find(([value]) => value === row?.type)?.[2],
|
||||
},
|
||||
{
|
||||
path: "text",
|
||||
label: (row) => TEXT_LABEL[row?.type] ?? "Text",
|
||||
widget: "textarea",
|
||||
full: true,
|
||||
when: { path: "type", value: TEXT_TYPES },
|
||||
help: (row) => TEXT_HELP[row?.type],
|
||||
},
|
||||
{
|
||||
path: "cite",
|
||||
label: "Attribution",
|
||||
help: "Who said it, eg. Jane Doe, Retreat 2024",
|
||||
full: true,
|
||||
when: { path: "type", value: "quote" },
|
||||
},
|
||||
{
|
||||
path: "href",
|
||||
label: "Link",
|
||||
full: true,
|
||||
when: { path: "type", value: ["paragraph", "button", "image", "video"] },
|
||||
help: (row) => HREF_HELP[row?.type],
|
||||
},
|
||||
{
|
||||
path: "media",
|
||||
label: "Image",
|
||||
widget: "image",
|
||||
resolve: mediaUrl,
|
||||
full: true,
|
||||
when: { path: "type", value: ["image", "video"] },
|
||||
help: (row) =>
|
||||
row?.type === "video" ? "Still shown before it plays. Default: YouTube's own thumbnail." : undefined,
|
||||
},
|
||||
{
|
||||
path: "alt",
|
||||
label: "Alt text",
|
||||
full: true,
|
||||
when: { path: "type", value: "image" },
|
||||
help: "Describes the picture for someone who can't see it, eg. Campers around a fire at dusk",
|
||||
},
|
||||
],
|
||||
children: [
|
||||
{
|
||||
key: "items",
|
||||
label: "Items",
|
||||
addLabel: "Add item",
|
||||
when: { path: "type", value: ["list", "links", "schedule"] },
|
||||
title: (row) => [row.day, row.time, row.text].filter(Boolean).join(" · ") || "New item",
|
||||
blank: { text: "" },
|
||||
fields: [
|
||||
{
|
||||
path: "day",
|
||||
label: "Day",
|
||||
help: "The tab it's under, eg. Friday. Entries with the same day share a tab, in this order.",
|
||||
when: SCHEDULE_ENTRY,
|
||||
},
|
||||
{ path: "time", label: "Time", help: "eg. 7:00pm, or 9:00 to 10:30am", when: SCHEDULE_ENTRY },
|
||||
{ path: "text", label: "Text", required: true, help: "Schedules: the entry's title" },
|
||||
{
|
||||
path: "location",
|
||||
label: "Location",
|
||||
help: "eg. Main Hall",
|
||||
when: SCHEDULE_ENTRY,
|
||||
},
|
||||
{
|
||||
path: "person_id",
|
||||
label: "Person",
|
||||
widget: "select",
|
||||
optionsFrom: "people",
|
||||
blankLabel: "Default: none",
|
||||
help: "Who hosts or speaks: shown with their photo, linked to their page",
|
||||
when: SCHEDULE_ENTRY,
|
||||
},
|
||||
{ path: "detail", label: "Detail", help: "A line under the text. Lists: shown after the text" },
|
||||
{ path: "url", label: "URL", help: "Blank for plain text. Link buttons need one." },
|
||||
{
|
||||
path: "description",
|
||||
label: "More",
|
||||
widget: "textarea",
|
||||
full: true,
|
||||
help: "Shown when the entry is folded out. " + FORMATTING_HELP,
|
||||
when: SCHEDULE_ENTRY,
|
||||
},
|
||||
{
|
||||
path: "media",
|
||||
label: "Graphic",
|
||||
widget: "image",
|
||||
resolve: mediaUrl,
|
||||
full: true,
|
||||
help: "Optional, in the fold-out: a map of the site, a slide, a poster",
|
||||
when: SCHEDULE_ENTRY,
|
||||
},
|
||||
{
|
||||
path: "media_alt",
|
||||
label: "Graphic description",
|
||||
full: true,
|
||||
help: "For screen readers: what the graphic shows, eg. a map of the camp. Default: skipped as decoration.",
|
||||
when: SCHEDULE_ENTRY,
|
||||
},
|
||||
{
|
||||
path: "map",
|
||||
label: "Map",
|
||||
full: true,
|
||||
help: "Optional, in the fold-out: a place or address for a Google map, eg. Camp Hebron, Halifax PA",
|
||||
when: SCHEDULE_ENTRY,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
120
src/lib/adminSchema/siteSettings.ts
Normal file
120
src/lib/adminSchema/siteSettings.ts
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
import siteConfiguration from "../../../site.json";
|
||||
import { mediaUrl } from "../media.ts";
|
||||
|
||||
/* ── Site settings (035_site_settings.sql) ───────────────────────
|
||||
Overrides for site.json, superadmins only: every blank falls back
|
||||
to what site.json says, which is shown as the default. */
|
||||
const SITE_PAGES: [string, string][] = Object.entries(siteConfiguration.pages).map(
|
||||
([path, page]) => [path, `${page.title} (${path})`],
|
||||
);
|
||||
|
||||
export const siteSettings = {
|
||||
key: "site_settings",
|
||||
label: "Site settings",
|
||||
singular: "site settings",
|
||||
idLabel: "Settings",
|
||||
singleton: "site",
|
||||
writeRole: "superadmin",
|
||||
|
||||
list: { columns: [], filters: [] },
|
||||
|
||||
groups: [
|
||||
{
|
||||
legend: "The site",
|
||||
note: "Anything left blank uses site.json, so the build and these settings agree until you change one.",
|
||||
fields: [
|
||||
{ path: "site_name", label: "Site name", help: `Default: ${siteConfiguration.title}` },
|
||||
{
|
||||
path: "description",
|
||||
label: "Description",
|
||||
widget: "textarea",
|
||||
full: true,
|
||||
help: "Search engines and link previews show this for pages without their own. Default: site.json's, or the front page's subhead.",
|
||||
},
|
||||
{
|
||||
path: "preview_image",
|
||||
label: "Preview image",
|
||||
widget: "image",
|
||||
resolve: mediaUrl,
|
||||
full: true,
|
||||
help: "Shown when a page without its own image is shared. 1200 × 630 works everywhere.",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Icons",
|
||||
fields: [
|
||||
{
|
||||
path: "favicon",
|
||||
label: "Favicon",
|
||||
widget: "image",
|
||||
resolve: mediaUrl,
|
||||
full: true,
|
||||
help: "The browser-tab icon: a square PNG (512px) or an SVG. Keep original when uploading an SVG.",
|
||||
},
|
||||
{
|
||||
path: "apple_touch_icon",
|
||||
label: "Home-screen icon",
|
||||
widget: "image",
|
||||
resolve: mediaUrl,
|
||||
full: true,
|
||||
help: "For iPhones saving the site to their home screen: a square PNG, 180px, no transparency.",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Search engines",
|
||||
fields: [
|
||||
{
|
||||
path: "indexing",
|
||||
label: "Let search engines list this site",
|
||||
widget: "select",
|
||||
options: [
|
||||
["on", "On: pages can appear in Google"],
|
||||
["off", "Off: hidden from search (use on the dev server)"],
|
||||
],
|
||||
blankLabel: `Default: site.json (${siteConfiguration.robots?.index === false ? "off" : "on"})`,
|
||||
help: "Applies to this server's database only, so dev can be off while production is on.",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Privacy",
|
||||
fields: [
|
||||
{
|
||||
path: "privacy_email",
|
||||
label: "Privacy contact email",
|
||||
help: `The Privacy page gives this for privacy questions and data requests, eg. privacy@nextgenerationofunity.org. ${
|
||||
siteConfiguration.privacyEmail ? `Default: ${siteConfiguration.privacyEmail}` : "Default: none, the page offers its request form only"
|
||||
}.`,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
children: [
|
||||
{
|
||||
key: "pages",
|
||||
label: "Page titles and intros",
|
||||
note: "Change a static page's heading and intro, which are also its search title and description. Blank fields keep site.json's.",
|
||||
addLabel: "Change a page",
|
||||
title: (row) => SITE_PAGES.find(([path]) => path === row.path)?.[1] ?? "New page",
|
||||
blank: { path: "", title: "", description: "" },
|
||||
fields: [
|
||||
{ path: "path", label: "Page", widget: "select", options: SITE_PAGES, required: true },
|
||||
{
|
||||
path: "title",
|
||||
label: "Title",
|
||||
help: (row) => (row?.path ? `Default: ${siteConfiguration.pages[row.path]?.title ?? ""}` : undefined),
|
||||
},
|
||||
{
|
||||
path: "description",
|
||||
label: "Intro",
|
||||
widget: "textarea",
|
||||
full: true,
|
||||
help: (row) => (row?.path ? `Default: ${siteConfiguration.pages[row.path]?.description ?? ""}` : undefined),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
83
src/lib/adminSchema/teams.ts
Normal file
83
src/lib/adminSchema/teams.ts
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
import { mediaUrl } from "../media.ts";
|
||||
import { PUBLISH_FIELDS, AFFILIATION_ROLE_FIELDS, linksChild, blocksChild } from "./shared.ts";
|
||||
|
||||
/* ── Teams ───────────────────────────────────────────────────── */
|
||||
|
||||
export const teams = {
|
||||
key: "teams",
|
||||
label: "Teams",
|
||||
singular: "team",
|
||||
idLabel: "URL ID",
|
||||
// teams.id is a global primary key, not scoped to the org, so
|
||||
// 'board' can only exist once across the whole site. Composing
|
||||
// the slug from both fields is what keeps NGU's board and the
|
||||
// Northwest's board from colliding.
|
||||
slugFrom: ["org_id", "name"],
|
||||
|
||||
list: {
|
||||
columns: [
|
||||
{ key: "name", label: "Name", primary: true },
|
||||
{ key: "org_id", label: "Organization" },
|
||||
{ key: "tagline", label: "Tagline" },
|
||||
{ key: "is_published", label: "Live", widget: "bool" },
|
||||
{ key: "is_listed", label: "Listed", widget: "bool" },
|
||||
],
|
||||
filters: [
|
||||
{ key: "org_id", label: "Organization", 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:
|
||||
"Pick the organization first: the id is built from it, " +
|
||||
"and it can't be changed once anyone is filed under this team.",
|
||||
fields: [
|
||||
{
|
||||
path: "org_id",
|
||||
label: "Organization",
|
||||
widget: "select",
|
||||
optionsFrom: "organizations",
|
||||
required: true,
|
||||
help: "Who this team belongs to",
|
||||
},
|
||||
{ path: "name", label: "Name", required: true, help: "Board, Leadership Team" },
|
||||
{ path: "tagline", label: "Tagline", full: true },
|
||||
{ path: "color", label: "Colour", widget: "color" },
|
||||
{ path: "logo", label: "Logo", widget: "image", resolve: mediaUrl, full: true },
|
||||
],
|
||||
},
|
||||
{ legend: "Publishing", fields: PUBLISH_FIELDS },
|
||||
],
|
||||
|
||||
children: [
|
||||
{
|
||||
key: "members",
|
||||
label: "Members",
|
||||
addLabel: "Add member",
|
||||
note:
|
||||
"This order is the order they appear on the site. Owners are " +
|
||||
"still listed first, in this order among themselves.",
|
||||
title: (row, options) =>
|
||||
[options?.people?.find((p) => p.id === row.person_id)?.label, row.title]
|
||||
.filter(Boolean)
|
||||
.join(" · ") || "New member",
|
||||
blank: { person_id: "", role: "member", is_public: 1, is_owner: 0 },
|
||||
fields: [
|
||||
{
|
||||
path: "person_id",
|
||||
label: "Person",
|
||||
widget: "select",
|
||||
optionsFrom: "people",
|
||||
required: true,
|
||||
},
|
||||
...AFFILIATION_ROLE_FIELDS,
|
||||
],
|
||||
},
|
||||
linksChild,
|
||||
blocksChild,
|
||||
],
|
||||
};
|
||||
152
src/lib/adminSchema/timeline.ts
Normal file
152
src/lib/adminSchema/timeline.ts
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
/* ── Timeline ─────────────────────────────────────────── */
|
||||
|
||||
// The only entity with no slug: the table assigns the id, because an
|
||||
// entry referencing an event has no name of its own and one gets
|
||||
// created every time somebody ticks a checkbox. `idKind: "auto"` tells
|
||||
// EntityEdit to show the id rather than ask for it.
|
||||
//
|
||||
// Most rows here are created from an event or organization page, not
|
||||
// this one. What this page is for: hand-authored milestones with no
|
||||
// record behind them, 'people' entries about a team forming, and fixing
|
||||
// up the entries the checkboxes made.
|
||||
export const timeline = {
|
||||
key: "timeline",
|
||||
label: "Timeline",
|
||||
singular: "entry",
|
||||
idLabel: "Entry",
|
||||
idKind: "auto",
|
||||
titleFrom: "title",
|
||||
|
||||
list: {
|
||||
columns: [
|
||||
{ key: "title", label: "Title", primary: true },
|
||||
{ key: "occurred_on", label: "Date" },
|
||||
{ key: "kind", label: "Kind" },
|
||||
{ key: "ref_id", label: "References" },
|
||||
{ key: "is_featured", label: "Featured", widget: "bool" },
|
||||
{ key: "is_published", label: "Live", widget: "bool" },
|
||||
],
|
||||
filters: [
|
||||
{
|
||||
key: "kind",
|
||||
label: "Kind",
|
||||
options: ["milestone", "event", "organization", "award", "people"],
|
||||
},
|
||||
{
|
||||
key: "ref_kind",
|
||||
label: "References",
|
||||
options: ["event", "organization", "award", "person", "team"],
|
||||
},
|
||||
{ key: "is_featured", label: "Featured", options: [["1", "Featured"], ["0", "Normal"]] },
|
||||
{ key: "is_published", label: "Published", options: [["1", "Live"], ["0", "Hidden"]] },
|
||||
],
|
||||
},
|
||||
|
||||
groups: [
|
||||
{
|
||||
legend: "What this is",
|
||||
note:
|
||||
"An entry either points at a record or stands on its own. " +
|
||||
"Pointing at one means its title, date and logo come from that " +
|
||||
"record and nothing is copied, so editing the record updates this.",
|
||||
fields: [
|
||||
{
|
||||
path: "kind",
|
||||
label: "Kind",
|
||||
widget: "select",
|
||||
options: ["milestone", "event", "organization", "award", "people"],
|
||||
required: true,
|
||||
help: "Drives the marker and the layout. 'people' renders a roster",
|
||||
},
|
||||
{
|
||||
path: "ref_kind",
|
||||
label: "Points at",
|
||||
widget: "select",
|
||||
options: ["event", "organization", "award", "person", "team"],
|
||||
blankLabel: "Default: nothing",
|
||||
help: "Changing this leaves the record below orphaned, pick a new one",
|
||||
},
|
||||
{
|
||||
path: "ref_id",
|
||||
label: "Record",
|
||||
widget: "select",
|
||||
optionsFrom: "record_refs",
|
||||
blankLabel: "Default: none",
|
||||
// One flat list of every referenceable row, narrowed to the
|
||||
// kind chosen above. Five dropdowns of which four are always
|
||||
// wrong would be worse.
|
||||
filterBy: (option, row) => option.kind === row.ref_kind,
|
||||
help: "Only records of the kind chosen above",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "When",
|
||||
note:
|
||||
"Blank takes the referenced record's own date. Precision is what " +
|
||||
"says how much of the date to believe, a backfilled entry that " +
|
||||
"only knows the year should say so.",
|
||||
fields: [
|
||||
{
|
||||
path: "occurred_on",
|
||||
label: "Date",
|
||||
help: "2012, 2012-06 or 2012-06-14",
|
||||
},
|
||||
{
|
||||
path: "precision",
|
||||
label: "Precision",
|
||||
widget: "select",
|
||||
options: ["year", "month", "day"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Text",
|
||||
note: "All optional. Blank uses the referenced record's own wording.",
|
||||
fields: [
|
||||
{ path: "title", label: "Title", full: true },
|
||||
{ path: "blurb", label: "Blurb", widget: "textarea", full: true },
|
||||
{ path: "meta", label: "Secondary line", help: "Region, venue, recipient" },
|
||||
{ path: "link_url", label: "Link", help: "Blank links to the record's own page" },
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Publishing",
|
||||
fields: [
|
||||
{
|
||||
path: "is_featured",
|
||||
label: "Featured",
|
||||
widget: "checkbox",
|
||||
help: "Shown large, above the month list for its year",
|
||||
},
|
||||
{ path: "is_published", label: "Published", widget: "checkbox" },
|
||||
{ path: "sort_order", label: "Sort order", widget: "number" },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
children: [
|
||||
{
|
||||
key: "people",
|
||||
label: "People",
|
||||
addLabel: "Add person",
|
||||
note:
|
||||
"For an entry about people. A 'people' entry pointing at a team " +
|
||||
"already shows that team's members, this is for the cases where " +
|
||||
"the list is editorial rather than structural.",
|
||||
title: (row, options) =>
|
||||
options?.people?.find((p) => p.id === row.person_id)?.label ?? "New person",
|
||||
blank: { person_id: "" },
|
||||
fields: [
|
||||
{
|
||||
path: "person_id",
|
||||
label: "Person",
|
||||
widget: "select",
|
||||
optionsFrom: "people",
|
||||
required: true,
|
||||
},
|
||||
{ path: "note", label: "Note", help: "Founding lead, first chair" },
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
hand a file to <video> and a link to an <iframe>.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { heroVideo } from './media.ts'
|
||||
import { mediaUrl } from './media.ts'
|
||||
|
||||
const VIDEO_FILE = /\.(mp4|webm|m4v|mov|ogv)$/i
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ export function videoSource(raw?: string | null): VideoSource | null {
|
|||
|
||||
if (VIDEO_FILE.test(value.split(/[?#]/)[0])) {
|
||||
if (/^https:\/\//i.test(value) || !/^[a-z][a-z0-9+.-]*:/i.test(value)) {
|
||||
const src = heroVideo(value)
|
||||
const src = mediaUrl(value)
|
||||
if (src) return { kind: 'file', src }
|
||||
}
|
||||
return null
|
||||
|
|
|
|||
|
|
@ -152,8 +152,6 @@ export function refHref(
|
|||
}
|
||||
}
|
||||
|
||||
/* What to call the kind in a breadcrumb or a back link. */
|
||||
|
||||
/* Where "back" goes from a record page. A chapter belongs to
|
||||
/community, a retreat to /retreats. */
|
||||
export function orgListHref(kind?: string | null): { to: string; label: string } {
|
||||
|
|
|
|||
|
|
@ -24,72 +24,17 @@
|
|||
|
||||
const ABSOLUTE = /^(https?:|\/|data:)/
|
||||
|
||||
function inDir(dir: string) {
|
||||
return (file?: string | null): string | null => {
|
||||
if (!file) return null
|
||||
if (ABSOLUTE.test(file)) return file
|
||||
return `${dir}/${file}`
|
||||
}
|
||||
}
|
||||
const UPLOADS = '/uploads'
|
||||
|
||||
export const UPLOADS = '/uploads'
|
||||
|
||||
const inUploads = inDir(UPLOADS)
|
||||
|
||||
/* One helper per field, all the same rule, so a caller says what the
|
||||
image is and a future exception is one line here. */
|
||||
export const personPhoto = inUploads
|
||||
export const eventLogo = inUploads
|
||||
export const eventBackground = inUploads
|
||||
export const orgLogo = inUploads
|
||||
export const teamLogo = inUploads
|
||||
export const awardLogo = inUploads
|
||||
|
||||
/* front_page_slides.media, the hero's photos. */
|
||||
export const heroPhoto = inUploads
|
||||
|
||||
/* front_page.video_url when it names a file rather than a link.
|
||||
Videos can't be uploaded through the media library, so a file is
|
||||
one copied into the uploads directory by hand. */
|
||||
export const heroVideo = inUploads
|
||||
|
||||
/* content_blocks.media and content_block_items.media. */
|
||||
export const blockMedia = inUploads
|
||||
|
||||
/* featured_cards.image. */
|
||||
export const featuredImage = inUploads
|
||||
|
||||
/* blog_posts.cover_image and guest_photo. */
|
||||
export const blogImage = inUploads
|
||||
|
||||
/* ── By record kind ────────────────────────────────────────────
|
||||
The timeline sends `logo: { file, kind }` rather than a path,
|
||||
because v_timeline COALESCEs across five tables and only the
|
||||
ref_kind says which one the filename came from. Featured cards
|
||||
send the same shape. Every kind resolves to the uploads directory
|
||||
today; the map is what lets one kind differ later.
|
||||
───────────────────────────────────────────────────────────── */
|
||||
|
||||
const BY_KIND: Record<string, (file?: string | null) => string | null> = {
|
||||
event: eventLogo,
|
||||
organization: orgLogo,
|
||||
team: teamLogo,
|
||||
award: awardLogo,
|
||||
person: personPhoto,
|
||||
// Featured cards (loadFeaturedCards in shape.js) add two of their own.
|
||||
'event-background': eventBackground,
|
||||
featured: featuredImage,
|
||||
}
|
||||
|
||||
export function logoForKind(
|
||||
kind?: string | null,
|
||||
file?: string | null,
|
||||
): string | null {
|
||||
/* Any record image or media field (photos, logos, backgrounds, hero
|
||||
slides and video files, block and card images, blog covers), and
|
||||
the timeline's and featured cards' `{ file, kind }` logos by their
|
||||
file. One rule for all of them; if a kind ever needs its own
|
||||
directory, that's the time to add a parameter. */
|
||||
export function mediaUrl(file?: string | null): string | null {
|
||||
if (!file) return null
|
||||
// An unrecognised kind still renders: a filename with no home
|
||||
// directory is a bug, but a broken <img> says so louder than a
|
||||
// silently absent one.
|
||||
return (BY_KIND[kind ?? ''] ?? blockMedia)(file)
|
||||
if (ABSOLUTE.test(file)) return file
|
||||
return `${UPLOADS}/${file}`
|
||||
}
|
||||
|
||||
/* Initials for a photo that is missing or fails to load. Same
|
||||
|
|
|
|||
5
src/lib/motion.ts
Normal file
5
src/lib/motion.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
/* Smooth scrolling, unless the visitor has asked for less motion.
|
||||
index.css covers CSS scrolling; this is for scrollIntoView and
|
||||
scrollTo calls, which don't read that setting themselves. */
|
||||
export const scrollBehavior = (): ScrollBehavior =>
|
||||
window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth'
|
||||
|
|
@ -23,6 +23,7 @@
|
|||
fetch.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { isBadId, orgHref } from "./hrefs.ts";
|
||||
import { useResource } from "./useResource.ts";
|
||||
|
||||
|
||||
|
|
@ -41,20 +42,15 @@ export function useOrganizations(kind) {
|
|||
}
|
||||
|
||||
/* ── Where an organization's page lives ────────────────────────
|
||||
One place to change when routes move. Kinds with no page of
|
||||
their own return null, and a list should render no link rather
|
||||
than a dead one.
|
||||
The route is hrefs.ts's (orgHref). A list links only the kinds
|
||||
with a page of their own, and renders no link rather than a dead
|
||||
one for the rest (NGU itself) or a bad id.
|
||||
───────────────────────────────────────────────────────────── */
|
||||
|
||||
const PATHS = {
|
||||
region: "/regions",
|
||||
chapter: "/chapters",
|
||||
partner: "/partners",
|
||||
};
|
||||
const WITH_PAGE = new Set(["region", "chapter", "partner"]);
|
||||
|
||||
export function orgPath(org) {
|
||||
const base = PATHS[org?.kind];
|
||||
return base ? `${base}/${org.id}` : null;
|
||||
return WITH_PAGE.has(org?.kind) && !isBadId(org.id) ? orgHref(org.id, org.kind) : null;
|
||||
}
|
||||
|
||||
/* ── "AK, ID, MT, OR, UT (Salt Lake City area), WA" ────────────
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { refHref } from './hrefs.ts'
|
||||
import { logoForKind, personPhoto } from './media.ts'
|
||||
import { mediaUrl } from './media.ts'
|
||||
import type { TimelineItem } from './timeline.ts'
|
||||
|
||||
/**
|
||||
|
|
@ -58,18 +58,9 @@ export function hrefFor(item: TimelineItem): string | null {
|
|||
}
|
||||
|
||||
/**
|
||||
* The entry's image, resolved against the directory for whatever
|
||||
* kind of record the filename came from.
|
||||
* The entry's image, whatever kind of record the filename came from.
|
||||
*/
|
||||
export function logoSrc(item: TimelineItem): string | null {
|
||||
if (!item.logo) return null
|
||||
return logoForKind(item.logo.kind, item.logo.file)
|
||||
}
|
||||
|
||||
/**
|
||||
* A roster member's photo. Same rule as everywhere else, the API
|
||||
* sends a bare filename.
|
||||
*/
|
||||
export function photoSrc(photo?: string | null): string | null {
|
||||
return personPhoto(photo)
|
||||
return mediaUrl(item.logo.file)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ export type FeaturedCard = {
|
|||
eyebrow?: string | null
|
||||
title?: string | null
|
||||
blurb?: string | null
|
||||
/** Resolve with logoForKind in media.ts. */
|
||||
/** Resolve the file with mediaUrl in media.ts. */
|
||||
image: { file: string; kind: string } | null
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,83 +1,17 @@
|
|||
/**
|
||||
* Loads the history timeline from `GET /api/history`.
|
||||
* Loads the history timeline from `GET /api/history`, through
|
||||
* useRecord (its `items`), so it shares the cache, the reload that
|
||||
* invalidates first, and the error handling with every detail page.
|
||||
*
|
||||
* Goes through the shared client, so the request is deduped and cached
|
||||
* for 60s like every other read. Two consequences worth knowing:
|
||||
*
|
||||
* · `reload` has to invalidate before it refetches. Without that, the
|
||||
* retry button inside the TTL would hand back the same settled
|
||||
* promise and look like it did nothing. A *failed* request is
|
||||
* already evicted by the client, so this matters for the refresh
|
||||
* case rather than the error case.
|
||||
*
|
||||
* · there's no AbortController. `get` shares one promise between
|
||||
* callers, so aborting on unmount would cancel someone else's
|
||||
* request. The `live` flag drops the result instead.
|
||||
*
|
||||
*
|
||||
* `undated` is the number of published entries the API left out because
|
||||
* nothing gave them a date. Not rendered publicly, a visitor can't act
|
||||
* on it, but returned so it's reachable if you want a warning in the
|
||||
* admin later.
|
||||
* The API also sends `undated`, the number of published entries it
|
||||
* left out for having no date. Nothing shows it; read it here if the
|
||||
* admin ever wants a warning.
|
||||
*/
|
||||
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { get, invalidate, ApiError } from './api.ts'
|
||||
import type { TimelineItem } from './timeline.ts'
|
||||
import { useRecord } from './useRecord.ts'
|
||||
|
||||
const PATH = '/history'
|
||||
|
||||
type HistoryResponse = {
|
||||
items?: TimelineItem[]
|
||||
undated?: number
|
||||
}
|
||||
|
||||
type State = {
|
||||
items: TimelineItem[]
|
||||
undated: number
|
||||
loading: boolean
|
||||
error: string | null
|
||||
reload: () => void
|
||||
}
|
||||
|
||||
export function useHistory(): State {
|
||||
const [items, setItems] = useState<TimelineItem[]>([])
|
||||
const [undated, setUndated] = useState(0)
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [attempt, setAttempt] = useState(0)
|
||||
|
||||
const reload = useCallback(() => {
|
||||
invalidate(PATH)
|
||||
setAttempt((n) => n + 1)
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
let live = true
|
||||
|
||||
async function load() {
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
try {
|
||||
const data: HistoryResponse = await get(PATH)
|
||||
if (!live) return
|
||||
setItems(Array.isArray(data?.items) ? data.items : [])
|
||||
setUndated(Number(data?.undated) || 0)
|
||||
} catch (err) {
|
||||
if (!live) return
|
||||
setError(
|
||||
err instanceof ApiError ? err.message : "Couldn't reach the server.",
|
||||
)
|
||||
} finally {
|
||||
if (live) setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
load()
|
||||
return () => {
|
||||
live = false
|
||||
}
|
||||
}, [attempt])
|
||||
|
||||
return { items, undated, loading, error, reload }
|
||||
export function useHistory() {
|
||||
const { data, loading, error, reload } = useRecord<TimelineItem[]>('/history', 'items')
|
||||
return { items: data ?? [], loading, error, reload }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
/**
|
||||
* useRecord, one record from one endpoint, on the useHistory
|
||||
* pattern.
|
||||
* useRecord, one record (one top-level key) from one endpoint.
|
||||
*
|
||||
* Named for what it returns, and deliberately not useResource:
|
||||
* src/lib/useResource.ts is a different hook, it hands back the
|
||||
|
|
@ -21,7 +20,7 @@
|
|||
* out would silently use a stale closure. A string has neither
|
||||
* problem.
|
||||
*
|
||||
* Carried over from useHistory, and worth restating:
|
||||
* Worth knowing:
|
||||
*
|
||||
* · `reload` invalidates before it refetches. Without that, the
|
||||
* retry button inside the 60s TTL hands back the same settled
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import PageShell from '../components/PageShell.tsx'
|
|||
import PageState from '../components/PageState.tsx'
|
||||
import { useAward, type Recipient } from '../lib/useContent.ts'
|
||||
import { eventHref, orgHref, personHref } from '../lib/hrefs.ts'
|
||||
import { awardLogo, initials, personPhoto } from '../lib/media.ts'
|
||||
import { mediaUrl, initials } from '../lib/media.ts'
|
||||
import { accentText } from '../lib/color.ts'
|
||||
|
||||
const TEAL = '#0f7183'
|
||||
|
|
@ -47,7 +47,7 @@ export default function AwardDetail() {
|
|||
}
|
||||
|
||||
const accent = TEAL
|
||||
const logo = awardLogo(award.logo)
|
||||
const logo = mediaUrl(award.logo)
|
||||
|
||||
return (
|
||||
<PageShell
|
||||
|
|
@ -105,7 +105,7 @@ export default function AwardDetail() {
|
|||
}
|
||||
|
||||
function RecipientRow({ recipient, accent }: { recipient: Recipient; accent: string }) {
|
||||
const photo = personPhoto(recipient.photo)
|
||||
const photo = mediaUrl(recipient.photo)
|
||||
|
||||
return (
|
||||
<div className="flex gap-5">
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import PageShell, { type ShellSection } from '../components/PageShell.tsx'
|
|||
import PageState from '../components/PageState.tsx'
|
||||
import ContentBlocks from '../components/ContentBlocks.tsx'
|
||||
import PeopleTiles from '../components/PeopleTiles.tsx'
|
||||
import { blogImage, personPhoto } from '../lib/media.ts'
|
||||
import { mediaUrl } from '../lib/media.ts'
|
||||
import { postDate, useBlogPost } from '../lib/useBlog.ts'
|
||||
import { accentText } from '../lib/color.ts'
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ export default function BlogPost() {
|
|||
}
|
||||
|
||||
const date = postDate(post.published_on)
|
||||
const cover = blogImage(post.cover_image)
|
||||
const cover = mediaUrl(post.cover_image)
|
||||
const byline = [
|
||||
...post.authors.map((author) => author.name),
|
||||
...(post.guest ? [post.guest.name] : []),
|
||||
|
|
@ -57,9 +57,9 @@ export default function BlogPost() {
|
|||
name: author.name,
|
||||
tagline: author.tagline,
|
||||
pronouns: author.pronouns,
|
||||
photo: personPhoto(author.photo),
|
||||
photo: mediaUrl(author.photo),
|
||||
})),
|
||||
...(post.guest ? [{ name: post.guest.name, title: 'Guest author', photo: blogImage(post.guest.photo) }] : []),
|
||||
...(post.guest ? [{ name: post.guest.name, title: 'Guest author', photo: mediaUrl(post.guest.photo) }] : []),
|
||||
]
|
||||
|
||||
const sections: ShellSection[] = [
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import {
|
|||
type EventRecord,
|
||||
} from '../lib/useContent.ts'
|
||||
import { awardHref, personHref, refHref } from '../lib/hrefs.ts'
|
||||
import { personPhoto } from '../lib/media.ts'
|
||||
import { mediaUrl } from '../lib/media.ts'
|
||||
import { eventTypeLabel } from '../lib/eventTypes.ts'
|
||||
import { occurrenceLabel, seriesLabel, seriesTimes, upcomingOccurrences } from '../lib/eventSeries.ts'
|
||||
import { capitalize } from '../lib/text.ts'
|
||||
|
|
@ -395,7 +395,7 @@ function peopleGroups(people: EventPerson[], accent: string): PeopleGroupInput[]
|
|||
pronouns: person.pronouns,
|
||||
// PeopleTiles resolves a bare filename itself; this is here
|
||||
// so a hand-written entry elsewhere can't diverge.
|
||||
photo: personPhoto(person.photo),
|
||||
photo: mediaUrl(person.photo),
|
||||
})),
|
||||
}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,9 @@ import {
|
|||
type OrganizationRecord,
|
||||
} from '../lib/useContent.ts'
|
||||
import { orgHref, orgListHref, teamHref } from '../lib/hrefs.ts'
|
||||
import { orgLogo, personPhoto } from '../lib/media.ts'
|
||||
import { withAlpha, accentText } from '../lib/color.ts'
|
||||
import { initials, mediaUrl } from '../lib/media.ts'
|
||||
import Logo from '../components/Logo.tsx'
|
||||
import { withAlpha, accentText, readableOn } from '../lib/color.ts'
|
||||
|
||||
const TEAL = '#0f7183'
|
||||
const BODY = 'var(--color-muted)'
|
||||
|
|
@ -147,7 +148,7 @@ export default function OrganizationDetail() {
|
|||
title: leader.title,
|
||||
pronouns: leader.pronouns,
|
||||
public_email: leader.public_email,
|
||||
photo: personPhoto(leader.photo),
|
||||
photo: mediaUrl(leader.photo),
|
||||
is_owner: leader.is_owner,
|
||||
}))}
|
||||
/>
|
||||
|
|
@ -179,7 +180,7 @@ export default function OrganizationDetail() {
|
|||
className="flex items-center gap-4 rounded-lg border p-4 transition-colors hover:bg-tint"
|
||||
style={{ borderColor: `${withAlpha(accent, 25)}` }}
|
||||
>
|
||||
<Logo file={chapter.logo} name={chapter.name} accent={accent} />
|
||||
<ChapterMark file={chapter.logo} name={chapter.name} accent={accent} />
|
||||
<span>
|
||||
<span className="block font-semibold" style={{ color: accentText(accent) }}>
|
||||
{chapter.name}
|
||||
|
|
@ -359,28 +360,22 @@ function Contact({ org, accent }: { org: OrganizationRecord; accent: string }) {
|
|||
)
|
||||
}
|
||||
|
||||
function Logo({
|
||||
file,
|
||||
name,
|
||||
accent,
|
||||
}: {
|
||||
file?: string | null
|
||||
name: string
|
||||
accent: string
|
||||
}) {
|
||||
const src = orgLogo(file)
|
||||
if (!src) {
|
||||
return (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="flex h-10 w-10 shrink-0 items-center justify-center rounded-full text-xs font-bold text-white"
|
||||
style={{ background: accent }}
|
||||
>
|
||||
{name.slice(0, 2).toUpperCase()}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
return <img src={src} alt="" loading="lazy" className="h-10 w-10 shrink-0 object-contain" />
|
||||
function ChapterMark({ file, name, accent }: { file?: string | null; name: string; accent: string }) {
|
||||
return (
|
||||
<Logo
|
||||
src={mediaUrl(file)}
|
||||
className="h-10 w-10 shrink-0 object-contain"
|
||||
fallback={
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="flex h-10 w-10 shrink-0 items-center justify-center rounded-full text-xs font-bold"
|
||||
style={{ background: accent, color: readableOn(accent) }}
|
||||
>
|
||||
{initials(name)}
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
/* ── Leadership → team blocks ────────────────────────────────── */
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import {
|
|||
type PersonRole,
|
||||
} from '../lib/useContent.ts'
|
||||
import { awardHref, eventHref, orgHref, teamHref } from '../lib/hrefs.ts'
|
||||
import { initials, personPhoto } from '../lib/media.ts'
|
||||
import { mediaUrl, initials } from '../lib/media.ts'
|
||||
import { eventTypeLabel } from '../lib/eventTypes.ts'
|
||||
import { capitalize } from '../lib/text.ts'
|
||||
import { accentText } from '../lib/color.ts'
|
||||
|
|
@ -199,7 +199,7 @@ export default function PersonDetail() {
|
|||
/* ── The strip of facts under the heading ────────────────────── */
|
||||
|
||||
function Facts({ person, accent }: { person: PersonRecord; accent: string }) {
|
||||
const photo = personPhoto(person.photo)
|
||||
const photo = mediaUrl(person.photo)
|
||||
|
||||
return (
|
||||
<div className="flex flex-wrap items-center gap-x-6 gap-y-3 text-sm">
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import { Link } from 'react-router-dom'
|
|||
import FeaturedCards from '../../components/FeaturedCards.tsx'
|
||||
import PlatformIcon from '../../components/PlatformIcon.tsx'
|
||||
import { blogHref } from '../../lib/hrefs.ts'
|
||||
import { blogImage } from '../../lib/media.ts'
|
||||
import { mediaUrl } from '../../lib/media.ts'
|
||||
import { preview } from '../../lib/text.ts'
|
||||
import { postDate, useCommunityBlog, type BlogPostSummary } from '../../lib/useBlog.ts'
|
||||
import HomeLink from './home/HomeLink.tsx'
|
||||
|
|
@ -36,7 +36,7 @@ const DEFAULTS = {
|
|||
const EXCERPT_CHARS = 180
|
||||
|
||||
function PostCard({ post, accent }: { post: BlogPostSummary; accent: string }) {
|
||||
const cover = blogImage(post.cover_image)
|
||||
const cover = mediaUrl(post.cover_image)
|
||||
const date = postDate(post.published_on)
|
||||
const authors = post.authors.map((author) => author.name).join(', ')
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { useState } from "react";
|
||||
import ArrowLink from "../../components/ArrowLink.tsx";
|
||||
import { orgLogo } from "../../lib/media.ts";
|
||||
import { mediaUrl } from "../../lib/media.ts";
|
||||
import Logo from "../../components/Logo.tsx";
|
||||
import {
|
||||
initialsFor,
|
||||
orgPath,
|
||||
|
|
@ -35,27 +35,20 @@ const CARD_MIN = "20rem";
|
|||
const GRID_MAX = "88rem";
|
||||
|
||||
function OrgMark({ org, color }) {
|
||||
const [failed, setFailed] = useState(false);
|
||||
|
||||
if (org.logo && !failed) {
|
||||
return (
|
||||
<img
|
||||
src={orgLogo(org.logo) ?? undefined}
|
||||
alt=""
|
||||
onError={() => setFailed(true)}
|
||||
className="h-14 w-14 object-contain rounded-xl shrink-0"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<span
|
||||
className="h-14 w-14 rounded-xl shrink-0 flex items-center justify-center font-extrabold"
|
||||
style={{ border: `1px solid ${color}`, color }}
|
||||
aria-hidden="true"
|
||||
>
|
||||
{initialsFor(org.name)}
|
||||
</span>
|
||||
<Logo
|
||||
src={mediaUrl(org.logo)}
|
||||
className="h-14 w-14 object-contain rounded-xl shrink-0"
|
||||
fallback={
|
||||
<span
|
||||
className="h-14 w-14 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>
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@ import { useEffect, useRef, useState } from "react";
|
|||
import { useCommunity } from "../../lib/chapters.ts";
|
||||
import { Link } from "react-router-dom";
|
||||
import ArrowLink from "../../components/ArrowLink.tsx";
|
||||
import { orgLogo } from "../../lib/media.ts";
|
||||
import { mediaUrl } from "../../lib/media.ts";
|
||||
import { initialsFor, orgPath } from "../../lib/organizations.ts";
|
||||
import { AREAS, AREA_NAMES } from "../../data/mapGrid.ts";
|
||||
import { withAlpha, accentText, readableOn } from '../../lib/color.ts'
|
||||
import { scrollBehavior } from "../../lib/motion.ts";
|
||||
|
||||
/* ═══════════════════════════════════════════════════════════════
|
||||
ORGANIZATION LIST: MAP
|
||||
|
|
@ -472,7 +473,7 @@ function OrgLogo({ org, color, size = "h-14 w-14" }) {
|
|||
if (org.logo && !failed) {
|
||||
return (
|
||||
<img
|
||||
src={orgLogo(org.logo) ?? undefined}
|
||||
src={mediaUrl(org.logo) ?? undefined}
|
||||
alt={org.name}
|
||||
onError={() => setFailed(true)}
|
||||
className={`${size} object-contain rounded-xl shrink-0`}
|
||||
|
|
@ -798,7 +799,7 @@ export default function OrgListMap({ view = "map", accent = FALLBACK_COLOR }) {
|
|||
// that it's stacked under the map and scrolling it would fight
|
||||
// the page.
|
||||
if (box.scrollHeight <= box.clientHeight) return;
|
||||
box.scrollTo({ top: el.offsetTop - 8, behavior: "smooth" });
|
||||
box.scrollTo({ top: el.offsetTop - 8, behavior: scrollBehavior() });
|
||||
};
|
||||
|
||||
// Hovering or selecting a region on the map or legend brings its
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { useId, useState } from "react";
|
||||
import ArrowLink from "../../components/ArrowLink.tsx";
|
||||
import { orgLogo } from "../../lib/media.ts";
|
||||
import { mediaUrl } from "../../lib/media.ts";
|
||||
import Logo from "../../components/Logo.tsx";
|
||||
import PlatformIcon from "../../components/PlatformIcon.tsx";
|
||||
import {
|
||||
areasSentence,
|
||||
|
|
@ -62,38 +63,18 @@ function RowButton({ as: As = "button", color, children, ...rest }: any) {
|
|||
}
|
||||
|
||||
function OrgMark({ org, color }) {
|
||||
const [failed, setFailed] = useState(false);
|
||||
|
||||
if (org.logo && !failed) {
|
||||
return (
|
||||
<img
|
||||
src={orgLogo(org.logo) ?? undefined}
|
||||
alt=""
|
||||
onError={() => setFailed(true)}
|
||||
className="h-8 w-8 object-contain shrink-0"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (org.color) {
|
||||
return (
|
||||
<span
|
||||
className="h-3 w-3 rounded-full shrink-0"
|
||||
style={{ background: color }}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
const fallback = org.color ? (
|
||||
<span className="h-3 w-3 rounded-full shrink-0" style={{ background: color }} aria-hidden="true" />
|
||||
) : (
|
||||
<span
|
||||
className="h-8 w-8 rounded-lg shrink-0 flex items-center justify-center text-xs font-extrabold"
|
||||
style={{ border: `1px solid ${color}`, color }}
|
||||
style={{ border: `1px solid ${color}`, color: accentText(color) }}
|
||||
aria-hidden="true"
|
||||
>
|
||||
{initialsFor(org.name)}
|
||||
</span>
|
||||
);
|
||||
return <Logo src={mediaUrl(org.logo)} className="h-8 w-8 object-contain shrink-0" fallback={fallback} />;
|
||||
}
|
||||
|
||||
function OrgRow({ org, pageLabel, siteLabel }) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Link } from 'react-router-dom'
|
||||
import { MONTH_LABELS, type PersonRef, type TimelineItem } from '../../../lib/timeline.ts'
|
||||
import { hrefFor, logoSrc, photoSrc } from '../../../lib/timelineRefs.ts'
|
||||
import { initials } from '../../../lib/media.ts'
|
||||
import { hrefFor, logoSrc } from '../../../lib/timelineRefs.ts'
|
||||
import { initials, mediaUrl } from '../../../lib/media.ts'
|
||||
|
||||
const KIND_NAMES: Record<TimelineItem['kind'], string> = {
|
||||
milestone: 'Milestone',
|
||||
|
|
@ -28,7 +28,7 @@ function fullMarker(item: TimelineItem): string {
|
|||
}
|
||||
|
||||
function PersonChip({ person }: { person: PersonRef }) {
|
||||
const src = photoSrc(person.photo)
|
||||
const src = mediaUrl(person.photo)
|
||||
return (
|
||||
<li className="ngu-tl__person">
|
||||
{src ? (
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import { useHistory } from '../../../lib/useHistory.ts'
|
|||
import { hrefFor, logoSrc } from '../../../lib/timelineRefs.ts'
|
||||
import { MONTH_LABELS, type TimelineItem } from '../../../lib/timeline.ts'
|
||||
import { accentText } from '../../../lib/color.ts'
|
||||
import { scrollBehavior } from '../../../lib/motion.ts';
|
||||
|
||||
const TEAL = '#0f7183'
|
||||
const DRAG_SLOP = 6
|
||||
|
|
@ -49,7 +50,7 @@ export default function FeaturedTimelineRail({ id, title, blurb }: RailProps) {
|
|||
const rail = railRef.current
|
||||
const card = rail?.querySelector('li')
|
||||
if (!rail || !card) return
|
||||
rail.scrollBy({ left: direction * (card.clientWidth + 24), behavior: 'smooth' })
|
||||
rail.scrollBy({ left: direction * (card.clientWidth + 24), behavior: scrollBehavior() })
|
||||
}
|
||||
|
||||
const onPointerDown = (e: ReactPointerEvent<HTMLOListElement>) => {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ import VideoPlayer from '../../../components/VideoPlayer.tsx'
|
|||
import DoveMark from '../../../components/DoveMark.tsx'
|
||||
import PlatformIcon from '../../../components/PlatformIcon.tsx'
|
||||
import { livestreamEmbedUrl, videoSource, type VideoSource } from '../../../lib/embeds.ts'
|
||||
import { eventBackground, heroPhoto } from '../../../lib/media.ts'
|
||||
import { mediaUrl } from '../../../lib/media.ts'
|
||||
import { eventHref } from '../../../lib/hrefs.ts'
|
||||
import { seriesLabel } from '../../../lib/eventSeries.ts'
|
||||
import type { Hero, HeroBackdrop, HeroEvent, HeroFeature, HeroSlide } from '../../../lib/useFrontPage.ts'
|
||||
|
|
@ -53,7 +53,7 @@ import { withAlpha } from '../../../lib/color.ts'
|
|||
const DEEP = '#04262e'
|
||||
|
||||
export default function HeroStage({ hero }: { hero: Hero | null }) {
|
||||
const slides = (hero?.slides ?? []).filter((slide) => heroPhoto(slide.media))
|
||||
const slides = (hero?.slides ?? []).filter((slide) => mediaUrl(slide.media))
|
||||
const embed = livestreamEmbedUrl(hero?.livestream?.url)
|
||||
const video = videoSource(hero?.video?.url)
|
||||
|
||||
|
|
@ -290,7 +290,7 @@ function PhotoBackdrop({ slides, seconds }: { slides: HeroSlide[]; seconds: numb
|
|||
className={`hp-slide ${i === index ? 'hp-slide--on' : ''}`}
|
||||
aria-hidden={i !== index}
|
||||
>
|
||||
<img src={heroPhoto(slide.media) ?? ''} alt={slide.alt ?? ''} loading={i === 0 ? 'eager' : 'lazy'} />
|
||||
<img src={mediaUrl(slide.media) ?? ''} alt={slide.alt ?? ''} loading={i === 0 ? 'eager' : 'lazy'} />
|
||||
</div>
|
||||
))}
|
||||
<div
|
||||
|
|
@ -455,7 +455,7 @@ function VideoFrame({
|
|||
it's usually Register. */
|
||||
function EventPanel({ event }: { event: HeroEvent }) {
|
||||
const color = event.color || '#0f7183'
|
||||
const photo = eventBackground(event.card_image)
|
||||
const photo = mediaUrl(event.card_image)
|
||||
const when = seriesLabel(event.series, event.starts_on) ?? event.date_label
|
||||
const where = event.is_online && !event.location_label ? 'Online' : event.location_label
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue