diff --git a/CLAUDE.md b/CLAUDE.md index eb258a1..4f51c98 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -35,6 +35,7 @@ In dev, Vite proxies `/api` to the target set in `vite.config.ts`, so the API mu - Analytics: self-hosted Plausible, proxied by nginx at `/pa/`. The API adds its script to every page (`analyticsTag` in `server/src/pageMeta.js`), counting under the hostname of `site.json`'s `url`, so each deployment reports as itself. Nothing in `index.html` or the app. Daily and weekly reports go to Discord when Panel → Site settings → Reports turns them on and `PLAUSIBLE_API_KEY` and `DISCORD_WEBHOOK_URL` are set (`server/src/analyticsReport.js`): `docs/analytics-reports.md`. Short links `/go/` (Data → Links/redirects, `server/src/routes/redirects.js`) count clicks, report each to Plausible as a pageview and add the link's UTM tags: `docs/redirects.md`. - Page HTML goes through the API, which fills in each page's title, description, preview image and structured data (`server/src/pageMeta.js`), and serves `/sitemap.xml`. It reads `SITE_CONFIG` (site.json) and `SITE_INDEX` (the built index.html), with Panel → Site settings (the `site_settings` table) laid over site.json, and serves `/robots.txt` from the same merge. nginx setup: `docs/seo.md`. - Video clips (Tools, admins and up): yt-dlp downloads our YouTube/Facebook videos into `CLIPS_DIR`, ffmpeg cuts them; one job at a time, files swept after a day (`server/src/clips.js`). Needs yt-dlp and ffmpeg on the VPS: `docs/video-clips.md`. +- Present remote: a presenting screen (`/events/:id/present`) shows a code; a phone at `/remote/` steps, pauses, jumps and changes its setup, anyone with the code (`server/src/routes/present.js`, `src/pages/PresentRemote.tsx`). Server-sent events held in memory (one process); the API sends `X-Accel-Buffering: no`, so nginx needs no block of its own. - Newsletter countdown pictures: `/api/countdown/:id.png` (`server/src/routes/countdown.js`), drawn with sharp when an email is opened; it uses the VPS's fonts, so install Poppins there (eg. into `/usr/local/share/fonts`, then `fc-cache`) or it falls back to a plain sans. The social bar's icons are static files in `public/email/`. - Word import: Blog posts → Import from Word turns a .docx into an unpublished post (headings, paragraphs, lists, tables, links); nginx needs a block for `/api/admin/import/docx` with an 11m body limit: `docs/importing.md`. - Speed: nginx must gzip JS/CSS/JSON/SVG and speak HTTP/2; page HTML is `no-cache`; uploads get a `-640.webp` small copy made at upload and at boot: `docs/performance.md`. diff --git a/docs/seo.md b/docs/seo.md index 9b9cf26..84770f6 100644 --- a/docs/seo.md +++ b/docs/seo.md @@ -111,6 +111,18 @@ with it off it blocks everything. client_max_body_size 26m; proxy_read_timeout 60s; } + + # The admin's saves send a record whole (every content block, + # schedule entry and sub-item), well over 64k for a big page or + # event: nginx answers 413 "Too large for the web server" without + # this. A longer prefix than /api/, so it wins; the exact and + # longer admin blocks (media, files, import, clips) still win over + # it. Same proxy_set_header lines as /api/. + location /api/admin/ { + proxy_pass http://127.0.0.1:3001; + client_max_body_size 4m; + proxy_read_timeout 30s; + } ``` Keep the existing `/api/` and `/uploads/` blocks; they're more diff --git a/docs/updating-data-in-code.md b/docs/updating-data-in-code.md index 36d92c0..ccdf11b 100644 --- a/docs/updating-data-in-code.md +++ b/docs/updating-data-in-code.md @@ -181,8 +181,14 @@ also in `server/src/admin-schema/` and a CHECK): | Links → Kind (on organizations, events, people, teams) | action, social, website, email | no | `splitLinks` in `server/src/shape.js` | | Links → Platform | instagram, facebook, discord, youtube, tiktok, x, substack, spotify, linkedin | **yes**, `PLATFORMS` | `PlatformIcon.tsx` draws the icon on the button. **No CHECK and no `enumeration`**: the column is plain text, so adding one is an entry in `PLATFORMS` (`src/lib/platforms.ts`) and its icon in `src/components/PlatformIcon.tsx`, no migration. | | Content blocks → Shown in (slot) | card, body | **yes** | `paragraphs()` in `server/src/shape.js` (card), `ContentBlocks.tsx` (body) | -| Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout, schedule, table | **yes**, `BLOCK_TYPES` (with each type's description) | `ContentBlocks.tsx` (one renderer per type). Which fields each type shows is `when` on the fields in `blocksChild` (`src/lib/adminSchema/shared.ts`). | -| Content blocks → Schedule items → Type | (blank: normal entry), block, break, heading | **yes**, migration 086 | `SCHEDULE_KINDS` in `src/lib/adminSchema/shared.ts`; drawn by `ScheduleBlock.tsx` and `SchedulePresent.tsx` (which slides each kind gets). A block's sub-items are `content_block_subitems`. A schedule's own tags (087) are `content_block_tags`, rows of the block typed in the admin (not a fixed list); entries name them by `tag_key`, made in the admin as the tag is added. | +| Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout, schedule, table, cards, people, map, events, organizations | **yes**, `BLOCK_TYPES` (with each type's description) | `ContentBlocks.tsx` (one renderer per type). Which fields each type shows is `when` on the fields in `blocksChild` (`src/lib/adminSchema/shared.ts`). | +| Content blocks → Schedule items → Type | (blank: normal entry), block, break, heading | **yes**, migration 086 | `SCHEDULE_KINDS` in `src/lib/adminSchema/shared.ts`; drawn by `ScheduleBlock.tsx` and `EventPresent.tsx` (which slides each kind gets; the presentation cuts the event's page into sections at its Heading blocks). A block's sub-items are `content_block_subitems`. A schedule's own tags (087) are `content_block_tags`, rows of the block typed in the admin (not a fixed list); entries name them by `tag_key`, made in the admin as the tag is added. A schedule's Venue (088) lends its locations (Data → Venues, `venue_locations`) to its entries' Map location, named by `location_key` the same way; an entry's Event (a workshop) fills what it leaves blank in `shape.js` (`attachEvents`). | +| Content blocks → Image → Size | (blank: the column's full width), small (20rem), medium (32rem), large (48rem) | **yes**, migration 101 | The `image_size` field in `src/lib/adminSchema/shared.ts`; `IMAGE_SIZE` in `ContentBlocks.tsx` sets the widths | +| Content blocks → List → Style | (blank: bold text, normal detail), plain (plain text, gray detail) | **yes**, migration 092 | The Style field in `src/lib/adminSchema/shared.ts`; drawn by the `list` case in `ContentBlocks.tsx`. | +| Content blocks (an event's) → Shown | (blank: the page and the presentation), page, presentation | **yes**, migration 099 | `PRESENT_BLOCK_FIELDS` in `src/lib/adminSchema/shared.ts`; `ContentBlocks.tsx` leaves out a presentation-only block on the page and a page-only one presented, `sectionsOf` in `src/pages/EventPresent.tsx` too | +| Content blocks (an event's) → Map → Location slides | (blank: each marked location), picked (the Locations with a slide), none | **yes**, migration 095 | `PRESENT_BLOCK_FIELDS` in `src/lib/adminSchema/shared.ts`; read by `mapSlides` in `src/pages/EventPresent.tsx` | +| Events → Presentation → Frame | (blank: the accent bar, title line and timer), border, none | **yes**, migration 095 | The `present_frame` field in `src/lib/adminSchema/events.ts`; drawn by `Player` in `src/pages/EventPresent.tsx` | +| Content blocks → Organizations → List | (blank: only the picked ones), partner, region, group, ministry | **yes**, migration 093 | The `org_kind` field in `src/lib/adminSchema/shared.ts`; the `organizations` case in `ContentBlocks.tsx` passes it as the kind to `OrgListCards` (`nested`); items picked by `org_id` replace it | | Timeline → Kind (+ list filter) | milestone, event, organization, award, people | no | `KIND_NAMES` in `src/pages/sections/history/TimelineEntry.tsx` | | Timeline → Points at (+ list filter) | event, organization, award, person, team | no | `refHref` in `src/lib/hrefs.ts` | | Timeline → Precision (and on events/orgs) | year, month, day | no | the history page's grouping | @@ -272,7 +278,7 @@ A Numbers section's "Number Source" dropdown works the same way: | The icons a Connect nav section's path can pick | `src/data/pathIcons.ts` (keys and labels) **and** `ICONS` in `src/pages/sections/home/Pathfinder.tsx` (the Phosphor icon for each key) | Add a line to both. A path saved with an emoji from before the list shows it as it is. | | A page section's accent color | `BRAND` and `ACCENTS` in `src/lib/color.ts` | Pages pick from these (`accent: ACCENTS.green`); add a color there, not a hex in a page. Each is readable as text on white and the tints. | | The palette (the 16-color grid the theme is drawn from) | `PALETTE` in `src/lib/color.ts` | Four families, a column each. `PALETTE_LIGHT` / `PALETTE_DARK` are the fills things colored by data use (a person's initials tile, `paletteFill`); the page background's layers (how many circles, their sizes and parallax speeds) are `LAYERS` in `src/components/PageBackdrop.tsx` and its shades are in `PageBackdrop.css`; the admin home's two alternating group colors are `BLOCK_COLORS` in `src/pages/admin/AdminHome.tsx`. | -| The accessibility panel's choices (bottom right of every public page) | `SETTINGS` in `src/components/AccessibilityPanel.tsx`; the color blind modes are `VISIONS` and `SWAPS` in `src/lib/color.ts` | Each choice is an attribute on `` styled in `src/index.css`, and `index.html` sets it again before the first paint, so a new one goes in all three. A color blind mode replaces all three color families, teal, green and amber (`SWAPS`, picked by simulating each type: see the comment there), in code, in data colors as they load (`src/lib/api.ts`, never under /admin), in CSS (the `--pal-*` variables in `src/index.css`, which hold the same values as `SWAPS`: change both) and in the theme tokens drawn from them. A palette hex in a component or CSS file should be `var(--pal--)` (eg. `var(--pal-amber-2)`), or a color blind mode won't reach it. Reading mode is `src/components/ReaderView.tsx`, which reads the hidden page and writes out its headings, paragraphs, links and described pictures. A part it can't read well (a carousel, tabs, details behind a click, a map) draws its own text version when `useReadingMode()` (`src/lib/readingMode.ts`) is on: the hero, pathfinder, stats, history rail, event lists, calendar (the next six weeks), featured cards, org lists and groups map, history timeline, schedule, people tiles and video player; the countdown draws nothing. A new component with any of those should do the same. Something saved or sent (the newsletter's colors) is a stored hex, which is never swapped. | +| The accessibility panel's choices (bottom right of every public page) | `SETTINGS` in `src/components/AccessibilityPanel.tsx`; the color blind modes are `VISIONS` and `SWAPS` in `src/lib/color.ts` | Each choice is an attribute on `` styled in `src/index.css`, and `index.html` sets it again before the first paint, so a new one goes in all three. A color blind mode replaces all three color families, teal, green and amber (`SWAPS`, picked by simulating each type: see the comment there), in code, in data colors as they load (`src/lib/api.ts`, never under /admin), in CSS (the `--pal-*` variables in `src/index.css`, which hold the same values as `SWAPS`: change both) and in the theme tokens drawn from them. A palette hex in a component or CSS file should be `var(--pal--)` (eg. `var(--pal-amber-2)`), or a color blind mode won't reach it. Reading mode is `src/components/ReaderView.tsx`, which reads the hidden page and writes out its headings, paragraphs, links and described pictures. A part it can't read well (a carousel, tabs, details behind a click, a map) draws its own text version when `useReadingMode()` (`src/lib/readingMode.ts`) is on: the hero, pathfinder, stats, history rail, event lists, calendar (the next six weeks), featured cards, org lists and groups map, history timeline, schedule, map block (its list alone), people tiles and video player; the countdown draws nothing. A new component with any of those should do the same. Something saved or sent (the newsletter's colors) is a stored hex, which is never swapped. | | Privacy Policy and Terms wording | the database (082) | Admin → Pages → Page management → Privacy Policy or Terms of Service: their sections' blocks, and the "Last updated" date in the section's blurb whenever the wording changes. The privacy contact email is in the policy's text. The Privacy page must stay true of the code: what the feedback form stores, what the browser keeps, which embeds wait for a click. | | Event type labels and plurals (public site) | `src/lib/eventTypes.ts` | Also the order of the type filter chips. | | Event and person role labels (public site) | `ROLE_LABEL` in `src/pages/EventDetail.tsx` and `src/pages/PersonDetail.tsx` | | diff --git a/server/src/admin-schema.js b/server/src/admin-schema.js index 824c108..0846fb2 100644 --- a/server/src/admin-schema.js +++ b/server/src/admin-schema.js @@ -64,6 +64,7 @@ import { tags } from "./admin-schema/tags.js"; import { contactTypes } from "./admin-schema/contactTypes.js"; import { redirects } from "./admin-schema/redirects.js"; import { pages } from "./admin-schema/sitePages.js"; +import { venues } from "./admin-schema/venues.js"; export const ENTITIES = { organizations, @@ -73,6 +74,7 @@ export const ENTITIES = { tags, contact_types: contactTypes, redirects, + venues, teams, awards, timeline, @@ -98,6 +100,10 @@ export const OPTION_QUERIES = { // What an organization cards section can hand-pick (067). card_orgs: "SELECT id, name || ' (' || kind || ')' AS label FROM organizations WHERE kind IN ('partner', 'ministry') ORDER BY kind, name", + // What an organizations content block can pick (093): every kind, + // a card needing no page of its own. + block_orgs: + "SELECT id, name || ' (' || kind || ')' AS label FROM organizations ORDER BY kind, name", event_scopes: "SELECT id, name AS label FROM event_scopes ORDER BY sort_order", events: "SELECT id, title AS label FROM events ORDER BY starts_on DESC, title", people: "SELECT id, display_name AS label FROM people ORDER BY sort_name, display_name", @@ -106,6 +112,15 @@ export const OPTION_QUERIES = { contact_types: "SELECT id, name AS label FROM contact_types ORDER BY sort_order, name", // Link fields with `redirects: true` pick from these (068). redirects: "SELECT id, id || ' (' || target_url || ')' AS label FROM redirects ORDER BY id", + // A map block's venue; its locations ride along (as JSON) for a + // schedule's entries to pick from and for the block's preview. + venues: ` + SELECT v.id, v.name AS label, v.map_image, v.map_alt, + (SELECT json_group_array(json_object('key', l.location_key, 'name', l.name, 'detail', l.detail, + 'x', l.x, 'y', l.y, 'w', l.w, 'h', l.h)) + FROM (SELECT * FROM venue_locations WHERE venue_id = v.id ORDER BY sort_order) l) AS locations + FROM venues v + ORDER BY v.name`, blog_posts: "SELECT id, title AS label FROM blog_posts ORDER BY published_on DESC, title", // Navigation's Under page: a page by its address (080). site_pages: "SELECT path AS id, title || ' (' || path || ')' AS label FROM site_pages ORDER BY sort_order, title", diff --git a/server/src/admin-schema/columns.js b/server/src/admin-schema/columns.js index 3416e07..d7d1672 100644 --- a/server/src/admin-schema/columns.js +++ b/server/src/admin-schema/columns.js @@ -154,11 +154,18 @@ export const blocksChild = (ownerKind) => ({ "people", // A blog post's tab (079): its text is the tab's title. "tab", + // A venue's map, and event cards (088). + "map", + "events", + // Organization cards (093). + "organizations", ], { required: true }, ), text("text"), text("media"), + // Image blocks (102): shown in place of media in the dark theme. + text("media_dark"), url("href"), text("alt"), text("cite"), @@ -170,6 +177,23 @@ export const blocksChild = (ownerKind) => ({ int("word_seconds"), // People blocks only (054): whose team's tiles to show. text("team_id"), + // Map and schedule blocks (088): whose map and locations. + text("venue_id"), + // List blocks (092): null bold text, 'plain' the old look. + enumeration("list_style", ["plain"]), + // Image blocks (101): null full width, else a narrower size. + enumeration("image_size", ["small", "medium", "large"]), + // Organizations blocks (093): the kind listed when none are picked. + enumeration("org_kind", ["region", "group", "partner", "ministry"]), + // How it's presented (095): EventPresent.tsx. + // Where it shows (099): null both, the page or the presentation. + enumeration("present_show", ["page", "presentation"]), + text("present_text"), + bool("present_map_split"), + bool("present_map_no_list"), + bool("present_map_no_details"), + enumeration("present_places", ["picked", "none"]), + text("present_place_keys"), ], children: [ { @@ -198,6 +222,15 @@ export const blocksChild = (ownerKind) => ({ bool("featured"), // The block's tags it has, by key, comma-separated (087). text("tags"), + // A workshop or other event it is, and its place on the + // block's venue map (088). + text("event_id"), + text("location_key"), + // A featured event's heading and subheading (090). + text("heading"), + text("subheading"), + // An organizations block's organization (093). + text("org_id"), ], children: [ { @@ -223,6 +256,8 @@ export const blocksChild = (ownerKind) => ({ text("map_image"), bool("featured"), text("tags"), + text("event_id"), + text("location_key"), ], }, ], @@ -242,6 +277,15 @@ export const blocksChild = (ownerKind) => ({ bool("no_tab"), ], }, + { + // A map block's own sections of its venue's locations (094). + key: "map_sections", + table: "content_block_map_sections", + owner: { column: "block_id" }, + order: "sort_order", + when: { column: "type", value: "map" }, + columns: [text("name", { required: true }), text("location_keys")], + }, ], }); diff --git a/server/src/admin-schema/events.js b/server/src/admin-schema/events.js index 253a1b8..21dc3a9 100644 --- a/server/src/admin-schema/events.js +++ b/server/src/admin-schema/events.js @@ -1,4 +1,4 @@ -import { text, int, bool, date, time, enumeration, placeColumns, timelineExtension, linksChild, blocksChild, hostsChild } from "./columns.js"; +import { text, int, real, bool, date, time, enumeration, placeColumns, timelineExtension, linksChild, blocksChild, hostsChild } from "./columns.js"; import { tagsChild } from "./tags.js"; /* ── Events ──────────────────────────────────────────────────── */ @@ -67,6 +67,28 @@ export const events = { bool("is_published"), bool("is_listed"), bool("in_timeline"), + bool("show_contents"), + text("links_heading"), + // Its page presented (095). + text("present_background"), + text("present_background_color"), + int("present_dim"), + enumeration("present_frame", ["border", "none"]), + text("present_accent"), + text("present_text_color"), + text("present_logo"), + // The same in the dark theme (096), null the above. + text("present_background_dark"), + text("present_background_color_dark"), + int("present_dim_dark"), + text("present_accent_dark"), + text("present_text_color_dark"), + text("present_logo_dark"), + // Room clear at each edge, eg. inside a frame picture (097). + real("present_inset_top"), + real("present_inset_right"), + real("present_inset_bottom"), + real("present_inset_left"), // A repeating schedule. Columns rather than a side table: the // schedule is always exactly one per event, and the public view diff --git a/server/src/admin-schema/sitePages.js b/server/src/admin-schema/sitePages.js index def70c6..0117871 100644 --- a/server/src/admin-schema/sitePages.js +++ b/server/src/admin-schema/sitePages.js @@ -214,11 +214,11 @@ const sectionsChild = { export const CORE_PAGES = { home: "/", give: "/give", feedback: "/feedback", request: "/request", qr: "/qr", privacy: "/privacy", terms: "/terms" }; /* Addresses a page can't take: the admin, the API, the uploads, the - records' own pages and the account pages. */ + records' own pages, the account pages and the remote. */ const RESERVED = [ "admin", "api", "uploads", "assets", "pa", "go", "events", "regions", "groups", "partners", "organizations", "teams", "awards", "people", "blog", "directory", - "sign-in", "account", "sitemap.xml", "robots.txt", + "sign-in", "account", "remote", "sitemap.xml", "robots.txt", ]; /* After a save: the address is one a page may have. */ diff --git a/server/src/admin-schema/venues.js b/server/src/admin-schema/venues.js new file mode 100644 index 0000000..932f433 --- /dev/null +++ b/server/src/admin-schema/venues.js @@ -0,0 +1,47 @@ +import { text, real, url } from "./columns.js"; + +/* ── Venues (088_venues.sql) ───────────────────────────────────── + + A place we gather, with its map picture and the locations marked + on it. Map blocks draw it, and schedule entries link to its + locations. Its own entity because content_blocks.venue_id points + at it; nothing points at a location's row, entries name one by + location_key, so the locations can be replaced wholesale. */ + +export const venues = { + key: "venues", + table: "venues", + idColumn: "id", + idKind: "slug", + + list: { + columns: ["id", "name", "address"], + filters: [], + search: ["name", "id", "address"], + order: "name", + }, + + columns: [text("name", { required: true }), text("address"), text("map_image"), text("map_alt")], + + children: [ + { + key: "locations", + table: "venue_locations", + owner: { column: "venue_id" }, + order: "sort_order", + columns: [ + // Made by the admin as the row is added, so it isn't input. + text("location_key", { required: true, seeded: true }), + text("name", { required: true }), + text("detail"), + real("x"), + real("y"), + real("w"), + real("h"), + // The place in Google and Apple Maps (091). + url("google_maps_url"), + url("apple_maps_url"), + ], + }, + ], +}; diff --git a/server/src/index.js b/server/src/index.js index 51c369e..a273f03 100644 --- a/server/src/index.js +++ b/server/src/index.js @@ -43,6 +43,7 @@ import imports from "./routes/import.js"; import files from "./routes/files.js"; import countdown from "./routes/countdown.js"; import redirects from "./routes/redirects.js"; +import present from "./routes/present.js"; import { CLIPS_DIR, startClipWorker } from "./clips.js"; import { UPLOADS_DIR, writeMissingThumbs } from "./media.js"; import { logSafe, requireStaff, startSessionSweeper } from "./auth.js"; @@ -137,7 +138,7 @@ app.use( so each is capped well above its longest real body (a 5000 character message) and far below nginx's limit. */ const smallBody = bodyLimit({ maxSize: 64 * 1024, onError: (c) => c.json({ error: "That's too long." }, 413) }); -for (const path of ["/api/csp-report", "/api/feedback", "/api/auth/login", "/api/account/accept", "/api/account/claim", "/api/account/profile"]) app.use(path, smallBody); +for (const path of ["/api/csp-report", "/api/feedback", "/api/auth/login", "/api/account/accept", "/api/account/claim", "/api/account/profile", "/api/present/*"]) app.use(path, smallBody); /* What the policy above would have blocked. Browsers post these on their own; a short line per report is plenty to go on. */ @@ -202,6 +203,11 @@ app.use("/api/countdown/*", rateLimit({ windowMs: 60_000, max: 600 })); app.route("/api", countdown); // Tighter limit on the write path than anything else gets. +// A presenting screen and its remotes, by the screen's code +// (routes/present.js): a cap far above tapping, far below guessing. +app.use("/api/present/*", rateLimit({ windowMs: 60_000, max: 300 })); +app.route("/api", present); + app.use("/api/feedback", rateLimit({ windowMs: 60_000, max: 5 })); app.route("/api/feedback", feedback); // Requests carry files: fewer again. diff --git a/server/src/migrations/088_venues.sql b/server/src/migrations/088_venues.sql new file mode 100644 index 0000000..9be8b4c --- /dev/null +++ b/server/src/migrations/088_venues.sql @@ -0,0 +1,125 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 088 VENUES, MAP BLOCKS AND EVENT BLOCKS +-- +-- Data → Venues: a place we gather (a camp, a church), with one map +-- picture and its marked locations, each a pin (x, y) or a box +-- (x, y, w, h), in percent of the picture from its top left. +-- +-- A 'map' content block draws a venue's map with its locations +-- listed beside it; a schedule block names a venue too, and its +-- entries and sub-items pick one of its locations (location_key), +-- which links to the map block on the same page, the location +-- lit up. The venue's locations are rewritten on every save, so an +-- entry names one by `location_key` (made in the admin when the +-- location is added), as schedule tags do (087). +-- +-- An 'events' content block shows events as cards, an item each +-- (event_id); a schedule entry or sub-item can name an event too +-- (a workshop), and takes what it leaves blank from it. +-- +-- content_blocks.type's CHECK can't change in place, so the table +-- is rebuilt (as in 079), then its index and owner trigger made +-- again. +-- ═══════════════════════════════════════════════════════════════ + +CREATE TABLE venues ( + id TEXT PRIMARY KEY + CONSTRAINT "A venue's URL ID can use only lowercase letters, numbers and hyphens, eg. camp-hebron." + CHECK (id <> '' AND id NOT GLOB '*[^a-z0-9-]*'), + name TEXT NOT NULL, + address TEXT, + map_image TEXT, -- an upload + map_alt TEXT +) STRICT; + +CREATE TABLE venue_locations ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + venue_id TEXT NOT NULL REFERENCES venues (id) ON DELETE CASCADE, + sort_order INTEGER NOT NULL DEFAULT 0, + location_key TEXT NOT NULL, + name TEXT NOT NULL, + detail TEXT, + x REAL CHECK (x BETWEEN 0 AND 100), + y REAL CHECK (y BETWEEN 0 AND 100), + w REAL CHECK (w > 0 AND w <= 100), -- null: a pin + h REAL CHECK (h > 0 AND h <= 100), + UNIQUE (venue_id, location_key) +) STRICT; + +ALTER TABLE content_block_items ADD COLUMN event_id TEXT + REFERENCES events (id) ON DELETE SET NULL; +ALTER TABLE content_block_items ADD COLUMN location_key TEXT; +ALTER TABLE content_block_subitems ADD COLUMN event_id TEXT + REFERENCES events (id) ON DELETE SET NULL; +ALTER TABLE content_block_subitems ADD COLUMN location_key TEXT; + +CREATE TABLE content_blocks_new ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + owner_kind TEXT NOT NULL + CHECK (owner_kind IN ('organization', 'event', 'person', 'team', 'blog_post', 'page_section', + 'newsletter')), + owner_id TEXT NOT NULL, + slot TEXT NOT NULL DEFAULT 'body' CHECK (slot IN ('card', 'body', 'both')), + sort_order INTEGER NOT NULL DEFAULT 0, + + type TEXT NOT NULL + CHECK (type IN ('heading', 'subheading', 'paragraph', + 'list', 'links', 'quote', 'image', 'divider', + 'video', 'button', 'callout', 'schedule', 'table', 'cards', + 'people', 'tab', 'map', 'events')), + text TEXT, + media TEXT, + href TEXT, + alt TEXT, + cite TEXT, + team_id TEXT REFERENCES teams (id) ON DELETE SET NULL, + captions TEXT, + word_motion TEXT CHECK (word_motion IN ('slide', 'flip', 'fade', 'type', 'mirror')), + word_direction TEXT CHECK (word_direction IN ('top', 'bottom')), + word_seconds INTEGER CHECK (word_seconds BETWEEN 1 AND 20), + -- Map and schedule blocks: whose map, and whose locations. + venue_id TEXT REFERENCES venues (id) ON DELETE SET NULL +) STRICT; + +INSERT INTO content_blocks_new + (id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id, captions, + word_motion, word_direction, word_seconds) +SELECT id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id, captions, + word_motion, word_direction, word_seconds + FROM content_blocks; + +PRAGMA legacy_alter_table = ON; +DROP TABLE content_blocks; +ALTER TABLE content_blocks_new RENAME TO content_blocks; +PRAGMA legacy_alter_table = OFF; + +CREATE INDEX content_blocks_owner_idx + ON content_blocks (owner_kind, owner_id, slot, sort_order); + +CREATE TRIGGER content_blocks_owner_exists +BEFORE INSERT ON content_blocks +BEGIN + SELECT CASE + WHEN new.owner_kind = 'event' + AND NOT EXISTS (SELECT 1 FROM events WHERE id = new.owner_id) + THEN RAISE(ABORT, 'content_blocks: no such event') + WHEN new.owner_kind = 'organization' + AND NOT EXISTS (SELECT 1 FROM organizations WHERE id = new.owner_id) + THEN RAISE(ABORT, 'content_blocks: no such organization') + WHEN new.owner_kind = 'person' + AND NOT EXISTS (SELECT 1 FROM people WHERE id = new.owner_id) + THEN RAISE(ABORT, 'content_blocks: no such person') + WHEN new.owner_kind = 'team' + AND NOT EXISTS (SELECT 1 FROM teams WHERE id = new.owner_id) + THEN RAISE(ABORT, 'content_blocks: no such team') + WHEN new.owner_kind = 'blog_post' + AND NOT EXISTS (SELECT 1 FROM blog_posts WHERE id = new.owner_id) + THEN RAISE(ABORT, 'content_blocks: no such blog post') + WHEN new.owner_kind = 'page_section' + AND NOT EXISTS (SELECT 1 FROM page_sections WHERE CAST(id AS TEXT) = new.owner_id) + THEN RAISE(ABORT, 'content_blocks: no such page section') + WHEN new.owner_kind = 'newsletter' + AND NOT EXISTS (SELECT 1 FROM newsletters WHERE CAST(id AS TEXT) = new.owner_id) + THEN RAISE(ABORT, 'content_blocks: no such newsletter') + END; +END; diff --git a/server/src/migrations/089_event_page_options.sql b/server/src/migrations/089_event_page_options.sql new file mode 100644 index 0000000..073c77e --- /dev/null +++ b/server/src/migrations/089_event_page_options.sql @@ -0,0 +1,14 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 089 EVENT PAGE OPTIONS +-- +-- show_contents the page's headings listed beside its content +-- blocks, as a blog post's are (PostContents.tsx) +-- links_heading a heading above the event's link buttons; null +-- shows none +-- +-- v_events is SELECT e.*, so it carries both with no rebuild. +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE events ADD COLUMN show_contents INTEGER NOT NULL DEFAULT 0 + CHECK (show_contents IN (0, 1)); +ALTER TABLE events ADD COLUMN links_heading TEXT; diff --git a/server/src/migrations/090_featured_event_items.sql b/server/src/migrations/090_featured_event_items.sql new file mode 100644 index 0000000..864615d --- /dev/null +++ b/server/src/migrations/090_featured_event_items.sql @@ -0,0 +1,15 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 090 FEATURED EVENTS IN AN EVENTS BLOCK +-- +-- An events block's item ticked Featured (086's `featured`) shows +-- opened in full above the cards, under its own heading and +-- subheading, both optional: +-- +-- heading eg. This year's keynote +-- subheading a line under it +-- +-- Other item kinds ignore both. +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE content_block_items ADD COLUMN heading TEXT; +ALTER TABLE content_block_items ADD COLUMN subheading TEXT; diff --git a/server/src/migrations/091_location_map_links.sql b/server/src/migrations/091_location_map_links.sql new file mode 100644 index 0000000..ddeb57f --- /dev/null +++ b/server/src/migrations/091_location_map_links.sql @@ -0,0 +1,10 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 091 A VENUE LOCATION'S MAP LINKS +-- +-- Each location on a venue's map can link to the same place in +-- Google Maps and Apple Maps, shown as buttons beside it in a map +-- block's list. Null shows no button. +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE venue_locations ADD COLUMN google_maps_url TEXT; +ALTER TABLE venue_locations ADD COLUMN apple_maps_url TEXT; diff --git a/server/src/migrations/092_list_style.sql b/server/src/migrations/092_list_style.sql new file mode 100644 index 0000000..5865aae --- /dev/null +++ b/server/src/migrations/092_list_style.sql @@ -0,0 +1,13 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 092 A LIST BLOCK'S STYLE +-- +-- How a list block's items read: +-- +-- null the item's text bold, its detail in the body color +-- plain the text plain, the detail gray (the look before 092) +-- +-- Other block types ignore it. +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE content_blocks ADD COLUMN list_style TEXT + CHECK (list_style IN ('plain')); diff --git a/server/src/migrations/093_organizations_block.sql b/server/src/migrations/093_organizations_block.sql new file mode 100644 index 0000000..b2d6b6e --- /dev/null +++ b/server/src/migrations/093_organizations_block.sql @@ -0,0 +1,91 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 093 ORGANIZATIONS BLOCK +-- +-- An 'organizations' content block shows organizations as the +-- Partners page's cards (OrgList-Card.tsx): the ones picked as its +-- items, in their order (content_block_items.org_id), else every +-- published, listed one of its kind (content_blocks.org_kind), by +-- name. +-- +-- content_blocks.type's CHECK can't change in place, so the table +-- is rebuilt (as in 088), then its index and owner trigger made +-- again. +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE content_block_items ADD COLUMN org_id TEXT + REFERENCES organizations (id) ON DELETE SET NULL; + +CREATE TABLE content_blocks_new ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + owner_kind TEXT NOT NULL + CHECK (owner_kind IN ('organization', 'event', 'person', 'team', 'blog_post', 'page_section', + 'newsletter')), + owner_id TEXT NOT NULL, + slot TEXT NOT NULL DEFAULT 'body' CHECK (slot IN ('card', 'body', 'both')), + sort_order INTEGER NOT NULL DEFAULT 0, + + type TEXT NOT NULL + CHECK (type IN ('heading', 'subheading', 'paragraph', + 'list', 'links', 'quote', 'image', 'divider', + 'video', 'button', 'callout', 'schedule', 'table', 'cards', + 'people', 'tab', 'map', 'events', 'organizations')), + text TEXT, + media TEXT, + href TEXT, + alt TEXT, + cite TEXT, + team_id TEXT REFERENCES teams (id) ON DELETE SET NULL, + captions TEXT, + word_motion TEXT CHECK (word_motion IN ('slide', 'flip', 'fade', 'type', 'mirror')), + word_direction TEXT CHECK (word_direction IN ('top', 'bottom')), + word_seconds INTEGER CHECK (word_seconds BETWEEN 1 AND 20), + -- Map and schedule blocks: whose map, and whose locations. + venue_id TEXT REFERENCES venues (id) ON DELETE SET NULL, + -- List blocks (092): null bold text, 'plain' the old look. + list_style TEXT CHECK (list_style IN ('plain')), + -- Organizations blocks: the kind listed when none are picked. + org_kind TEXT CHECK (org_kind IN ('region', 'group', 'partner', 'ministry')) +) STRICT; + +INSERT INTO content_blocks_new + (id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id, captions, + word_motion, word_direction, word_seconds, venue_id, list_style) +SELECT id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id, captions, + word_motion, word_direction, word_seconds, venue_id, list_style + FROM content_blocks; + +PRAGMA legacy_alter_table = ON; +DROP TABLE content_blocks; +ALTER TABLE content_blocks_new RENAME TO content_blocks; +PRAGMA legacy_alter_table = OFF; + +CREATE INDEX content_blocks_owner_idx + ON content_blocks (owner_kind, owner_id, slot, sort_order); + +CREATE TRIGGER content_blocks_owner_exists +BEFORE INSERT ON content_blocks +BEGIN + SELECT CASE + WHEN new.owner_kind = 'event' + AND NOT EXISTS (SELECT 1 FROM events WHERE id = new.owner_id) + THEN RAISE(ABORT, 'content_blocks: no such event') + WHEN new.owner_kind = 'organization' + AND NOT EXISTS (SELECT 1 FROM organizations WHERE id = new.owner_id) + THEN RAISE(ABORT, 'content_blocks: no such organization') + WHEN new.owner_kind = 'person' + AND NOT EXISTS (SELECT 1 FROM people WHERE id = new.owner_id) + THEN RAISE(ABORT, 'content_blocks: no such person') + WHEN new.owner_kind = 'team' + AND NOT EXISTS (SELECT 1 FROM teams WHERE id = new.owner_id) + THEN RAISE(ABORT, 'content_blocks: no such team') + WHEN new.owner_kind = 'blog_post' + AND NOT EXISTS (SELECT 1 FROM blog_posts WHERE id = new.owner_id) + THEN RAISE(ABORT, 'content_blocks: no such blog post') + WHEN new.owner_kind = 'page_section' + AND NOT EXISTS (SELECT 1 FROM page_sections WHERE CAST(id AS TEXT) = new.owner_id) + THEN RAISE(ABORT, 'content_blocks: no such page section') + WHEN new.owner_kind = 'newsletter' + AND NOT EXISTS (SELECT 1 FROM newsletters WHERE CAST(id AS TEXT) = new.owner_id) + THEN RAISE(ABORT, 'content_blocks: no such newsletter') + END; +END; diff --git a/server/src/migrations/094_map_sections.sql b/server/src/migrations/094_map_sections.sql new file mode 100644 index 0000000..567a2cb --- /dev/null +++ b/server/src/migrations/094_map_sections.sql @@ -0,0 +1,27 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 094 A MAP BLOCK'S SECTIONS +-- +-- A map content block can group its venue's locations into +-- sections of its own, eg. Main spaces, Small group spaces: the +-- block's list shows them under those names, and a visitor can pick +-- one to see only its locations on the map. They're the block's, +-- not the venue's, so each event groups the same venue its own way. +-- +-- With sections, the block shows only the locations they name (in +-- the sections' order); without, every location, as before. +-- +-- location_keys the venue's location_keys (088) it holds, +-- comma-separated, as schedule tags are (087). A +-- key the venue no longer has is skipped. +-- ═══════════════════════════════════════════════════════════════ + +CREATE TABLE content_block_map_sections ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + block_id INTEGER NOT NULL REFERENCES content_blocks (id) ON DELETE CASCADE, + sort_order INTEGER NOT NULL DEFAULT 0, + name TEXT NOT NULL, + location_keys TEXT +) STRICT; + +CREATE INDEX content_block_map_sections_block_idx + ON content_block_map_sections (block_id, sort_order); diff --git a/server/src/migrations/095_presentation.sql b/server/src/migrations/095_presentation.sql new file mode 100644 index 0000000..641896d --- /dev/null +++ b/server/src/migrations/095_presentation.sql @@ -0,0 +1,56 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 095 PRESENTATION SETTINGS +-- +-- How an event's page looks presented (EventPresent.tsx), set on +-- the event; nothing here changes the page itself. +-- +-- On events (v_events is SELECT e.*, so no rebuild): +-- present_background an image behind every slide +-- present_background_color the slides' background color; with an +-- image, laid over it at present_dim +-- present_dim percent of the color over the image, +-- 0 to 90; null 60 +-- present_frame null the accent bar, title line and +-- timer; 'border' an accent border around +-- the slide; 'none' the slide alone +-- present_accent in place of the event's color +-- present_text_color the slides' text; null the background +-- color's readable one, else the site's +-- present_logo in the slide's bottom-right corner +-- +-- On content blocks (any owner's; only an event's are presented): +-- present_hide left out of the presentation +-- present_text shown presented in place of its text, +-- eg. a shorter heading +-- present_map_split a map: a slide per map section (094) +-- present_map_no_list a map: no locations list beside it +-- present_map_no_details a map: no location detail lines +-- present_places a map: which locations get a slide of +-- their own; null every marked one, +-- 'picked' present_place_keys, 'none' +-- present_place_keys the venue's location_keys (088), +-- comma-separated +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE events ADD COLUMN present_background TEXT; +ALTER TABLE events ADD COLUMN present_background_color TEXT; +ALTER TABLE events ADD COLUMN present_dim INTEGER + CHECK (present_dim BETWEEN 0 AND 90); +ALTER TABLE events ADD COLUMN present_frame TEXT + CHECK (present_frame IN ('border', 'none')); +ALTER TABLE events ADD COLUMN present_accent TEXT; +ALTER TABLE events ADD COLUMN present_text_color TEXT; +ALTER TABLE events ADD COLUMN present_logo TEXT; + +ALTER TABLE content_blocks ADD COLUMN present_hide INTEGER NOT NULL DEFAULT 0 + CHECK (present_hide IN (0, 1)); +ALTER TABLE content_blocks ADD COLUMN present_text TEXT; +ALTER TABLE content_blocks ADD COLUMN present_map_split INTEGER NOT NULL DEFAULT 0 + CHECK (present_map_split IN (0, 1)); +ALTER TABLE content_blocks ADD COLUMN present_map_no_list INTEGER NOT NULL DEFAULT 0 + CHECK (present_map_no_list IN (0, 1)); +ALTER TABLE content_blocks ADD COLUMN present_map_no_details INTEGER NOT NULL DEFAULT 0 + CHECK (present_map_no_details IN (0, 1)); +ALTER TABLE content_blocks ADD COLUMN present_places TEXT + CHECK (present_places IN ('picked', 'none')); +ALTER TABLE content_blocks ADD COLUMN present_place_keys TEXT; diff --git a/server/src/migrations/096_presentation_dark.sql b/server/src/migrations/096_presentation_dark.sql new file mode 100644 index 0000000..69e2b24 --- /dev/null +++ b/server/src/migrations/096_presentation_dark.sql @@ -0,0 +1,24 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 096 PRESENTATION SETTINGS IN THE DARK THEME +-- +-- The same as 095's, for a screen in the dark theme (the device's +-- setting, or the setup's Theme pick). Each one null takes the +-- light theme's (095), so only what differs needs setting. +-- +-- present_background_dark the image behind every slide +-- present_background_color_dark the slides' background color +-- present_dim_dark percent of the color over the +-- image, 0 to 90 +-- present_accent_dark in place of the accent +-- present_text_color_dark the slides' text +-- present_logo_dark the bottom-right logo, eg. a +-- light version +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE events ADD COLUMN present_background_dark TEXT; +ALTER TABLE events ADD COLUMN present_background_color_dark TEXT; +ALTER TABLE events ADD COLUMN present_dim_dark INTEGER + CHECK (present_dim_dark BETWEEN 0 AND 90); +ALTER TABLE events ADD COLUMN present_accent_dark TEXT; +ALTER TABLE events ADD COLUMN present_text_color_dark TEXT; +ALTER TABLE events ADD COLUMN present_logo_dark TEXT; diff --git a/server/src/migrations/097_presentation_inset.sql b/server/src/migrations/097_presentation_inset.sql new file mode 100644 index 0000000..5f2b043 --- /dev/null +++ b/server/src/migrations/097_presentation_inset.sql @@ -0,0 +1,20 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 097 PRESENTATION CONTENT INSET +-- +-- Room kept clear at each edge of a presented slide, so its content +-- sits inside a background image that is a frame (eg. a 1920x1080 +-- picture with a border drawn in it). Percent of the screen: top +-- and bottom of its height, left and right of its width, 0 to 45. +-- Null is 0. With any set, the background image is stretched to the +-- screen rather than cropped, so the frame stays where the inset +-- expects it. Both themes share them. +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE events ADD COLUMN present_inset_top REAL + CHECK (present_inset_top BETWEEN 0 AND 45); +ALTER TABLE events ADD COLUMN present_inset_right REAL + CHECK (present_inset_right BETWEEN 0 AND 45); +ALTER TABLE events ADD COLUMN present_inset_bottom REAL + CHECK (present_inset_bottom BETWEEN 0 AND 45); +ALTER TABLE events ADD COLUMN present_inset_left REAL + CHECK (present_inset_left BETWEEN 0 AND 45); diff --git a/server/src/migrations/098_present_list.sql b/server/src/migrations/098_present_list.sql new file mode 100644 index 0000000..7851b18 --- /dev/null +++ b/server/src/migrations/098_present_list.sql @@ -0,0 +1,18 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 098 A LIST BLOCK'S PRESENTATION SLIDES +-- +-- A list block presented (EventPresent.tsx) is a section's text, +-- unless it has slides of its own: +-- +-- present_list_overview one slide of every item's text, without +-- the detail, centered +-- present_list_items a slide per item: its text the heading, +-- its detail under it, centered +-- +-- Either or both. Other block types ignore them. +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE content_blocks ADD COLUMN present_list_overview INTEGER NOT NULL DEFAULT 0 + CHECK (present_list_overview IN (0, 1)); +ALTER TABLE content_blocks ADD COLUMN present_list_items INTEGER NOT NULL DEFAULT 0 + CHECK (present_list_items IN (0, 1)); diff --git a/server/src/migrations/099_present_show.sql b/server/src/migrations/099_present_show.sql new file mode 100644 index 0000000..dba78f7 --- /dev/null +++ b/server/src/migrations/099_present_show.sql @@ -0,0 +1,20 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 099 WHERE A BLOCK SHOWS: THE PAGE, THE PRESENTATION OR BOTH +-- +-- present_hide (095) could only leave a block out of the +-- presentation. present_show says where it shows instead: +-- +-- null the page and the presentation +-- 'page' only on the page (was present_hide = 1) +-- 'presentation' only in the presentation (EventPresent.tsx), eg. +-- a slide's welcome line the page doesn't need +-- +-- present_hide is copied over, then dropped. +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE content_blocks ADD COLUMN present_show TEXT + CHECK (present_show IN ('page', 'presentation')); + +UPDATE content_blocks SET present_show = 'page' WHERE present_hide = 1; + +ALTER TABLE content_blocks DROP COLUMN present_hide; diff --git a/server/src/migrations/100_present_list_picked.sql b/server/src/migrations/100_present_list_picked.sql new file mode 100644 index 0000000..8ee15da --- /dev/null +++ b/server/src/migrations/100_present_list_picked.sql @@ -0,0 +1,10 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 100 A LIST'S SLIDES PICKED WHEN PRESENTING +-- +-- A list block's Overview slide and A slide per item (098) are +-- picked on the Present setup screen (EventPresent.tsx, `lists` in +-- its address) rather than on the block, so 098's columns go. +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE content_blocks DROP COLUMN present_list_overview; +ALTER TABLE content_blocks DROP COLUMN present_list_items; diff --git a/server/src/migrations/101_image_size.sql b/server/src/migrations/101_image_size.sql new file mode 100644 index 0000000..5000b55 --- /dev/null +++ b/server/src/migrations/101_image_size.sql @@ -0,0 +1,15 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 101 AN IMAGE BLOCK'S SIZE +-- +-- How wide an image block shows, centered in the column: +-- +-- null the column's full width (as before) +-- small up to 20rem +-- medium up to 32rem +-- large up to 48rem +-- +-- Never wider than the column. Other block types ignore it. +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE content_blocks ADD COLUMN image_size TEXT + CHECK (image_size IN ('small', 'medium', 'large')); diff --git a/server/src/migrations/102_image_dark.sql b/server/src/migrations/102_image_dark.sql new file mode 100644 index 0000000..a4f457f --- /dev/null +++ b/server/src/migrations/102_image_dark.sql @@ -0,0 +1,13 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 102 AN IMAGE BLOCK'S DARK THEME PICTURE +-- +-- media_dark shown in place of media while the site is in its +-- dark theme (the visitor's setting, or a presentation +-- held dark), eg. a chart or a logo drawn light on +-- dark. Null shows media in both themes. +-- +-- Image blocks only; other types ignore it. Its alt text and caption +-- are the block's, so it should show the same thing. +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE content_blocks ADD COLUMN media_dark TEXT; diff --git a/server/src/pageMeta.js b/server/src/pageMeta.js index f6054e4..06daa23 100644 --- a/server/src/pageMeta.js +++ b/server/src/pageMeta.js @@ -413,6 +413,9 @@ export function metaFor(db, rawPath, user = null) { // in particular, so never indexed or in the sitemap. if (ACCOUNT_PAGES[pathname]) return { ...meta, title: titled(site, ACCOUNT_PAGES[pathname]), noindex: true }; + // A presenting screen's remote (src/pages/PresentRemote.tsx). + if (/^\/remote(\/|$)/.test(pathname)) return { ...meta, title: titled(site, "Remote"), noindex: true }; + // A page of the site (site_pages): hidden is Not found below // viewer; disabled stays out of search. const page = pageAt(db, pathname); @@ -426,7 +429,7 @@ export function metaFor(db, rawPath, user = null) { }; } - // An event's schedule presentation (SchedulePresent.tsx): the + // An event page's presentation (EventPresent.tsx): the // event's own title and preview, kept out of search, pointing // search engines at the event page. const present = pathname.match(/^\/events\/([^/]+)\/present$/); diff --git a/server/src/routes/content.js b/server/src/routes/content.js index 3191e17..140ceae 100644 --- a/server/src/routes/content.js +++ b/server/src/routes/content.js @@ -591,7 +591,42 @@ content.get("/events/:id", (c) => { citation: r.citation, })); - const event = { ...shapeEvent(row, links, cards, hosts), blocks: body, people, awards }; + const event = { + ...shapeEvent(row, links, cards, hosts), + show_contents: row.show_contents === 1, + links_heading: row.links_heading, + // Its page presented (095). + present: { + background: row.present_background, + background_color: row.present_background_color, + dim: row.present_dim, + frame: row.present_frame, + accent: row.present_accent, + text_color: row.present_text_color, + logo: row.present_logo, + // Room clear at each edge, percent of the screen (097). + inset: [row.present_inset_top, row.present_inset_right, row.present_inset_bottom, row.present_inset_left].some((n) => n) + ? { + top: row.present_inset_top ?? 0, + right: row.present_inset_right ?? 0, + bottom: row.present_inset_bottom ?? 0, + left: row.present_inset_left ?? 0, + } + : null, + // In the dark theme (096); null takes the above. + dark: { + background: row.present_background_dark, + background_color: row.present_background_color_dark, + dim: row.present_dim_dark, + accent: row.present_accent_dark, + text_color: row.present_text_color_dark, + logo: row.present_logo_dark, + }, + }, + blocks: body, + people, + awards, + }; attachTags(db, "event", [event]); return json(c, { event }); diff --git a/server/src/routes/present.js b/server/src/routes/present.js new file mode 100644 index 0000000..a99af38 --- /dev/null +++ b/server/src/routes/present.js @@ -0,0 +1,151 @@ +/* ═══════════════════════════════════════════════════════════════ + PRESENT REMOTE: a phone drives a presenting screen by its code + + A screen (src/pages/EventPresent.tsx) opens /present/screen, a + stream that first says its code and key, then carries commands. + It posts what it shows (state) with the key. A remote + (src/pages/PresentRemote.tsx) opens /present/:code, a stream of + that state, and posts commands. Anyone with the code can drive + the screen: the code is the only lock, so it's long enough not to + guess at the rate limit set where this is mounted. + + In memory only: one process, and a restart only makes each screen + reconnect (keeping its code when no one took it) and post its + state again. A screen gone for SWEEP_AFTER is forgotten. + ═══════════════════════════════════════════════════════════════ */ + +import { randomBytes, randomInt } from "node:crypto"; +import { Hono } from "hono"; +import { streamSSE } from "hono/streaming"; + +const present = new Hono(); + +// No 0/O, 1/I/L: read off a screen across a room. +const LETTERS = "ABCDEFGHJKMNPQRSTUVWXYZ23456789"; +const CODE = /^[A-Z0-9]{6}$/; +const PING_EVERY = 25_000; // under nginx's 60 second read timeout +const SWEEP_AFTER = 10 * 60_000; +const COMMANDS = ["next", "prev", "pause", "resume", "go", "setup", "start"]; + +// A screen's state before it first says. +const NOTHING_YET = { event: "", title: "", query: "", playing: false, paused: false, index: 0, slides: [] }; + +// code → { key, state, screen (its stream, or null), gone (ms), remotes (streams) } +const screens = new Map(); + +setInterval(() => { + const now = Date.now(); + for (const [code, s] of screens) { + if (!s.screen && s.remotes.size === 0 && now - s.gone > SWEEP_AFTER) screens.delete(code); + } +}, 60_000).unref(); + +function newCode() { + for (;;) { + const code = Array.from({ length: 6 }, () => LETTERS[randomInt(LETTERS.length)]).join(""); + // SCREEN would be the screen's own stream's address. + if (!screens.has(code) && code !== "SCREEN") return code; + } +} + +const send = (stream, event, data) => stream.writeSSE({ event, data: JSON.stringify(data) }).catch(() => {}); + +function tellRemotes(s) { + for (const remote of s.remotes) send(remote, "state", { connected: !!s.screen, ...s.state }); +} + +// Holds a stream open, pinging, until the other end goes. +function hold(stream, onGone) { + return new Promise((resolve) => { + const ping = setInterval(() => stream.write(": ping\n\n").catch(() => {}), PING_EVERY); + stream.onAbort(() => { + clearInterval(ping); + onGone(); + resolve(); + }); + }); +} + +/* A screen's stream. It asks for the code it had (code and key) and + gets it back unless that's wrong or another screen holds it now. */ +present.get("/present/screen", (c) => { + let code = c.req.query("code"); + const key = c.req.query("key"); + let s = screens.get(code); + if (!s || s.key !== key || s.screen) { + code = newCode(); + s = { key: randomBytes(16).toString("hex"), state: NOTHING_YET, screen: null, gone: 0, remotes: new Set() }; + screens.set(code, s); + } + // Tells nginx to pass each event on as it's written. + c.header("X-Accel-Buffering", "no"); + return streamSSE(c, async (stream) => { + s.screen = stream; + await send(stream, "hello", { code, key: s.key }); + tellRemotes(s); + await hold(stream, () => { + if (s.screen !== stream) return; + s.screen = null; + s.gone = Date.now(); + tellRemotes(s); + }); + }); +}); + +/* What the screen shows, for its remotes: shown as text there, so + only capped here. */ +present.post("/present/:code/state", async (c) => { + const s = screens.get(c.req.param("code")); + const body = await c.req.json().catch(() => null); + if (!s || !body || body.key !== s.key) return c.json({ error: "Not found" }, 404); + const text = (v, max) => (typeof v === "string" ? v.slice(0, max) : ""); + const count = (v) => (Number.isInteger(v) && v >= 0 ? v : 0); + s.state = { + event: text(body.event, 200), + title: text(body.title, 300), + query: text(body.query, 4000), + playing: body.playing === true, + paused: body.paused === true, + index: count(body.index), + slides: Array.isArray(body.slides) ? body.slides.slice(0, 500).map((name) => text(name, 150)) : [], + }; + tellRemotes(s); + return c.body(null, 204); +}); + +// A remote's stream: the screen's state now and each time it changes. +present.get("/present/:code", (c) => { + const s = screens.get(c.req.param("code").toUpperCase()); + if (!s) return c.json({ error: "No screen has that code." }, 404); + c.header("X-Accel-Buffering", "no"); + return streamSSE(c, async (stream) => { + s.remotes.add(stream); + await send(stream, "state", { connected: !!s.screen, ...s.state }); + await hold(stream, () => s.remotes.delete(stream)); + }); +}); + +/* A command for the screen: next, prev, pause, resume, go (to + `index`), setup (back to its setup) or start (playing `query`, the + setup's choices as EventPresent's address reads them). */ +present.post("/present/:code/command", async (c) => { + const code = c.req.param("code").toUpperCase(); + const s = CODE.test(code) ? screens.get(code) : null; + if (!s) return c.json({ error: "No screen has that code." }, 404); + if (!s.screen) return c.json({ error: "The screen isn't connected right now." }, 409); + const body = await c.req.json().catch(() => null); + if (!body || !COMMANDS.includes(body.do)) return c.json({ error: "Unknown command." }, 400); + const command = { do: body.do }; + if (body.do === "go") { + if (!Number.isInteger(body.index) || body.index < 0) return c.json({ error: "Which slide?" }, 400); + command.index = body.index; + } + if (body.do === "start") { + if (typeof body.query !== "string" || body.query.length > 4000) return c.json({ error: "That setup is too long." }, 400); + command.query = body.query; + } + await send(s.screen, "command", command); + return c.body(null, 204); +}); + +export default present; diff --git a/server/src/seed-showcase.js b/server/src/seed-showcase.js index 07c8a77..7b6e776 100644 --- a/server/src/seed-showcase.js +++ b/server/src/seed-showcase.js @@ -79,6 +79,7 @@ const MEMBERS = ["showcase-member-1", "showcase-member-2", "showcase-member-3"]; const EVENT = "showcase-event"; const SERIES = "showcase-series"; const PAST = "showcase-past-event"; +const VENUE = "showcase-venue"; /* ── Content ───────────────────────────────────────────────── */ @@ -87,21 +88,24 @@ const PAST = "showcase-past-event"; a description, graphic and map, one linked, a heading, a featured entry, a block with sub-items, a break, typed and picked times, tags (one a tab of its own in its color, one with No tab), and one - with no day (it lands in a tab of its own). */ + with no day (it lands in a tab of its own). Its venue's locations + (088) are picked on some entries, one with no typed Location, and + one sub-item is the showcase workshop, filled in from it. */ const SCHEDULE = [ "schedule", - { text: "The weekend at a glance. Tap an entry for more." }, + { text: "The weekend at a glance. Tap an entry for more.", venue_id: VENUE }, [ { day: "Friday", start_time: "16:00", text: "Arrivals and check-in", location: "Front desk", tags: "showcase-youth,showcase-all" }, { day: "Friday", kind: "heading", text: "Evening", detail: "A heading across the day" }, - { day: "Friday", time: "7:00 to 8:30pm", text: "Opening session", location: "Main Hall", person_id: "showcase-person", detail: "Welcome and worship", description: "The **opening session** sets the theme for the weekend.\n\nBring a notebook.", media: "/uploads/showcase.jpg", map: "Camp Hebron, Halifax PA", map_image: "/uploads/showcase.jpg" }, + { day: "Friday", time: "7:00 to 8:30pm", text: "Opening session", location_key: "hall", person_id: "showcase-person", detail: "Welcome and worship", description: "The **opening session** sets the theme for the weekend.\n\nBring a notebook.", media: "/uploads/showcase.jpg", map: "Camp Hebron, Halifax PA", map_image: "/uploads/showcase.jpg" }, { day: "Saturday", start_time: "08:00", end_time: "09:00", kind: "break", text: "Breakfast", location: "Dining hall" }, { day: "Saturday", start_time: "09:00", end_time: "10:30", kind: "block", text: "Workshops", location: "Classrooms", detail: "Pick one of three", items: [ - { start_time: "09:00", end_time: "09:45", text: "Leading worship", location: "Room A", person_id: "showcase-member-2", url: "/blog/content-block-showcase" }, + { start_time: "09:00", end_time: "09:45", text: "Leading worship", location: "Room A", location_key: "rooma", person_id: "showcase-member-2", url: "/blog/content-block-showcase" }, + { start_time: "09:00", end_time: "09:45", text: "Showcase Past Workshop", event_id: PAST, location_key: "rooma" }, { start_time: "09:00", end_time: "09:45", text: "Speaking with confidence", location: "Room B", featured: 1, tags: "showcase-youth", description: "A featured sub-item that folds out." }, { time: "After the first round", text: "Open questions", location: "Room C" }, ] }, - { day: "Saturday", start_time: "19:00", featured: 1, tags: "showcase-youth", text: "Talent night", location: "Main Hall", person_id: "showcase-member-3", description: "Sign up at the front desk by noon." }, + { day: "Saturday", start_time: "19:00", featured: 1, tags: "showcase-youth", text: "Talent night", location: "Main Hall", location_key: "hall", person_id: "showcase-member-3", description: "Sign up at the front desk by noon." }, { day: "Sunday", time: "10:00am", text: "Closing service", location: "Chapel", map: "Main Street, Halifax PA" }, { time: "Any time", text: "Quiet room open", location: "Library", detail: "An entry with no day" }, ], @@ -141,6 +145,13 @@ const ALL_BLOCKS = [ ["image", { media: IMAGE, alt: "The same picture, linked", href: "/history" }], ["subheading", { text: "Schedule" }], SCHEDULE, + ["subheading", { text: "Map" }], + ["map", { venue_id: VENUE }], + ["subheading", { text: "Events" }], + ["events", {}, [ + { event_id: PAST, text: "Showcase Past Workshop" }, + { event_id: "showcase-event", text: "A card with its own title", detail: "And its own text in place of the event's." }, + ]], ["subheading", { text: "Video" }], ["video", { href: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", text: "A YouTube video, with its own thumbnail" }], ["video", { href: "https://vimeo.com/76979871", media: IMAGE, text: "A Vimeo video with an uploaded still" }], @@ -255,6 +266,7 @@ tx(db, () => { db.prepare(`DELETE FROM awards WHERE id LIKE 'showcase-%'`).run(); db.prepare(`DELETE FROM affiliations WHERE person_id LIKE 'showcase-%' OR org_id LIKE 'showcase-%'`).run(); db.prepare(`DELETE FROM teams WHERE id LIKE 'showcase-%'`).run(); + db.prepare(`DELETE FROM venues WHERE id LIKE 'showcase-%'`).run(); db.prepare(`DELETE FROM people WHERE id LIKE 'showcase-%'`).run(); db.prepare(`DELETE FROM organizations WHERE id = ?`).run(GROUP); db.prepare(`DELETE FROM organizations WHERE id LIKE 'showcase-%'`).run(); @@ -412,7 +424,6 @@ tx(db, () => { { kind: "social", platform: "instagram", label: "@showcaseretreat", url: "https://instagram.com/showcaseretreat" }, ]); blocks("event", EVENT, "both", cardText("event")); - blocks("event", EVENT, "body", [...pageBody("event"), ["heading", { text: "Schedule" }], SCHEDULE]); insert("events", { id: SERIES, @@ -458,6 +469,23 @@ tx(db, () => { insert("event_people", { event_id: PAST, person_id: PERSON, role: "host", is_public: 1, sort_order: 0 }); blocks("event", PAST, "card", cardText("past event")); + /* ── Venue (088): a pin, a box and an unmarked location ── */ + insert("venues", { id: VENUE, name: "Showcase Retreat Center", address: "123 Example Road, Exampletown PA", map_image: IMAGE }); + [ + { location_key: "hall", name: "Main Hall", detail: "Sessions and talent night", x: 30, y: 40 }, + { location_key: "rooma", name: "Room A", detail: "Workshops", x: 55, y: 20, w: 25, h: 30 }, + { location_key: "desk", name: "Front desk", detail: "Not marked on the map" }, + ].forEach((location, i) => insert("venue_locations", { venue_id: VENUE, sort_order: i, ...location })); + + // The retreat's page, after the workshop and venue its schedule names. + blocks("event", EVENT, "body", [ + ...pageBody("event"), + ["heading", { text: "Schedule" }], + SCHEDULE, + ["heading", { text: "Map" }], + ["map", { venue_id: VENUE }], + ]); + /* ── Award ── */ insert("awards", { id: AWARD, diff --git a/server/src/shape.js b/server/src/shape.js index aee9313..1e78ef2 100644 --- a/server/src/shape.js +++ b/server/src/shape.js @@ -64,14 +64,32 @@ export function loadLinks(db, ownerKind, ids) { rather than no key, so the renderer never has to check. ───────────────────────────────────────────────────────────── */ -export function loadBlocks(db, ownerKind, ids, slot = "body") { +/* A block's presentation settings (095), or null with none set. */ +function presentOf(row) { + const present = { + // Where it shows (099). + hide: row.present_show === "page", + only: row.present_show === "presentation", + text: row.present_text, + map_split: row.present_map_split === 1, + map_no_list: row.present_map_no_list === 1, + map_no_details: row.present_map_no_details === 1, + places: row.present_places, + place_keys: row.present_place_keys ? row.present_place_keys.split(",").filter(Boolean) : [], + }; + return Object.values(present).some((value) => (Array.isArray(value) ? value.length : value)) ? present : null; +} + +export function loadBlocks(db, ownerKind, ids, slot = "body", depth = 0) { const out = new Map(); if (ids.length === 0) return out; const blockRows = db .prepare( - `SELECT id, owner_id, type, text, media, href, alt, cite, captions, team_id, - word_motion, word_direction, word_seconds + `SELECT id, owner_id, type, text, media, media_dark, href, alt, cite, captions, team_id, venue_id, + word_motion, word_direction, word_seconds, list_style, image_size, org_kind, + present_show, present_text, present_map_split, present_map_no_list, + present_map_no_details, present_places, present_place_keys FROM content_blocks WHERE owner_kind = ? AND slot IN (?, 'both') AND owner_id IN (${placeholders(ids.length)}) ORDER BY owner_id, sort_order`, @@ -87,15 +105,22 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") { type: row.type, text: row.text, media: row.media, + media_dark: row.media_dark, href: row.href, alt: row.alt, cite: row.cite, captions: row.captions, team_id: row.team_id, + venue_id: row.venue_id, + list_style: row.list_style, + image_size: row.image_size, + org_kind: row.org_kind, // Its rotating words' motion (084), when it has its own. words: row.word_motion || row.word_direction || row.word_seconds ? { motion: row.word_motion, direction: row.word_direction, seconds: row.word_seconds } : null, + // How it's presented (095), when anything is set. + present: presentOf(row), items: [], }; byId.set(row.id, block); @@ -109,12 +134,13 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") { const ENTRY_FIELDS = `i.text, i.detail, i.url, i.start_time, i.end_time, i.time, i.location, i.description, i.media, i.media_alt, i.map, i.map_image, i.featured, i.tags, + i.event_id, i.location_key, p.id AS person_id, p.display_name AS person_name, p.photo AS person_photo, p.tagline AS person_tagline`; const itemRows = db .prepare( - `SELECT i.id, i.block_id, i.day, i.kind, ${ENTRY_FIELDS} + `SELECT i.id, i.block_id, i.day, i.kind, i.heading, i.subheading, i.org_id, ${ENTRY_FIELDS} FROM content_block_items i LEFT JOIN v_people_public p ON p.id = i.person_id AND p.is_published = 1 WHERE i.block_id IN (${placeholders(blockIds.length)}) @@ -126,7 +152,15 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") { // ride along anyway rather than branching on the block's type. const itemsById = new Map(); for (const row of itemRows) { - const item = { ...scheduleEntry(row), day: row.day, kind: row.kind ?? "entry", items: [] }; + const item = { + ...scheduleEntry(row), + day: row.day, + kind: row.kind ?? "entry", + heading: row.heading, + subheading: row.subheading, + org_id: row.org_id, + items: [], + }; itemsById.set(row.id, item); byId.get(row.block_id)?.items.push(item); } @@ -172,9 +206,146 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") { block.items.forEach(cut); } + attachVenues(db, [...byId.values()]); + attachEvents(db, [...byId.values()], depth); + + // A map block's sections (094): each names some of its venue's + // locations. With any, the block's venue is cut to the locations + // they name, in their order, so the page, its schedule's links + // and the presentation all see the same places, numbered alike. + const sectionRows = db + .prepare( + `SELECT block_id, name, location_keys + FROM content_block_map_sections + WHERE block_id IN (${placeholders(blockIds.length)}) + ORDER BY block_id, sort_order`, + ) + .all(...blockIds); + for (const row of sectionRows) { + const block = byId.get(row.block_id); + if (!block?.venue) continue; + const known = new Set(block.venue.locations.map((location) => location.key)); + const keys = (row.location_keys ?? "").split(",").filter((key) => known.has(key)); + if (keys.length) (block.map_sections ??= []).push({ name: row.name, keys }); + } + for (const block of byId.values()) { + if (!block.map_sections) continue; + const byKey = new Map(block.venue.locations.map((location) => [location.key, location])); + const shown = [...new Set(block.map_sections.flatMap((section) => section.keys))]; + block.venue = { ...block.venue, locations: shown.map((key) => byKey.get(key)) }; + } + return out; } +/* A map or schedule block's venue (088), its locations in order, + and each entry's location_key made its place on it: `place` is + the location, and the location's name stands in for a blank + typed Location. A key the venue no longer has is dropped. */ +function attachVenues(db, blocks) { + const ids = [...new Set(blocks.map((block) => block.venue_id).filter(Boolean))]; + if (ids.length === 0) return; + const venues = new Map( + db + .prepare(`SELECT id, name, address, map_image, map_alt FROM venues WHERE id IN (${placeholders(ids.length)})`) + .all(...ids) + .map((row) => [row.id, { ...row, locations: [] }]), + ); + const locationRows = db + .prepare( + `SELECT venue_id, location_key AS key, name, detail, x, y, w, h, google_maps_url, apple_maps_url + FROM venue_locations + WHERE venue_id IN (${placeholders(ids.length)}) + ORDER BY venue_id, sort_order`, + ) + .all(...ids); + for (const { venue_id, ...location } of locationRows) venues.get(venue_id)?.locations.push(location); + + for (const block of blocks) { + const venue = venues.get(block.venue_id); + block.venue = venue ?? null; + const place = (entry) => { + const location = venue?.locations.find((l) => l.key === entry.location_key) ?? null; + entry.place = location ? { venue_id: venue.id, key: location.key, name: location.name } : null; + if (location && !entry.location) entry.location = location.name; + entry.items?.forEach(place); + }; + block.items.forEach(place); + } +} + +/* The events named by items (088): an events block's cards, and a + schedule entry or sub-item that is a workshop, which takes what + it leaves blank from its event: the link, the description (its + card text), the graphic (its photo) and the person (a person + host). An unpublished event is no event. + + An events block's event also brings its own page's blocks + (`blocks`), drawn when its card is opened. Only at the top + (`depth` 0): a workshop's blocks don't bring theirs, so two + events listing each other can't go round forever. */ +function attachEvents(db, blocks, depth = 0) { + const entries = []; + const walk = (entry) => { + entries.push(entry); + entry.items?.forEach(walk); + }; + blocks.forEach((block) => block.items.forEach(walk)); + const ids = [...new Set(entries.map((entry) => entry.event_id).filter(Boolean))]; + if (ids.length === 0) return; + + const rows = db + .prepare( + `SELECT e.id, e.title, e.tagline, e.event_type, e.starts_on, e.ends_on, e.date_label, + e.effective_color AS color, COALESCE(e.card_image, e.photo) AS image, e.photo, e.photo_alt, + e.location_label, + p.id AS person_id, p.display_name AS person_name, p.photo AS person_photo, + p.tagline AS person_tagline + FROM v_events e + LEFT JOIN v_people_public p ON e.host_kind = 'person' AND p.id = e.host_id AND p.is_published = 1 + WHERE e.is_published = 1 AND e.id IN (${placeholders(ids.length)})`, + ) + .all(...ids); + const cards = loadBlocks(db, "event", rows.map((row) => row.id), "card"); + const events = new Map(rows.map((row) => [row.id, row])); + const shown = blocks.filter((block) => block.type === "events").flatMap((block) => block.items); + const shownIds = [...new Set(shown.map((item) => item.event_id).filter((id) => events.has(id)))]; + const bodies = depth === 0 && shownIds.length ? loadBlocks(db, "event", shownIds, "body", depth + 1) : new Map(); + + for (const entry of entries) { + const row = events.get(entry.event_id); + if (!row) { + entry.event = null; + continue; + } + const blurb = paragraphs(cards.get(row.id) ?? []).join("\n\n") || row.tagline || null; + entry.event = { + id: row.id, + title: row.title, + event_type: row.event_type, + starts_on: row.starts_on, + ends_on: row.ends_on, + date_label: row.date_label, + color: row.color, + image: row.image, + photo: row.photo, + photo_alt: row.photo_alt, + location_label: row.location_label, + blurb, + }; + if (shown.includes(entry)) entry.event.blocks = bodies.get(row.id) ?? []; + entry.url ||= `/events/${row.id}`; + entry.description ||= blurb; + if (!entry.media && row.image) { + entry.media = row.image; + entry.media_alt = row.photo_alt; + } + if (!entry.person && row.person_id) { + entry.person = { id: row.person_id, name: row.person_name, photo: row.person_photo, tagline: row.person_tagline }; + } + } +} + /* A schedule entry or sub-item as the page gets it. `time` is what to show: the typed override, else the picked times (086). An unpublished person comes back as no person. */ @@ -194,6 +365,8 @@ function scheduleEntry(row) { map_image: row.map_image, featured: row.featured === 1, tags: row.tags ? row.tags.split(",").filter(Boolean) : [], + event_id: row.event_id, + location_key: row.location_key, person: row.person_id ? { id: row.person_id, diff --git a/src/App.tsx b/src/App.tsx index 4f6b860..d0f0de7 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -67,7 +67,8 @@ const AwardDetail = lazyPage(() => import("./pages/AwardDetail.tsx")) const PersonDetail = lazyPage(() => import("./pages/PersonDetail.tsx")) const BlogPost = lazyPage(() => import("./pages/BlogPost.tsx")) const DirectoryPage = lazyPage(() => import("./pages/DirectoryPage.tsx")) -const SchedulePresent = lazyPage(() => import("./pages/SchedulePresent.tsx")) +const EventPresent = lazyPage(() => import("./pages/EventPresent.tsx")) +const PresentRemote = lazyPage(() => import("./pages/PresentRemote.tsx")) /*Admin Pages*/ const AdminLayout = lazyPage(() => import("./pages/admin/AdminLayout.tsx")) @@ -110,12 +111,21 @@ export default function App() { {/* Every page of the site: Pages → Page management (PageAtPath). */} } /> - {/* A schedule as a slideshow for a screen: full screen, no Layout. */} + {/* An event page as a slideshow for a screen: full screen, no Layout. */} - + + + } + /> + {/* A phone driving a presenting screen, by its code. */} + + } /> diff --git a/src/components/ContentBlocks.tsx b/src/components/ContentBlocks.tsx index 4d9299e..ab992ed 100644 --- a/src/components/ContentBlocks.tsx +++ b/src/components/ContentBlocks.tsx @@ -30,6 +30,14 @@ people team_id's members as people tiles, then items as more tiles: person, text their title (an unpublished person is left out) + map venue: its map, locations marked and + listed (MapBlock); a schedule's places + link to it + events items as event cards: event (from + event_id), text the title shown, detail + in place of the event's card text; a card + opens the event in full under them, its + own page's blocks too (EventsBlock) divider nothing "Formatted" is InlineText.tsx: **bold**, *italic*, [text](url), @@ -44,26 +52,38 @@ visible even if the renderer hasn't caught up with it. ═══════════════════════════════════════════════════════════════ */ +import { CaretDown } from '@phosphor-icons/react' +import { useEffect, useId, useRef, useState } from 'react' +import { Link } from 'react-router-dom' + import { mediaUrl } from '../lib/media.ts' import PeopleTiles from './PeopleTiles.tsx' -import type { ContentBlock, ContentBlockItem } from '../lib/useContent.ts' +import type { ContentBlock, ContentBlockItem, ItemEvent } from '../lib/useContent.ts' import { Anchor, Inline, Paragraphs, isExternalUrl } from './InlineText.tsx' import VideoPlayer from './VideoPlayer.tsx' -import ScheduleBlock from './ScheduleBlock.tsx' +import ScheduleBlock, { Avatar } from './ScheduleBlock.tsx' +import MapBlock, { PageMaps, mapAnchor } from './MapBlock.tsx' +import { eventHref, personHref } from '../lib/hrefs.ts' +import { occurrenceLabel } from '../lib/eventSeries.ts' import { accentText, BRAND } from '../lib/color.ts' import { headingAnchors } from '../lib/contents.ts' import { SITE_NAME } from '../lib/site.ts' import { useSmallImage } from '../lib/useSmallImage.ts' import { useReadingMode } from '../lib/readingMode.ts' import { WordMotion, Words } from './RotatingWords.tsx' +import OrgListCards, { OrgLogoRow } from '../pages/sections/OrgList-Card.tsx' +import { usePresenting } from '../lib/presenting.ts' +import { useDarkTheme } from '../lib/darkTheme.ts' const BODY = 'var(--color-muted)' +/* An image block's Size (101): its widest, centered. */ +const IMAGE_SIZE = { small: 'max-w-[20rem]', medium: 'max-w-[32rem]', large: 'max-w-[48rem]' } as const + export default function ContentBlocks({ blocks, accent = BRAND, className = '', - presentAt, anchorPrefix = '', }: { blocks?: ContentBlock[] | null @@ -71,10 +91,19 @@ export default function ContentBlocks({ className?: string /** Put before each heading's id: a blog post's tab (contents.ts, splitTabs). */ anchorPrefix?: string - /** An event page's presentation route: each schedule gets a Present - * button to it, `?block=` naming which schedule (from 0). */ - presentAt?: string }) { + const presenting = usePresenting() + // Presented, a block shown only on the page is left out, so is a + // divider (a slide has its own edges), and the rest take their + // Presentation text (095, 099); on the page, a block shown only in + // the presentation is. + if (blocks) { + blocks = presenting + ? blocks + .filter((block) => !block.present?.hide && block.type !== 'divider') + .map((block) => (block.present?.text ? { ...block, text: block.present.text } : block)) + : blocks.filter((block) => !block.present?.only) + } if (!blocks?.length) return null // Headings get ids so a post's contents (PostContents) and a shared // link (#getting-there) can point at them. @@ -89,12 +118,19 @@ export default function ContentBlocks({ return level }) - let schedules = 0 - const presentHrefs = blocks.map((block) => - presentAt && block.type === 'schedule' ? `${presentAt}?block=${schedules++}` : undefined, + + // The places mapped here, for a schedule's places to link to: a + // map block's venue's locations (only those its sections show). + const maps = new Set( + blocks.flatMap((block) => + block.type === 'map' && block.venue + ? block.venue.locations.map((location) => mapAnchor(block.venue!.id, location.key)) + : [], + ), ) return ( +
{blocks.map((block, index) => ( @@ -103,11 +139,11 @@ export default function ContentBlocks({ accent={accent} anchor={idAt.get(index)} level={levels[index]} - presentHref={presentHrefs[index]} /> ))}
+
) } @@ -144,6 +180,182 @@ function LinkCard({ item }: { item: ContentBlockItem }) { ) } +/* One event card (088): the event's picture, its type and date, + its title (or the item's text) and card text (or the item's + detail); the whole card links to the event. */ +/* An event's type and date, eg. workshop · June 14, 2025 (shown + capitalized), or null with neither. */ +export function eventLine(event: ItemEvent): string | null { + const when = event.date_label || (event.starts_on ? occurrenceLabel(event.starts_on) : null) + const kind = event.event_type && event.event_type !== 'other' ? event.event_type : null + return [kind, when].filter(Boolean).join(' · ') || null +} + +function EventCard({ + item, + accent, + open, + panelId, + onToggle, +}: { + item: ContentBlockItem + accent: string + open: boolean + panelId: string + onToggle: () => void +}) { + const event = item.event! + const img = useSmallImage(mediaUrl(event.image)) + const color = event.color || accent + const line = eventLine(event) + return ( + + ) +} + +/* An event in full (088): its photo, type and date, title, place and + person host, then its own page's blocks (else its card text), and + a link to its page. */ +function EventInFull({ item, accent, level }: { item: ContentBlockItem; accent: string; level: 3 | 4 | 5 }) { + const event = item.event! + const color = event.color || accent + const photo = mediaUrl(event.photo || event.image) + const line = eventLine(event) + const Title = `h${level}` as 'h3' + const blurb = item.detail || event.blurb + return ( +
+ {photo && {event.photo_alt} +
+ {line && ( +

+ {line} +

+ )} + {item.text || event.title} + {(event.location_label || item.person) && ( +

+ {event.location_label && {event.location_label}} + {item.person && ( + + + {item.person.name} + + )} +

+ )} +
+ {event.blocks?.length ? ( + + ) : blurb ? ( +
+ +
+ ) : null} + + {event.title}: the event's page + +
+ ) +} + +/* An events block (088): its events as cards; one opened shows in + full under them, scrolled into view. A featured one (090) is + already open, above the cards, under its own heading and + subheading. Reading mode has them all in full. */ +function EventsBlock({ items, accent, level }: { items: ContentBlockItem[]; accent: string; level: 3 | 4 | 5 }) { + const [open, setOpen] = useState(null) + const panelId = useId() + const panel = useRef(null) + const reading = useReadingMode() + useEffect(() => { + if (open != null) panel.current?.scrollIntoView({ behavior: 'smooth', block: 'nearest' }) + }, [open]) + + const featured = reading ? items : items.filter((item) => item.featured) + const cards = reading ? [] : items.filter((item) => !item.featured) + + return ( +
+ {featured.map((item, i) => ( + + ))} + {cards.length > 0 && ( + <> +
    + {cards.map((item, i) => ( +
  • + setOpen(open === i ? null : i)} + /> +
  • + ))} +
+
+ {open != null && cards[open] && } +
+ + )} +
+ ) +} + +/* A featured event: its heading and subheading, if set, then the + event in full, its title a level under the heading. */ +function FeaturedEvent({ item, accent, level }: { item: ContentBlockItem; accent: string; level: 3 | 4 | 5 }) { + if (!item.heading && !item.subheading) return + const Heading = `h${level}` as 'h3' + const color = item.event?.color || accent + return ( +
+
+ {item.heading && ( + + {item.heading} + + )} + {item.subheading &&

{item.subheading}

} +
+ +
+ ) +} + /* A table block's text as rows of cells: one row per line, cells split by "|" (a literal bar is "\|"), blank lines skipped. A leading and trailing bar, as in Markdown, is allowed. */ @@ -175,16 +387,19 @@ function Block({ accent, anchor, level, - presentHref, }: { block: ContentBlock accent: string anchor?: string level: 3 | 4 | 5 - presentHref?: string }) { const text = block.text ?? '' const reading = useReadingMode() + // On a screen: links are their text, people and organizations + // just pictures and names (095). + const presenting = usePresenting() + // An image block's dark theme picture (102). + const dark = useDarkTheme() switch (block.type) { // A blog post's tab marker (BlogPost.tsx splits the post at @@ -204,7 +419,10 @@ function Block({ ) - case 'list': + case 'list': { + // Bold text and a plain detail, unless the block is set Plain + // (092): plain text, gray detail. + const plain = block.list_style === 'plain' return (
    {(block.items ?? []).map((item, index) => ( @@ -212,20 +430,23 @@ function Block({ - - {item.url ? ( - - {item.text} - - ) : ( - - )} - {item.detail && : {item.detail}} + + + {item.url && !presenting ? ( + + {item.text} + + ) : ( + + )} + + {item.detail && : {item.detail}} ))}
) + } case 'links': return ( @@ -343,7 +564,7 @@ function Block({ ) case 'image': { - const src = mediaUrl(block.media) + const src = mediaUrl((dark && block.media_dark) || block.media) if (!src) return null // The reader leaves out a picture with no alt, and its link with it. if (reading && block.href && !block.alt) { @@ -365,7 +586,7 @@ function Block({ /> ) return ( -
+
{block.href ? {img} : img}
@@ -391,10 +612,36 @@ function Block({ tags={block.tags} intro={block.text} accent={accent} - presentHref={presentHref} /> ) + case 'map': + if (!block.venue) return null + return + + case 'events': { + const events = (block.items ?? []).filter((item) => item.event) + if (events.length === 0) return null + return + } + + case 'organizations': { + // Picked ones in their order, else every listed one of its kind. + const ids = (block.items ?? []).map((item) => item.org_id).filter((id): id is string => Boolean(id)) + if (ids.length === 0 && !block.org_kind) return null + if (presenting) return + return ( + + ) + } + case 'people': { const picked = (block.items ?? []) .filter((item) => item.person) @@ -402,8 +649,8 @@ function Block({ if (!block.team_id && picked.length === 0) return null return (
- {block.team_id && } - {picked.length > 0 && } + {block.team_id && } + {picked.length > 0 && }
) } @@ -414,7 +661,7 @@ function Block({ case 'paragraph': default: if (!text) return null - return block.href ? ( + return block.href && !presenting ? (

{text} diff --git a/src/components/InlineText.tsx b/src/components/InlineText.tsx index 7528c3b..0c7f4f7 100644 --- a/src/components/InlineText.tsx +++ b/src/components/InlineText.tsx @@ -22,6 +22,7 @@ import { Fragment, type CSSProperties, type ReactNode } from 'react' import { Link } from 'react-router-dom' import { accentText } from '../lib/color.ts' import { RotatingWords } from './RotatingWords.tsx' +import { usePresenting } from '../lib/presenting.ts' const TOKEN = /\*\*(.+?)\*\*|\*(.+?)\*|\[([^\]]+)\]\(([^)\s]+)\)|\{([^{}|\n]+(?:\|[^{}|\n]+)+)\}/g const SAFE_URL = /^(\/(?!\/)|#|https?:\/\/|mailto:|tel:)/i @@ -77,7 +78,8 @@ export function Anchor({ ) } -function line(text: string, accent: string, key: string): ReactNode[] { +/* `plain`: a link's text alone, presented (095). */ +function line(text: string, accent: string, key: string, plain = false): ReactNode[] { const out: ReactNode[] = [] let last = 0 let n = 0 @@ -89,6 +91,7 @@ function line(text: string, accent: string, key: string): ReactNode[] { if (words != null) out.push( word.trim())} />) else if (bold != null) out.push({bold}) else if (italic != null) out.push({italic}) + else if (label != null && plain) out.push(label) else if (label != null && SAFE_URL.test(url)) { out.push( @@ -104,13 +107,14 @@ function line(text: string, accent: string, key: string): ReactNode[] { /** Text inside another element: formatting and line breaks. */ export function Inline({ text, accent }: { text?: string | null; accent: string }) { + const plain = usePresenting() const lines = (text ?? '').split('\n') return ( <> {lines.map((part, i) => ( {i > 0 &&
} - {line(part, accent, `l${i}`)} + {line(part, accent, `l${i}`, plain)}
))} diff --git a/src/components/MapBlock.tsx b/src/components/MapBlock.tsx new file mode 100644 index 0000000..3778e80 --- /dev/null +++ b/src/components/MapBlock.tsx @@ -0,0 +1,372 @@ +/* ═══════════════════════════════════════════════════════════════ + MAP BLOCK + + The 'map' content block (088): a venue's map picture with its + locations marked on it, each a numbered pin or a box, and the + locations listed beside it (under it on a phone). + + One picture, the marks drawn over it in percent of its size, so + they stay on their places at any width. A location is lit up + (in the accent, the rest dimmed) while its row or mark is hovered + or focused, and when the address points at it: #map--, + the link a schedule entry's place makes (mapAnchor). Those ids + sit at the block's top, so Layout's jump to the anchor brings the + whole map into view, not the mark at the top of the screen. + + The picture zooms (the buttons over it), scrolling inside its box + when it's bigger than it; the marks are in percent, so they keep + their places. A location's Google and Apple Maps links (091) are + buttons at the right of its row. + + MapPicture is the picture and its marks alone; the event's + presentation (EventPresent.tsx) draws it too, with no links. + + Reading mode (readingMode.ts) gets the list alone, no picture. + + A block's own sections (094), eg. Main spaces, group the list + under their names; the API has already cut the venue to the + locations they hold. Buttons over the list (All, then one per + section) show one section alone, its marks on the map and its + rows in the list. A link to a location outside the section in + view goes back to All. + + PageMaps holds the locations mapped by the blocks drawn together + (their anchors, ContentBlocks), so a schedule's places link only + when there's a map on the page showing them. + ═══════════════════════════════════════════════════════════════ */ + +import { createContext, useEffect, useState, type CSSProperties, type ReactNode } from 'react' +import { AppleLogo, ArrowsIn, GoogleLogo, MagnifyingGlassMinus, MagnifyingGlassPlus } from '@phosphor-icons/react' +import { Link, useLocation, type To } from 'react-router-dom' + +import { mediaUrl } from '../lib/media.ts' +import type { MapSection, Venue, VenueLocation } from '../lib/useContent.ts' +import { accentText, readableOn, withAlpha } from '../lib/color.ts' +import { useReadingMode } from '../lib/readingMode.ts' + +export const PageMaps = createContext>(new Set()) + +export const mapAnchor = (venueId: string, key: string) => `map-${venueId}-${key}` + +/* The picture's zoom steps, 1 the column's width. */ +const ZOOMS = [1, 1.5, 2, 3, 4] + +const isBox = (location: VenueLocation) => location.w != null && location.h != null +export const isMarked = (location: VenueLocation) => location.x != null && location.y != null + +/* A location's number on the map and in the list: its place in the + venue's order. */ +export const locationNumber = (venue: Venue, location: VenueLocation) => venue.locations.indexOf(location) + 1 + +/* A location's numbered dot, in the accent. */ +export function LocationNumber({ + n, + accent, + className = 'h-6 w-6 text-xs', + style, +}: { + n: number + accent: string + className?: string + style?: CSSProperties +}) { + return ( + + ) +} + +/* The venue's picture with its marks, `active` lit up. With `link` + each mark is a link (and `light` its hover and focus); without, + the marks are only drawn. `className` sizes the picture's box. */ +export function MapPicture({ + venue, + accent, + active, + link, + light, + className = '', + big = false, + only, +}: { + venue: Venue + accent: string + active: string | null + /** Marks only these locations' keys; all when unset. */ + only?: Set + link?: (key: string) => To + light?: (key: string) => object + className?: string + /** Bigger marks, for a screen across a room. */ + big?: boolean +}) { + const image = mediaUrl(venue.map_image) + if (!image) return null + return ( +

+ {venue.map_alt + {venue.locations.filter((location) => isMarked(location) && (!only || only.has(location.key))).map((location) => { + const on = active === location.key + const dim = active != null && !on + const style: CSSProperties = isBox(location) + ? { + left: `${location.x}%`, + top: `${location.y}%`, + width: `${location.w}%`, + height: `${location.h}%`, + border: `${big ? 4 : 2}px solid ${accent}`, + background: withAlpha(accent, on ? 35 : 12), + opacity: dim ? 0.35 : 1, + } + : { + left: `${location.x}%`, + top: `${location.y}%`, + transform: 'translate(-50%, -50%)', + opacity: dim ? 0.35 : 1, + zIndex: on ? 1 : undefined, + } + const dot = big + ? isBox(location) + ? 'absolute top-[0.5vw] left-[0.5vw] h-[2.6vw] w-[2.6vw] text-[1.3vw]' + : on + ? 'h-[4vw] w-[4vw] text-[2vw]' + : 'h-[2.8vw] w-[2.8vw] text-[1.4vw]' + : isBox(location) + ? 'absolute top-1 left-1 h-6 w-6 text-xs' + : on + ? 'h-9 w-9 text-xs' + : 'h-7 w-7 text-xs' + const inside = ( + <> + + {on && !big && ( + + )} + + ) + return link ? ( + + {inside} + + ) : ( + + ) + })} +
+ ) +} + +export default function MapBlock({ + venue, + sections = [], + accent, +}: { + venue: Venue + sections?: MapSection[] + accent: string +}) { + const { hash, search } = useLocation() + const [hovered, setHovered] = useState(null) + const [zoom, setZoom] = useState(0) + // The section in view, by index; null is All. + const [view, setView] = useState(null) + const fromHash = venue.locations.find((location) => hash === `#${mapAnchor(venue.id, location.key)}`)?.key ?? null + const viewed = view != null ? sections[view] : undefined + + // A link to a place outside the section in view shows All again. + useEffect(() => { + if (fromHash && viewed && !viewed.keys.includes(fromHash)) setView(null) + }, [fromHash, viewed]) + + const byKey = new Map(venue.locations.map((location) => [location.key, location])) + const groups: { name?: string; locations: VenueLocation[] }[] = sections.length + ? (viewed ? [viewed] : sections).map((section) => ({ + name: section.name, + locations: section.keys.flatMap((key) => byKey.get(key) ?? []), + })) + : [{ locations: venue.locations }] + const only = viewed ? new Set(viewed.keys) : undefined + const active = hovered ?? fromHash + const picture = !useReadingMode() && Boolean(venue.map_image) + + const to = (key: string) => ({ search, hash: mapAnchor(venue.id, key) }) + const light = (key: string) => ({ + onMouseEnter: () => setHovered(key), + onMouseLeave: () => setHovered(null), + onFocus: () => setHovered(key), + onBlur: () => setHovered(null), + }) + + return ( +
+ {/* Where a link to a location lands: the map's top. */} + {venue.locations.map((location) => ( + + ))} + + {picture && ( +
+
+
+ +
+
+
+ setZoom(zoom + 1)}> + + + setZoom(zoom - 1)}> + + + {zoom > 0 && ( + setZoom(0)}> + + + )} +
+
+ )} + +
+

{venue.name}

+ {venue.address &&

{venue.address}

} + {sections.length > 1 && ( +
+ {[null, ...sections.map((_, i) => i)].map((i) => { + const selected = view === i + return ( + + ) + })} +
+ )} + {groups.map((group, g) => ( +
+ {group.name &&

{group.name}

} +
    + {group.locations.map((location) => { + const on = active === location.key + const row = ( + <> + + + + {location.name} + + {location.detail && {location.detail}} + + + ) + const rowClass = 'flex items-start gap-3 px-2 py-1.5 text-body' + const rowStyle = on ? { background: withAlpha(accent, 12) } : undefined + return ( +
  1. + {isMarked(location) ? ( + + {row} + + ) : ( +
    {row}
    + )} + +
  2. + ) + })} +
+
+ ))} +
+
+ ) +} + +/* A zoom button over the map picture. */ +function ZoomButton({ + label, + disabled, + onClick, + children, +}: { + label: string + disabled?: boolean + onClick: () => void + children: ReactNode +}) { + return ( + + ) +} + +/* A location's Google and Apple Maps links (091), as buttons that + open them in a new tab. */ +function MapLinks({ location, accent }: { location: VenueLocation; accent: string }) { + const links = [ + { href: location.google_maps_url, label: 'Google Maps', Icon: GoogleLogo }, + { href: location.apple_maps_url, label: 'Apple Maps', Icon: AppleLogo }, + ].filter((link) => link.href) + if (links.length === 0) return null + return ( + + {links.map(({ href, label, Icon }) => ( + + + ))} + + ) +} diff --git a/src/components/PeopleTiles.tsx b/src/components/PeopleTiles.tsx index d0371a7d..c01ccd5 100644 --- a/src/components/PeopleTiles.tsx +++ b/src/components/PeopleTiles.tsx @@ -165,6 +165,10 @@ export interface PeopleTilesProps /** The group labels' heading level, by what they sit under (3 under * a section's h2). In reading mode the names are one level under. */ headingLevel?: 3 | 4 | 5; + /** Just round photos and names in a row, as presented (095). */ + row?: boolean; + /** In the row, each one's role or title under their name. */ + titles?: boolean; /** How long a fetched team or person is reused, in ms. */ ttl?: number; emptyMessage?: string; @@ -195,8 +199,14 @@ export default function PeopleTiles({ ttl = 5 * 60_000, loadingMessage = "Loading…", errorMessage = "Couldn't load this list right now.", + row = false, + titles = false, ...view }: PeopleTilesProps) { + const View = useMemo( + () => (row ? (props) => : PeopleTilesView), + [row, titles], + ); const specs = useMemo(() => normalizeTeams(teams), [teams]); const teamKey = specs.map((spec) => spec.id).join(","); @@ -278,14 +288,14 @@ export default function PeopleTiles({ if (specs.length) { if (failed) return

{errorMessage}

; if (!teamGroups) return

{loadingMessage}

; - return ; + return ; } if (slugKey) { if (failed) return

{errorMessage}

; if (!directory) return

{loadingMessage}

; return ( - ({ ...group, @@ -297,7 +307,7 @@ export default function PeopleTiles({ } return ( - group.people), ...(people ?? [])]; + return ( +
    + {everyone.map((person, i) => ( +
  • + + + + {person.name} + {titles && person.title && {person.title}} +
  • + ))} +
+ ); +} + function Photo({ src, name }: { src?: string | null; name: string }) { const img = useSmallImage(src); diff --git a/src/components/ScheduleBlock.tsx b/src/components/ScheduleBlock.tsx index ef7a5a2..daa5406 100644 --- a/src/components/ScheduleBlock.tsx +++ b/src/components/ScheduleBlock.tsx @@ -28,12 +28,18 @@ Tags (087) are the block's own: an entry or sub-item shows its tags as chips, and each tag (unless it's set No tab) is a tab - after the days, gathering what it's on from every day under the - day's name. A tagged entry comes whole; an untagged block comes + in a row of its own under the days, with a note saying what it + does, gathering what it's on from every day under the day's name. A tagged entry comes whole; an untagged block comes with only its tagged sub-items. A tag on nothing draws no tab. - On an event page a Present button opens the schedule as a - slideshow for a screen (SchedulePresent.tsx). + An entry's place on the block's venue (088) links to the map + block on the same page, the location lit up there (MapBlock); + with no map of that venue on the page it's plain text. An entry + that is an event (a workshop) has already taken what it left + blank from it (shape.js). + + The event page's Present button shows it, with the rest of the + page, as a slideshow for a screen (EventPresent.tsx). Tabs follow the ARIA tab pattern: arrow keys move between them. @@ -42,9 +48,9 @@ it, no map frame (ReadingSchedule). ═══════════════════════════════════════════════════════════════ */ -import { CaretDown, Presentation, Star } from '@phosphor-icons/react' +import { CaretDown, MapPin, Star, Tag as TagIcon } from '@phosphor-icons/react' import { Fragment, createContext, useContext, useId, useState, type KeyboardEvent, type ReactNode } from 'react' -import { Link } from 'react-router-dom' +import { Link, useLocation } from 'react-router-dom' import { personHref } from '../lib/hrefs.ts' import { mediaUrl, initials } from '../lib/media.ts' @@ -54,6 +60,7 @@ import { withAlpha, accentText, readableOn } from '../lib/color.ts' import { useSmallImage } from '../lib/useSmallImage.ts' import { focusOnMount } from '../lib/focus.ts' import { useReadingMode } from '../lib/readingMode.ts' +import { PageMaps, mapAnchor } from './MapBlock.tsx' const BODY = 'var(--color-muted)' const WEEKDAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'] @@ -136,6 +143,26 @@ function todayIndex(days: Day[]): number { return found >= 0 ? found : 0 } +/* An entry's location, linked to its place on a map block on the + page when there is one (088). */ +function Place({ entry, accent }: { entry: ContentBlockItem; accent: string }) { + const maps = useContext(PageMaps) + const { search } = useLocation() + if (!entry.location) return null + if (!entry.place || !maps.has(mapAnchor(entry.place.venue_id, entry.place.key))) return {entry.location} + return ( + +