v1.14.2-present: event schedules, venues and map blocks, Present mode and its phone remote #33
58 changed files with 5945 additions and 809 deletions
|
|
@ -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/<id>` (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/<code>` 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`.
|
||||
|
|
|
|||
12
docs/seo.md
12
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
|
||||
|
|
|
|||
|
|
@ -181,7 +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 → 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 |
|
||||
|
|
@ -271,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 `<html>` 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-<family>-<shade>)` (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 `<html>` 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-<family>-<shade>)` (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` | |
|
||||
|
|
|
|||
|
|
@ -494,6 +494,8 @@ function isBlankChildRow(child, raw) {
|
|||
if (!raw || typeof raw !== "object") return true;
|
||||
|
||||
for (const column of child.columns) {
|
||||
// A value the admin seeds every new row with (`seeded`), not input.
|
||||
if (column.seeded) continue;
|
||||
const value = raw[column.name];
|
||||
if (value === undefined || value === null || value === "") continue;
|
||||
// An unchecked box is the default state of a new row, not input.
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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: [
|
||||
{
|
||||
|
|
@ -191,7 +215,76 @@ export const blocksChild = (ownerKind) => ({
|
|||
text("media_alt"),
|
||||
text("map"),
|
||||
text("map_image"),
|
||||
// Its kind, picked times and Featured tick (086).
|
||||
enumeration("kind", ["block", "break", "heading"]),
|
||||
time("start_time"),
|
||||
time("end_time"),
|
||||
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: [
|
||||
{
|
||||
// A block entry's sub-items (086).
|
||||
key: "items",
|
||||
table: "content_block_subitems",
|
||||
owner: { column: "item_id" },
|
||||
order: "sort_order",
|
||||
when: { column: "kind", value: "block" },
|
||||
columns: [
|
||||
text("text", { required: true }),
|
||||
text("detail"),
|
||||
url("url"),
|
||||
time("start_time"),
|
||||
time("end_time"),
|
||||
text("time"),
|
||||
text("location"),
|
||||
text("person_id"),
|
||||
text("description"),
|
||||
text("media"),
|
||||
text("media_alt"),
|
||||
text("map"),
|
||||
text("map_image"),
|
||||
bool("featured"),
|
||||
text("tags"),
|
||||
text("event_id"),
|
||||
text("location_key"),
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
// A schedule's own tags (087).
|
||||
key: "tags",
|
||||
table: "content_block_tags",
|
||||
owner: { column: "block_id" },
|
||||
order: "sort_order",
|
||||
when: { column: "type", value: "schedule" },
|
||||
columns: [
|
||||
// Made by the admin as the row is added, so it isn't input.
|
||||
text("tag_key", { required: true, seeded: true }),
|
||||
text("name", { required: true }),
|
||||
text("color"),
|
||||
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")],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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. */
|
||||
|
|
|
|||
47
server/src/admin-schema/venues.js
Normal file
47
server/src/admin-schema/venues.js
Normal file
|
|
@ -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"),
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
@ -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.
|
||||
|
|
|
|||
47
server/src/migrations/086_schedule_entry_types.sql
Normal file
47
server/src/migrations/086_schedule_entry_types.sql
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 086 SCHEDULE ENTRY TYPES
|
||||
--
|
||||
-- A schedule entry gets a kind:
|
||||
-- null a normal entry
|
||||
-- block a time frame holding several things, its sub-items
|
||||
-- (content_block_subitems below), each with its own time
|
||||
-- break a meal or free time: a quieter row, no spotlight slide
|
||||
-- heading a label across the day, eg. Evening sessions
|
||||
-- and `featured`, which makes the row stand out.
|
||||
--
|
||||
-- Times are picked (start_time, end_time, HH:MM 24-hour) and shown
|
||||
-- as 7:00pm or 9:00 to 10:30am (shape.js). The old typed `time`
|
||||
-- stays as the override: when it's filled it shows instead, so the
|
||||
-- entries typed before this look the same.
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
|
||||
ALTER TABLE content_block_items ADD COLUMN kind TEXT
|
||||
CHECK (kind IN ('block', 'break', 'heading'));
|
||||
ALTER TABLE content_block_items ADD COLUMN start_time TEXT;
|
||||
ALTER TABLE content_block_items ADD COLUMN end_time TEXT;
|
||||
ALTER TABLE content_block_items ADD COLUMN featured INTEGER NOT NULL DEFAULT 0
|
||||
CHECK (featured IN (0, 1));
|
||||
|
||||
-- A block entry's sub-items: every field an entry has but day and
|
||||
-- kind (they're under their block's day, and don't nest further).
|
||||
CREATE TABLE content_block_subitems (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
item_id INTEGER NOT NULL REFERENCES content_block_items (id) ON DELETE CASCADE,
|
||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||
text TEXT NOT NULL,
|
||||
detail TEXT,
|
||||
url TEXT,
|
||||
start_time TEXT,
|
||||
end_time TEXT,
|
||||
time TEXT, -- the override, as on an entry
|
||||
location TEXT,
|
||||
person_id TEXT REFERENCES people (id) ON DELETE SET NULL,
|
||||
description TEXT,
|
||||
media TEXT,
|
||||
media_alt TEXT,
|
||||
map TEXT,
|
||||
map_image TEXT,
|
||||
featured INTEGER NOT NULL DEFAULT 0 CHECK (featured IN (0, 1))
|
||||
) STRICT;
|
||||
CREATE INDEX content_block_subitems_item_idx
|
||||
ON content_block_subitems (item_id, sort_order);
|
||||
28
server/src/migrations/087_schedule_tags.sql
Normal file
28
server/src/migrations/087_schedule_tags.sql
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 087 SCHEDULE TAGS
|
||||
--
|
||||
-- A schedule block's own tags, eg. Youth or Worship: entries and
|
||||
-- sub-items are tagged with them, a tag can be a tab of its own
|
||||
-- gathering every entry it's on (across the days), and the schedule
|
||||
-- presentation can show only one tag's entries and a slide per tag.
|
||||
--
|
||||
-- These are the block's, not Data → Tags (070). The block's rows are
|
||||
-- rewritten on every save, so entries name a tag by `tag_key` (made
|
||||
-- in the admin when the tag is added, kept when it's renamed), not
|
||||
-- by its row id. An entry's `tags` is its keys, comma-separated; a
|
||||
-- key no tag has any more is skipped.
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
|
||||
CREATE TABLE content_block_tags (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
block_id INTEGER NOT NULL REFERENCES content_blocks (id) ON DELETE CASCADE,
|
||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||
tag_key TEXT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
color TEXT, -- null: the event's accent
|
||||
no_tab INTEGER NOT NULL DEFAULT 0 CHECK (no_tab IN (0, 1)),
|
||||
UNIQUE (block_id, tag_key)
|
||||
) STRICT;
|
||||
|
||||
ALTER TABLE content_block_items ADD COLUMN tags TEXT;
|
||||
ALTER TABLE content_block_subitems ADD COLUMN tags TEXT;
|
||||
125
server/src/migrations/088_venues.sql
Normal file
125
server/src/migrations/088_venues.sql
Normal file
|
|
@ -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;
|
||||
14
server/src/migrations/089_event_page_options.sql
Normal file
14
server/src/migrations/089_event_page_options.sql
Normal file
|
|
@ -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;
|
||||
15
server/src/migrations/090_featured_event_items.sql
Normal file
15
server/src/migrations/090_featured_event_items.sql
Normal file
|
|
@ -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;
|
||||
10
server/src/migrations/091_location_map_links.sql
Normal file
10
server/src/migrations/091_location_map_links.sql
Normal file
|
|
@ -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;
|
||||
13
server/src/migrations/092_list_style.sql
Normal file
13
server/src/migrations/092_list_style.sql
Normal file
|
|
@ -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'));
|
||||
91
server/src/migrations/093_organizations_block.sql
Normal file
91
server/src/migrations/093_organizations_block.sql
Normal file
|
|
@ -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;
|
||||
27
server/src/migrations/094_map_sections.sql
Normal file
27
server/src/migrations/094_map_sections.sql
Normal file
|
|
@ -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);
|
||||
56
server/src/migrations/095_presentation.sql
Normal file
56
server/src/migrations/095_presentation.sql
Normal file
|
|
@ -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;
|
||||
24
server/src/migrations/096_presentation_dark.sql
Normal file
24
server/src/migrations/096_presentation_dark.sql
Normal file
|
|
@ -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;
|
||||
20
server/src/migrations/097_presentation_inset.sql
Normal file
20
server/src/migrations/097_presentation_inset.sql
Normal file
|
|
@ -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);
|
||||
18
server/src/migrations/098_present_list.sql
Normal file
18
server/src/migrations/098_present_list.sql
Normal file
|
|
@ -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));
|
||||
20
server/src/migrations/099_present_show.sql
Normal file
20
server/src/migrations/099_present_show.sql
Normal file
|
|
@ -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;
|
||||
10
server/src/migrations/100_present_list_picked.sql
Normal file
10
server/src/migrations/100_present_list_picked.sql
Normal file
|
|
@ -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;
|
||||
15
server/src/migrations/101_image_size.sql
Normal file
15
server/src/migrations/101_image_size.sql
Normal file
|
|
@ -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'));
|
||||
13
server/src/migrations/102_image_dark.sql
Normal file
13
server/src/migrations/102_image_dark.sql
Normal file
|
|
@ -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;
|
||||
|
|
@ -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$/);
|
||||
|
|
|
|||
|
|
@ -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 });
|
||||
|
|
|
|||
151
server/src/routes/present.js
Normal file
151
server/src/routes/present.js
Normal file
|
|
@ -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;
|
||||
|
|
@ -79,24 +79,40 @@ 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 ───────────────────────────────────────────────── */
|
||||
|
||||
/* A schedule over three days, using every entry field: a plain
|
||||
entry, one with a location and person, one folding out with a
|
||||
description, graphic and map, one linked, and one with no day
|
||||
(it lands in a tab of its own). */
|
||||
/* A schedule over three days, using every entry field and kind: a
|
||||
plain entry, one with a location and person, one folding out with
|
||||
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). 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", time: "4:00pm", text: "Arrivals and check-in", location: "Front desk" },
|
||||
{ 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: "Saturday", time: "9:00am", text: "Workshops", location: "Classrooms", person_id: "showcase-member-2", detail: "Pick one of three", url: "/blog/content-block-showcase" },
|
||||
{ day: "Saturday", time: "7:00pm", text: "Talent night", location: "Main Hall", person_id: "showcase-member-3", description: "Sign up at the front desk by noon." },
|
||||
{ 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_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", 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", 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" },
|
||||
],
|
||||
[
|
||||
{ tag_key: "showcase-youth", name: "Youth", color: "#00748a" },
|
||||
{ tag_key: "showcase-all", name: "Everyone", no_tab: 1 },
|
||||
],
|
||||
];
|
||||
|
||||
/* Every block type, for the blog showcase. [type, fields, items?] */
|
||||
|
|
@ -129,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" }],
|
||||
|
|
@ -201,7 +224,7 @@ function insert(table, row) {
|
|||
}
|
||||
|
||||
function blocks(ownerKind, ownerId, slot, list) {
|
||||
list.forEach(([type, f, items = []], order) => {
|
||||
list.forEach(([type, f, items = [], tags = []], order) => {
|
||||
const { lastInsertRowid } = insert("content_blocks", {
|
||||
owner_kind: ownerKind,
|
||||
owner_id: ownerId,
|
||||
|
|
@ -210,7 +233,11 @@ function blocks(ownerKind, ownerId, slot, list) {
|
|||
type,
|
||||
...f,
|
||||
});
|
||||
items.forEach((item, i) => insert("content_block_items", { block_id: lastInsertRowid, sort_order: i, ...item }));
|
||||
items.forEach(({ items: subitems = [], ...item }, i) => {
|
||||
const entry = insert("content_block_items", { block_id: lastInsertRowid, sort_order: i, ...item });
|
||||
subitems.forEach((sub, j) => insert("content_block_subitems", { item_id: entry.lastInsertRowid, sort_order: j, ...sub }));
|
||||
});
|
||||
tags.forEach((tag, i) => insert("content_block_tags", { block_id: lastInsertRowid, sort_order: i, ...tag }));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -239,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();
|
||||
|
|
@ -396,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,
|
||||
|
|
@ -442,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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
@ -107,12 +132,15 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
|
|||
|
||||
const blockIds = [...byId.keys()];
|
||||
|
||||
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.block_id, i.text, i.detail, i.url,
|
||||
i.day, i.time, i.location, i.description, i.media, i.media_alt, i.map, i.map_image,
|
||||
p.id AS person_id, p.display_name AS person_name,
|
||||
p.photo AS person_photo, p.tagline AS person_tagline
|
||||
`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)})
|
||||
|
|
@ -122,20 +150,223 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
|
|||
|
||||
// The schedule fields are null on a list or link-row item; they
|
||||
// ride along anyway rather than branching on the block's type.
|
||||
// An unpublished person comes back as no person.
|
||||
const itemsById = new Map();
|
||||
for (const row of itemRows) {
|
||||
byId.get(row.block_id)?.items.push({
|
||||
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);
|
||||
}
|
||||
|
||||
// A block entry's sub-items (086).
|
||||
const blockEntryIds = itemRows.filter((row) => row.kind === "block").map((row) => row.id);
|
||||
if (blockEntryIds.length) {
|
||||
const subRows = db
|
||||
.prepare(
|
||||
`SELECT i.item_id, ${ENTRY_FIELDS}
|
||||
FROM content_block_subitems i
|
||||
LEFT JOIN v_people_public p ON p.id = i.person_id AND p.is_published = 1
|
||||
WHERE i.item_id IN (${placeholders(blockEntryIds.length)})
|
||||
ORDER BY i.item_id, i.sort_order`,
|
||||
)
|
||||
.all(...blockEntryIds);
|
||||
for (const row of subRows) itemsById.get(row.item_id)?.items.push(scheduleEntry(row));
|
||||
}
|
||||
|
||||
// A schedule's own tags (087), and each entry's cut to the ones
|
||||
// the block still has.
|
||||
const tagRows = db
|
||||
.prepare(
|
||||
`SELECT block_id, tag_key, name, color, no_tab
|
||||
FROM content_block_tags
|
||||
WHERE block_id IN (${placeholders(blockIds.length)})
|
||||
ORDER BY block_id, sort_order`,
|
||||
)
|
||||
.all(...blockIds);
|
||||
for (const row of tagRows) {
|
||||
const block = byId.get(row.block_id);
|
||||
if (!block) continue;
|
||||
block.tags ??= [];
|
||||
block.tags.push({ key: row.tag_key, name: row.name, color: row.color, tab: row.no_tab === 0 });
|
||||
}
|
||||
for (const block of byId.values()) {
|
||||
if (block.type !== "schedule") continue;
|
||||
const known = new Set((block.tags ??= []).map((tag) => tag.key));
|
||||
const cut = (entry) => {
|
||||
entry.tags = entry.tags.filter((key) => known.has(key));
|
||||
entry.items?.forEach(cut);
|
||||
};
|
||||
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. */
|
||||
function scheduleEntry(row) {
|
||||
return {
|
||||
text: row.text,
|
||||
detail: row.detail,
|
||||
url: row.url,
|
||||
day: row.day,
|
||||
time: row.time,
|
||||
time: row.time || clockRange(row.start_time, row.end_time),
|
||||
start_time: row.start_time,
|
||||
end_time: row.end_time,
|
||||
location: row.location,
|
||||
description: row.description,
|
||||
media: row.media,
|
||||
media_alt: row.media_alt,
|
||||
map: row.map,
|
||||
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,
|
||||
|
|
@ -144,10 +375,21 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
|
|||
tagline: row.person_tagline,
|
||||
}
|
||||
: null,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
return out;
|
||||
/* "19:00" → 7:00pm, and a range as 9:00 to 10:30am, or 11:30am to
|
||||
1:00pm when it crosses noon. */
|
||||
export function clockRange(start, end) {
|
||||
if (!start) return null;
|
||||
const clock = (hhmm) => {
|
||||
const [h, m] = hhmm.split(":").map(Number);
|
||||
return { text: `${h % 12 || 12}:${String(m).padStart(2, "0")}`, half: h < 12 ? "am" : "pm" };
|
||||
};
|
||||
const from = clock(start);
|
||||
if (!end) return from.text + from.half;
|
||||
const to = clock(end);
|
||||
return `${from.text}${from.half === to.half ? "" : from.half} to ${to.text}${to.half}`;
|
||||
}
|
||||
|
||||
/* ── Card description ──────────────────────────────────────────
|
||||
|
|
|
|||
16
src/App.tsx
16
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). */}
|
||||
<Route path="*" element={<PageAtPath />} />
|
||||
</Route>
|
||||
{/* 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. */}
|
||||
<Route
|
||||
path="/events/:id/present"
|
||||
element={
|
||||
<Suspense fallback={null}>
|
||||
<SchedulePresent />
|
||||
<EventPresent />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
{/* A phone driving a presenting screen, by its code. */}
|
||||
<Route
|
||||
path="/remote/:code?"
|
||||
element={
|
||||
<Suspense fallback={null}>
|
||||
<PresentRemote />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -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=<n>` 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 (
|
||||
<PageMaps.Provider value={maps}>
|
||||
<div className={`space-y-6 ${className}`}>
|
||||
{blocks.map((block, index) => (
|
||||
<WordMotion key={block.id ?? index} settings={block.words}>
|
||||
|
|
@ -103,11 +139,11 @@ export default function ContentBlocks({
|
|||
accent={accent}
|
||||
anchor={idAt.get(index)}
|
||||
level={levels[index]}
|
||||
presentHref={presentHrefs[index]}
|
||||
/>
|
||||
</WordMotion>
|
||||
))}
|
||||
</div>
|
||||
</PageMaps.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -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 (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onToggle}
|
||||
aria-expanded={open}
|
||||
aria-controls={panelId}
|
||||
className="group flex h-full w-full flex-col overflow-hidden border bg-raised text-left shadow-sm transition-shadow hover:shadow-lg"
|
||||
style={{
|
||||
borderColor: open ? accent : 'color-mix(in srgb, var(--color-brand) 15%, transparent)',
|
||||
boxShadow: open ? `inset 0 -4px 0 ${accent}` : undefined,
|
||||
}}
|
||||
>
|
||||
{!img.failed && (
|
||||
<img src={img.src} alt="" loading="lazy" onError={img.onError} className="aspect-video w-full object-cover" />
|
||||
)}
|
||||
<span className="flex flex-1 flex-col gap-1 p-4">
|
||||
{line && (
|
||||
<span className="text-xs font-semibold capitalize" style={{ color: accentText(color) }}>
|
||||
{line}
|
||||
</span>
|
||||
)}
|
||||
<span className="font-display text-base font-bold leading-snug text-ink group-hover:text-link">
|
||||
{item.text || event.title}
|
||||
</span>
|
||||
{(item.detail || event.blurb) && (
|
||||
<span className="line-clamp-3 text-sm leading-snug text-body">{item.detail || event.blurb}</span>
|
||||
)}
|
||||
<span className="mt-auto inline-flex items-center gap-1 pt-2 text-sm font-semibold" style={{ color: accentText(color) }}>
|
||||
{open ? 'Close' : 'More'}
|
||||
<CaretDown aria-hidden="true" weight="bold" className={`h-4 w-4 transition-transform ${open ? 'rotate-180' : ''}`} />
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
/* 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 (
|
||||
<section aria-label={item.text || event.title} className="space-y-6 bg-raised p-6 shadow-md">
|
||||
{photo && <img src={photo} alt={event.photo_alt ?? ''} loading="lazy" className="aspect-video w-full object-cover" />}
|
||||
<div>
|
||||
{line && (
|
||||
<p className="text-sm font-semibold capitalize" style={{ color: accentText(color) }}>
|
||||
{line}
|
||||
</p>
|
||||
)}
|
||||
<Title className="text-2xl font-bold text-ink">{item.text || event.title}</Title>
|
||||
{(event.location_label || item.person) && (
|
||||
<p className="mt-2 flex flex-wrap items-center gap-x-4 gap-y-2 text-sm text-muted">
|
||||
{event.location_label && <span>{event.location_label}</span>}
|
||||
{item.person && (
|
||||
<Link to={personHref(item.person.id)} className="inline-flex items-center gap-2 hover:underline">
|
||||
<Avatar person={item.person} size="h-8 w-8" />
|
||||
{item.person.name}
|
||||
</Link>
|
||||
)}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
{event.blocks?.length ? (
|
||||
<ContentBlocks blocks={event.blocks} accent={color} anchorPrefix={`${event.id}-`} />
|
||||
) : blurb ? (
|
||||
<div className="space-y-3 leading-relaxed" style={{ color: BODY }}>
|
||||
<Paragraphs text={blurb} accent={color} />
|
||||
</div>
|
||||
) : null}
|
||||
<Anchor href={eventHref(event.id)} className="inline-block text-sm font-semibold underline" style={{ color: accentText(color) }}>
|
||||
{event.title}: the event's page
|
||||
</Anchor>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
/* 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<number | null>(null)
|
||||
const panelId = useId()
|
||||
const panel = useRef<HTMLDivElement>(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 (
|
||||
<div className="space-y-6">
|
||||
{featured.map((item, i) => (
|
||||
<FeaturedEvent key={i} item={item} accent={accent} level={level} />
|
||||
))}
|
||||
{cards.length > 0 && (
|
||||
<>
|
||||
<ul className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{cards.map((item, i) => (
|
||||
<li key={i}>
|
||||
<EventCard
|
||||
item={item}
|
||||
accent={accent}
|
||||
open={open === i}
|
||||
panelId={panelId}
|
||||
onToggle={() => setOpen(open === i ? null : i)}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<div ref={panel} id={panelId}>
|
||||
{open != null && cards[open] && <EventInFull item={cards[open]} accent={accent} level={level} />}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/* 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 <EventInFull item={item} accent={accent} level={level} />
|
||||
const Heading = `h${level}` as 'h3'
|
||||
const color = item.event?.color || accent
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
{item.heading && (
|
||||
<Heading className="text-2xl font-bold" style={{ color: accentText(color) }}>
|
||||
{item.heading}
|
||||
</Heading>
|
||||
)}
|
||||
{item.subheading && <p className="mt-1 text-lg text-body">{item.subheading}</p>}
|
||||
</div>
|
||||
<EventInFull item={item} accent={accent} level={item.heading ? (Math.min(level + 1, 5) as 3 | 4 | 5) : level} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/* 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({
|
|||
</h4>
|
||||
)
|
||||
|
||||
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 (
|
||||
<ul className="space-y-2">
|
||||
{(block.items ?? []).map((item, index) => (
|
||||
|
|
@ -212,20 +430,23 @@ function Block({
|
|||
<span aria-hidden="true" style={{ color: accentText(accent) }}>
|
||||
•
|
||||
</span>
|
||||
<span style={{ color: BODY }}>
|
||||
{item.url ? (
|
||||
<span style={{ color: plain ? BODY : 'var(--color-body)' }}>
|
||||
<span className={plain ? undefined : 'font-bold'}>
|
||||
{item.url && !presenting ? (
|
||||
<Anchor href={item.url} className="underline" style={{ color: accentText(accent) }}>
|
||||
{item.text}
|
||||
</Anchor>
|
||||
) : (
|
||||
<Inline text={item.text} accent={accent} />
|
||||
)}
|
||||
{item.detail && <span className="opacity-70">: {item.detail}</span>}
|
||||
</span>
|
||||
{item.detail && <span className={plain ? 'opacity-70' : undefined}>: {item.detail}</span>}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
|
||||
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 (
|
||||
<figure>
|
||||
<figure className={block.image_size ? `mx-auto ${IMAGE_SIZE[block.image_size]}` : undefined}>
|
||||
{block.href ? <Anchor href={block.href}>{img}</Anchor> : img}
|
||||
<Caption text={text} />
|
||||
</figure>
|
||||
|
|
@ -385,7 +606,41 @@ function Block({
|
|||
|
||||
case 'schedule':
|
||||
if (!block.items?.length) return null
|
||||
return <ScheduleBlock items={block.items} intro={block.text} accent={accent} presentHref={presentHref} />
|
||||
return (
|
||||
<ScheduleBlock
|
||||
items={block.items}
|
||||
tags={block.tags}
|
||||
intro={block.text}
|
||||
accent={accent}
|
||||
/>
|
||||
)
|
||||
|
||||
case 'map':
|
||||
if (!block.venue) return null
|
||||
return <MapBlock venue={block.venue} sections={block.map_sections} accent={accent} />
|
||||
|
||||
case 'events': {
|
||||
const events = (block.items ?? []).filter((item) => item.event)
|
||||
if (events.length === 0) return null
|
||||
return <EventsBlock items={events} accent={accent} level={level} />
|
||||
}
|
||||
|
||||
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 <OrgLogoRow kind={block.org_kind} ids={ids} accent={accent} />
|
||||
return (
|
||||
<OrgListCards
|
||||
kind={block.org_kind}
|
||||
ids={ids}
|
||||
accent={accent}
|
||||
pageLabel="Their page"
|
||||
empty="Organizations coming soon."
|
||||
nested
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
case 'people': {
|
||||
const picked = (block.items ?? [])
|
||||
|
|
@ -394,8 +649,8 @@ function Block({
|
|||
if (!block.team_id && picked.length === 0) return null
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{block.team_id && <PeopleTiles size="lg" teams={block.team_id} accent={accent} headingLevel={level} />}
|
||||
{picked.length > 0 && <PeopleTiles size="lg" people={picked} accent={accent} headingLevel={level} />}
|
||||
{block.team_id && <PeopleTiles size="lg" teams={block.team_id} accent={accent} headingLevel={level} row={presenting} titles={block.present?.titles} />}
|
||||
{picked.length > 0 && <PeopleTiles size="lg" people={picked} accent={accent} headingLevel={level} row={presenting} titles={block.present?.titles} />}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
@ -406,7 +661,7 @@ function Block({
|
|||
case 'paragraph':
|
||||
default:
|
||||
if (!text) return null
|
||||
return block.href ? (
|
||||
return block.href && !presenting ? (
|
||||
<p className="leading-relaxed" style={{ color: BODY }}>
|
||||
<Anchor href={block.href} className="underline" style={{ color: accentText(accent) }}>
|
||||
{text}
|
||||
|
|
|
|||
|
|
@ -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(<RotatingWords key={k} words={words.split('|').map((word) => word.trim())} />)
|
||||
else if (bold != null) out.push(<strong key={k} className="font-semibold">{bold}</strong>)
|
||||
else if (italic != null) out.push(<em key={k}>{italic}</em>)
|
||||
else if (label != null && plain) out.push(label)
|
||||
else if (label != null && SAFE_URL.test(url)) {
|
||||
out.push(
|
||||
<Anchor key={k} href={url} className="underline underline-offset-2" style={{ color: accentText(accent) }}>
|
||||
|
|
@ -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) => (
|
||||
<Fragment key={i}>
|
||||
{i > 0 && <br />}
|
||||
{line(part, accent, `l${i}`)}
|
||||
{line(part, accent, `l${i}`, plain)}
|
||||
</Fragment>
|
||||
))}
|
||||
</>
|
||||
|
|
|
|||
372
src/components/MapBlock.tsx
Normal file
372
src/components/MapBlock.tsx
Normal file
|
|
@ -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-<venue>-<key>,
|
||||
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<Set<string>>(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 (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={`flex shrink-0 items-center justify-center rounded-full font-bold ${className}`}
|
||||
style={{ background: accent, color: readableOn(accent.startsWith('#') ? accent : '#000000'), ...style }}
|
||||
>
|
||||
{n}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
/* 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<string>
|
||||
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 (
|
||||
<div className={`relative ${className}`}>
|
||||
<img src={image} alt={venue.map_alt || `Map of ${venue.name}`} className="block w-full" />
|
||||
{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 = (
|
||||
<>
|
||||
<LocationNumber
|
||||
n={locationNumber(venue, location)}
|
||||
accent={accent}
|
||||
className={`shadow ${dot}`}
|
||||
style={on ? { outline: `${big ? 4 : 3}px solid white` } : undefined}
|
||||
/>
|
||||
{on && !big && (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="absolute top-full left-1/2 mt-1 -translate-x-1/2 whitespace-nowrap bg-raised px-2 py-0.5 text-xs font-semibold text-ink shadow"
|
||||
>
|
||||
{location.name}
|
||||
</span>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
return link ? (
|
||||
<Link
|
||||
key={location.key}
|
||||
to={link(location.key)}
|
||||
aria-label={location.name}
|
||||
{...light?.(location.key)}
|
||||
className="absolute transition-opacity"
|
||||
style={style}
|
||||
>
|
||||
{inside}
|
||||
</Link>
|
||||
) : (
|
||||
<span key={location.key} aria-hidden="true" className="absolute transition-opacity duration-500" style={style}>
|
||||
{inside}
|
||||
</span>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default function MapBlock({
|
||||
venue,
|
||||
sections = [],
|
||||
accent,
|
||||
}: {
|
||||
venue: Venue
|
||||
sections?: MapSection[]
|
||||
accent: string
|
||||
}) {
|
||||
const { hash, search } = useLocation()
|
||||
const [hovered, setHovered] = useState<string | null>(null)
|
||||
const [zoom, setZoom] = useState(0)
|
||||
// The section in view, by index; null is All.
|
||||
const [view, setView] = useState<number | null>(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 (
|
||||
<figure className="relative grid gap-6 md:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]">
|
||||
{/* Where a link to a location lands: the map's top. */}
|
||||
{venue.locations.map((location) => (
|
||||
<span key={location.key} id={mapAnchor(venue.id, location.key)} className="absolute top-0 left-0" />
|
||||
))}
|
||||
|
||||
{picture && (
|
||||
<div className="relative self-start">
|
||||
<div className="max-h-[80vh] overflow-auto border border-brand/15">
|
||||
<div style={{ width: `${ZOOMS[zoom] * 100}%` }}>
|
||||
<MapPicture venue={venue} accent={accent} active={active} link={to} light={light} only={only} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="absolute top-2 right-2 flex gap-1">
|
||||
<ZoomButton label="Zoom in" disabled={zoom === ZOOMS.length - 1} onClick={() => setZoom(zoom + 1)}>
|
||||
<MagnifyingGlassPlus weight="bold" className="h-5 w-5" />
|
||||
</ZoomButton>
|
||||
<ZoomButton label="Zoom out" disabled={zoom === 0} onClick={() => setZoom(zoom - 1)}>
|
||||
<MagnifyingGlassMinus weight="bold" className="h-5 w-5" />
|
||||
</ZoomButton>
|
||||
{zoom > 0 && (
|
||||
<ZoomButton label="Fit the map" onClick={() => setZoom(0)}>
|
||||
<ArrowsIn weight="bold" className="h-5 w-5" />
|
||||
</ZoomButton>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<figcaption className={picture ? '' : 'md:col-span-2'}>
|
||||
<p className="font-display font-bold text-ink">{venue.name}</p>
|
||||
{venue.address && <p className="text-sm text-muted">{venue.address}</p>}
|
||||
{sections.length > 1 && (
|
||||
<div role="group" aria-label="Show" className="mt-3 flex flex-wrap gap-2">
|
||||
{[null, ...sections.map((_, i) => i)].map((i) => {
|
||||
const selected = view === i
|
||||
return (
|
||||
<button
|
||||
key={i ?? 'all'}
|
||||
type="button"
|
||||
aria-pressed={selected}
|
||||
onClick={() => setView(i)}
|
||||
className="btn border px-3 py-1 text-xs transition-colors"
|
||||
style={
|
||||
selected
|
||||
? { background: accent, borderColor: accent, color: readableOn(accent) }
|
||||
: { borderColor: withAlpha(accent, 33), color: accentText(accent) }
|
||||
}
|
||||
>
|
||||
{i == null ? 'All' : sections[i].name}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
{groups.map((group, g) => (
|
||||
<div key={group.name ?? g} className="mt-3">
|
||||
{group.name && <p className="px-2 text-sm font-bold text-ink">{group.name}</p>}
|
||||
<ol className="mt-1 space-y-1">
|
||||
{group.locations.map((location) => {
|
||||
const on = active === location.key
|
||||
const row = (
|
||||
<>
|
||||
<LocationNumber n={locationNumber(venue, location)} accent={accent} />
|
||||
<span className="min-w-0">
|
||||
<span className="block font-semibold" style={on ? { color: accentText(accent) } : undefined}>
|
||||
{location.name}
|
||||
</span>
|
||||
{location.detail && <span className="block text-sm text-muted">{location.detail}</span>}
|
||||
</span>
|
||||
</>
|
||||
)
|
||||
const rowClass = 'flex items-start gap-3 px-2 py-1.5 text-body'
|
||||
const rowStyle = on ? { background: withAlpha(accent, 12) } : undefined
|
||||
return (
|
||||
<li key={location.key} className="flex items-start gap-2">
|
||||
{isMarked(location) ? (
|
||||
<Link to={to(location.key)} {...light(location.key)} className={`${rowClass} flex-1`} style={rowStyle}>
|
||||
{row}
|
||||
</Link>
|
||||
) : (
|
||||
<div className={`${rowClass} flex-1`}>{row}</div>
|
||||
)}
|
||||
<MapLinks location={location} accent={accent} />
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ol>
|
||||
</div>
|
||||
))}
|
||||
</figcaption>
|
||||
</figure>
|
||||
)
|
||||
}
|
||||
|
||||
/* A zoom button over the map picture. */
|
||||
function ZoomButton({
|
||||
label,
|
||||
disabled,
|
||||
onClick,
|
||||
children,
|
||||
}: {
|
||||
label: string
|
||||
disabled?: boolean
|
||||
onClick: () => void
|
||||
children: ReactNode
|
||||
}) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
aria-label={label}
|
||||
title={label}
|
||||
disabled={disabled}
|
||||
onClick={onClick}
|
||||
className="btn flex h-9 w-9 items-center justify-center bg-raised text-ink shadow transition-colors hover:text-link disabled:opacity-40"
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
/* 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 (
|
||||
<span className="flex shrink-0 gap-1 py-1.5">
|
||||
{links.map(({ href, label, Icon }) => (
|
||||
<a
|
||||
key={label}
|
||||
href={href!}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
aria-label={`${location.name} in ${label} (opens in a new tab)`}
|
||||
title={label}
|
||||
className="btn flex h-8 w-8 items-center justify-center border transition-colors hover:bg-tint"
|
||||
style={{ borderColor: withAlpha(accent, 33), color: accentText(accent) }}
|
||||
>
|
||||
<Icon weight="bold" className="h-4 w-4" aria-hidden="true" />
|
||||
</a>
|
||||
))}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
|
@ -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) => <PeopleRow {...props} titles={titles} /> : 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 <p className="pl__empty">{errorMessage}</p>;
|
||||
if (!teamGroups) return <p className="pl__empty">{loadingMessage}</p>;
|
||||
return <PeopleTilesView {...view} groups={teamGroups} />;
|
||||
return <View {...view} groups={teamGroups} />;
|
||||
}
|
||||
|
||||
if (slugKey) {
|
||||
if (failed) return <p className="pl__empty">{errorMessage}</p>;
|
||||
if (!directory) return <p className="pl__empty">{loadingMessage}</p>;
|
||||
return (
|
||||
<PeopleTilesView
|
||||
<View
|
||||
{...view}
|
||||
groups={groups?.map((group) => ({
|
||||
...group,
|
||||
|
|
@ -297,7 +307,7 @@ export default function PeopleTiles({
|
|||
}
|
||||
|
||||
return (
|
||||
<PeopleTilesView
|
||||
<View
|
||||
{...view}
|
||||
groups={groups as PeopleGroup[] | undefined}
|
||||
people={people as Person[] | undefined}
|
||||
|
|
@ -768,6 +778,25 @@ function Tile({
|
|||
);
|
||||
}
|
||||
|
||||
/* Everyone in the groups, then the people, as round photos over
|
||||
their names, left to right: a people block presented (095). */
|
||||
function PeopleRow({ groups, people, titles = false }: { groups?: PeopleGroup[]; people?: Person[]; titles?: boolean }) {
|
||||
const everyone = [...(groups ?? []).flatMap((group) => group.people), ...(people ?? [])];
|
||||
return (
|
||||
<ul className="flex flex-wrap justify-center gap-6">
|
||||
{everyone.map((person, i) => (
|
||||
<li key={person.id ?? i} className="flex w-28 flex-col items-center text-center">
|
||||
<span className="block h-24 w-24 overflow-hidden rounded-full">
|
||||
<Photo src={mediaUrl(person.photo)} name={person.name} />
|
||||
</span>
|
||||
<span className="mt-2 text-sm font-semibold leading-tight text-ink">{person.name}</span>
|
||||
{titles && person.title && <span className="mt-0.5 text-xs leading-tight text-muted">{person.title}</span>}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
function Photo({ src, name }: { src?: string | null; name: string }) {
|
||||
const img = useSmallImage(src);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,28 @@
|
|||
the place typed in, with a link out to the full map; an entry's
|
||||
own map image (069) shows instead, the link out kept.
|
||||
|
||||
On an event page a Present button opens the schedule as a
|
||||
slideshow for a screen (SchedulePresent.tsx).
|
||||
An entry's kind (086): a normal entry; a block, its sub-items
|
||||
listed under it, each a row of its own with its own fold-out; a
|
||||
break (a meal, free time), a quieter row with no fold-out; or a
|
||||
heading across the day. A featured entry stands out in the
|
||||
accent, with a star. Rows alternate a faint tint, for reading
|
||||
across. The time shown is `time`, which the API has already made
|
||||
from the picked times or the typed override.
|
||||
|
||||
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
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
|
|
@ -28,18 +48,19 @@
|
|||
it, no map frame (ReadingSchedule).
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { CaretDown, Presentation } from '@phosphor-icons/react'
|
||||
import { Fragment, useId, useState, type KeyboardEvent, type ReactNode } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
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, useLocation } from 'react-router-dom'
|
||||
|
||||
import { personHref } from '../lib/hrefs.ts'
|
||||
import { mediaUrl, initials } from '../lib/media.ts'
|
||||
import type { ContentBlockItem } from '../lib/useContent.ts'
|
||||
import type { ContentBlockItem, ScheduleTag } from '../lib/useContent.ts'
|
||||
import { Anchor, Paragraphs } from './InlineText.tsx'
|
||||
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']
|
||||
|
|
@ -60,6 +81,57 @@ export function groupByDay(items: ContentBlockItem[]): Day[] {
|
|||
return days
|
||||
}
|
||||
|
||||
/* What a tag is on (087): a tagged entry whole, and an untagged
|
||||
block with only its tagged sub-items. */
|
||||
export function withTag(entries: ContentBlockItem[], key: string): ContentBlockItem[] {
|
||||
return entries.flatMap((entry) => {
|
||||
if (entry.tags?.includes(key)) return [entry]
|
||||
if (entry.kind !== 'block') return []
|
||||
const items = (entry.items ?? []).filter((item) => item.tags?.includes(key))
|
||||
return items.length ? [{ ...entry, items }] : []
|
||||
})
|
||||
}
|
||||
|
||||
/* The days, each cut to what a tag is on, empty ones dropped. */
|
||||
export const daysWithTag = (days: Day[], key: string): Day[] =>
|
||||
days.map((day) => ({ name: day.name, entries: withTag(day.entries, key) })).filter((day) => day.entries.length)
|
||||
|
||||
/* The schedule's tags, for its rows' chips. */
|
||||
export const ScheduleTags = createContext<ScheduleTag[]>([])
|
||||
|
||||
/* An entry's tags as chips, each in its tag's color (else the
|
||||
accent). `className` sizes them. */
|
||||
export function TagChips({
|
||||
keys,
|
||||
tags,
|
||||
accent,
|
||||
className = 'px-2 py-0.5 text-xs',
|
||||
}: {
|
||||
keys?: string[]
|
||||
tags: ScheduleTag[]
|
||||
accent: string
|
||||
className?: string
|
||||
}) {
|
||||
const shown = tags.filter((tag) => keys?.includes(tag.key))
|
||||
if (shown.length === 0) return null
|
||||
return (
|
||||
<span className="inline-flex flex-wrap gap-1.5">
|
||||
{shown.map((tag) => {
|
||||
const color = tag.color || accent
|
||||
return (
|
||||
<span
|
||||
key={tag.key}
|
||||
className={`font-semibold ${className}`}
|
||||
style={{ background: withAlpha(color, 14), color: accentText(color) }}
|
||||
>
|
||||
{tag.name}
|
||||
</span>
|
||||
)
|
||||
})}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
/* The tab to open with: today's weekday if a tab starts with it (or
|
||||
its three-letter form), else the first. */
|
||||
function todayIndex(days: Day[]): number {
|
||||
|
|
@ -71,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 <span>{entry.location}</span>
|
||||
return (
|
||||
<Link
|
||||
to={{ search, hash: mapAnchor(entry.place.venue_id, entry.place.key) }}
|
||||
className="inline-flex items-center gap-1 underline-offset-2 hover:underline"
|
||||
style={{ color: accentText(accent) }}
|
||||
>
|
||||
<MapPin aria-hidden="true" weight="bold" className="h-4 w-4 shrink-0" />
|
||||
{entry.location}
|
||||
<span className="sr-only">, on the map</span>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
||||
/* An entry's own map image says what it maps. */
|
||||
export const mapAlt = (entry: ContentBlockItem) => `Map: ${entry.map?.trim() || entry.location || entry.text}`
|
||||
|
||||
|
|
@ -93,7 +185,25 @@ export function Avatar({ person, size }: { person: NonNullable<ContentBlockItem[
|
|||
)
|
||||
}
|
||||
|
||||
function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
|
||||
/* A featured entry's star, read as a word by a screen reader. */
|
||||
export function FeaturedStar({ className = 'h-4 w-4' }: { className?: string }) {
|
||||
return (
|
||||
<>
|
||||
<Star aria-hidden="true" weight="fill" className={`inline shrink-0 ${className}`} />
|
||||
<span className="sr-only">Featured: </span>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
/* A featured row's look: a faint wash of the accent and a bar down
|
||||
its left edge. */
|
||||
export const featuredStyle = (accent: string) => ({
|
||||
background: withAlpha(accent, 10),
|
||||
boxShadow: `inset 4px 0 0 ${accent}`,
|
||||
})
|
||||
|
||||
function Entry({ entry, accent, sub = false }: { entry: ContentBlockItem; accent: string; sub?: boolean }) {
|
||||
const tags = useContext(ScheduleTags)
|
||||
const [open, setOpen] = useState(false)
|
||||
// Google's map loads only when asked for (Privacy page).
|
||||
const [showMap, setShowMap] = useState(false)
|
||||
|
|
@ -101,7 +211,23 @@ function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
|
|||
const graphic = mediaUrl(entry.media)
|
||||
const place = entry.map?.trim()
|
||||
const mapImage = mediaUrl(entry.map_image)
|
||||
const more = Boolean(entry.description || graphic || place || mapImage || entry.person)
|
||||
const quiet = entry.kind === 'break'
|
||||
const more = !quiet && Boolean(entry.description || graphic || place || mapImage || entry.person)
|
||||
|
||||
if (entry.kind === 'heading') {
|
||||
return (
|
||||
<li className="border-b border-brand/10 px-5 pt-6 pb-2 last:border-b-0">
|
||||
<p className="text-sm font-bold uppercase tracking-wide" style={{ color: accentText(accent) }}>
|
||||
{entry.text}
|
||||
</p>
|
||||
{entry.detail && (
|
||||
<p className="mt-1 text-sm" style={{ color: BODY }}>
|
||||
{entry.detail}
|
||||
</p>
|
||||
)}
|
||||
</li>
|
||||
)
|
||||
}
|
||||
|
||||
const title = entry.url ? (
|
||||
<Anchor href={entry.url} className="underline-offset-2 hover:underline" style={{ color: accentText(accent) }}>
|
||||
|
|
@ -112,19 +238,36 @@ function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
|
|||
)
|
||||
|
||||
return (
|
||||
<li className="border-b border-brand/10 last:border-b-0">
|
||||
<li
|
||||
className={sub ? 'pl-4' : 'border-b border-brand/10 px-5 last:border-b-0 even:bg-tint-soft/60'}
|
||||
style={entry.featured ? featuredStyle(accent) : undefined}
|
||||
>
|
||||
{/* On a phone the time sits on its own line above the entry,
|
||||
leaving the title the full width. */}
|
||||
<div className="flex flex-wrap gap-x-4 gap-y-1 py-4 sm:flex-nowrap sm:gap-6">
|
||||
<p className="w-full shrink-0 pt-0.5 text-sm font-semibold sm:w-32" style={{ color: accentText(accent) }}>
|
||||
<div
|
||||
className={`flex flex-wrap gap-x-4 gap-y-1 sm:flex-nowrap ${quiet || sub ? 'py-2.5' : 'py-4'} ${
|
||||
sub ? 'sm:gap-4' : 'sm:gap-6'
|
||||
}`}
|
||||
>
|
||||
<p
|
||||
className={`w-full shrink-0 pt-0.5 text-sm font-semibold ${sub ? 'sm:w-28' : 'sm:w-32'}`}
|
||||
style={{ color: quiet ? BODY : accentText(accent) }}
|
||||
>
|
||||
{entry.time}
|
||||
</p>
|
||||
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="font-semibold text-body">{title}</p>
|
||||
<p className={quiet ? 'text-muted' : 'font-semibold text-body'}>
|
||||
{entry.featured && (
|
||||
<span className="mr-1.5" style={{ color: accentText(accent) }}>
|
||||
<FeaturedStar className="h-4 w-4 -translate-y-px" />
|
||||
</span>
|
||||
)}
|
||||
{title}
|
||||
</p>
|
||||
{(entry.location || entry.person) && (
|
||||
<p className="mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-sm" style={{ color: BODY }}>
|
||||
{entry.location && <span>{entry.location}</span>}
|
||||
<Place entry={entry} accent={accent} />
|
||||
{entry.person && (
|
||||
<span className="inline-flex items-center gap-2">
|
||||
<Avatar person={entry.person} size="h-6 w-6" />
|
||||
|
|
@ -138,6 +281,11 @@ function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
|
|||
{entry.detail}
|
||||
</p>
|
||||
)}
|
||||
{entry.tags?.length ? (
|
||||
<div className="mt-2">
|
||||
<TagChips keys={entry.tags} tags={tags} accent={accent} />
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{more && (
|
||||
|
|
@ -160,7 +308,7 @@ function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
|
|||
</div>
|
||||
|
||||
{more && open && (
|
||||
<div id={panelId} className="mb-5 space-y-5 bg-tint-soft p-5 sm:ml-38">
|
||||
<div id={panelId} className={`mb-5 space-y-5 bg-tint-soft p-5 ${sub ? 'sm:ml-32' : 'sm:ml-38'}`}>
|
||||
{entry.person && (
|
||||
<div className="flex items-center gap-4">
|
||||
<Avatar person={entry.person} size="h-16 w-16" />
|
||||
|
|
@ -228,21 +376,31 @@ function Entry({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
|
|||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* A block's sub-items, under its title. */}
|
||||
{entry.kind === 'block' && entry.items?.length ? (
|
||||
<ul className="mb-4 sm:ml-38" style={{ borderLeft: `2px solid ${withAlpha(accent, 33)}` }}>
|
||||
{entry.items.map((item, index) => (
|
||||
<Entry key={index} entry={item} accent={accent} sub />
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
</li>
|
||||
)
|
||||
}
|
||||
|
||||
/* Reading mode: every day, every entry and its fold-out, as text. A
|
||||
day is an h4, under the page's h3 block headings (ContentBlocks). */
|
||||
function ReadingSchedule({ days, intro, accent }: { days: Day[]; intro?: string | null; accent: string }) {
|
||||
/* One entry in reading mode, a block's sub-items in a list under it. */
|
||||
function readingEntry(entry: ContentBlockItem, accent: string, key: number, tags: ScheduleTag[]): ReactNode {
|
||||
if (entry.kind === 'heading') {
|
||||
return (
|
||||
<div>
|
||||
{intro && <Paragraphs text={intro} accent={accent} />}
|
||||
{days.map((day, index) => (
|
||||
<div key={day.name || index}>
|
||||
{days.length > 1 && <h4>{day.name || 'Schedule'}</h4>}
|
||||
<ul>
|
||||
{day.entries.map((entry, i) => {
|
||||
<li key={key}>
|
||||
<p>
|
||||
<strong>{entry.text}</strong>
|
||||
</p>
|
||||
{entry.detail && <p>{entry.detail}</p>}
|
||||
</li>
|
||||
)
|
||||
}
|
||||
const graphic = mediaUrl(entry.media)
|
||||
const place = entry.map?.trim()
|
||||
const mapImage = mediaUrl(entry.map_image)
|
||||
|
|
@ -253,8 +411,9 @@ function ReadingSchedule({ days, intro, accent }: { days: Day[]; intro?: string
|
|||
entry.person && <Link to={personHref(entry.person.id)}>{entry.person.name}</Link>,
|
||||
].filter(Boolean)
|
||||
return (
|
||||
<li key={i}>
|
||||
<li key={key}>
|
||||
<p>
|
||||
{entry.featured && 'Featured: '}
|
||||
{parts.map((part, j) => (
|
||||
<Fragment key={j}>
|
||||
{j > 0 && ' · '}
|
||||
|
|
@ -263,6 +422,9 @@ function ReadingSchedule({ days, intro, accent }: { days: Day[]; intro?: string
|
|||
))}
|
||||
</p>
|
||||
{entry.detail && <p>{entry.detail}</p>}
|
||||
{entry.tags?.length ? (
|
||||
<p>Tags: {tags.filter((tag) => entry.tags!.includes(tag.key)).map((tag) => tag.name).join(', ')}</p>
|
||||
) : null}
|
||||
{entry.person?.tagline && <p>{entry.person.tagline}</p>}
|
||||
{entry.description && <Paragraphs text={entry.description} accent={accent} />}
|
||||
{graphic && <img src={graphic} alt={entry.media_alt ?? ''} />}
|
||||
|
|
@ -272,27 +434,52 @@ function ReadingSchedule({ days, intro, accent }: { days: Day[]; intro?: string
|
|||
<a href={mapLink(place)}>Open {place} in Google Maps</a>
|
||||
</p>
|
||||
)}
|
||||
{entry.kind === 'block' && entry.items?.length ? (
|
||||
<ul>{entry.items.map((item, i) => readingEntry(item, accent, i, tags))}</ul>
|
||||
) : null}
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
}
|
||||
|
||||
/* Reading mode: every day, every entry and its fold-out, as text. A
|
||||
day is an h4, under the page's h3 block headings (ContentBlocks). */
|
||||
function ReadingSchedule({
|
||||
days,
|
||||
tags,
|
||||
intro,
|
||||
accent,
|
||||
}: {
|
||||
days: Day[]
|
||||
tags: ScheduleTag[]
|
||||
intro?: string | null
|
||||
accent: string
|
||||
}) {
|
||||
return (
|
||||
<div>
|
||||
{intro && <Paragraphs text={intro} accent={accent} />}
|
||||
{days.map((day, index) => (
|
||||
<div key={day.name || index}>
|
||||
{days.length > 1 && <h4>{day.name || 'Schedule'}</h4>}
|
||||
<ul>{day.entries.map((entry, i) => readingEntry(entry, accent, i, tags))}</ul>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/* A tab: a day, or a tag's entries from every day (087). */
|
||||
type Tab = { label: string; days: Day[]; color?: string | null; tag?: boolean }
|
||||
|
||||
export default function ScheduleBlock({
|
||||
items,
|
||||
tags = [],
|
||||
intro,
|
||||
accent,
|
||||
presentHref,
|
||||
}: {
|
||||
items: ContentBlockItem[]
|
||||
tags?: ScheduleTag[]
|
||||
intro?: string | null
|
||||
accent: string
|
||||
/** Where the Present button goes; no button without it. */
|
||||
presentHref?: string
|
||||
}) {
|
||||
const days = groupByDay(items)
|
||||
const [active, setActive] = useState(() => todayIndex(days))
|
||||
|
|
@ -300,15 +487,56 @@ export default function ScheduleBlock({
|
|||
const reading = useReadingMode()
|
||||
|
||||
if (days.length === 0) return null
|
||||
if (reading) return <ReadingSchedule days={days} intro={intro} accent={accent} />
|
||||
const current = days[Math.min(active, days.length - 1)]
|
||||
if (reading) return <ReadingSchedule days={days} tags={tags} intro={intro} accent={accent} />
|
||||
|
||||
const tabs: Tab[] = [
|
||||
...days.map((day) => ({ label: day.name || 'Schedule', days: [day] })),
|
||||
...tags
|
||||
.filter((tag) => tag.tab)
|
||||
.map((tag) => ({ label: tag.name, days: daysWithTag(days, tag.key), color: tag.color, tag: true }))
|
||||
.filter((tab) => tab.days.length),
|
||||
]
|
||||
const dayCount = days.length
|
||||
const at = Math.min(active, tabs.length - 1)
|
||||
const current = tabs[at]
|
||||
|
||||
// A day's tab, or a tag's: smaller, its tag icon in front.
|
||||
const tabButton = (tab: Tab, index: number) => {
|
||||
const selected = index === at
|
||||
const color = tab.color || accent
|
||||
return (
|
||||
<button
|
||||
key={index}
|
||||
id={`${baseId}-tab-${index}`}
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={selected}
|
||||
aria-controls={`${baseId}-panel`}
|
||||
tabIndex={selected ? 0 : -1}
|
||||
onClick={() => setActive(index)}
|
||||
onKeyDown={onKey}
|
||||
className={
|
||||
'btn inline-flex items-center gap-1.5 border transition-colors ' +
|
||||
(tab.tag ? 'px-3 py-1 text-xs' : 'px-5 py-2 text-sm')
|
||||
}
|
||||
style={
|
||||
selected
|
||||
? { background: color, borderColor: color, color: readableOn(color) }
|
||||
: { borderColor: withAlpha(color, 33), color: accentText(color) }
|
||||
}
|
||||
>
|
||||
{tab.tag && <TagIcon aria-hidden="true" weight="bold" className="h-3.5 w-3.5" />}
|
||||
{tab.label}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
// Arrows move one tab and wrap; Home and End jump to the ends.
|
||||
const onKey = (e: KeyboardEvent<HTMLButtonElement>) => {
|
||||
const last = days.length - 1
|
||||
const last = tabs.length - 1
|
||||
const next =
|
||||
e.key === 'ArrowRight' ? (active + 1) % days.length
|
||||
: e.key === 'ArrowLeft' ? (active + last) % days.length
|
||||
e.key === 'ArrowRight' ? (at + 1) % tabs.length
|
||||
: e.key === 'ArrowLeft' ? (at + last) % tabs.length
|
||||
: e.key === 'Home' ? 0
|
||||
: e.key === 'End' ? last
|
||||
: null
|
||||
|
|
@ -319,6 +547,7 @@ export default function ScheduleBlock({
|
|||
}
|
||||
|
||||
return (
|
||||
<ScheduleTags.Provider value={tags}>
|
||||
<div className="space-y-4">
|
||||
{intro && (
|
||||
<div className="space-y-3 leading-relaxed" style={{ color: BODY }}>
|
||||
|
|
@ -326,60 +555,55 @@ export default function ScheduleBlock({
|
|||
</div>
|
||||
)}
|
||||
|
||||
{presentHref && (
|
||||
<div className="flex justify-end">
|
||||
<Link
|
||||
to={presentHref}
|
||||
target="_blank"
|
||||
className="btn inline-flex items-center gap-2 border px-4 py-2 text-sm transition-colors hover:bg-tint"
|
||||
style={{ borderColor: `${withAlpha(accent, 33)}`, color: accentText(accent) }}
|
||||
>
|
||||
<Presentation aria-hidden="true" weight="bold" className="h-4 w-4" />
|
||||
Present
|
||||
<span className="sr-only">(opens in a new tab)</span>
|
||||
</Link>
|
||||
{tabs.length > 1 && (
|
||||
<div className="space-y-3">
|
||||
{/* Days, then the tags in a row of their own: one tablist,
|
||||
so the arrow keys still walk every tab. */}
|
||||
<div role="tablist" aria-label="Days and tags" className="space-y-3">
|
||||
<div role="presentation" className="flex flex-wrap gap-2">
|
||||
{tabs.slice(0, dayCount).map((tab, index) => tabButton(tab, index))}
|
||||
</div>
|
||||
{tabs.length > dayCount && (
|
||||
<div role="presentation" className="flex flex-wrap items-center gap-2 border-t border-brand/15 pt-3">
|
||||
<span aria-hidden="true" className="mr-1 inline-flex items-center gap-1.5 text-sm font-semibold text-ink">
|
||||
<TagIcon weight="bold" className="h-4 w-4" />
|
||||
By tag
|
||||
</span>
|
||||
{tabs.slice(dayCount).map((tab, i) => tabButton(tab, dayCount + i))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{tabs.length > dayCount && (
|
||||
<p className="text-sm text-muted">
|
||||
Pick a tag to see everything it's on, from every day.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{days.length > 1 && (
|
||||
<div role="tablist" aria-label="Days" className="flex flex-wrap gap-2">
|
||||
{days.map((day, index) => {
|
||||
const selected = day === current
|
||||
return (
|
||||
<button
|
||||
key={day.name || index}
|
||||
id={`${baseId}-tab-${index}`}
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={selected}
|
||||
aria-controls={`${baseId}-panel`}
|
||||
tabIndex={selected ? 0 : -1}
|
||||
onClick={() => setActive(index)}
|
||||
onKeyDown={onKey}
|
||||
className="btn border px-5 py-2 text-sm transition-colors"
|
||||
style={
|
||||
selected
|
||||
? { background: accent, borderColor: accent, color: readableOn(accent) }
|
||||
: { borderColor: `${withAlpha(accent, 33)}`, color: accentText(accent) }
|
||||
}
|
||||
>
|
||||
{day.name || 'Schedule'}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<ul
|
||||
<div
|
||||
id={`${baseId}-panel`}
|
||||
role={days.length > 1 ? 'tabpanel' : undefined}
|
||||
aria-labelledby={days.length > 1 ? `${baseId}-tab-${days.indexOf(current)}` : undefined}
|
||||
className="border border-brand/15 bg-surface px-5"
|
||||
role={tabs.length > 1 ? 'tabpanel' : undefined}
|
||||
aria-labelledby={tabs.length > 1 ? `${baseId}-tab-${at}` : undefined}
|
||||
className="border border-brand/15 bg-surface"
|
||||
>
|
||||
{current.entries.map((entry, index) => (
|
||||
<Entry key={`${current.name}-${index}`} entry={entry} accent={accent} />
|
||||
{current.days.map((day, d) => (
|
||||
<Fragment key={`${at}-${d}`}>
|
||||
{/* A tag's tab names each day it gathers from. */}
|
||||
{current.tag && current.days.length > 1 && (
|
||||
<p className="border-b border-brand/15 bg-tint px-5 py-2 text-sm font-bold text-ink">
|
||||
{day.name || 'Schedule'}
|
||||
</p>
|
||||
)}
|
||||
<ul>
|
||||
{day.entries.map((entry, index) => (
|
||||
<Entry key={`${at}-${d}-${index}`} entry={entry} accent={accent} />
|
||||
))}
|
||||
</ul>
|
||||
</Fragment>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</ScheduleTags.Provider>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
130
src/components/admin/MapMarkerInput.tsx
Normal file
130
src/components/admin/MapMarkerInput.tsx
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
/* A venue location's mark on the venue's map (088), for the
|
||||
`mapMarker` widget (fields.tsx): click the picture for a pin, drag
|
||||
for a box. Saved as x, y (and w, h for a box) in percent of the
|
||||
picture from its top left, one decimal, through onPatch. The
|
||||
numbers under it set the same thing by keyboard. */
|
||||
|
||||
import { useRef, useState, type PointerEvent } from "react";
|
||||
|
||||
type Mark = { x: number | null; y: number | null; w: number | null; h: number | null };
|
||||
|
||||
const round = (n: number) => Math.round(Math.min(100, Math.max(0, n)) * 10) / 10;
|
||||
// Moved less than this (percent) between press and release: a click.
|
||||
const CLICK = 1.5;
|
||||
|
||||
export default function MapMarkerInput({ image, row, locked, onPatch }: any) {
|
||||
const box = useRef<HTMLDivElement>(null);
|
||||
const [drag, setDrag] = useState<{ x0: number; y0: number; x1: number; y1: number } | null>(null);
|
||||
const mark: Mark = { x: row.x ?? null, y: row.y ?? null, w: row.w ?? null, h: row.h ?? null };
|
||||
|
||||
const at = (e: PointerEvent) => {
|
||||
const r = box.current!.getBoundingClientRect();
|
||||
return { x: round(((e.clientX - r.left) / r.width) * 100), y: round(((e.clientY - r.top) / r.height) * 100) };
|
||||
};
|
||||
|
||||
const up = (e: PointerEvent) => {
|
||||
if (!drag) return;
|
||||
const { x, y } = at(e);
|
||||
setDrag(null);
|
||||
if (Math.abs(x - drag.x0) < CLICK && Math.abs(y - drag.y0) < CLICK) {
|
||||
onPatch({ x: drag.x0, y: drag.y0, w: null, h: null });
|
||||
} else {
|
||||
onPatch({
|
||||
x: Math.min(x, drag.x0),
|
||||
y: Math.min(y, drag.y0),
|
||||
w: round(Math.abs(x - drag.x0)),
|
||||
h: round(Math.abs(y - drag.y0)),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const shown = drag
|
||||
? {
|
||||
x: Math.min(drag.x0, drag.x1),
|
||||
y: Math.min(drag.y0, drag.y1),
|
||||
w: Math.abs(drag.x1 - drag.x0),
|
||||
h: Math.abs(drag.y1 - drag.y0),
|
||||
}
|
||||
: mark;
|
||||
|
||||
const number = (key: keyof Mark, label: string) => (
|
||||
<label className="flex items-center gap-1">
|
||||
{label}
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
max={100}
|
||||
step={0.1}
|
||||
value={mark[key] ?? ""}
|
||||
disabled={locked}
|
||||
onChange={(e) => onPatch({ [key]: e.target.value === "" ? null : round(Number(e.target.value)) })}
|
||||
className="w-20 border border-muted/25 bg-surface px-2 py-1 text-body"
|
||||
/>
|
||||
</label>
|
||||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{image ? (
|
||||
<div
|
||||
ref={box}
|
||||
className={`relative select-none ${locked ? "" : "cursor-crosshair"}`}
|
||||
onPointerDown={(e) => {
|
||||
if (locked) return;
|
||||
e.currentTarget.setPointerCapture(e.pointerId);
|
||||
const { x, y } = at(e);
|
||||
setDrag({ x0: x, y0: y, x1: x, y1: y });
|
||||
}}
|
||||
onPointerMove={(e) => drag && setDrag({ ...drag, x1: at(e).x, y1: at(e).y })}
|
||||
onPointerUp={up}
|
||||
>
|
||||
<img src={image} alt="" draggable={false} className="block w-full" />
|
||||
{shown.x != null && shown.y != null && (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="pointer-events-none absolute"
|
||||
style={
|
||||
shown.w && shown.h
|
||||
? {
|
||||
left: `${shown.x}%`,
|
||||
top: `${shown.y}%`,
|
||||
width: `${shown.w}%`,
|
||||
height: `${shown.h}%`,
|
||||
border: "2px solid var(--color-action)",
|
||||
background: "color-mix(in srgb, var(--color-action) 20%, transparent)",
|
||||
}
|
||||
: {
|
||||
left: `${shown.x}%`,
|
||||
top: `${shown.y}%`,
|
||||
width: 16,
|
||||
height: 16,
|
||||
transform: "translate(-50%, -50%)",
|
||||
borderRadius: "50%",
|
||||
background: "var(--color-action)",
|
||||
outline: "2px solid white",
|
||||
}
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<p className="notice p-3 text-sm text-muted">Add the venue's map above, then mark this location on it.</p>
|
||||
)}
|
||||
<div className="mt-2 flex flex-wrap items-center gap-3 text-xs text-muted">
|
||||
{number("x", "Left %")}
|
||||
{number("y", "Top %")}
|
||||
{number("w", "Width %")}
|
||||
{number("h", "Height %")}
|
||||
{mark.x != null && !locked && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onPatch({ x: null, y: null, w: null, h: null })}
|
||||
className="text-link hover:underline"
|
||||
>
|
||||
Clear mark
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -24,7 +24,18 @@
|
|||
server doesn't also declare as a column default. If you give a
|
||||
blank row a starting value here, add the matching default: to
|
||||
that column in the server's admin-schema.js or the row will be
|
||||
saved as real input.
|
||||
saved as real input. `blank` can be a function instead, for a
|
||||
value made fresh for every new row and every copy (a schedule
|
||||
tag's key); mark that column `seeded` on the server so a row with
|
||||
only that in it still counts as blank.
|
||||
|
||||
`lends: (row) => ({ name: [{ id, label }] })` on a collection gives
|
||||
the collections nested in each row (at any depth) more options,
|
||||
made from that row: a schedule block lends its tags to its
|
||||
entries and their sub-items.
|
||||
|
||||
`widget: "checklist"` is a checkbox per option of `optionsFrom`,
|
||||
saved as the picked ids, comma-separated, in the options' order.
|
||||
|
||||
In a repeater row, `when: { path, value }` shows a field only
|
||||
while another field of the row holds that value (or one of them,
|
||||
|
|
@ -66,6 +77,15 @@
|
|||
Data → Links/redirects (the `redirects` options) that fills the
|
||||
field with the short link's full address, <site>/go/<URL ID>.
|
||||
|
||||
`fills: "text"` on a select fills that field of the row, while
|
||||
it's empty, with the picked option's label.
|
||||
|
||||
`widget: "mapMarker"` (on `x`) marks a venue's location on the
|
||||
map picture its parent row holds in `imageFrom`: a click is a
|
||||
pin (x, y), a drag a box (x, y, w, h), in percent (MapMarkerInput
|
||||
below). `lends` gets the form's options too, so a block can lend
|
||||
its venue's locations from the venues list.
|
||||
|
||||
`widget: "testNotice"` is a text box of email addresses with a
|
||||
"Send a test notice" button (TestNoticeInput below), for Site
|
||||
settings → Notices.
|
||||
|
|
@ -103,6 +123,9 @@ import ContentBlocks from "../ContentBlocks.tsx";
|
|||
import { FILTER_FROM, OptionFilter, narrow } from "../OptionFilter.tsx";
|
||||
import { ImageInput, LinkPreviewInput } from "./MediaLibrary.tsx";
|
||||
import { ChooseFileButton } from "./DriveFiles.tsx";
|
||||
import MapMarkerInput from "./MapMarkerInput.tsx";
|
||||
import { venueFromOption } from "../../lib/adminSchema/shared.ts";
|
||||
import { mediaUrl } from "../../lib/media.ts";
|
||||
import { siteUrl } from "../../lib/site.ts";
|
||||
|
||||
/* Live previews a collection can name with `preview`. Each gets the
|
||||
|
|
@ -111,21 +134,41 @@ const PREVIEWS = {
|
|||
// The form holds an entry's person as person_id; the renderer wants
|
||||
// the person, so it's looked up in the select options (a name, no
|
||||
// photo: the options carry no more).
|
||||
contentBlock: (row, options) => (
|
||||
// A venue and an item's event and map location come from the
|
||||
// options the same way (088): an event as its title only. A map
|
||||
// block's sections (094) are made as the API makes them (shape.js):
|
||||
// their keys the venue still has, the venue cut to those.
|
||||
contentBlock: (row, options) => {
|
||||
const venue = venueFromOption(options?.venues?.find((v) => v.id === row.venue_id));
|
||||
const known = new Map((venue?.locations ?? []).map((l) => [l.key, l]));
|
||||
const sections = (row.map_sections ?? [])
|
||||
.map((section) => ({
|
||||
name: section.name,
|
||||
keys: (section.location_keys ?? "").split(",").filter((key) => known.has(key)),
|
||||
}))
|
||||
.filter((section) => section.keys.length);
|
||||
const mapped = venue && sections.length
|
||||
? { ...venue, locations: [...new Set(sections.flatMap((section) => section.keys))].map((key) => known.get(key)) }
|
||||
: venue;
|
||||
const shape = (item) => {
|
||||
const person = item.person_id ? options?.people?.find((p) => p.id === item.person_id) : null;
|
||||
const event = item.event_id ? options?.events?.find((e) => e.id === item.event_id) : null;
|
||||
const location = venue?.locations.find((l) => l.key === item.location_key);
|
||||
return {
|
||||
...item,
|
||||
person: person ? { id: person.id, name: person.label } : null,
|
||||
event: event ? { id: event.id, title: event.label } : null,
|
||||
place: location ? { venue_id: venue!.id, key: location.key, name: location.name } : null,
|
||||
location: item.location || location?.name,
|
||||
items: (item.items ?? []).map(shape),
|
||||
};
|
||||
};
|
||||
return (
|
||||
<ContentBlocks
|
||||
blocks={[
|
||||
{
|
||||
...row,
|
||||
items: (row.items ?? []).map((item) => {
|
||||
const person = item.person_id
|
||||
? options?.people?.find((p) => p.id === item.person_id)
|
||||
: null;
|
||||
return { ...item, person: person ? { id: person.id, name: person.label } : null };
|
||||
}),
|
||||
},
|
||||
]}
|
||||
blocks={[{ ...row, venue: mapped, map_sections: sections, items: (row.items ?? []).map(shape) }]}
|
||||
/>
|
||||
),
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
const input =
|
||||
|
|
@ -226,11 +269,52 @@ function withoutIds(value) {
|
|||
return copy;
|
||||
}
|
||||
|
||||
/* A new row, and the fresh values a function `blank` gives every
|
||||
new row (a copy keeps the rest of what it copies). */
|
||||
const newRow = (spec) => (typeof spec.blank === "function" ? spec.blank() : { ...spec.blank });
|
||||
const seeded = (spec) => (typeof spec.blank === "function" ? spec.blank() : {});
|
||||
|
||||
const helpText = (field, row) => (typeof field.help === "function" ? field.help(row) : field.help);
|
||||
|
||||
/* `widget: "checklist"`: the picked ids, comma-separated. An id no
|
||||
option has any more is dropped at the next change. */
|
||||
function Checklist({ id, options, value, disabled, empty, onChange }: {
|
||||
id: string
|
||||
options: { id: string; label: string }[]
|
||||
value?: string | null
|
||||
disabled?: boolean
|
||||
empty?: string
|
||||
onChange: (value: string) => void
|
||||
}) {
|
||||
const picked = new Set((value ?? "").split(",").filter(Boolean));
|
||||
if (options.length === 0) return <p id={id} className="text-sm text-muted">{empty ?? "Nothing to pick yet."}</p>;
|
||||
const toggle = (key: string) => {
|
||||
const next = new Set(picked);
|
||||
if (next.has(key)) next.delete(key);
|
||||
else next.add(key);
|
||||
onChange(options.filter((o) => next.has(o.id)).map((o) => o.id).join(","));
|
||||
};
|
||||
return (
|
||||
<div id={id} role="group" className="flex flex-wrap gap-x-4 gap-y-1.5">
|
||||
{options.map((o) => (
|
||||
<label key={o.id} className="flex items-center gap-2 text-sm text-body">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={picked.has(o.id)}
|
||||
disabled={disabled}
|
||||
onChange={() => toggle(o.id)}
|
||||
className="h-4 w-4 border-muted/40 text-link focus:ring-brand/40 disabled:opacity-50"
|
||||
/>
|
||||
{o.label}
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/* ── Field ───────────────────────────────────────────────────── */
|
||||
|
||||
export function Field({ field, value, row, options, error, onChange, onPatch }: any) {
|
||||
export function Field({ field, value, row, parentRow, options, error, onChange, onPatch }: any) {
|
||||
const id = `f-${field.path.replace(/\./g, "-")}`;
|
||||
const widget = field.widget ?? "text";
|
||||
// readOnly may be a test of the row (a core page's address).
|
||||
|
|
@ -315,6 +399,15 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
|
|||
/>
|
||||
{helpText(field, row) ?? "Yes"}
|
||||
</label>
|
||||
) : widget === "checklist" ? (
|
||||
<Checklist
|
||||
id={id}
|
||||
options={options?.[field.optionsFrom] ?? []}
|
||||
value={value}
|
||||
disabled={locked}
|
||||
empty={field.emptyNote}
|
||||
onChange={onChange}
|
||||
/>
|
||||
) : widget === "textarea" ? (
|
||||
<textarea
|
||||
{...common}
|
||||
|
|
@ -336,6 +429,14 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
|
|||
)}
|
||||
<select
|
||||
{...common}
|
||||
onChange={(e) => {
|
||||
// `fills`: a pick also fills that empty field of the
|
||||
// row with the option's label (a workshop's title).
|
||||
const picked = e.target.value;
|
||||
const label = list?.find(([optionId]) => String(optionId) === picked)?.[1];
|
||||
if (field.fills && picked && !row?.[field.fills] && onPatch) onPatch({ [field.path]: picked, [field.fills]: label });
|
||||
else onChange(picked);
|
||||
}}
|
||||
disabled={locked}
|
||||
className={`${locked ? inputLocked : common.className} ${
|
||||
orphaned && !locked ? inputError : ""
|
||||
|
|
@ -379,6 +480,13 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
|
|||
onChange={onChange}
|
||||
onPatch={onPatch}
|
||||
/>
|
||||
) : widget === "mapMarker" ? (
|
||||
<MapMarkerInput
|
||||
image={field.imageFrom ? mediaUrl(parentRow?.[field.imageFrom]) : null}
|
||||
row={row}
|
||||
locked={locked}
|
||||
onPatch={onPatch}
|
||||
/>
|
||||
) : widget === "testNotice" ? (
|
||||
<TestNoticeInput
|
||||
id={id}
|
||||
|
|
@ -558,7 +666,7 @@ export function Repeater({
|
|||
|
||||
const add = () => {
|
||||
setOpen((prev) => new Set(prev).add(list.length));
|
||||
onChange([...list, { ...spec.blank }]);
|
||||
onChange([...list, newRow(spec)]);
|
||||
};
|
||||
|
||||
/* A row placed at `at`, pushing everything from there down one,
|
||||
|
|
@ -714,13 +822,13 @@ export function Repeater({
|
|||
</IconButton>
|
||||
<IconButton
|
||||
label="Insert a new one below"
|
||||
onClick={() => insertAt(index + 1, { ...spec.blank })}
|
||||
onClick={() => insertAt(index + 1, newRow(spec))}
|
||||
>
|
||||
<Plus size={14} weight="bold" aria-hidden="true" />
|
||||
</IconButton>
|
||||
<IconButton
|
||||
label="Duplicate"
|
||||
onClick={() => insertAt(index + 1, withoutIds(row))}
|
||||
onClick={() => insertAt(index + 1, { ...withoutIds(row), ...seeded(spec) })}
|
||||
>
|
||||
<Copy size={14} weight="bold" aria-hidden="true" />
|
||||
</IconButton>
|
||||
|
|
@ -744,8 +852,11 @@ export function Repeater({
|
|||
key={field.path}
|
||||
field={field}
|
||||
row={row}
|
||||
parentRow={parentRow}
|
||||
value={row[field.path]}
|
||||
options={options}
|
||||
// Its own lent options too: a map block's
|
||||
// Locations with a slide (095).
|
||||
options={spec.lends ? { ...options, ...spec.lends(row, options) } : options}
|
||||
error={errors?.[`${errorPrefix}${index}.${field.path}`]}
|
||||
onChange={(value) => update(index, { ...row, [field.path]: value })}
|
||||
onPatch={(patch) => update(index, { ...row, ...patch })}
|
||||
|
|
@ -760,7 +871,7 @@ export function Repeater({
|
|||
<Repeater
|
||||
spec={nested}
|
||||
rows={row[nested.key]}
|
||||
options={options}
|
||||
options={spec.lends ? { ...options, ...spec.lends(row, options) } : options}
|
||||
errors={errors}
|
||||
errorPrefix={`${errorPrefix}${index}.${nested.key}.`}
|
||||
parentRow={row}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import { tags } from "./adminSchema/tags.ts";
|
|||
import { contactTypes } from "./adminSchema/contactTypes.ts";
|
||||
import { redirects } from "./adminSchema/redirects.ts";
|
||||
import { pages } from "./adminSchema/sitePages.ts";
|
||||
import { venues } from "./adminSchema/venues.ts";
|
||||
|
||||
export const ADMIN_ENTITIES: Record<string, any> = {
|
||||
organizations,
|
||||
|
|
@ -42,6 +43,7 @@ export const ADMIN_ENTITIES: Record<string, any> = {
|
|||
tags,
|
||||
contact_types: contactTypes,
|
||||
redirects,
|
||||
venues,
|
||||
teams,
|
||||
awards,
|
||||
timeline,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import { mediaUrl } from "../media.ts";
|
||||
import { PLACE_FIELDS, PUBLISHED_FIELD, LISTED_FIELD, timelineGroup, timelineDetailGroup, linksChild, hostsChild, blocksChild, tagsChild } from "./shared.ts";
|
||||
import { PLACE_FIELDS, PUBLISHED_FIELD, LISTED_FIELD, timelineGroup, timelineDetailGroup, linksChild, hostsChild, blocksChild, tagsChild, PRESENT_BLOCK_FIELDS } from "./shared.ts";
|
||||
|
||||
/* An event's blocks also say how they're presented (095). */
|
||||
const eventBlocksChild = { ...blocksChild, fields: [...blocksChild.fields, ...PRESENT_BLOCK_FIELDS] };
|
||||
|
||||
/* ── Events ──────────────────────────────────────────────────── */
|
||||
|
||||
|
|
@ -173,6 +176,113 @@ export const events = {
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Page",
|
||||
fields: [
|
||||
{
|
||||
path: "show_contents",
|
||||
label: "Show contents",
|
||||
widget: "checkbox",
|
||||
help: "Lists the content blocks' headings beside them, the one being read lit (a fold-out on phones), as on a blog post. Worth it with two or more headings.",
|
||||
},
|
||||
{
|
||||
path: "links_heading",
|
||||
label: "Links heading",
|
||||
help: "Above the link buttons, eg. Sign up. Default: no heading.",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Presentation",
|
||||
fields: [
|
||||
{
|
||||
path: "present_background",
|
||||
label: "Background image",
|
||||
widget: "image",
|
||||
crop: "free",
|
||||
resolve: mediaUrl,
|
||||
full: true,
|
||||
help: "Behind every slide when the page is presented, under the background color. Default: none.",
|
||||
},
|
||||
{
|
||||
path: "present_background_color",
|
||||
label: "Background color",
|
||||
widget: "color",
|
||||
help: "The slides' background, laid over the image at Dim. Default: the site's background.",
|
||||
},
|
||||
{
|
||||
path: "present_dim",
|
||||
label: "Dim",
|
||||
widget: "number",
|
||||
help: "How much of the background color covers the image, 0 to 90 percent, so the text stays readable. Default: 60.",
|
||||
},
|
||||
{
|
||||
path: "present_frame",
|
||||
label: "Frame",
|
||||
widget: "select",
|
||||
options: [
|
||||
["border", "A border around the slide"],
|
||||
["none", "None: the slide alone"],
|
||||
],
|
||||
blankLabel: "Default: a bar on top, the title line and the timer",
|
||||
},
|
||||
...([
|
||||
["top", "Inset top", "of the screen's height"],
|
||||
["right", "Inset right", "of the screen's width"],
|
||||
["bottom", "Inset bottom", "of the screen's height"],
|
||||
["left", "Inset left", "of the screen's width"],
|
||||
] as const).map(([side, label, of]) => ({
|
||||
path: `present_inset_${side}`,
|
||||
label,
|
||||
widget: "number",
|
||||
help: `Room kept clear at this edge, in percent ${of} (0 to 45), eg. to keep the slides inside a frame drawn in the background image. With any inset the image is stretched to the screen, not cropped. Default: 0.`,
|
||||
})),
|
||||
{ path: "present_accent", label: "Accent", widget: "color", help: "Default: the event's color" },
|
||||
{
|
||||
path: "present_text_color",
|
||||
label: "Text color",
|
||||
widget: "color",
|
||||
help: "Default: readable on the background color, else the site's text colors",
|
||||
},
|
||||
{
|
||||
path: "present_logo",
|
||||
label: "Logo",
|
||||
widget: "image",
|
||||
folder: "logos",
|
||||
resolve: mediaUrl,
|
||||
full: true,
|
||||
help: "In the bottom-right corner of every slide. Default: none.",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
legend: "Presentation, dark theme",
|
||||
note: "For a screen in the dark theme (its own setting, or the Theme picked when presenting). Each one left blank uses the one above.",
|
||||
fields: [
|
||||
{
|
||||
path: "present_background_dark",
|
||||
label: "Background image",
|
||||
widget: "image",
|
||||
crop: "free",
|
||||
resolve: mediaUrl,
|
||||
full: true,
|
||||
help: "Default: the background image above",
|
||||
},
|
||||
{ path: "present_background_color_dark", label: "Background color", widget: "color", help: "Default: the one above, else the site's dark background" },
|
||||
{ path: "present_dim_dark", label: "Dim", widget: "number", help: "0 to 90 percent. Default: the one above" },
|
||||
{ path: "present_accent_dark", label: "Accent", widget: "color", help: "Default: the accent above" },
|
||||
{ path: "present_text_color_dark", label: "Text color", widget: "color", help: "Default: the one above" },
|
||||
{
|
||||
path: "present_logo_dark",
|
||||
label: "Logo",
|
||||
widget: "image",
|
||||
folder: "logos",
|
||||
resolve: mediaUrl,
|
||||
full: true,
|
||||
help: "eg. a light version of the logo. Default: the logo above",
|
||||
},
|
||||
],
|
||||
},
|
||||
timelineGroup("event"),
|
||||
timelineDetailGroup("event"),
|
||||
{ legend: "Publishing", fields: [PUBLISHED_FIELD, LISTED_FIELD] },
|
||||
|
|
@ -215,6 +325,6 @@ export const events = {
|
|||
],
|
||||
},
|
||||
linksChild,
|
||||
blocksChild,
|
||||
eventBlocksChild,
|
||||
],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -309,16 +309,74 @@ export const BLOCK_TYPES = [
|
|||
["table", "Table", "A grid of text, eg. a comparison chart: one row per line, cells split by |, the first row the header."],
|
||||
["cards", "Link cards", "Cards with a picture, title and description, each a link to a page or a file, like a link shared in a chat; up to three in a row. Paste a link and press Fetch preview, or Choose a file."],
|
||||
["people", "People", "People tiles: a team's members, or people picked one by one as items (each with their title), or both."],
|
||||
["map", "Map", "A venue's map with its locations marked and listed beside it (Data → Venues). A schedule on the same page with the same venue links its locations here."],
|
||||
["events", "Events", "Event cards, eg. the workshops on offer: picture, type, date, title and card text, each linking to the event's page."],
|
||||
["organizations", "Organizations", "Organization cards, as on the Partners page: picked one by one as items, or every listed one of a kind."],
|
||||
["divider", "Divider", "A thin line between parts."],
|
||||
];
|
||||
|
||||
/* An item field that only a schedule's entries have. */
|
||||
export const SCHEDULE_ENTRY = { scope: "parent", path: "type", value: "schedule" };
|
||||
/* A schedule entry's kinds (086); blank is a normal entry. */
|
||||
export const SCHEDULE_KINDS = [
|
||||
["block", "Block, with sub-items"],
|
||||
["break", "Break or meal"],
|
||||
["heading", "Heading"],
|
||||
];
|
||||
/* Picked times and the typed override, on an entry and a sub-item. */
|
||||
const scheduleTimeFields = (when?: any) => [
|
||||
{ path: "start_time", label: "Starts", widget: "time", when },
|
||||
{ path: "end_time", label: "Ends", widget: "time", help: "Optional", when },
|
||||
{
|
||||
path: "time",
|
||||
label: "Display as",
|
||||
help: "Default: the times picked, eg. 7:00pm or 9:00 to 10:30am. Type here to show something else, eg. After dinner.",
|
||||
when,
|
||||
},
|
||||
];
|
||||
/* Item fields for a link card, and for every other kind of item. */
|
||||
export const CARD_ITEM = { scope: "parent", path: "type", value: "cards" };
|
||||
export const NOT_CARD_ITEM = { scope: "parent", path: "type", value: ["list", "links", "schedule"] };
|
||||
/* An item that's a person on a people block. */
|
||||
export const PEOPLE_ITEM = { scope: "parent", path: "type", value: "people" };
|
||||
/* An item that's an event card on an events block (088). */
|
||||
export const EVENT_ITEM = { scope: "parent", path: "type", value: "events" };
|
||||
/* An item that's an organization on an organizations block (093). */
|
||||
export const ORG_ITEM = { scope: "parent", path: "type", value: "organizations" };
|
||||
|
||||
/* A venues option (the /admin/options query) as a Venue: its
|
||||
locations arrive as JSON. */
|
||||
export const venueFromOption = (option) =>
|
||||
option
|
||||
? {
|
||||
id: option.id,
|
||||
name: option.label,
|
||||
map_image: option.map_image,
|
||||
map_alt: option.map_alt,
|
||||
locations: JSON.parse(option.locations || "[]"),
|
||||
}
|
||||
: null;
|
||||
|
||||
/* A schedule entry's or sub-item's workshop and place (088). */
|
||||
const eventField = (when?: any) => ({
|
||||
path: "event_id",
|
||||
label: "Event",
|
||||
widget: "select",
|
||||
optionsFrom: "events",
|
||||
fills: "text",
|
||||
blankLabel: "Default: none",
|
||||
help: "Optional: a workshop or other event this is. Its title fills an empty Title; its card text, photo, person host and page fill what's left blank here.",
|
||||
when,
|
||||
});
|
||||
const placeField = (when?: any) => ({
|
||||
path: "location_key",
|
||||
label: "Map location",
|
||||
widget: "select",
|
||||
optionsFrom: "mapLocations",
|
||||
blankLabel: "Default: none",
|
||||
help: "One of the block's venue's locations (the block's Venue, Data → Venues). Links to the map on the page and fills an empty Location.",
|
||||
when,
|
||||
});
|
||||
|
||||
export const blockTypeLabel = (type) => BLOCK_TYPES.find(([value]) => value === type)?.[1] ?? type;
|
||||
|
||||
|
|
@ -385,6 +443,121 @@ export const wordFields = (prefix: string, label: string, when?: any) => [
|
|||
{ path: `${prefix}word_seconds`, label: label ? `${label}seconds per word` : "Seconds per word", widget: "number", help: "1 to 20. Default: the site's", when },
|
||||
];
|
||||
|
||||
/* An entry's or sub-item's tags (087): the block's, lent by
|
||||
blocksChild. */
|
||||
const TAGS_FIELD = {
|
||||
path: "tags",
|
||||
label: "Tags",
|
||||
widget: "checklist",
|
||||
optionsFrom: "scheduleTags",
|
||||
full: true,
|
||||
emptyNote: "No tags yet: add them under the block's Tags.",
|
||||
};
|
||||
|
||||
/* A block entry's sub-item (086): an entry's fields, under its
|
||||
block's day. */
|
||||
const SUB_ITEM_FIELDS = [
|
||||
...scheduleTimeFields(),
|
||||
eventField(),
|
||||
{ path: "text", label: "Title", required: true },
|
||||
placeField(),
|
||||
{ path: "location", label: "Location", help: "eg. Room B. Default: the map location's name" },
|
||||
{
|
||||
path: "person_id",
|
||||
label: "Person",
|
||||
widget: "select",
|
||||
optionsFrom: "people",
|
||||
blankLabel: "Default: none",
|
||||
help: "Who hosts or speaks: shown with their photo, linked to their page",
|
||||
},
|
||||
{ path: "detail", label: "Detail", help: "A line under the title" },
|
||||
{ path: "url", label: "URL", help: "Optional: makes the title a link", files: true },
|
||||
{ path: "description", label: "More", widget: "textarea", full: true, help: "Shown when it's folded out. " + FORMATTING_HELP },
|
||||
{ path: "media", label: "Graphic", widget: "image", crop: "free", resolve: mediaUrl, full: true, help: "Optional, in the fold-out" },
|
||||
{
|
||||
path: "media_alt",
|
||||
label: "Graphic description",
|
||||
full: true,
|
||||
help: "For screen readers: what the graphic shows. Default: skipped as decoration.",
|
||||
},
|
||||
{ path: "map", label: "Map", full: true, help: "Optional: a place or address for a Google map" },
|
||||
{
|
||||
path: "map_image",
|
||||
label: "Map image",
|
||||
widget: "image",
|
||||
crop: "free",
|
||||
resolve: mediaUrl,
|
||||
full: true,
|
||||
help: "Optional: your own map, shown in place of the Google map and as a slide when presented",
|
||||
},
|
||||
{ path: "featured", label: "Featured", widget: "checkbox", help: "Makes it stand out" },
|
||||
TAGS_FIELD,
|
||||
];
|
||||
|
||||
/* An event's blocks' presentation fields (095), EventPresent.tsx. */
|
||||
export const PRESENT_BLOCK_FIELDS = [
|
||||
{
|
||||
path: "present_show",
|
||||
label: "Shown",
|
||||
widget: "select",
|
||||
options: [
|
||||
["page", "Only on the page"],
|
||||
["presentation", "Only in the presentation"],
|
||||
],
|
||||
blankLabel: "Default: on the page and in the presentation",
|
||||
help: "Only in the presentation keeps it off the page, eg. a welcome line for the screen.",
|
||||
},
|
||||
{
|
||||
path: "present_text",
|
||||
label: "Presentation text",
|
||||
widget: "textarea",
|
||||
full: true,
|
||||
when: { path: "type", value: TEXT_TYPES },
|
||||
help: "Shown in place of the text when the page is presented, eg. a shorter heading. Default: the text.",
|
||||
},
|
||||
{
|
||||
path: "present_map_split",
|
||||
label: "A slide per section",
|
||||
widget: "checkbox",
|
||||
help: "Presented: each of the sections below gets its own map slide with only its locations. Default: one map slide with every location.",
|
||||
when: { path: "type", value: "map" },
|
||||
},
|
||||
{
|
||||
path: "present_map_no_list",
|
||||
label: "Map only",
|
||||
widget: "checkbox",
|
||||
help: "Presented: no locations list beside the map, so the map fills the slide.",
|
||||
when: { path: "type", value: "map" },
|
||||
},
|
||||
{
|
||||
path: "present_map_no_details",
|
||||
label: "No location details",
|
||||
widget: "checkbox",
|
||||
help: "Presented: each location's name only, without its detail line.",
|
||||
when: { path: "type", value: "map" },
|
||||
},
|
||||
{
|
||||
path: "present_places",
|
||||
label: "Location slides",
|
||||
widget: "select",
|
||||
options: [
|
||||
["picked", "Only the locations picked below"],
|
||||
["none", "None"],
|
||||
],
|
||||
blankLabel: "Default: each marked location, lit up on the map",
|
||||
when: { path: "type", value: "map" },
|
||||
},
|
||||
{
|
||||
path: "present_place_keys",
|
||||
label: "Locations with a slide",
|
||||
widget: "checklist",
|
||||
optionsFrom: "mapLocations",
|
||||
full: true,
|
||||
when: { path: "present_places", value: "picked" },
|
||||
emptyNote: "No locations yet: pick the block's Venue, and give it locations under Data → Venues.",
|
||||
},
|
||||
];
|
||||
|
||||
export const blocksChild = {
|
||||
key: "content_blocks",
|
||||
label: "Content blocks",
|
||||
|
|
@ -423,6 +596,28 @@ export const blocksChild = {
|
|||
when: { path: "type", value: TEXT_TYPES },
|
||||
help: (row) => TEXT_HELP[row?.type],
|
||||
},
|
||||
{
|
||||
path: "org_kind",
|
||||
label: "List",
|
||||
widget: "select",
|
||||
options: [
|
||||
["partner", "Partners"],
|
||||
["region", "Regions"],
|
||||
["group", "Groups"],
|
||||
["ministry", "Ministries"],
|
||||
],
|
||||
blankLabel: "Default: only the organizations picked below",
|
||||
help: "Every published, listed one of this kind, by name. Organizations picked as items replace this list.",
|
||||
when: { path: "type", value: "organizations" },
|
||||
},
|
||||
{
|
||||
path: "list_style",
|
||||
label: "Style",
|
||||
widget: "select",
|
||||
options: [["plain", "Plain text, gray detail"]],
|
||||
blankLabel: "Default: bold text, normal detail",
|
||||
when: { path: "type", value: "list" },
|
||||
},
|
||||
{
|
||||
path: "cite",
|
||||
label: "Attribution",
|
||||
|
|
@ -464,6 +659,29 @@ export const blocksChild = {
|
|||
when: { path: "type", value: "video" },
|
||||
help: "A WebVTT (.vtt) file, for an uploaded video; YouTube, Vimeo and Facebook show their own. Default: none.",
|
||||
},
|
||||
{
|
||||
path: "media_dark",
|
||||
label: "Dark theme image",
|
||||
widget: "image",
|
||||
crop: "free",
|
||||
resolve: mediaUrl,
|
||||
full: true,
|
||||
when: { path: "type", value: "image" },
|
||||
help: "Shown in place of the image while the site is dark, eg. a chart drawn light on dark. Same alt text and caption. Default: the image above in both themes.",
|
||||
},
|
||||
{
|
||||
path: "image_size",
|
||||
label: "Size",
|
||||
widget: "select",
|
||||
options: [
|
||||
["small", "Small (up to 20rem)"],
|
||||
["medium", "Medium (up to 32rem)"],
|
||||
["large", "Large (up to 48rem)"],
|
||||
],
|
||||
blankLabel: "Default: the column's full width",
|
||||
help: "A smaller one is centered. Never wider than the column.",
|
||||
when: { path: "type", value: "image" },
|
||||
},
|
||||
{
|
||||
path: "alt",
|
||||
label: "Alt text",
|
||||
|
|
@ -480,24 +698,89 @@ export const blocksChild = {
|
|||
help: "Shows the team's members as tiles, its leads first. People added as items show after it.",
|
||||
when: { path: "type", value: "people" },
|
||||
},
|
||||
{
|
||||
path: "venue_id",
|
||||
label: "Venue",
|
||||
widget: "select",
|
||||
optionsFrom: "venues",
|
||||
blankLabel: "Default: none",
|
||||
help: (row) =>
|
||||
row?.type === "map"
|
||||
? "Whose map to show (Data → Venues). Without one the block shows nothing."
|
||||
: "Optional: the venue whose locations entries pick from (Data → Venues). With a Map block of it on the page, they link to it.",
|
||||
when: { path: "type", value: ["map", "schedule"] },
|
||||
},
|
||||
...wordFields("", "", { path: "type", value: ["heading", "subheading", "paragraph", "callout", "quote"] }),
|
||||
],
|
||||
// A schedule's tags, for its entries' and sub-items' Tags (087).
|
||||
lends: (row, options) => ({
|
||||
scheduleTags: (row.tags ?? [])
|
||||
.filter((tag) => tag.name?.trim())
|
||||
.map((tag) => ({ id: tag.tag_key, label: tag.name })),
|
||||
// Its venue's locations, for entries' Map location (088).
|
||||
mapLocations: (venueFromOption(options?.venues?.find((v) => v.id === row.venue_id))?.locations ?? []).map(
|
||||
(location) => ({ id: location.key, label: location.name }),
|
||||
),
|
||||
}),
|
||||
children: [
|
||||
{
|
||||
key: "tags",
|
||||
label: "Tags",
|
||||
addLabel: "Add tag",
|
||||
note: "Tag entries with these, eg. Youth or Worship. Each tag is a tab of its own gathering the entries it's on, and can be shown alone or as a slide when the schedule is presented.",
|
||||
when: { path: "type", value: "schedule" },
|
||||
title: (row) => row.name || "New tag",
|
||||
blank: () => ({ tag_key: crypto.randomUUID().slice(0, 8) }),
|
||||
fields: [
|
||||
{ path: "name", label: "Name", required: true, help: "eg. Youth" },
|
||||
{ path: "color", label: "Color", widget: "color", help: "Default: the event's color" },
|
||||
{ path: "no_tab", label: "No tab", widget: "checkbox", help: "Leave it out of the tabs (it still shows on entries)" },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "map_sections",
|
||||
label: "Sections",
|
||||
addLabel: "Add section",
|
||||
note: "Optional: group the venue's locations for this page, eg. Main spaces, Small group spaces. Visitors can pick one to see only its places on the map. With sections, only the locations they hold are shown. The venue itself is unchanged.",
|
||||
when: { path: "type", value: "map" },
|
||||
title: (row) => row.name || "New section",
|
||||
blank: { name: "" },
|
||||
fields: [
|
||||
{ path: "name", label: "Name", required: true, help: "eg. Main spaces" },
|
||||
{
|
||||
path: "location_keys",
|
||||
label: "Locations",
|
||||
widget: "checklist",
|
||||
optionsFrom: "mapLocations",
|
||||
full: true,
|
||||
emptyNote: "No locations yet: pick the block's Venue, and give it locations under Data → Venues.",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: "items",
|
||||
label: "Items",
|
||||
addLabel: "Add item",
|
||||
when: { path: "type", value: ["list", "links", "schedule", "cards", "people"] },
|
||||
title: (row) => [row.day, row.time, row.text].filter(Boolean).join(" · ") || "New item",
|
||||
when: { path: "type", value: ["list", "links", "schedule", "cards", "people", "events", "organizations"] },
|
||||
title: (row) => [row.day, row.time || row.start_time, row.text].filter(Boolean).join(" · ") || "New item",
|
||||
blank: { text: "" },
|
||||
fields: [
|
||||
{
|
||||
path: "kind",
|
||||
label: "Type",
|
||||
widget: "select",
|
||||
options: SCHEDULE_KINDS,
|
||||
blankLabel: "Default: Normal entry",
|
||||
help: "A block holds several things in one time frame, each a sub-item with its own time. A break is a quieter row (a meal, free time). A heading labels part of the day, eg. Evening sessions.",
|
||||
when: SCHEDULE_ENTRY,
|
||||
},
|
||||
{
|
||||
path: "day",
|
||||
label: "Day",
|
||||
help: "The tab it's under, eg. Friday. Entries with the same day share a tab, in this order.",
|
||||
when: SCHEDULE_ENTRY,
|
||||
},
|
||||
{ path: "time", label: "Time", help: "eg. 7:00pm, or 9:00 to 10:30am", when: SCHEDULE_ENTRY },
|
||||
...scheduleTimeFields(SCHEDULE_ENTRY),
|
||||
// A card: the link first, so Fetch preview can fill the rest.
|
||||
{
|
||||
path: "url",
|
||||
|
|
@ -518,11 +801,38 @@ export const blocksChild = {
|
|||
help: "Shown as a tile with their photo, linked to their page",
|
||||
when: PEOPLE_ITEM,
|
||||
},
|
||||
{ path: "text", label: "Text", required: true, help: "Schedules: the entry's title. Cards: the card's title. People: their title on the tile, eg. Speaker" },
|
||||
{
|
||||
path: "event_id",
|
||||
label: "Event",
|
||||
widget: "select",
|
||||
optionsFrom: "events",
|
||||
fills: "text",
|
||||
required: true,
|
||||
help: "The event the card shows and links to. An unpublished one is left out.",
|
||||
when: EVENT_ITEM,
|
||||
},
|
||||
{
|
||||
path: "org_id",
|
||||
label: "Organization",
|
||||
widget: "select",
|
||||
optionsFrom: "block_orgs",
|
||||
fills: "text",
|
||||
required: true,
|
||||
help: "Shown as its card, in this order. An unpublished one is left out.",
|
||||
when: ORG_ITEM,
|
||||
},
|
||||
eventField(SCHEDULE_ENTRY),
|
||||
{
|
||||
path: "text",
|
||||
label: "Text",
|
||||
required: true,
|
||||
help: "Schedules: the entry's title. Cards: the card's title. Events: the title shown, filled from the event. People: their title on the tile, eg. Speaker. Organizations: filled from it, only the admin shows it",
|
||||
},
|
||||
placeField(SCHEDULE_ENTRY),
|
||||
{
|
||||
path: "location",
|
||||
label: "Location",
|
||||
help: "eg. Main Hall",
|
||||
help: "eg. Main Hall. Default: the map location's name",
|
||||
when: SCHEDULE_ENTRY,
|
||||
},
|
||||
{
|
||||
|
|
@ -536,6 +846,7 @@ export const blocksChild = {
|
|||
},
|
||||
{ path: "detail", label: "Detail", help: "A line under the text. Lists: shown after the text", when: NOT_CARD_ITEM },
|
||||
{ path: "detail", label: "Description", widget: "textarea", full: true, when: CARD_ITEM },
|
||||
{ path: "detail", label: "Card text", widget: "textarea", full: true, help: "Default: the event's card text", when: EVENT_ITEM },
|
||||
{ path: "url", label: "URL", help: "Blank for plain text. Link buttons need one.", files: true, when: NOT_CARD_ITEM },
|
||||
{
|
||||
path: "media",
|
||||
|
|
@ -589,6 +900,28 @@ export const blocksChild = {
|
|||
help: "Optional: your own map, eg. the camp with the room marked. Shown in the fold-out in place of the Google map (which stays a link), and as a slide when the schedule is presented.",
|
||||
when: SCHEDULE_ENTRY,
|
||||
},
|
||||
{ path: "featured", label: "Featured", widget: "checkbox", help: "Makes the row stand out", when: SCHEDULE_ENTRY },
|
||||
{ ...TAGS_FIELD, when: SCHEDULE_ENTRY },
|
||||
{
|
||||
path: "featured",
|
||||
label: "Featured",
|
||||
widget: "checkbox",
|
||||
help: "Shows it opened in full above the cards, under the heading and subheading below",
|
||||
when: EVENT_ITEM,
|
||||
},
|
||||
{ path: "heading", label: "Heading", help: "Featured only, eg. This year's keynote. Default: none", when: EVENT_ITEM },
|
||||
{ path: "subheading", label: "Subheading", help: "Featured only: a line under the heading. Default: none", full: true, when: EVENT_ITEM },
|
||||
],
|
||||
children: [
|
||||
{
|
||||
key: "items",
|
||||
label: "Sub-items",
|
||||
addLabel: "Add sub-item",
|
||||
when: { path: "kind", value: "block" },
|
||||
title: (row) => [row.time || row.start_time, row.text].filter(Boolean).join(" · ") || "New sub-item",
|
||||
blank: { text: "" },
|
||||
fields: SUB_ITEM_FIELDS,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
|
|
|||
82
src/lib/adminSchema/venues.ts
Normal file
82
src/lib/adminSchema/venues.ts
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/* ── Venues (088_venues.sql) ─────────────────────────────────────
|
||||
Data → Venues: a place we gather, with one map picture and the
|
||||
locations marked on it (a pin or a box each). A Map content block
|
||||
draws it; a schedule block names it, and its entries pick one of
|
||||
its locations, linking to the map. Server side:
|
||||
server/src/admin-schema/venues.js. */
|
||||
|
||||
import { mediaUrl } from "../media.ts";
|
||||
|
||||
export const venues = {
|
||||
key: "venues",
|
||||
label: "Venues",
|
||||
singular: "venue",
|
||||
idLabel: "URL ID",
|
||||
slugFrom: "name",
|
||||
|
||||
list: {
|
||||
columns: [
|
||||
{ key: "name", label: "Name", primary: true },
|
||||
{ key: "address", label: "Address" },
|
||||
],
|
||||
filters: [],
|
||||
},
|
||||
|
||||
groups: [
|
||||
{
|
||||
legend: "Venue",
|
||||
fields: [
|
||||
{ path: "name", label: "Name", required: true, help: "eg. Camp Hebron" },
|
||||
{ path: "address", label: "Address", help: "Shown over the list of locations. Optional." },
|
||||
{
|
||||
path: "map_image",
|
||||
label: "Map",
|
||||
widget: "image",
|
||||
crop: "free",
|
||||
resolve: mediaUrl,
|
||||
full: true,
|
||||
help: "One picture of the whole place, eg. the camp's site plan. Locations are marked on it below.",
|
||||
},
|
||||
{
|
||||
path: "map_alt",
|
||||
label: "Map description",
|
||||
full: true,
|
||||
help: "For screen readers. Default: Map of <name>.",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
children: [
|
||||
{
|
||||
key: "locations",
|
||||
label: "Locations",
|
||||
addLabel: "Add location",
|
||||
note: "The places on the map, in the order they're listed. Schedule entries pick one of these.",
|
||||
title: (row) => row.name || "New location",
|
||||
blank: () => ({ location_key: crypto.randomUUID().slice(0, 8) }),
|
||||
fields: [
|
||||
{ path: "name", label: "Name", required: true, help: "eg. Main Hall" },
|
||||
{ path: "detail", label: "Detail", help: "A line under the name, eg. Upstairs, by the dining hall" },
|
||||
{
|
||||
path: "x",
|
||||
label: "On the map",
|
||||
widget: "mapMarker",
|
||||
imageFrom: "map_image",
|
||||
full: true,
|
||||
help: "Click the map for a pin, or drag out a box for an area. Default: listed, not marked.",
|
||||
},
|
||||
{
|
||||
path: "google_maps_url",
|
||||
label: "Google Maps link",
|
||||
help: "eg. https://maps.app.goo.gl/... Shown as a button beside it. Default: none",
|
||||
},
|
||||
{
|
||||
path: "apple_maps_url",
|
||||
label: "Apple Maps link",
|
||||
help: "eg. https://maps.apple.com/?... Shown as a button beside it. Default: none",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
import { visionColor } from "./color.ts";
|
||||
|
||||
const BASE = import.meta.env?.VITE_API_BASE ?? "/api";
|
||||
export const BASE = import.meta.env?.VITE_API_BASE ?? "/api";
|
||||
const DEFAULT_TTL = 60_000;
|
||||
|
||||
/* A draft's preview (server/src/drafts.js): a tab opened from the
|
||||
|
|
|
|||
15
src/lib/darkTheme.ts
Normal file
15
src/lib/darkTheme.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/* Whether the site is in its dark theme: <html data-theme="dark">,
|
||||
set before the first paint (index.html) and by ThemeToggle. A
|
||||
hook, so a page redraws the moment it changes. */
|
||||
|
||||
import { useSyncExternalStore } from 'react'
|
||||
|
||||
const read = () => document.documentElement.dataset.theme === 'dark'
|
||||
|
||||
function subscribe(onChange: () => void) {
|
||||
const observer = new MutationObserver(onChange)
|
||||
observer.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] })
|
||||
return () => observer.disconnect()
|
||||
}
|
||||
|
||||
export const useDarkTheme = (): boolean => useSyncExternalStore(subscribe, read, () => false)
|
||||
10
src/lib/presenting.ts
Normal file
10
src/lib/presenting.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/* Whether the blocks are drawn for a presentation screen
|
||||
(EventPresent.tsx, 095): ContentBlocks leaves out the blocks set to,
|
||||
takes their Presentation text, and draws links as plain text,
|
||||
people as a row of round photos and organizations as logos. */
|
||||
|
||||
import { createContext, useContext } from 'react'
|
||||
|
||||
export const Presenting = createContext(false)
|
||||
|
||||
export const usePresenting = () => useContext(Presenting)
|
||||
|
|
@ -43,6 +43,9 @@ export type ContentBlock = {
|
|||
| 'tab'
|
||||
| 'cards'
|
||||
| 'people'
|
||||
| 'map'
|
||||
| 'events'
|
||||
| 'organizations'
|
||||
text?: string | null
|
||||
media?: string | null
|
||||
href?: string | null
|
||||
|
|
@ -52,11 +55,115 @@ export type ContentBlock = {
|
|||
team_id?: string | null
|
||||
/** Who a quote is by. */
|
||||
cite?: string | null
|
||||
/** A list block's style (092): null bold text, 'plain' the old look. */
|
||||
list_style?: 'plain' | null
|
||||
/** An image block's picture for the dark theme (102). */
|
||||
media_dark?: string | null
|
||||
/** An image block's size (101): null the column's width. */
|
||||
image_size?: 'small' | 'medium' | 'large' | null
|
||||
/** An organizations block's kind, listed when none are picked (093). */
|
||||
org_kind?: 'region' | 'group' | 'partner' | 'ministry' | null
|
||||
/** A video block's WebVTT file, for an uploaded video (066). */
|
||||
captions?: string | null
|
||||
items?: ContentBlockItem[]
|
||||
/** A schedule's own tags (087). */
|
||||
tags?: ScheduleTag[]
|
||||
/** A map or schedule block's venue (088). */
|
||||
venue_id?: string | null
|
||||
venue?: Venue | null
|
||||
/** A map block's own sections of its venue's locations, by key
|
||||
* (094). With any, `venue` holds only the locations they name. */
|
||||
map_sections?: MapSection[]
|
||||
/** How it's presented (095); null with nothing set. */
|
||||
present?: BlockPresent | null
|
||||
}
|
||||
|
||||
/** A block's presentation settings (095), EventPresent.tsx. */
|
||||
export type BlockPresent = {
|
||||
/** A people block: each one's role or title under their name, as
|
||||
* the Present setup picks (not stored). */
|
||||
titles?: boolean
|
||||
/** Only on the page: left out of the presentation (099). */
|
||||
hide: boolean
|
||||
/** Only in the presentation: left off the page (099). */
|
||||
only: boolean
|
||||
/** In place of its text, eg. a shorter heading. */
|
||||
text: string | null
|
||||
/** A map: a slide per map section. */
|
||||
map_split: boolean
|
||||
map_no_list: boolean
|
||||
map_no_details: boolean
|
||||
/** A map: which locations get a slide; null every marked one. */
|
||||
places: 'picked' | 'none' | null
|
||||
place_keys: string[]
|
||||
}
|
||||
|
||||
/** An event's presentation look (095). */
|
||||
export type EventPresentLook = {
|
||||
background: string | null
|
||||
background_color: string | null
|
||||
/** Percent of the color over the image; null 60. */
|
||||
dim: number | null
|
||||
/** null the accent bar, title line and timer. */
|
||||
frame: 'border' | 'none' | null
|
||||
accent: string | null
|
||||
text_color: string | null
|
||||
logo: string | null
|
||||
/** Room clear at each edge (097): percent of the screen's height
|
||||
* (top, bottom) and width (left, right); null none. */
|
||||
inset?: { top: number; right: number; bottom: number; left: number } | null
|
||||
/** In the dark theme (096); a null one takes the above. */
|
||||
dark?: Partial<Omit<EventPresentLook, 'frame' | 'dark' | 'inset'>>
|
||||
}
|
||||
|
||||
export type MapSection = { name: string; keys: string[] }
|
||||
|
||||
/** A venue (088): its map picture and the locations marked on it,
|
||||
* each a pin (x, y) or a box (x, y, w, h), in percent. */
|
||||
export type Venue = {
|
||||
id: string
|
||||
name: string
|
||||
address?: string | null
|
||||
map_image?: string | null
|
||||
map_alt?: string | null
|
||||
locations: VenueLocation[]
|
||||
}
|
||||
export type VenueLocation = {
|
||||
key: string
|
||||
name: string
|
||||
detail?: string | null
|
||||
x?: number | null
|
||||
y?: number | null
|
||||
w?: number | null
|
||||
h?: number | null
|
||||
/** The place in Google and Apple Maps (091). */
|
||||
google_maps_url?: string | null
|
||||
apple_maps_url?: string | null
|
||||
}
|
||||
|
||||
/** An event an item names (088): an events block's card, or the
|
||||
* workshop a schedule entry is. */
|
||||
export type ItemEvent = {
|
||||
id: string
|
||||
title: string
|
||||
event_type?: string | null
|
||||
starts_on?: string | null
|
||||
ends_on?: string | null
|
||||
date_label?: string | null
|
||||
color?: string | null
|
||||
image?: string | null
|
||||
/** Its own 16:9 photo, and where it is, for showing it in full. */
|
||||
photo?: string | null
|
||||
photo_alt?: string | null
|
||||
location_label?: string | null
|
||||
blurb?: string | null
|
||||
/** Its own page's blocks: an events block's events only. */
|
||||
blocks?: ContentBlock[]
|
||||
}
|
||||
|
||||
/** A schedule's tag (087). `tab` is whether it gets a tab of its own. */
|
||||
export type ScheduleTag = { key: string; name: string; color?: string | null; tab: boolean }
|
||||
|
||||
/** A list, link-row or schedule entry. The schedule fields are
|
||||
* empty on the other two (034_schedule_block.sql). */
|
||||
export type ContentBlockItem = {
|
||||
|
|
@ -74,6 +181,26 @@ export type ContentBlockItem = {
|
|||
/** The entry's own map picture (069), shown in place of Google's. */
|
||||
map_image?: string | null
|
||||
person?: { id: string; name: string; photo?: string | null; tagline?: string | null } | null
|
||||
/** A schedule entry's kind (086); sub-items have none. */
|
||||
kind?: 'entry' | 'block' | 'break' | 'heading'
|
||||
/** Picked times, HH:MM; `time` is already what to show. */
|
||||
start_time?: string | null
|
||||
end_time?: string | null
|
||||
featured?: boolean
|
||||
/** A featured event's heading and subheading (090). */
|
||||
heading?: string | null
|
||||
subheading?: string | null
|
||||
/** An organizations block's organization (093). */
|
||||
org_id?: string | null
|
||||
/** A block entry's sub-items. */
|
||||
items?: ContentBlockItem[]
|
||||
/** Its block's tags it has, by key (087). */
|
||||
tags?: string[]
|
||||
/** The event it is, and its place on the block's venue (088). */
|
||||
event_id?: string | null
|
||||
event?: ItemEvent | null
|
||||
location_key?: string | null
|
||||
place?: { venue_id: string; key: string; name: string } | null
|
||||
}
|
||||
|
||||
export type Link = {
|
||||
|
|
@ -159,6 +286,12 @@ export type EventRecord = {
|
|||
links: Link[]
|
||||
/** The instagram link's label, the handle. See splitLinks in shape.js. */
|
||||
instagram?: string | null
|
||||
/** Its headings listed beside the blocks (089). */
|
||||
show_contents?: boolean
|
||||
/** Above the link buttons; null shows none (089). */
|
||||
links_heading?: string | null
|
||||
/** Its page presented (095). */
|
||||
present?: EventPresentLook
|
||||
blocks: ContentBlock[]
|
||||
people: EventPerson[]
|
||||
awards: EventAward[]
|
||||
|
|
|
|||
88
src/lib/useScreenRemote.ts
Normal file
88
src/lib/useScreenRemote.ts
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/* A presenting screen's link to its remotes (server/src/routes/
|
||||
present.js, src/pages/PresentRemote.tsx): the code to show, the
|
||||
commands as they come, and `report` for what the screen shows.
|
||||
The code and its key are kept in this browser, so a reload or a
|
||||
restart of the server keeps the same code. */
|
||||
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
|
||||
import { BASE, post } from './api.ts'
|
||||
|
||||
export type RemoteCommand = {
|
||||
do: 'next' | 'prev' | 'pause' | 'resume' | 'go' | 'setup' | 'start'
|
||||
index?: number
|
||||
query?: string
|
||||
}
|
||||
|
||||
export type ScreenState = {
|
||||
event: string
|
||||
title: string
|
||||
// EventPresent's address query: the setup's choices.
|
||||
query: string
|
||||
playing: boolean
|
||||
paused: boolean
|
||||
index: number
|
||||
// Each slide's name, in order.
|
||||
slides: string[]
|
||||
}
|
||||
|
||||
const STORE = 'present-remote'
|
||||
const RETRY = 3000
|
||||
|
||||
export function useScreenRemote(onCommand: (command: RemoteCommand) => void) {
|
||||
const [code, setCode] = useState<string | null>(null)
|
||||
const link = useRef<{ code: string; key: string } | null>(null)
|
||||
const last = useRef<ScreenState | null>(null)
|
||||
const handler = useRef(onCommand)
|
||||
handler.current = onCommand
|
||||
|
||||
const send = (state: ScreenState) => {
|
||||
const l = link.current
|
||||
if (l) post(`/present/${l.code}/state`, { key: l.key, ...state }).catch(() => {})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
let source: EventSource | null = null
|
||||
let retry = 0
|
||||
const open = () => {
|
||||
let saved: Record<string, string> = {}
|
||||
try {
|
||||
saved = JSON.parse(localStorage.getItem(STORE) ?? '{}')
|
||||
} catch {
|
||||
// Nothing kept: the server gives a new code.
|
||||
}
|
||||
source = new EventSource(`${BASE}/present/screen?${new URLSearchParams(saved)}`)
|
||||
source.addEventListener('hello', (e) => {
|
||||
link.current = JSON.parse((e as MessageEvent).data)
|
||||
setCode(link.current!.code)
|
||||
try {
|
||||
localStorage.setItem(STORE, JSON.stringify(link.current))
|
||||
} catch {
|
||||
// Kept for this visit only.
|
||||
}
|
||||
if (last.current) send(last.current)
|
||||
})
|
||||
source.addEventListener('command', (e) => handler.current(JSON.parse((e as MessageEvent).data)))
|
||||
// Reopened by hand, so it asks for its code again.
|
||||
source.onerror = () => {
|
||||
source?.close()
|
||||
link.current = null
|
||||
retry = window.setTimeout(open, RETRY)
|
||||
}
|
||||
}
|
||||
open()
|
||||
return () => {
|
||||
window.clearTimeout(retry)
|
||||
source?.close()
|
||||
}
|
||||
}, [])
|
||||
|
||||
const report = useCallback((state: ScreenState) => {
|
||||
// Unchanged, eg. the page drawn again for something else.
|
||||
if (JSON.stringify(state) === JSON.stringify(last.current)) return
|
||||
last.current = state
|
||||
send(state)
|
||||
}, [])
|
||||
|
||||
return { code, report }
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
A version with no words after its number has no name.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
export const SITE_VERSION = "NGU-Web.v1.14.0-profiles";
|
||||
export const SITE_VERSION = "NGU-Web.v1.14.2-present";
|
||||
|
||||
/** The number, eg. v1.13.2. */
|
||||
export const VERSION_NUMBER: string = SITE_VERSION.match(/v\d+(?:\.\d+)*/)?.[0] ?? SITE_VERSION
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ import PageShell, { type ShellSection } from '../components/PageShell.tsx'
|
|||
import PageState from '../components/PageState.tsx'
|
||||
import PlatformIcon from '../components/PlatformIcon.tsx'
|
||||
import ContentBlocks from '../components/ContentBlocks.tsx'
|
||||
import PostContents from '../components/PostContents.tsx'
|
||||
import { headingAnchors } from '../lib/contents.ts'
|
||||
import Tags from '../components/Tags.tsx'
|
||||
import PeopleTiles, { type PeopleGroupInput } from '../components/PeopleTiles.tsx'
|
||||
import {
|
||||
|
|
@ -35,7 +37,8 @@ import { mediaUrl } from '../lib/media.ts'
|
|||
import { eventTypeLabel } from '../lib/eventTypes.ts'
|
||||
import { occurrenceLabel, seriesLabel, seriesTimes, upcomingOccurrences } from '../lib/eventSeries.ts'
|
||||
import { capitalize } from '../lib/text.ts'
|
||||
import { accentText, readableOn, BRAND } from '../lib/color.ts'
|
||||
import { accentText, readableOn, withAlpha, BRAND } from '../lib/color.ts'
|
||||
import { Presentation } from '@phosphor-icons/react'
|
||||
|
||||
const BODY = 'var(--color-muted)'
|
||||
|
||||
|
|
@ -88,6 +91,12 @@ export default function EventDetail() {
|
|||
|
||||
const accent = event.color || BRAND
|
||||
const groups = peopleGroups(event.people, accent)
|
||||
// Two headings or more make a list worth showing, as on a post.
|
||||
// Not a heading shown only in the presentation (099).
|
||||
const contents = event.show_contents
|
||||
? headingAnchors(event.blocks.filter((block) => !block.present?.only)).entries
|
||||
: []
|
||||
const withContents = contents.length >= 2
|
||||
|
||||
const sections: ShellSection[] = [
|
||||
{
|
||||
|
|
@ -104,15 +113,41 @@ export default function EventDetail() {
|
|||
<img
|
||||
src={mediaUrl(event.photo) ?? ''}
|
||||
alt={event.photo_alt ?? ''}
|
||||
className="aspect-video w-full max-w-3xl object-cover"
|
||||
className="aspect-video w-full object-cover"
|
||||
/>
|
||||
)}
|
||||
|
||||
<div className="max-w-3xl">
|
||||
<ContentBlocks blocks={event.blocks} accent={accent} presentAt={`/events/${encodeURIComponent(event.id)}/present`} />
|
||||
{/* The blocks take the column's whole width, beside the
|
||||
contents list when it shows. */}
|
||||
<div className={withContents ? 'grid gap-8 lg:grid-cols-[14rem_minmax(0,1fr)] lg:gap-12 print:block' : undefined}>
|
||||
{withContents && <PostContents entries={contents} />}
|
||||
<div className="min-w-0">
|
||||
{/* The page as a slideshow for a screen (EventPresent.tsx). */}
|
||||
{event.blocks.length > 0 && (
|
||||
<div className="mb-6 flex justify-end">
|
||||
<Link
|
||||
to={`/events/${encodeURIComponent(event.id)}/present`}
|
||||
target="_blank"
|
||||
className="btn inline-flex items-center gap-2 border px-4 py-2 text-sm transition-colors hover:bg-tint"
|
||||
style={{ borderColor: withAlpha(accent, 33), color: accentText(accent) }}
|
||||
>
|
||||
<Presentation aria-hidden="true" weight="bold" className="h-4 w-4" />
|
||||
Present
|
||||
<span className="sr-only">(opens in a new tab)</span>
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
<ContentBlocks blocks={event.blocks} accent={accent} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{event.links.length > 0 && (
|
||||
<div className="space-y-4">
|
||||
{event.links_heading && (
|
||||
<h3 className="text-2xl font-bold" style={{ color: accentText(accent) }}>
|
||||
{event.links_heading}
|
||||
</h3>
|
||||
)}
|
||||
<div className="flex flex-wrap gap-3">
|
||||
{event.links.map((link) => (
|
||||
<a
|
||||
|
|
@ -128,6 +163,7 @@ export default function EventDetail() {
|
|||
</a>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* The schedule presentation's motion (SchedulePresent.tsx). The
|
||||
/* The event presentation's motion (EventPresent.tsx). The
|
||||
reduced motion rule in index.css stops all of it. */
|
||||
|
||||
.present-in {
|
||||
|
|
@ -38,3 +38,24 @@
|
|||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
/* A slide part taller than its room (Scroll): moves up by
|
||||
--present-scroll at a steady pace; its wait at the top is the
|
||||
inline animation-delay, and it stays at the end after. With
|
||||
reduced motion it stays at the top. */
|
||||
.present-scroll {
|
||||
animation: present-scroll linear both;
|
||||
}
|
||||
@keyframes present-scroll {
|
||||
from {
|
||||
transform: none;
|
||||
}
|
||||
to {
|
||||
transform: translateY(var(--present-scroll));
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.present-scroll {
|
||||
animation: none !important;
|
||||
}
|
||||
}
|
||||
2200
src/pages/EventPresent.tsx
Normal file
2200
src/pages/EventPresent.tsx
Normal file
File diff suppressed because it is too large
Load diff
250
src/pages/PresentRemote.tsx
Normal file
250
src/pages/PresentRemote.tsx
Normal file
|
|
@ -0,0 +1,250 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
PRESENT REMOTE: /remote and /remote/:code
|
||||
|
||||
A phone driving a presenting screen (EventPresent.tsx) by the
|
||||
code the screen shows (server/src/routes/present.js): what's on
|
||||
it now, back, pause and next, any slide by name, back to its
|
||||
setup, and the setup itself (EventPresent's Setup), whose Play
|
||||
starts the screen with those choices. Anyone with the code can.
|
||||
Outside the site's Layout, like the presentation.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { ArrowLeft, CaretLeft, CaretRight, Gear, Pause, Play, SlidersHorizontal } from '@phosphor-icons/react'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
|
||||
import { Setup, addressFor, readSettings, schedulesOf, sectionsOf } from './EventPresent.tsx'
|
||||
import { BASE, post } from '../lib/api.ts'
|
||||
import { useEvent } from '../lib/useContent.ts'
|
||||
import { BRAND, accentText } from '../lib/color.ts'
|
||||
import { documentTitle } from '../lib/site.ts'
|
||||
import type { RemoteCommand, ScreenState } from '../lib/useScreenRemote.ts'
|
||||
|
||||
type Seen = ScreenState & { connected: boolean }
|
||||
|
||||
export default function PresentRemote() {
|
||||
const { code } = useParams()
|
||||
|
||||
useEffect(() => {
|
||||
document.title = documentTitle('Remote')
|
||||
}, [])
|
||||
|
||||
return code ? <Connected code={code.toUpperCase()} /> : <EnterCode />
|
||||
}
|
||||
|
||||
function EnterCode() {
|
||||
const navigate = useNavigate()
|
||||
const [code, setCode] = useState('')
|
||||
return (
|
||||
<main className="flex min-h-screen items-center justify-center bg-surface px-4 text-body">
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault()
|
||||
if (code.trim()) navigate(`/remote/${encodeURIComponent(code.trim().toUpperCase())}`)
|
||||
}}
|
||||
className="w-full max-w-sm space-y-4 bg-raised p-6 shadow-md"
|
||||
>
|
||||
<h1 className="text-2xl font-bold text-ink">Remote</h1>
|
||||
<label className="block">
|
||||
<span className="text-sm text-muted">The code on the screen (with its controls, or on its setup)</span>
|
||||
<input
|
||||
value={code}
|
||||
onChange={(e) => setCode(e.target.value)}
|
||||
autoFocus
|
||||
autoCapitalize="characters"
|
||||
autoComplete="off"
|
||||
maxLength={6}
|
||||
className="mt-1 w-full border border-muted/25 bg-surface px-3 py-2 font-mono text-2xl tracking-widest uppercase"
|
||||
/>
|
||||
</label>
|
||||
<button type="submit" className="btn w-full bg-action px-5 py-3 text-white">
|
||||
Connect
|
||||
</button>
|
||||
</form>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
function Connected({ code }: { code: string }) {
|
||||
const [seen, setSeen] = useState<Seen | null>(null)
|
||||
const [lost, setLost] = useState(false)
|
||||
const [tries, setTries] = useState(0)
|
||||
const [problem, setProblem] = useState('')
|
||||
const [editing, setEditing] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
setLost(false)
|
||||
const source = new EventSource(`${BASE}/present/${encodeURIComponent(code)}`)
|
||||
source.addEventListener('state', (e) => setSeen(JSON.parse((e as MessageEvent).data)))
|
||||
// Closed is the server's no (no such code); otherwise it retries.
|
||||
source.onerror = () => source.readyState === EventSource.CLOSED && setLost(true)
|
||||
return () => source.close()
|
||||
}, [code, tries])
|
||||
|
||||
const { data: event } = useEvent(seen?.event || undefined)
|
||||
const sections = useMemo(() => (event ? sectionsOf(event.blocks ?? [], event.title) : []), [event])
|
||||
const schedules = useMemo(() => schedulesOf(event?.blocks ?? []), [event])
|
||||
|
||||
const send = (command: RemoteCommand) => {
|
||||
setProblem('')
|
||||
post(`/present/${encodeURIComponent(code)}/command`, command).catch((err) => setProblem(err.message))
|
||||
}
|
||||
|
||||
if (lost) {
|
||||
return (
|
||||
<main className="flex min-h-screen flex-col items-center justify-center gap-4 bg-surface px-4 text-body">
|
||||
<p className="notice">No screen has the code {code} right now.</p>
|
||||
<div className="flex gap-3">
|
||||
<button type="button" onClick={() => setTries((n) => n + 1)} className="btn border border-muted/25 px-5 py-2 text-ink">
|
||||
Try again
|
||||
</button>
|
||||
<a href="/remote" className="btn border border-muted/25 px-5 py-2 text-ink">
|
||||
Another code
|
||||
</a>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
const accent = event?.present?.accent || event?.color || BRAND
|
||||
|
||||
if (editing && seen?.event && event) {
|
||||
return (
|
||||
<>
|
||||
<div className="sticky top-0 z-10 flex items-center gap-3 bg-raised px-4 py-3 shadow-md">
|
||||
<button type="button" onClick={() => setEditing(false)} className="btn inline-flex items-center gap-2 px-3 py-2 text-ink">
|
||||
<ArrowLeft aria-hidden="true" weight="bold" className="h-4 w-4" />
|
||||
Remote
|
||||
</button>
|
||||
<span className="text-sm text-muted">Play starts the screen with these choices.</span>
|
||||
</div>
|
||||
<Setup
|
||||
// Fresh choices each time the screen's setup changes.
|
||||
key={seen.query}
|
||||
title={event.title}
|
||||
back={`/events/${encodeURIComponent(event.id)}`}
|
||||
accent={accent}
|
||||
sections={sections}
|
||||
schedules={schedules}
|
||||
settings={readSettings(new URLSearchParams(seen.query))}
|
||||
onPlay={(next) => {
|
||||
send({ do: 'start', query: addressFor(next).toString() })
|
||||
setEditing(false)
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
const control = 'btn flex h-16 flex-1 items-center justify-center bg-raised text-ink shadow-md disabled:opacity-50'
|
||||
const playing = !!seen?.event && seen.playing
|
||||
const off = !seen?.connected
|
||||
return (
|
||||
<main className="min-h-screen bg-surface text-body">
|
||||
<div className="h-2" style={{ background: accent }} />
|
||||
<div className="mx-auto max-w-lg space-y-6 px-4 py-6">
|
||||
<header>
|
||||
<p className="text-sm font-semibold text-muted">
|
||||
Remote <span className="font-mono tracking-widest">{code}</span>
|
||||
</p>
|
||||
<h1 className="text-2xl font-bold" style={{ color: accentText(accent) }}>
|
||||
{seen?.event ? seen.title : 'Connecting…'}
|
||||
</h1>
|
||||
</header>
|
||||
|
||||
{seen && off && <p className="notice">The screen isn't connected right now. This page carries on when it is.</p>}
|
||||
|
||||
{seen?.event && (
|
||||
<p className="bg-raised p-4 shadow-sm" aria-live="polite">
|
||||
{playing ? (
|
||||
<>
|
||||
<span className="block text-sm text-muted">
|
||||
Slide {seen.index + 1} of {seen.slides.length}
|
||||
{seen.paused ? ', paused' : ''}
|
||||
</span>
|
||||
<span className="font-semibold text-ink">{seen.slides[seen.index]}</span>
|
||||
</>
|
||||
) : (
|
||||
<span className="text-muted">The screen is on its setup. Change the setup to pick what it plays.</span>
|
||||
)}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{seen && playing && (
|
||||
<div className="flex gap-3">
|
||||
<button type="button" disabled={off} onClick={() => send({ do: 'prev' })} className={control} aria-label="Previous slide">
|
||||
<CaretLeft weight="bold" className="h-6 w-6" aria-hidden="true" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
disabled={off}
|
||||
onClick={() => send({ do: seen.paused ? 'resume' : 'pause' })}
|
||||
className={control}
|
||||
aria-label={seen.paused ? 'Play' : 'Pause'}
|
||||
>
|
||||
{seen.paused ? (
|
||||
<Play weight="fill" className="h-6 w-6" aria-hidden="true" />
|
||||
) : (
|
||||
<Pause weight="bold" className="h-6 w-6" aria-hidden="true" />
|
||||
)}
|
||||
</button>
|
||||
<button type="button" disabled={off} onClick={() => send({ do: 'next' })} className={control} aria-label="Next slide">
|
||||
<CaretRight weight="bold" className="h-6 w-6" aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{seen?.event && (
|
||||
<div className="flex flex-wrap gap-3">
|
||||
<button
|
||||
type="button"
|
||||
disabled={off || !event}
|
||||
onClick={() => setEditing(true)}
|
||||
className="btn inline-flex items-center gap-2 border border-muted/25 px-4 py-2 text-ink disabled:opacity-50"
|
||||
>
|
||||
<SlidersHorizontal aria-hidden="true" weight="bold" className="h-4 w-4" />
|
||||
Change setup
|
||||
</button>
|
||||
{playing && (
|
||||
<button
|
||||
type="button"
|
||||
disabled={off}
|
||||
onClick={() => send({ do: 'setup' })}
|
||||
className="btn inline-flex items-center gap-2 border border-muted/25 px-4 py-2 text-ink disabled:opacity-50"
|
||||
>
|
||||
<Gear aria-hidden="true" weight="bold" className="h-4 w-4" />
|
||||
Screen to its setup
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<p role="status" className="text-sm text-muted">
|
||||
{problem}
|
||||
</p>
|
||||
|
||||
{seen && playing && seen.slides.length > 0 && (
|
||||
<section>
|
||||
<h2 className="mb-2 text-lg font-bold text-ink">Go to a slide</h2>
|
||||
<ol className="divide-y divide-muted/15 bg-raised shadow-sm">
|
||||
{seen.slides.map((name, i) => (
|
||||
<li key={i}>
|
||||
<button
|
||||
type="button"
|
||||
disabled={off}
|
||||
onClick={() => send({ do: 'go', index: i })}
|
||||
aria-current={i === seen.index ? 'true' : undefined}
|
||||
className={`flex w-full gap-3 px-4 py-3 text-left hover:bg-tint ${i === seen.index ? 'bg-tint font-semibold text-ink' : ''}`}
|
||||
>
|
||||
<span className="w-6 shrink-0 text-right text-muted">{i + 1}</span>
|
||||
<span>{name}</span>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</section>
|
||||
)}
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
|
@ -1,550 +0,0 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
SCHEDULE PRESENTATION: /events/:id/present?block=<n>
|
||||
|
||||
An event's schedule block as an endless slideshow for a screen
|
||||
(digital signage), opened from the block's Present button. Outside
|
||||
the site's Layout: no header, footer or backdrop.
|
||||
|
||||
First a setup screen: which days and entries, and how many seconds
|
||||
each kind of slide stays up (0 leaves that kind out). Play writes
|
||||
the choices into the address, so a signage device can bookmark it
|
||||
and start the same way every time (`play=1` skips the setup).
|
||||
|
||||
The slides, for each day picked, in order:
|
||||
overview the day's picked entries on one slide
|
||||
spotlight one entry: its person beside title, time and place
|
||||
graphic an entry's graphic, full screen
|
||||
map an entry's own map image (069), full screen
|
||||
|
||||
Keys while playing: arrows step, Space pauses, Escape leaves full
|
||||
screen (the browser's), S goes back to the setup.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { ArrowsOut, CaretLeft, CaretRight, Gear, Pause, Play } from '@phosphor-icons/react'
|
||||
import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
|
||||
import { useParams, useSearchParams } from 'react-router-dom'
|
||||
|
||||
import PageState from '../components/PageState.tsx'
|
||||
import { Avatar, groupByDay, mapAlt, type Day } from '../components/ScheduleBlock.tsx'
|
||||
import { Paragraphs } from '../components/InlineText.tsx'
|
||||
import { useEvent, type ContentBlockItem } from '../lib/useContent.ts'
|
||||
import { mediaUrl } from '../lib/media.ts'
|
||||
import { BRAND, accentText, readableOn } from '../lib/color.ts'
|
||||
import { documentTitle } from '../lib/site.ts'
|
||||
import './SchedulePresent.css'
|
||||
|
||||
/* Each kind of slide, its address key and seconds when unset. */
|
||||
const KINDS = [
|
||||
{ key: 'overview', label: 'Day overview', help: 'The whole day on one slide', seconds: 20 },
|
||||
{ key: 'spotlight', label: 'Entry spotlight', help: 'One entry at a time, with its person', seconds: 12 },
|
||||
{ key: 'graphic', label: 'Graphics', help: "An entry's graphic, full screen", seconds: 10 },
|
||||
{ key: 'map', label: 'Map images', help: "An entry's own map, full screen", seconds: 10 },
|
||||
] as const
|
||||
type Kind = (typeof KINDS)[number]['key']
|
||||
|
||||
/* An overview with more entries than this goes to two columns. */
|
||||
const ONE_COLUMN = 8
|
||||
/* How long the controls stay up after the pointer last moved (ms). */
|
||||
const CONTROLS_FOR = 2500
|
||||
|
||||
type Slide = { kind: Kind; seconds: number; day: Day; entry?: ContentBlockItem }
|
||||
|
||||
/* An entry's key in the address: day index, a dot, entry index. */
|
||||
const entryKey = (day: number, entry: number) => `${day}.${entry}`
|
||||
const list = (value: string | null) => (value ? value.split(',').filter(Boolean) : null)
|
||||
|
||||
function readSettings(params: URLSearchParams, days: Day[]) {
|
||||
const pickedDays = list(params.get('days'))?.map(Number) ?? days.map((_, i) => i)
|
||||
const hidden = new Set(list(params.get('hide')) ?? [])
|
||||
const seconds = Object.fromEntries(
|
||||
KINDS.map((kind) => {
|
||||
const value = Number(params.get(kind.key) ?? kind.seconds)
|
||||
return [kind.key, Number.isFinite(value) && value > 0 ? value : 0]
|
||||
}),
|
||||
) as Record<Kind, number>
|
||||
return { pickedDays: new Set(pickedDays), hidden, seconds }
|
||||
}
|
||||
type Settings = ReturnType<typeof readSettings>
|
||||
|
||||
function buildSlides(days: Day[], { pickedDays, hidden, seconds }: Settings): Slide[] {
|
||||
const slides: Slide[] = []
|
||||
days.forEach((all, d) => {
|
||||
if (!pickedDays.has(d)) return
|
||||
const day = { ...all, entries: all.entries.filter((_, e) => !hidden.has(entryKey(d, e))) }
|
||||
if (day.entries.length === 0) return
|
||||
if (seconds.overview) slides.push({ kind: 'overview', seconds: seconds.overview, day })
|
||||
for (const entry of day.entries) {
|
||||
if (seconds.spotlight) slides.push({ kind: 'spotlight', seconds: seconds.spotlight, day, entry })
|
||||
if (seconds.graphic && entry.media) slides.push({ kind: 'graphic', seconds: seconds.graphic, day, entry })
|
||||
if (seconds.map && entry.map_image) slides.push({ kind: 'map', seconds: seconds.map, day, entry })
|
||||
}
|
||||
})
|
||||
return slides
|
||||
}
|
||||
|
||||
export default function SchedulePresent() {
|
||||
const { id } = useParams()
|
||||
const [params, setParams] = useSearchParams()
|
||||
const { data: event, loading, error, notFound, reload } = useEvent(id)
|
||||
|
||||
const blockIndex = Number(params.get('block') ?? 0)
|
||||
const schedule = event?.blocks?.filter((block) => block.type === 'schedule')[blockIndex]
|
||||
const days = useMemo(() => groupByDay(schedule?.items ?? []), [schedule])
|
||||
|
||||
useEffect(() => {
|
||||
if (event) document.title = documentTitle(`${event.title}: schedule`)
|
||||
}, [event])
|
||||
|
||||
if (!event) {
|
||||
return (
|
||||
<PageState
|
||||
loading={loading}
|
||||
error={error}
|
||||
notFound={notFound}
|
||||
onRetry={reload}
|
||||
noun="retreat"
|
||||
backTo="/retreats"
|
||||
backLabel="All retreats"
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
const accent = event.color || BRAND
|
||||
const back = `/events/${encodeURIComponent(event.id)}`
|
||||
|
||||
if (!schedule || days.length === 0) {
|
||||
return (
|
||||
<main className="min-h-screen bg-surface p-8">
|
||||
<p className="notice">This event has no schedule to present.</p>
|
||||
<a href={back} className="mt-4 inline-block text-link underline">
|
||||
Back to {event.title}
|
||||
</a>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
const settings = readSettings(params, days)
|
||||
if (params.get('play') === '1') {
|
||||
return (
|
||||
<Player
|
||||
title={event.title}
|
||||
accent={accent}
|
||||
slides={buildSlides(days, settings)}
|
||||
onSetup={() => {
|
||||
const next = new URLSearchParams(params)
|
||||
next.delete('play')
|
||||
setParams(next)
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<Setup
|
||||
title={event.title}
|
||||
back={back}
|
||||
accent={accent}
|
||||
days={days}
|
||||
settings={settings}
|
||||
onPlay={(next) => {
|
||||
// Full screen needs the click itself, so it's asked for here.
|
||||
document.documentElement.requestFullscreen?.().catch(() => {})
|
||||
const out = new URLSearchParams({ block: String(blockIndex) })
|
||||
if (next.pickedDays.size < days.length) out.set('days', [...next.pickedDays].sort((a, b) => a - b).join(','))
|
||||
if (next.hidden.size) out.set('hide', [...next.hidden].join(','))
|
||||
for (const kind of KINDS) out.set(kind.key, String(next.seconds[kind.key]))
|
||||
out.set('play', '1')
|
||||
setParams(out)
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
/* ── Setup ──────────────────────────────────────────────────── */
|
||||
|
||||
function Setup({
|
||||
title,
|
||||
back,
|
||||
accent,
|
||||
days,
|
||||
settings,
|
||||
onPlay,
|
||||
}: {
|
||||
title: string
|
||||
back: string
|
||||
accent: string
|
||||
days: Day[]
|
||||
settings: Settings
|
||||
onPlay: (settings: Settings) => void
|
||||
}) {
|
||||
const [pickedDays, setPickedDays] = useState(settings.pickedDays)
|
||||
const [hidden, setHidden] = useState(settings.hidden)
|
||||
const [seconds, setSeconds] = useState(settings.seconds)
|
||||
const count = buildSlides(days, { pickedDays, hidden, seconds }).length
|
||||
|
||||
const toggle = <T,>(set: Set<T>, value: T) => {
|
||||
const next = new Set(set)
|
||||
if (next.has(value)) next.delete(value)
|
||||
else next.add(value)
|
||||
return next
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="min-h-screen bg-surface text-body">
|
||||
<div className="h-2" style={{ background: accent }} />
|
||||
<div className="mx-auto max-w-4xl space-y-10 px-6 py-12">
|
||||
<header>
|
||||
<p className="text-sm font-semibold text-muted">Present the schedule</p>
|
||||
<h1 className="text-4xl font-bold" style={{ color: accentText(accent) }}>
|
||||
{title}
|
||||
</h1>
|
||||
<p className="mt-2 text-muted">
|
||||
Pick what to show and for how long, then Play. It loops until you stop it. Bookmark the address after
|
||||
pressing Play to start a screen the same way next time.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<section>
|
||||
<h2 className="mb-4 text-2xl font-bold text-ink">Slides</h2>
|
||||
<div className="grid gap-4 sm:grid-cols-2">
|
||||
{KINDS.map((kind) => (
|
||||
<label key={kind.key} className="flex items-center gap-4 bg-raised p-4 shadow-sm">
|
||||
<span className="flex-1">
|
||||
<span className="block font-semibold text-ink">{kind.label}</span>
|
||||
<span className="text-sm text-muted">{kind.help}</span>
|
||||
</span>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
max={600}
|
||||
value={seconds[kind.key]}
|
||||
onChange={(e) => setSeconds({ ...seconds, [kind.key]: Math.max(0, Number(e.target.value) || 0) })}
|
||||
className="w-20 border border-muted/25 bg-surface px-2 py-1 text-right"
|
||||
aria-describedby={`${kind.key}-unit`}
|
||||
/>
|
||||
<span id={`${kind.key}-unit`} className="text-sm text-muted">
|
||||
sec
|
||||
</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
<p className="mt-2 text-sm text-muted">0 leaves that kind of slide out.</p>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2 className="mb-4 text-2xl font-bold text-ink">Days and entries</h2>
|
||||
<div className="space-y-6">
|
||||
{days.map((day, d) => (
|
||||
<fieldset key={d} className="bg-raised p-4 shadow-sm">
|
||||
<legend className="sr-only">{day.name || 'Schedule'}</legend>
|
||||
<label className="flex items-center gap-3 font-bold text-ink">
|
||||
<input type="checkbox" checked={pickedDays.has(d)} onChange={() => setPickedDays(toggle(pickedDays, d))} />
|
||||
{day.name || 'Schedule'}
|
||||
</label>
|
||||
<ul className="mt-3 space-y-2 pl-7">
|
||||
{day.entries.map((entry, e) => (
|
||||
<li key={e}>
|
||||
<label className={`flex items-baseline gap-3 ${pickedDays.has(d) ? '' : 'opacity-50'}`}>
|
||||
<input
|
||||
type="checkbox"
|
||||
disabled={!pickedDays.has(d)}
|
||||
checked={!hidden.has(entryKey(d, e))}
|
||||
onChange={() => setHidden(toggle(hidden, entryKey(d, e)))}
|
||||
/>
|
||||
<span className="w-32 shrink-0 text-sm text-muted">{entry.time}</span>
|
||||
<span>{entry.text}</span>
|
||||
</label>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</fieldset>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-4">
|
||||
<button
|
||||
type="button"
|
||||
disabled={count === 0}
|
||||
onClick={() => onPlay({ pickedDays, hidden, seconds })}
|
||||
className="btn inline-flex items-center gap-2 px-6 py-3 disabled:opacity-50"
|
||||
style={{ background: accent, color: readableOn(accent) }}
|
||||
>
|
||||
<Play aria-hidden="true" weight="fill" className="h-5 w-5" />
|
||||
Play
|
||||
</button>
|
||||
<span className="text-sm text-muted">
|
||||
{count === 0 ? 'Nothing picked to show.' : `${count} slide${count === 1 ? '' : 's'} in the loop`}
|
||||
</span>
|
||||
<a href={back} className="ml-auto text-sm text-link underline">
|
||||
Back to the event
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
/* ── Player ─────────────────────────────────────────────────── */
|
||||
|
||||
function Player({
|
||||
title,
|
||||
accent,
|
||||
slides,
|
||||
onSetup,
|
||||
}: {
|
||||
title: string
|
||||
accent: string
|
||||
slides: Slide[]
|
||||
onSetup: () => void
|
||||
}) {
|
||||
const [index, setIndex] = useState(0)
|
||||
const [paused, setPaused] = useState(false)
|
||||
const [controls, setControls] = useState(true)
|
||||
const hideTimer = useRef(0)
|
||||
const slide = slides[index % Math.max(slides.length, 1)]
|
||||
const step = (by: number) => setIndex((i) => (i + by + slides.length) % slides.length)
|
||||
|
||||
// The next slide when this one's time is up.
|
||||
useEffect(() => {
|
||||
if (paused || !slide) return
|
||||
const timer = window.setTimeout(() => step(1), slide.seconds * 1000)
|
||||
return () => window.clearTimeout(timer)
|
||||
}, [index, paused, slide?.seconds, slides.length])
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.key === 'ArrowRight') step(1)
|
||||
else if (e.key === 'ArrowLeft') step(-1)
|
||||
else if (e.key === ' ') setPaused((p) => !p)
|
||||
else if (e.key === 's' || e.key === 'S') onSetup()
|
||||
else return
|
||||
e.preventDefault()
|
||||
}
|
||||
window.addEventListener('keydown', onKey)
|
||||
return () => window.removeEventListener('keydown', onKey)
|
||||
})
|
||||
|
||||
// Keeps a signage screen from going to sleep, where the browser can.
|
||||
useEffect(() => {
|
||||
let lock: { release: () => Promise<void> } | null = null
|
||||
const ask = () => {
|
||||
if (document.visibilityState !== 'visible') return
|
||||
;(navigator as any).wakeLock
|
||||
?.request('screen')
|
||||
.then((l: typeof lock) => (lock = l))
|
||||
.catch(() => {})
|
||||
}
|
||||
ask()
|
||||
document.addEventListener('visibilitychange', ask)
|
||||
return () => {
|
||||
document.removeEventListener('visibilitychange', ask)
|
||||
lock?.release().catch(() => {})
|
||||
}
|
||||
}, [])
|
||||
|
||||
// The controls show while the pointer moves, then get out of the way.
|
||||
const wake = () => {
|
||||
setControls(true)
|
||||
window.clearTimeout(hideTimer.current)
|
||||
hideTimer.current = window.setTimeout(() => setControls(false), CONTROLS_FOR)
|
||||
}
|
||||
useEffect(() => {
|
||||
wake()
|
||||
return () => window.clearTimeout(hideTimer.current)
|
||||
}, [])
|
||||
|
||||
if (!slide) {
|
||||
return (
|
||||
<main className="flex min-h-screen flex-col items-center justify-center gap-4 bg-surface">
|
||||
<p className="notice">Nothing picked to show.</p>
|
||||
<button type="button" onClick={onSetup} className="btn border border-muted/25 px-5 py-2">
|
||||
Back to setup
|
||||
</button>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
const control = 'btn flex h-12 w-12 items-center justify-center bg-raised text-ink shadow-md'
|
||||
return (
|
||||
<main
|
||||
onMouseMove={wake}
|
||||
className={`present relative flex h-screen flex-col overflow-hidden bg-surface text-body ${controls ? '' : 'cursor-none'}`}
|
||||
>
|
||||
<div className="h-3 shrink-0" style={{ background: accent }} />
|
||||
<div className="flex shrink-0 items-baseline justify-between gap-6 px-[4vw] pt-[2vh] text-[clamp(1rem,1.6vw,2rem)] text-muted">
|
||||
<span className="font-semibold">{title}</span>
|
||||
<span>{slide.day.name}</span>
|
||||
</div>
|
||||
|
||||
{/* Keyed by index, so every slide's entrance animation plays. */}
|
||||
<div key={index} className="min-h-0 flex-1 px-[4vw] py-[3vh]">
|
||||
<SlideView slide={slide} accent={accent} />
|
||||
</div>
|
||||
|
||||
{/* How long this slide has left. */}
|
||||
<div className="h-1.5 shrink-0" style={{ background: `color-mix(in srgb, ${accent} 20%, transparent)` }}>
|
||||
<div
|
||||
key={`${index}-${paused}`}
|
||||
className={paused ? 'h-full w-0' : 'present-timer h-full'}
|
||||
style={{ background: accent, animationDuration: `${slide.seconds}s` }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={`absolute bottom-6 left-1/2 flex -translate-x-1/2 items-center gap-3 transition-opacity duration-300 ${
|
||||
controls ? 'opacity-100' : 'pointer-events-none opacity-0'
|
||||
}`}
|
||||
>
|
||||
<button type="button" onClick={() => step(-1)} className={control} aria-label="Previous slide">
|
||||
<CaretLeft weight="bold" className="h-5 w-5" aria-hidden="true" />
|
||||
</button>
|
||||
<button type="button" onClick={() => setPaused((p) => !p)} className={control} aria-label={paused ? 'Play' : 'Pause'}>
|
||||
{paused ? (
|
||||
<Play weight="fill" className="h-5 w-5" aria-hidden="true" />
|
||||
) : (
|
||||
<Pause weight="bold" className="h-5 w-5" aria-hidden="true" />
|
||||
)}
|
||||
</button>
|
||||
<button type="button" onClick={() => step(1)} className={control} aria-label="Next slide">
|
||||
<CaretRight weight="bold" className="h-5 w-5" aria-hidden="true" />
|
||||
</button>
|
||||
<span className="bg-raised px-3 py-2 text-sm text-muted shadow-md">
|
||||
{index + 1} / {slides.length}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => document.documentElement.requestFullscreen?.().catch(() => {})}
|
||||
className={control}
|
||||
aria-label="Full screen"
|
||||
>
|
||||
<ArrowsOut weight="bold" className="h-5 w-5" aria-hidden="true" />
|
||||
</button>
|
||||
<button type="button" onClick={onSetup} className={control} aria-label="Back to setup">
|
||||
<Gear weight="bold" className="h-5 w-5" aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
/* ── Slides ─────────────────────────────────────────────────── */
|
||||
|
||||
/* Fades and rises in after `order` steps, so a slide's parts arrive
|
||||
one after another. */
|
||||
function Rise({ order = 0, from = 'below', className = '', children }: {
|
||||
order?: number
|
||||
from?: 'below' | 'left' | 'right'
|
||||
className?: string
|
||||
children: ReactNode
|
||||
}) {
|
||||
return (
|
||||
<div className={`present-in present-from-${from} ${className}`} style={{ animationDelay: `${order * 120}ms` }}>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function SlideView({ slide, accent }: { slide: Slide; accent: string }) {
|
||||
const color = accentText(accent)
|
||||
|
||||
if (slide.kind === 'overview') {
|
||||
const entries = slide.day.entries
|
||||
const two = entries.length > ONE_COLUMN
|
||||
return (
|
||||
<div className="flex h-full flex-col">
|
||||
<Rise>
|
||||
<h1 className="mb-[3vh] text-[clamp(2rem,5vw,6rem)] font-bold leading-none" style={{ color }}>
|
||||
{slide.day.name || 'Schedule'}
|
||||
</h1>
|
||||
</Rise>
|
||||
<ul className={`grid min-h-0 flex-1 content-start gap-x-[4vw] ${two ? 'grid-cols-2' : 'grid-cols-1'}`}>
|
||||
{entries.map((entry, i) => (
|
||||
<li key={i}>
|
||||
<Rise order={i + 1} from="left" className="flex items-baseline gap-[2vw] border-b border-brand/15 py-[1.2vh]">
|
||||
<span className="w-[12vw] shrink-0 text-[clamp(1rem,1.8vw,2.4rem)] font-semibold" style={{ color }}>
|
||||
{entry.time}
|
||||
</span>
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block text-[clamp(1.2rem,2.4vw,3rem)] font-bold leading-tight text-ink">
|
||||
{entry.text}
|
||||
</span>
|
||||
{(entry.location || entry.person) && (
|
||||
<span className="mt-1 flex flex-wrap items-center gap-x-[1.5vw] text-[clamp(0.9rem,1.4vw,1.8rem)] text-muted">
|
||||
{entry.location && <span>{entry.location}</span>}
|
||||
{entry.person && <span>{entry.person.name}</span>}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
</Rise>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const entry = slide.entry!
|
||||
|
||||
if (slide.kind === 'graphic' || slide.kind === 'map') {
|
||||
const src = mediaUrl(slide.kind === 'map' ? entry.map_image : entry.media)
|
||||
const alt = slide.kind === 'map' ? mapAlt(entry) : (entry.media_alt ?? '')
|
||||
return (
|
||||
<div className="flex h-full flex-col gap-[2vh]">
|
||||
<Rise className="min-h-0 flex-1">
|
||||
<img src={src ?? ''} alt={alt} className="h-full w-full object-contain" />
|
||||
</Rise>
|
||||
<Rise order={2} className="flex items-baseline gap-[2vw] text-[clamp(1.2rem,2.2vw,2.8rem)]">
|
||||
<span className="font-semibold" style={{ color }}>
|
||||
{entry.time}
|
||||
</span>
|
||||
<span className="font-bold text-ink">{entry.text}</span>
|
||||
{slide.kind === 'map' && (entry.map || entry.location) && (
|
||||
<span className="text-muted">{entry.map || entry.location}</span>
|
||||
)}
|
||||
</Rise>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// Spotlight: the person on the left, when there is one.
|
||||
return (
|
||||
<div className="flex h-full items-center gap-[5vw]">
|
||||
{entry.person && (
|
||||
<Rise from="left" className="flex w-[28vw] shrink-0 flex-col items-center text-center">
|
||||
<Avatar person={entry.person} size="aspect-square w-full text-[4vw]" />
|
||||
<p className="mt-[2vh] text-[clamp(1.4rem,2.6vw,3.2rem)] font-bold text-ink">{entry.person.name}</p>
|
||||
{entry.person.tagline && (
|
||||
<p className="text-[clamp(1rem,1.6vw,2rem)] text-muted">{entry.person.tagline}</p>
|
||||
)}
|
||||
</Rise>
|
||||
)}
|
||||
<div className="min-w-0 flex-1">
|
||||
<Rise from="right">
|
||||
<p className="text-[clamp(1.2rem,2.4vw,3rem)] font-semibold" style={{ color }}>
|
||||
{[slide.day.name, entry.time].filter(Boolean).join(' · ')}
|
||||
</p>
|
||||
</Rise>
|
||||
<Rise order={1} from="right">
|
||||
<h1 className="mt-[1vh] text-[clamp(2.4rem,5.5vw,7rem)] font-bold leading-[1.05] text-ink">{entry.text}</h1>
|
||||
</Rise>
|
||||
{entry.location && (
|
||||
<Rise order={2} from="right">
|
||||
<p className="mt-[2vh] text-[clamp(1.2rem,2.4vw,3rem)] text-body">{entry.location}</p>
|
||||
</Rise>
|
||||
)}
|
||||
{entry.detail && (
|
||||
<Rise order={3} from="right">
|
||||
<p className="mt-[1vh] text-[clamp(1rem,2vw,2.4rem)] text-muted">{entry.detail}</p>
|
||||
</Rise>
|
||||
)}
|
||||
{entry.description && (
|
||||
<Rise order={4} from="right">
|
||||
<div className="mt-[3vh] line-clamp-6 space-y-3 text-[clamp(1rem,1.8vw,2.2rem)] leading-snug text-muted">
|
||||
<Paragraphs text={entry.description} accent={accent} />
|
||||
</div>
|
||||
</Rise>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
@ -587,6 +587,7 @@ export default function EntityEdit() {
|
|||
options={options}
|
||||
errors={errors}
|
||||
errorPrefix={`${child.key}.`}
|
||||
parentRow={form}
|
||||
className=""
|
||||
onChange={(rows) => setForm((prev) => ({ ...prev, [child.key]: rows }))}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -90,6 +90,11 @@ export const DATA_NAV = {
|
|||
label: "Tags",
|
||||
blurb: "Descriptors for organizations and events, eg. Online, In-Person. Who carries a tag is edited on the record.",
|
||||
},
|
||||
{
|
||||
to: "/admin/venues",
|
||||
label: "Venues",
|
||||
blurb: "Places we gather, each with a map and its locations marked, for map blocks and schedules.",
|
||||
},
|
||||
{
|
||||
to: "/admin/redirects",
|
||||
label: "Links/redirects",
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ import { useReadingMode } from '../../lib/readingMode.ts'
|
|||
|
||||
<OrgListCards kind="partner" pageLabel="Partner page" />
|
||||
<OrgListCards ids={["unity-worldwide", "unity-of-x"]} /> in that order
|
||||
<OrgListCards ids={...} nested /> inside a content block (093):
|
||||
no page gutter, names under
|
||||
the block's heading
|
||||
|
||||
Where the vertical list expands in place, a card links out. The
|
||||
card carries as much as fits at a glance and the organization's
|
||||
|
|
@ -123,11 +126,11 @@ function OrgCard({ org, accent, pageLabel, siteLabel, titled }) {
|
|||
);
|
||||
}
|
||||
|
||||
function Block({ title, orgs, accent, pageLabel, siteLabel }) {
|
||||
function Block({ title, orgs, accent, pageLabel, siteLabel, nested = false }) {
|
||||
if (orgs.length === 0) return null;
|
||||
|
||||
return (
|
||||
<section className="mb-12">
|
||||
<section className={nested ? undefined : "mb-12"}>
|
||||
{title && (
|
||||
<h3 className="text-xl font-bold mb-5" style={{ color: FALLBACK_COLOR }}>
|
||||
{title}
|
||||
|
|
@ -147,7 +150,7 @@ function Block({ title, orgs, accent, pageLabel, siteLabel }) {
|
|||
accent={accent}
|
||||
pageLabel={pageLabel}
|
||||
siteLabel={siteLabel}
|
||||
titled={!!title}
|
||||
titled={!!title || nested}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
|
@ -156,6 +159,25 @@ function Block({ title, orgs, accent, pageLabel, siteLabel }) {
|
|||
}
|
||||
|
||||
|
||||
/* Just the logos, in a row: an organizations block presented (095).
|
||||
Picked ones in their order, else every one of the kind by name. */
|
||||
export function OrgLogoRow({ kind, ids, accent = FALLBACK_COLOR }: { kind?: string | null; ids?: string[]; accent?: string }) {
|
||||
const { organizations } = useOrganizations(kind, ids);
|
||||
const sorted = ids?.length
|
||||
? ids.flatMap((id) => organizations.filter((org) => org.id === id))
|
||||
: [...organizations].sort(byName);
|
||||
return (
|
||||
<ul className="flex flex-wrap items-center gap-8">
|
||||
{sorted.map((org) => (
|
||||
<li key={org.id} title={org.name}>
|
||||
<span className="sr-only">{org.name}</span>
|
||||
<OrgLogo org={org} color={org.color || accent} size="h-24 w-44" fallbackSize="h-24 w-24 text-3xl" />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
export default function OrgListCards({
|
||||
kind,
|
||||
ids,
|
||||
|
|
@ -167,10 +189,26 @@ export default function OrgListCards({
|
|||
siteLabel = "Visit site",
|
||||
sort = byName,
|
||||
empty = "Nothing to show here yet.",
|
||||
nested = false,
|
||||
}: {
|
||||
kind?: string | null;
|
||||
ids?: string[];
|
||||
title?: string;
|
||||
groups?: Array<{ key: string; title: string; pageLabel?: string; siteLabel?: string }>;
|
||||
groupBy?: (org: any) => unknown;
|
||||
accent?: string;
|
||||
pageLabel?: string;
|
||||
siteLabel?: string;
|
||||
sort?: ((a: any, b: any) => number) | null;
|
||||
empty?: string;
|
||||
nested?: boolean;
|
||||
}) {
|
||||
const { organizations, loading, error } = useOrganizations(kind, ids);
|
||||
|
||||
const shell = children => (
|
||||
const shell = children =>
|
||||
nested ? (
|
||||
<div>{children}</div>
|
||||
) : (
|
||||
<div className="mx-auto px-8 md:px-12" style={{ maxWidth: GRID_MAX }}>
|
||||
{children}
|
||||
</div>
|
||||
|
|
@ -214,6 +252,7 @@ export default function OrgListCards({
|
|||
accent={accent}
|
||||
pageLabel={pageLabel}
|
||||
siteLabel={siteLabel}
|
||||
nested={nested}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue