diff --git a/docs/updating-data-in-code.md b/docs/updating-data-in-code.md
index 36d92c0..fbfbe4b 100644
--- a/docs/updating-data-in-code.md
+++ b/docs/updating-data-in-code.md
@@ -181,8 +181,8 @@ also in `server/src/admin-schema/` and a CHECK):
| Links → Kind (on organizations, events, people, teams) | action, social, website, email | no | `splitLinks` in `server/src/shape.js` |
| Links → Platform | instagram, facebook, discord, youtube, tiktok, x, substack, spotify, linkedin | **yes**, `PLATFORMS` | `PlatformIcon.tsx` draws the icon on the button. **No CHECK and no `enumeration`**: the column is plain text, so adding one is an entry in `PLATFORMS` (`src/lib/platforms.ts`) and its icon in `src/components/PlatformIcon.tsx`, no migration. |
| Content blocks → Shown in (slot) | card, body | **yes** | `paragraphs()` in `server/src/shape.js` (card), `ContentBlocks.tsx` (body) |
-| Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout, schedule, table | **yes**, `BLOCK_TYPES` (with each type's description) | `ContentBlocks.tsx` (one renderer per type). Which fields each type shows is `when` on the fields in `blocksChild` (`src/lib/adminSchema/shared.ts`). |
-| Content blocks → Schedule items → Type | (blank: normal entry), block, break, heading | **yes**, migration 086 | `SCHEDULE_KINDS` in `src/lib/adminSchema/shared.ts`; drawn by `ScheduleBlock.tsx` and `SchedulePresent.tsx` (which slides each kind gets). A block's sub-items are `content_block_subitems`. A schedule's own tags (087) are `content_block_tags`, rows of the block typed in the admin (not a fixed list); entries name them by `tag_key`, made in the admin as the tag is added. |
+| Content blocks → Type | heading, subheading, paragraph, list, links, quote, image, divider, video, button, callout, schedule, table, cards, people, map, events | **yes**, `BLOCK_TYPES` (with each type's description) | `ContentBlocks.tsx` (one renderer per type). Which fields each type shows is `when` on the fields in `blocksChild` (`src/lib/adminSchema/shared.ts`). |
+| Content blocks → Schedule items → Type | (blank: normal entry), block, break, heading | **yes**, migration 086 | `SCHEDULE_KINDS` in `src/lib/adminSchema/shared.ts`; drawn by `ScheduleBlock.tsx` and `SchedulePresent.tsx` (which slides each kind gets). A block's sub-items are `content_block_subitems`. A schedule's own tags (087) are `content_block_tags`, rows of the block typed in the admin (not a fixed list); entries name them by `tag_key`, made in the admin as the tag is added. 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`). |
| Timeline → Kind (+ list filter) | milestone, event, organization, award, people | no | `KIND_NAMES` in `src/pages/sections/history/TimelineEntry.tsx` |
| Timeline → Points at (+ list filter) | event, organization, award, person, team | no | `refHref` in `src/lib/hrefs.ts` |
| Timeline → Precision (and on events/orgs) | year, month, day | no | the history page's grouping |
@@ -272,7 +272,7 @@ A Numbers section's "Number Source" dropdown works the same way:
| The icons a Connect nav section's path can pick | `src/data/pathIcons.ts` (keys and labels) **and** `ICONS` in `src/pages/sections/home/Pathfinder.tsx` (the Phosphor icon for each key) | Add a line to both. A path saved with an emoji from before the list shows it as it is. |
| A page section's accent color | `BRAND` and `ACCENTS` in `src/lib/color.ts` | Pages pick from these (`accent: ACCENTS.green`); add a color there, not a hex in a page. Each is readable as text on white and the tints. |
| The palette (the 16-color grid the theme is drawn from) | `PALETTE` in `src/lib/color.ts` | Four families, a column each. `PALETTE_LIGHT` / `PALETTE_DARK` are the fills things colored by data use (a person's initials tile, `paletteFill`); the page background's layers (how many circles, their sizes and parallax speeds) are `LAYERS` in `src/components/PageBackdrop.tsx` and its shades are in `PageBackdrop.css`; the admin home's two alternating group colors are `BLOCK_COLORS` in `src/pages/admin/AdminHome.tsx`. |
-| The accessibility panel's choices (bottom right of every public page) | `SETTINGS` in `src/components/AccessibilityPanel.tsx`; the color blind modes are `VISIONS` and `SWAPS` in `src/lib/color.ts` | Each choice is an attribute on `` styled in `src/index.css`, and `index.html` sets it again before the first paint, so a new one goes in all three. A color blind mode replaces all three color families, teal, green and amber (`SWAPS`, picked by simulating each type: see the comment there), in code, in data colors as they load (`src/lib/api.ts`, never under /admin), in CSS (the `--pal-*` variables in `src/index.css`, which hold the same values as `SWAPS`: change both) and in the theme tokens drawn from them. A palette hex in a component or CSS file should be `var(--pal--)` (eg. `var(--pal-amber-2)`), or a color blind mode won't reach it. Reading mode is `src/components/ReaderView.tsx`, which reads the hidden page and writes out its headings, paragraphs, links and described pictures. A part it can't read well (a carousel, tabs, details behind a click, a map) draws its own text version when `useReadingMode()` (`src/lib/readingMode.ts`) is on: the hero, pathfinder, stats, history rail, event lists, calendar (the next six weeks), featured cards, org lists and groups map, history timeline, schedule, people tiles and video player; the countdown draws nothing. A new component with any of those should do the same. Something saved or sent (the newsletter's colors) is a stored hex, which is never swapped. |
+| The accessibility panel's choices (bottom right of every public page) | `SETTINGS` in `src/components/AccessibilityPanel.tsx`; the color blind modes are `VISIONS` and `SWAPS` in `src/lib/color.ts` | Each choice is an attribute on `` styled in `src/index.css`, and `index.html` sets it again before the first paint, so a new one goes in all three. A color blind mode replaces all three color families, teal, green and amber (`SWAPS`, picked by simulating each type: see the comment there), in code, in data colors as they load (`src/lib/api.ts`, never under /admin), in CSS (the `--pal-*` variables in `src/index.css`, which hold the same values as `SWAPS`: change both) and in the theme tokens drawn from them. A palette hex in a component or CSS file should be `var(--pal--)` (eg. `var(--pal-amber-2)`), or a color blind mode won't reach it. Reading mode is `src/components/ReaderView.tsx`, which reads the hidden page and writes out its headings, paragraphs, links and described pictures. A part it can't read well (a carousel, tabs, details behind a click, a map) draws its own text version when `useReadingMode()` (`src/lib/readingMode.ts`) is on: the hero, pathfinder, stats, history rail, event lists, calendar (the next six weeks), featured cards, org lists and groups map, history timeline, schedule, map block (its list alone), people tiles and video player; the countdown draws nothing. A new component with any of those should do the same. Something saved or sent (the newsletter's colors) is a stored hex, which is never swapped. |
| Privacy Policy and Terms wording | the database (082) | Admin → Pages → Page management → Privacy Policy or Terms of Service: their sections' blocks, and the "Last updated" date in the section's blurb whenever the wording changes. The privacy contact email is in the policy's text. The Privacy page must stay true of the code: what the feedback form stores, what the browser keeps, which embeds wait for a click. |
| Event type labels and plurals (public site) | `src/lib/eventTypes.ts` | Also the order of the type filter chips. |
| Event and person role labels (public site) | `ROLE_LABEL` in `src/pages/EventDetail.tsx` and `src/pages/PersonDetail.tsx` | |
diff --git a/server/src/admin-schema.js b/server/src/admin-schema.js
index 824c108..7378685 100644
--- a/server/src/admin-schema.js
+++ b/server/src/admin-schema.js
@@ -64,6 +64,7 @@ import { tags } from "./admin-schema/tags.js";
import { contactTypes } from "./admin-schema/contactTypes.js";
import { redirects } from "./admin-schema/redirects.js";
import { pages } from "./admin-schema/sitePages.js";
+import { venues } from "./admin-schema/venues.js";
export const ENTITIES = {
organizations,
@@ -73,6 +74,7 @@ export const ENTITIES = {
tags,
contact_types: contactTypes,
redirects,
+ venues,
teams,
awards,
timeline,
@@ -106,6 +108,15 @@ export const OPTION_QUERIES = {
contact_types: "SELECT id, name AS label FROM contact_types ORDER BY sort_order, name",
// Link fields with `redirects: true` pick from these (068).
redirects: "SELECT id, id || ' (' || target_url || ')' AS label FROM redirects ORDER BY id",
+ // A map block's venue; its locations ride along (as JSON) for a
+ // schedule's entries to pick from and for the block's preview.
+ venues: `
+ SELECT v.id, v.name AS label, v.map_image, v.map_alt,
+ (SELECT json_group_array(json_object('key', l.location_key, 'name', l.name, 'detail', l.detail,
+ 'x', l.x, 'y', l.y, 'w', l.w, 'h', l.h))
+ FROM (SELECT * FROM venue_locations WHERE venue_id = v.id ORDER BY sort_order) l) AS locations
+ FROM venues v
+ ORDER BY v.name`,
blog_posts: "SELECT id, title AS label FROM blog_posts ORDER BY published_on DESC, title",
// Navigation's Under page: a page by its address (080).
site_pages: "SELECT path AS id, title || ' (' || path || ')' AS label FROM site_pages ORDER BY sort_order, title",
diff --git a/server/src/admin-schema/columns.js b/server/src/admin-schema/columns.js
index 3416e07..f15ffa7 100644
--- a/server/src/admin-schema/columns.js
+++ b/server/src/admin-schema/columns.js
@@ -154,6 +154,9 @@ 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",
],
{ required: true },
),
@@ -170,6 +173,8 @@ 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"),
],
children: [
{
@@ -198,6 +203,10 @@ export const blocksChild = (ownerKind) => ({
bool("featured"),
// The block's tags it has, by key, comma-separated (087).
text("tags"),
+ // A workshop or other event it is, and its place on the
+ // block's venue map (088).
+ text("event_id"),
+ text("location_key"),
],
children: [
{
@@ -223,6 +232,8 @@ export const blocksChild = (ownerKind) => ({
text("map_image"),
bool("featured"),
text("tags"),
+ text("event_id"),
+ text("location_key"),
],
},
],
diff --git a/server/src/admin-schema/venues.js b/server/src/admin-schema/venues.js
new file mode 100644
index 0000000..2525229
--- /dev/null
+++ b/server/src/admin-schema/venues.js
@@ -0,0 +1,44 @@
+import { text, real } 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"),
+ ],
+ },
+ ],
+};
diff --git a/server/src/migrations/088_venues.sql b/server/src/migrations/088_venues.sql
new file mode 100644
index 0000000..9be8b4c
--- /dev/null
+++ b/server/src/migrations/088_venues.sql
@@ -0,0 +1,125 @@
+-- ═══════════════════════════════════════════════════════════════
+-- 088 VENUES, MAP BLOCKS AND EVENT BLOCKS
+--
+-- Data → Venues: a place we gather (a camp, a church), with one map
+-- picture and its marked locations, each a pin (x, y) or a box
+-- (x, y, w, h), in percent of the picture from its top left.
+--
+-- A 'map' content block draws a venue's map with its locations
+-- listed beside it; a schedule block names a venue too, and its
+-- entries and sub-items pick one of its locations (location_key),
+-- which links to the map block on the same page, the location
+-- lit up. The venue's locations are rewritten on every save, so an
+-- entry names one by `location_key` (made in the admin when the
+-- location is added), as schedule tags do (087).
+--
+-- An 'events' content block shows events as cards, an item each
+-- (event_id); a schedule entry or sub-item can name an event too
+-- (a workshop), and takes what it leaves blank from it.
+--
+-- content_blocks.type's CHECK can't change in place, so the table
+-- is rebuilt (as in 079), then its index and owner trigger made
+-- again.
+-- ═══════════════════════════════════════════════════════════════
+
+CREATE TABLE venues (
+ id TEXT PRIMARY KEY
+ CONSTRAINT "A venue's URL ID can use only lowercase letters, numbers and hyphens, eg. camp-hebron."
+ CHECK (id <> '' AND id NOT GLOB '*[^a-z0-9-]*'),
+ name TEXT NOT NULL,
+ address TEXT,
+ map_image TEXT, -- an upload
+ map_alt TEXT
+) STRICT;
+
+CREATE TABLE venue_locations (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ venue_id TEXT NOT NULL REFERENCES venues (id) ON DELETE CASCADE,
+ sort_order INTEGER NOT NULL DEFAULT 0,
+ location_key TEXT NOT NULL,
+ name TEXT NOT NULL,
+ detail TEXT,
+ x REAL CHECK (x BETWEEN 0 AND 100),
+ y REAL CHECK (y BETWEEN 0 AND 100),
+ w REAL CHECK (w > 0 AND w <= 100), -- null: a pin
+ h REAL CHECK (h > 0 AND h <= 100),
+ UNIQUE (venue_id, location_key)
+) STRICT;
+
+ALTER TABLE content_block_items ADD COLUMN event_id TEXT
+ REFERENCES events (id) ON DELETE SET NULL;
+ALTER TABLE content_block_items ADD COLUMN location_key TEXT;
+ALTER TABLE content_block_subitems ADD COLUMN event_id TEXT
+ REFERENCES events (id) ON DELETE SET NULL;
+ALTER TABLE content_block_subitems ADD COLUMN location_key TEXT;
+
+CREATE TABLE content_blocks_new (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ owner_kind TEXT NOT NULL
+ CHECK (owner_kind IN ('organization', 'event', 'person', 'team', 'blog_post', 'page_section',
+ 'newsletter')),
+ owner_id TEXT NOT NULL,
+ slot TEXT NOT NULL DEFAULT 'body' CHECK (slot IN ('card', 'body', 'both')),
+ sort_order INTEGER NOT NULL DEFAULT 0,
+
+ type TEXT NOT NULL
+ CHECK (type IN ('heading', 'subheading', 'paragraph',
+ 'list', 'links', 'quote', 'image', 'divider',
+ 'video', 'button', 'callout', 'schedule', 'table', 'cards',
+ 'people', 'tab', 'map', 'events')),
+ text TEXT,
+ media TEXT,
+ href TEXT,
+ alt TEXT,
+ cite TEXT,
+ team_id TEXT REFERENCES teams (id) ON DELETE SET NULL,
+ captions TEXT,
+ word_motion TEXT CHECK (word_motion IN ('slide', 'flip', 'fade', 'type', 'mirror')),
+ word_direction TEXT CHECK (word_direction IN ('top', 'bottom')),
+ word_seconds INTEGER CHECK (word_seconds BETWEEN 1 AND 20),
+ -- Map and schedule blocks: whose map, and whose locations.
+ venue_id TEXT REFERENCES venues (id) ON DELETE SET NULL
+) STRICT;
+
+INSERT INTO content_blocks_new
+ (id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id, captions,
+ word_motion, word_direction, word_seconds)
+SELECT id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id, captions,
+ word_motion, word_direction, word_seconds
+ FROM content_blocks;
+
+PRAGMA legacy_alter_table = ON;
+DROP TABLE content_blocks;
+ALTER TABLE content_blocks_new RENAME TO content_blocks;
+PRAGMA legacy_alter_table = OFF;
+
+CREATE INDEX content_blocks_owner_idx
+ ON content_blocks (owner_kind, owner_id, slot, sort_order);
+
+CREATE TRIGGER content_blocks_owner_exists
+BEFORE INSERT ON content_blocks
+BEGIN
+ SELECT CASE
+ WHEN new.owner_kind = 'event'
+ AND NOT EXISTS (SELECT 1 FROM events WHERE id = new.owner_id)
+ THEN RAISE(ABORT, 'content_blocks: no such event')
+ WHEN new.owner_kind = 'organization'
+ AND NOT EXISTS (SELECT 1 FROM organizations WHERE id = new.owner_id)
+ THEN RAISE(ABORT, 'content_blocks: no such organization')
+ WHEN new.owner_kind = 'person'
+ AND NOT EXISTS (SELECT 1 FROM people WHERE id = new.owner_id)
+ THEN RAISE(ABORT, 'content_blocks: no such person')
+ WHEN new.owner_kind = 'team'
+ AND NOT EXISTS (SELECT 1 FROM teams WHERE id = new.owner_id)
+ THEN RAISE(ABORT, 'content_blocks: no such team')
+ WHEN new.owner_kind = 'blog_post'
+ AND NOT EXISTS (SELECT 1 FROM blog_posts WHERE id = new.owner_id)
+ THEN RAISE(ABORT, 'content_blocks: no such blog post')
+ WHEN new.owner_kind = 'page_section'
+ AND NOT EXISTS (SELECT 1 FROM page_sections WHERE CAST(id AS TEXT) = new.owner_id)
+ THEN RAISE(ABORT, 'content_blocks: no such page section')
+ WHEN new.owner_kind = 'newsletter'
+ AND NOT EXISTS (SELECT 1 FROM newsletters WHERE CAST(id AS TEXT) = new.owner_id)
+ THEN RAISE(ABORT, 'content_blocks: no such newsletter')
+ END;
+END;
diff --git a/server/src/seed-showcase.js b/server/src/seed-showcase.js
index 07c8a77..7b6e776 100644
--- a/server/src/seed-showcase.js
+++ b/server/src/seed-showcase.js
@@ -79,6 +79,7 @@ const MEMBERS = ["showcase-member-1", "showcase-member-2", "showcase-member-3"];
const EVENT = "showcase-event";
const SERIES = "showcase-series";
const PAST = "showcase-past-event";
+const VENUE = "showcase-venue";
/* ── Content ───────────────────────────────────────────────── */
@@ -87,21 +88,24 @@ const PAST = "showcase-past-event";
a description, graphic and map, one linked, a heading, a featured
entry, a block with sub-items, a break, typed and picked times,
tags (one a tab of its own in its color, one with No tab), and one
- with no day (it lands in a tab of its own). */
+ with no day (it lands in a tab of its own). Its venue's locations
+ (088) are picked on some entries, one with no typed Location, and
+ one sub-item is the showcase workshop, filled in from it. */
const SCHEDULE = [
"schedule",
- { text: "The weekend at a glance. Tap an entry for more." },
+ { text: "The weekend at a glance. Tap an entry for more.", venue_id: VENUE },
[
{ day: "Friday", start_time: "16:00", text: "Arrivals and check-in", location: "Front desk", tags: "showcase-youth,showcase-all" },
{ day: "Friday", kind: "heading", text: "Evening", detail: "A heading across the day" },
- { day: "Friday", time: "7:00 to 8:30pm", text: "Opening session", location: "Main Hall", person_id: "showcase-person", detail: "Welcome and worship", description: "The **opening session** sets the theme for the weekend.\n\nBring a notebook.", media: "/uploads/showcase.jpg", map: "Camp Hebron, Halifax PA", map_image: "/uploads/showcase.jpg" },
+ { day: "Friday", time: "7:00 to 8:30pm", text: "Opening session", location_key: "hall", person_id: "showcase-person", detail: "Welcome and worship", description: "The **opening session** sets the theme for the weekend.\n\nBring a notebook.", media: "/uploads/showcase.jpg", map: "Camp Hebron, Halifax PA", map_image: "/uploads/showcase.jpg" },
{ day: "Saturday", start_time: "08:00", end_time: "09:00", kind: "break", text: "Breakfast", location: "Dining hall" },
{ day: "Saturday", start_time: "09:00", end_time: "10:30", kind: "block", text: "Workshops", location: "Classrooms", detail: "Pick one of three", items: [
- { start_time: "09:00", end_time: "09:45", text: "Leading worship", location: "Room A", person_id: "showcase-member-2", url: "/blog/content-block-showcase" },
+ { start_time: "09:00", end_time: "09:45", text: "Leading worship", location: "Room A", location_key: "rooma", person_id: "showcase-member-2", url: "/blog/content-block-showcase" },
+ { start_time: "09:00", end_time: "09:45", text: "Showcase Past Workshop", event_id: PAST, location_key: "rooma" },
{ start_time: "09:00", end_time: "09:45", text: "Speaking with confidence", location: "Room B", featured: 1, tags: "showcase-youth", description: "A featured sub-item that folds out." },
{ time: "After the first round", text: "Open questions", location: "Room C" },
] },
- { day: "Saturday", start_time: "19:00", featured: 1, tags: "showcase-youth", text: "Talent night", location: "Main Hall", person_id: "showcase-member-3", description: "Sign up at the front desk by noon." },
+ { day: "Saturday", start_time: "19:00", featured: 1, tags: "showcase-youth", text: "Talent night", location: "Main Hall", location_key: "hall", person_id: "showcase-member-3", description: "Sign up at the front desk by noon." },
{ day: "Sunday", time: "10:00am", text: "Closing service", location: "Chapel", map: "Main Street, Halifax PA" },
{ time: "Any time", text: "Quiet room open", location: "Library", detail: "An entry with no day" },
],
@@ -141,6 +145,13 @@ const ALL_BLOCKS = [
["image", { media: IMAGE, alt: "The same picture, linked", href: "/history" }],
["subheading", { text: "Schedule" }],
SCHEDULE,
+ ["subheading", { text: "Map" }],
+ ["map", { venue_id: VENUE }],
+ ["subheading", { text: "Events" }],
+ ["events", {}, [
+ { event_id: PAST, text: "Showcase Past Workshop" },
+ { event_id: "showcase-event", text: "A card with its own title", detail: "And its own text in place of the event's." },
+ ]],
["subheading", { text: "Video" }],
["video", { href: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", text: "A YouTube video, with its own thumbnail" }],
["video", { href: "https://vimeo.com/76979871", media: IMAGE, text: "A Vimeo video with an uploaded still" }],
@@ -255,6 +266,7 @@ tx(db, () => {
db.prepare(`DELETE FROM awards WHERE id LIKE 'showcase-%'`).run();
db.prepare(`DELETE FROM affiliations WHERE person_id LIKE 'showcase-%' OR org_id LIKE 'showcase-%'`).run();
db.prepare(`DELETE FROM teams WHERE id LIKE 'showcase-%'`).run();
+ db.prepare(`DELETE FROM venues WHERE id LIKE 'showcase-%'`).run();
db.prepare(`DELETE FROM people WHERE id LIKE 'showcase-%'`).run();
db.prepare(`DELETE FROM organizations WHERE id = ?`).run(GROUP);
db.prepare(`DELETE FROM organizations WHERE id LIKE 'showcase-%'`).run();
@@ -412,7 +424,6 @@ tx(db, () => {
{ kind: "social", platform: "instagram", label: "@showcaseretreat", url: "https://instagram.com/showcaseretreat" },
]);
blocks("event", EVENT, "both", cardText("event"));
- blocks("event", EVENT, "body", [...pageBody("event"), ["heading", { text: "Schedule" }], SCHEDULE]);
insert("events", {
id: SERIES,
@@ -458,6 +469,23 @@ tx(db, () => {
insert("event_people", { event_id: PAST, person_id: PERSON, role: "host", is_public: 1, sort_order: 0 });
blocks("event", PAST, "card", cardText("past event"));
+ /* ── Venue (088): a pin, a box and an unmarked location ── */
+ insert("venues", { id: VENUE, name: "Showcase Retreat Center", address: "123 Example Road, Exampletown PA", map_image: IMAGE });
+ [
+ { location_key: "hall", name: "Main Hall", detail: "Sessions and talent night", x: 30, y: 40 },
+ { location_key: "rooma", name: "Room A", detail: "Workshops", x: 55, y: 20, w: 25, h: 30 },
+ { location_key: "desk", name: "Front desk", detail: "Not marked on the map" },
+ ].forEach((location, i) => insert("venue_locations", { venue_id: VENUE, sort_order: i, ...location }));
+
+ // The retreat's page, after the workshop and venue its schedule names.
+ blocks("event", EVENT, "body", [
+ ...pageBody("event"),
+ ["heading", { text: "Schedule" }],
+ SCHEDULE,
+ ["heading", { text: "Map" }],
+ ["map", { venue_id: VENUE }],
+ ]);
+
/* ── Award ── */
insert("awards", {
id: AWARD,
diff --git a/server/src/shape.js b/server/src/shape.js
index aee9313..721ab11 100644
--- a/server/src/shape.js
+++ b/server/src/shape.js
@@ -70,7 +70,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
const blockRows = db
.prepare(
- `SELECT id, owner_id, type, text, media, href, alt, cite, captions, team_id,
+ `SELECT id, owner_id, type, text, media, href, alt, cite, captions, team_id, venue_id,
word_motion, word_direction, word_seconds
FROM content_blocks
WHERE owner_kind = ? AND slot IN (?, 'both') AND owner_id IN (${placeholders(ids.length)})
@@ -92,6 +92,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
cite: row.cite,
captions: row.captions,
team_id: row.team_id,
+ venue_id: row.venue_id,
// 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 }
@@ -109,6 +110,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
const ENTRY_FIELDS = `i.text, i.detail, i.url, i.start_time, i.end_time, i.time, i.location,
i.description, i.media, i.media_alt, i.map, i.map_image, i.featured, i.tags,
+ i.event_id, i.location_key,
p.id AS person_id, p.display_name AS person_name,
p.photo AS person_photo, p.tagline AS person_tagline`;
@@ -172,9 +174,107 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") {
block.items.forEach(cut);
}
+ attachVenues(db, [...byId.values()]);
+ attachEvents(db, [...byId.values()]);
+
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
+ 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. */
+function attachEvents(db, blocks) {
+ 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_alt,
+ 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]));
+
+ 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,
+ blurb,
+ };
+ entry.url ||= `/events/${row.id}`;
+ entry.description ||= blurb;
+ if (!entry.media && row.image) {
+ entry.media = row.image;
+ entry.media_alt = row.photo_alt;
+ }
+ if (!entry.person && row.person_id) {
+ entry.person = { id: row.person_id, name: row.person_name, photo: row.person_photo, tagline: row.person_tagline };
+ }
+ }
+}
+
/* A schedule entry or sub-item as the page gets it. `time` is what
to show: the typed override, else the picked times (086). An
unpublished person comes back as no person. */
@@ -194,6 +294,8 @@ function scheduleEntry(row) {
map_image: row.map_image,
featured: row.featured === 1,
tags: row.tags ? row.tags.split(",").filter(Boolean) : [],
+ event_id: row.event_id,
+ location_key: row.location_key,
person: row.person_id
? {
id: row.person_id,
diff --git a/src/components/ContentBlocks.tsx b/src/components/ContentBlocks.tsx
index 4d9299e..eb4f2a5 100644
--- a/src/components/ContentBlocks.tsx
+++ b/src/components/ContentBlocks.tsx
@@ -30,6 +30,12 @@
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
divider nothing
"Formatted" is InlineText.tsx: **bold**, *italic*, [text](url),
@@ -50,6 +56,9 @@ import type { ContentBlock, ContentBlockItem } from '../lib/useContent.ts'
import { Anchor, Inline, Paragraphs, isExternalUrl } from './InlineText.tsx'
import VideoPlayer from './VideoPlayer.tsx'
import ScheduleBlock from './ScheduleBlock.tsx'
+import MapBlock, { PageMaps } from './MapBlock.tsx'
+import { eventHref } 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'
@@ -94,7 +103,11 @@ export default function ContentBlocks({
presentAt && block.type === 'schedule' ? `${presentAt}?block=${schedules++}` : undefined,
)
+ // The venues mapped here, for a schedule's places to link to.
+ const maps = new Set(blocks.flatMap((block) => (block.type === 'map' && block.venue ? [block.venue.id] : [])))
+
return (
+
+
)
}
@@ -144,6 +158,40 @@ 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. */
+function EventCard({ item, accent }: { item: ContentBlockItem; accent: string }) {
+ const event = item.event!
+ const img = useSmallImage(mediaUrl(event.image))
+ const color = event.color || accent
+ 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 (
+
+ {!img.failed && (
+
+ )}
+
+ {(kind || when) && (
+
+ {[kind, when].filter(Boolean).join(' · ')}
+
+ )}
+
+ {item.text || event.title}
+
+ {(item.detail || event.blurb) && (
+ {item.detail || event.blurb}
+ )}
+
+
+ )
+}
+
/* 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. */
@@ -395,6 +443,24 @@ function Block({
/>
)
+ case 'map':
+ if (!block.venue) return null
+ return
+
+ case 'events': {
+ const events = (block.items ?? []).filter((item) => item.event)
+ if (events.length === 0) return null
+ return (
+
+ {events.map((item, i) => (
+
+
+
+ ))}
+
+ )
+ }
+
case 'people': {
const picked = (block.items ?? [])
.filter((item) => item.person)
diff --git a/src/components/MapBlock.tsx b/src/components/MapBlock.tsx
new file mode 100644
index 0000000..25728bd
--- /dev/null
+++ b/src/components/MapBlock.tsx
@@ -0,0 +1,155 @@
+/* ═══════════════════════════════════════════════════════════════
+ MAP BLOCK
+
+ The 'map' content block (088): a venue's map picture with its
+ locations marked on it, each a numbered pin or a box, and the
+ locations listed beside it (under it on a phone).
+
+ One picture, the marks drawn over it in percent of its size, so
+ they stay on their places at any width. A location is lit up
+ (in the accent, the rest dimmed) while its row or mark is hovered
+ or focused, and when the address points at it: #map--,
+ the link a schedule entry's place makes (mapAnchor). That id is
+ the mark's own, so Layout's jump to the anchor scrolls it into
+ view and focuses it.
+
+ Reading mode (readingMode.ts) gets the list alone, no picture.
+
+ PageMaps holds the venues that have a map block among the blocks
+ drawn together (ContentBlocks), so a schedule's places link only
+ when there's a map on the page to go to.
+ ═══════════════════════════════════════════════════════════════ */
+
+import { createContext, useState } from 'react'
+import { Link, useLocation } from 'react-router-dom'
+
+import { mediaUrl } from '../lib/media.ts'
+import type { Venue, VenueLocation } from '../lib/useContent.ts'
+import { accentText, readableOn, withAlpha } from '../lib/color.ts'
+import { useReadingMode } from '../lib/readingMode.ts'
+
+export const PageMaps = createContext>(new Set())
+
+export const mapAnchor = (venueId: string, key: string) => `map-${venueId}-${key}`
+
+const isBox = (location: VenueLocation) => location.w != null && location.h != null
+
+export default function MapBlock({ venue, accent }: { venue: Venue; accent: string }) {
+ const { hash, search } = useLocation()
+ const [hovered, setHovered] = useState(null)
+ const marked = venue.locations.filter((location) => location.x != null && location.y != null)
+ const fromHash = venue.locations.find((location) => hash === `#${mapAnchor(venue.id, location.key)}`)?.key ?? null
+ const active = hovered ?? fromHash
+ const image = useReadingMode() ? null : mediaUrl(venue.map_image)
+ const fill = accent.startsWith('#') ? accent : '#000000'
+
+ 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),
+ })
+ const number = (location: VenueLocation) => venue.locations.indexOf(location) + 1
+
+ return (
+
+ {image && (
+
+ )
+ })}
+
+
+
+ )
+}
diff --git a/src/components/ScheduleBlock.tsx b/src/components/ScheduleBlock.tsx
index ef7a5a2..7a65b96 100644
--- a/src/components/ScheduleBlock.tsx
+++ b/src/components/ScheduleBlock.tsx
@@ -32,6 +32,12 @@
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).
+
On an event page a Present button opens the schedule as a
slideshow for a screen (SchedulePresent.tsx).
@@ -42,9 +48,9 @@
it, no map frame (ReadingSchedule).
═══════════════════════════════════════════════════════════════ */
-import { CaretDown, Presentation, Star } from '@phosphor-icons/react'
+import { CaretDown, MapPin, Presentation, Star } from '@phosphor-icons/react'
import { Fragment, createContext, useContext, useId, useState, type KeyboardEvent, type ReactNode } from 'react'
-import { Link } from 'react-router-dom'
+import { Link, useLocation } from 'react-router-dom'
import { personHref } from '../lib/hrefs.ts'
import { mediaUrl, initials } from '../lib/media.ts'
@@ -54,6 +60,7 @@ import { withAlpha, accentText, readableOn } from '../lib/color.ts'
import { useSmallImage } from '../lib/useSmallImage.ts'
import { focusOnMount } from '../lib/focus.ts'
import { useReadingMode } from '../lib/readingMode.ts'
+import { PageMaps, mapAnchor } from './MapBlock.tsx'
const BODY = 'var(--color-muted)'
const WEEKDAYS = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
@@ -136,6 +143,26 @@ function todayIndex(days: Day[]): number {
return found >= 0 ? found : 0
}
+/* An entry's location, linked to its place on a map block on the
+ page when there is one (088). */
+function Place({ entry, accent }: { entry: ContentBlockItem; accent: string }) {
+ const maps = useContext(PageMaps)
+ const { search } = useLocation()
+ if (!entry.location) return null
+ if (!entry.place || !maps.has(entry.place.venue_id)) return {entry.location}
+ return (
+
+
+ {entry.location}
+ , on the map
+
+ )
+}
+
/* An entry's own map image says what it maps. */
export const mapAlt = (entry: ContentBlockItem) => `Map: ${entry.map?.trim() || entry.location || entry.text}`
@@ -240,7 +267,7 @@ function Entry({ entry, accent, sub = false }: { entry: ContentBlockItem; accent
{(entry.location || entry.person) && (
- {entry.location && {entry.location}}
+
{entry.person && (
diff --git a/src/components/admin/MapMarkerInput.tsx b/src/components/admin/MapMarkerInput.tsx
new file mode 100644
index 0000000..7ae0a8f
--- /dev/null
+++ b/src/components/admin/MapMarkerInput.tsx
@@ -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(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) => (
+
+ );
+
+ return (
+
+ );
+}
diff --git a/src/components/admin/fields.tsx b/src/components/admin/fields.tsx
index b80c2fc..8ff6ebe 100644
--- a/src/components/admin/fields.tsx
+++ b/src/components/admin/fields.tsx
@@ -77,6 +77,15 @@
Data → Links/redirects (the `redirects` options) that fills the
field with the short link's full address, /go/.
+ `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.
@@ -114,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
@@ -122,21 +134,25 @@ 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) => (
- {
- 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 };
- }),
- },
- ]}
- />
- ),
+ // A venue and an item's event and map location come from the
+ // options the same way (088): an event as its title only.
+ contentBlock: (row, options) => {
+ const venue = venueFromOption(options?.venues?.find((v) => v.id === row.venue_id));
+ 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 ;
+ },
};
const input =
@@ -282,7 +298,7 @@ function Checklist({ id, options, value, disabled, empty, onChange }: {
/* ── 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).
@@ -397,6 +413,14 @@ export function Field({ field, value, row, options, error, onChange, onPatch }:
)}