diff --git a/docs/media-uploads.md b/docs/media-uploads.md index 99ad77c..6e3bfdb 100644 --- a/docs/media-uploads.md +++ b/docs/media-uploads.md @@ -15,14 +15,6 @@ in the `media` table (`server/src/migrations/028_media.sql`). - **Keep original** stores the file exactly as uploaded (up to 10 MB), metadata and all. - SVGs are always kept as they are. -- A photo field with a shape (people, event photos and card - backgrounds, blog covers, hero photos, link card pictures, block - images and schedule graphics; not logos) opens **Frame the photo** - before uploading a JPEG, PNG or WebP: drag and zoom it inside the - field's shape, or pick another (As uploaded keeps the photo's own). - The framed part is what's uploaded; nothing about the framing is - saved, so framing again means uploading again. Upload as is skips - it. A field's shape is its `crop` option (`src/components/admin/fields.tsx`). - Accepted types: JPEG, PNG, GIF, WebP, SVG, and WebVTT captions (`.vtt`, kept as they are, always in `captions/`). The type is read from the file's contents, not its name: a captions file has to start diff --git a/docs/updating-data-in-code.md b/docs/updating-data-in-code.md index fd27b57..757a51c 100644 --- a/docs/updating-data-in-code.md +++ b/docs/updating-data-in-code.md @@ -29,7 +29,6 @@ what a dropdown in the admin editor says. | ------------------------------------------------------------ | ---------------- | ------------------------------------ | | A record: an event, organization, person, team, award, timeline entry | the database | editing it in the admin | | People tags (directories, eg. Musicians, at `/directory/`) and contact types (Minister, General info), and organizations' contacts | the database | Admin → Data → People tags, Contact types; who carries a tag is set on the person, contacts on the organization | -| Tags for organizations and events (Online, In-Person; URL ID `online` marks an event online for the calendar filter) | the database | Admin → Data → Tags; who carries a tag is set on the organization or event | | The front page's words, photos, bands, stats and paths | the database | Admin → Pages → Front page | | Blog posts, and the Community page's blog settings (headings, pins, feeds) | the database | Admin → Data → Blog posts, and Admin → Pages → Community | | The sections of Retreats, Community, Resources, Organization and History: titles, blurbs, accents, their content blocks and presets (the blog, groups map, regions, partners, events, timeline, a people directory) | the database | Admin → Pages → the page. A section title is 30 characters at most (it's listed in the side nav); a front page heading fits about 60. Preset names: `PRESETS` in `src/lib/adminSchema/sitePages.ts`, what each draws: `PRESETS` in `src/pages/SitePage.tsx` | @@ -205,7 +204,6 @@ code): | Group → Region | `regions` | organizations of kind region | | Group → Ministry | `ministries` | organizations of kind ministry | | People → Directories → Tag; Pages → Sections → Directory: tag | `person_tag_types` | Data → People tags | -| Organizations and Events → Tags → Tag | `tags` | Data → Tags | | Organizations → Contacts → Type | `contact_types` | Data → Contact types | | Event → Scope (+ list filter); Front page → Countdown → Only this scope | `event_scopes` | the `event_scopes` table (migration only) | | Event hosts → Organization; affiliations; team and award "Organization" / "Awarded by"; person → Home organization | `organizations` | organizations, labeled by name, except ministries (they have no page to link to) | diff --git a/server/src/admin-schema.js b/server/src/admin-schema.js index 7294fa9..8ac58f7 100644 --- a/server/src/admin-schema.js +++ b/server/src/admin-schema.js @@ -55,7 +55,6 @@ import { blogPosts } from "./admin-schema/blog.js"; import { siteSettings } from "./admin-schema/siteSettings.js"; import { newsletters } from "./admin-schema/newsletters.js"; import { personTagTypes } from "./admin-schema/personTags.js"; -import { tags } from "./admin-schema/tags.js"; import { contactTypes } from "./admin-schema/contactTypes.js"; import { redirects } from "./admin-schema/redirects.js"; import { @@ -71,7 +70,6 @@ export const ENTITIES = { events, people, person_tag_types: personTagTypes, - tags, contact_types: contactTypes, redirects, teams, @@ -107,7 +105,6 @@ export const OPTION_QUERIES = { 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", person_tag_types: "SELECT id, name AS label FROM person_tag_types ORDER BY sort_order, name", - tags: "SELECT id, name AS label FROM tags ORDER BY sort_order, name", 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", diff --git a/server/src/admin-schema/columns.js b/server/src/admin-schema/columns.js index bda56ea..bb96ef9 100644 --- a/server/src/admin-schema/columns.js +++ b/server/src/admin-schema/columns.js @@ -28,6 +28,7 @@ export const placeColumns = [ text("location_label"), real("latitude"), real("longitude"), + bool("is_online"), ]; /* The affiliation's own fields, minus whichever end owns the row. @@ -131,7 +132,7 @@ export const blocksChild = (ownerKind) => ({ owner: { column: "owner_id", kindColumn: "owner_kind", kindValue: ownerKind }, order: "sort_order", columns: [ - enumeration("slot", ["card", "body", "both"], { required: true }), + enumeration("slot", ["card", "body"], { required: true }), enumeration( "type", [ @@ -182,7 +183,6 @@ export const blocksChild = (ownerKind) => ({ text("media"), text("media_alt"), text("map"), - text("map_image"), ], }, ], diff --git a/server/src/admin-schema/events.js b/server/src/admin-schema/events.js index 253a1b8..396f5c3 100644 --- a/server/src/admin-schema/events.js +++ b/server/src/admin-schema/events.js @@ -1,5 +1,4 @@ import { text, int, bool, date, time, enumeration, placeColumns, timelineExtension, linksChild, blocksChild, hostsChild } from "./columns.js"; -import { tagsChild } from "./tags.js"; /* ── Events ──────────────────────────────────────────────────── */ @@ -86,7 +85,6 @@ export const events = { children: [ hostsChild, - tagsChild("event_tags", "event_id"), linksChild("event"), blocksChild("event"), { diff --git a/server/src/admin-schema/organizations.js b/server/src/admin-schema/organizations.js index bfc531d..8f19d14 100644 --- a/server/src/admin-schema/organizations.js +++ b/server/src/admin-schema/organizations.js @@ -1,5 +1,4 @@ import { text, int, real, bool, enumeration, placeColumns, timelineExtension, linksChild, blocksChild } from "./columns.js"; -import { tagsChild } from "./tags.js"; /* ── Organizations ───────────────────────────────────────────── */ @@ -68,7 +67,6 @@ export const organizations = { ], children: [ - tagsChild("organization_tags", "org_id"), linksChild("organization"), blocksChild("organization"), // Who to write to there, by role (064_org_contacts.sql): private, diff --git a/server/src/admin-schema/tags.js b/server/src/admin-schema/tags.js deleted file mode 100644 index d0831ef..0000000 --- a/server/src/admin-schema/tags.js +++ /dev/null @@ -1,35 +0,0 @@ -import { text, int } from "./columns.js"; - -/* ── Tags (070_tags.sql) ───────────────────────────────────────── - - Descriptor tags for organizations and events (Online, In-Person). - Its own entity, not a repeater, because organization_tags and - event_tags point at it: deleting a tag takes it off every record - (cascade). Which records carry a tag is edited on the record. The - URL ID "online" is what v_events reads as an online event. */ - -export const tags = { - key: "tags", - table: "tags", - idColumn: "id", - idKind: "slug", - - list: { - columns: ["id", "name", "sort_order"], - filters: [], - search: ["name", "id"], - order: "sort_order, name", - }, - - columns: [text("name", { required: true }), int("sort_order")], -}; - -/* The Tags repeater on an organization or event: owner is the - record's id column in that tag table. */ -export const tagsChild = (table, owner) => ({ - key: "tags", - table, - owner: { column: owner }, - order: "sort_order", - columns: [text("tag_id", { required: true })], -}); diff --git a/server/src/migrations/069_schedule_map_image.sql b/server/src/migrations/069_schedule_map_image.sql deleted file mode 100644 index 25c5e36..0000000 --- a/server/src/migrations/069_schedule_map_image.sql +++ /dev/null @@ -1,10 +0,0 @@ --- ═══════════════════════════════════════════════════════════════ --- 069 SCHEDULE MAP IMAGE --- --- A schedule entry's own map picture (an upload), eg. a drawn map of --- the camp with the room marked. Shown in the entry's fold-out in --- place of the Google map, and as a slide in the schedule --- presentation (/events//present). --- ═══════════════════════════════════════════════════════════════ - -ALTER TABLE content_block_items ADD COLUMN map_image TEXT; diff --git a/server/src/migrations/070_tags.sql b/server/src/migrations/070_tags.sql deleted file mode 100644 index 251f4bd..0000000 --- a/server/src/migrations/070_tags.sql +++ /dev/null @@ -1,84 +0,0 @@ --- ═══════════════════════════════════════════════════════════════ --- 070 TAGS --- --- Descriptor tags for organizations and events (Data → Tags), in --- place of the Online checkbox: Online and In-Person to start, more --- as they're needed. A record's tags show on its page and, for --- groups, on the Community map's list and grid. --- --- The tag with URL ID "online" still means online to the site: --- v_events turns it back into is_online, which the calendar's --- online filter, the "Online" place line and an event's search data --- read. Records ticked Online get the tag; nothing gets In-Person --- automatically. --- ═══════════════════════════════════════════════════════════════ - -CREATE TABLE tags ( - id TEXT PRIMARY KEY - CONSTRAINT "A tag's URL ID can use only lowercase letters, numbers and hyphens, eg. in-person." - CHECK (id <> '' AND id NOT GLOB '*[^a-z0-9-]*'), - name TEXT NOT NULL, -- 'In-Person', as shown - sort_order INTEGER NOT NULL DEFAULT 0 -) STRICT; - -INSERT INTO tags (id, name, sort_order) VALUES - ('online', 'Online', 0), - ('in-person', 'In-Person', 1); - -CREATE TABLE organization_tags ( - org_id TEXT NOT NULL REFERENCES organizations (id) ON DELETE CASCADE, - tag_id TEXT NOT NULL REFERENCES tags (id) ON DELETE CASCADE, - sort_order INTEGER NOT NULL DEFAULT 0, - PRIMARY KEY (org_id, tag_id) -) STRICT; -CREATE INDEX organization_tags_tag_idx ON organization_tags (tag_id); - -CREATE TABLE event_tags ( - event_id TEXT NOT NULL REFERENCES events (id) ON DELETE CASCADE, - tag_id TEXT NOT NULL REFERENCES tags (id) ON DELETE CASCADE, - sort_order INTEGER NOT NULL DEFAULT 0, - PRIMARY KEY (event_id, tag_id) -) STRICT; -CREATE INDEX event_tags_tag_idx ON event_tags (tag_id); - -INSERT INTO organization_tags (org_id, tag_id) SELECT id, 'online' FROM organizations WHERE is_online = 1; -INSERT INTO event_tags (event_id, tag_id) SELECT id, 'online' FROM events WHERE is_online = 1; - --- v_events reads e.*, so it goes while the column does and comes --- back with is_online from the tag. -DROP VIEW v_events; -ALTER TABLE organizations DROP COLUMN is_online; -ALTER TABLE events DROP COLUMN is_online; - -CREATE VIEW v_events AS -SELECT - e.*, - EXISTS (SELECT 1 FROM event_tags et WHERE et.event_id = e.id AND et.tag_id = 'online') - AS is_online, - CASE WHEN eh.id IS NULL THEN NULL - WHEN eh.person_id IS NULL THEN 'organization' ELSE 'person' END - AS host_kind, - COALESCE(eh.org_id, eh.person_id) AS host_id, - COALESCE(o.name, p.display_name) AS host_name, - o.kind AS host_org_kind, - COALESCE(e.org_logo, o.logo) AS effective_org_logo, - COALESCE(e.color, o.color) AS effective_color, - COALESCE( - e.status, - CASE WHEN e.ends_on IS NOT NULL AND e.ends_on < date('now') - THEN 'past' ELSE 'upcoming' END - ) AS effective_status -FROM events e -LEFT JOIN event_hosts eh - ON eh.id = ( - SELECT x.id - FROM event_hosts x - LEFT JOIN organizations xo ON xo.id = x.org_id - LEFT JOIN people xp ON xp.id = x.person_id - WHERE x.event_id = e.id - AND COALESCE(xo.is_published, xp.is_published) = 1 - ORDER BY x.sort_order, x.id - LIMIT 1 - ) -LEFT JOIN organizations o ON o.id = eh.org_id -LEFT JOIN people p ON p.id = eh.person_id; diff --git a/server/src/migrations/071_block_slot_both.sql b/server/src/migrations/071_block_slot_both.sql deleted file mode 100644 index 06432fe..0000000 --- a/server/src/migrations/071_block_slot_both.sql +++ /dev/null @@ -1,82 +0,0 @@ --- ═══════════════════════════════════════════════════════════════ --- 071 BLOCK SLOT: BOTH --- --- A content block's "Shown in" gets a third choice. Until now a card --- block showed on the card and on the record's page as well (the --- pages printed the card's paragraphs above the body), which the --- editor didn't say. Now: --- --- body the page only --- card the card only --- both the card and the page (the card takes paragraphs only) --- --- Every existing card block becomes both, so nothing on the site --- moves. The CHECK can't change in place, so the table is rebuilt. --- ═══════════════════════════════════════════════════════════════ - -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')), - text TEXT, - media TEXT, - href TEXT, - alt TEXT, - cite TEXT, - team_id TEXT REFERENCES teams (id) ON DELETE SET NULL, - captions TEXT -) STRICT; - -INSERT INTO content_blocks_new - (id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id, captions) -SELECT id, owner_kind, owner_id, CASE slot WHEN 'card' THEN 'both' ELSE slot END, - sort_order, type, text, media, href, alt, cite, team_id, captions - FROM content_blocks; - --- The cleanup triggers on other tables name content_blocks; legacy --- mode leaves them alone through the rename. -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/pageMeta.js b/server/src/pageMeta.js index 2d9bc72..3fbe257 100644 --- a/server/src/pageMeta.js +++ b/server/src/pageMeta.js @@ -400,21 +400,6 @@ export function metaFor(db, rawPath) { return { ...meta, title: titled(site, page.title), description: plainText(page.description) ?? meta.description }; } - // An event's schedule presentation (SchedulePresent.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$/); - if (present) { - let id; - try { - id = decodeURIComponent(present[1]); - } catch { - return notFound(meta); - } - const event = eventMeta(site, db, id, { ...meta, canonical: `${origin(site)}/events/${present[1]}` }); - return event.status === 200 ? { ...event, noindex: true, jsonLd: null } : event; - } - const match = pathname.match(/^\/(events|regions|groups|partners|organizations|teams|awards|people|blog|directory)\/([^/]+)$/); if (!match) return notFound(meta); diff --git a/server/src/routes/blog.js b/server/src/routes/blog.js index 0b437ea..420134a 100644 --- a/server/src/routes/blog.js +++ b/server/src/routes/blog.js @@ -75,7 +75,7 @@ function firstParagraphs(db, rows) { `SELECT owner_id, text FROM ( SELECT owner_id, text, ROW_NUMBER() OVER (PARTITION BY owner_id ORDER BY sort_order) AS n FROM content_blocks - WHERE owner_kind = 'blog_post' AND slot IN ('body', 'both') AND type = 'paragraph' + WHERE owner_kind = 'blog_post' AND slot = 'body' AND type = 'paragraph' AND text IS NOT NULL AND text <> '' AND owner_id IN (${marks(ids.length)}) ) WHERE n = 1`, diff --git a/server/src/routes/content.js b/server/src/routes/content.js index 1bcc307..5c026f8 100644 --- a/server/src/routes/content.js +++ b/server/src/routes/content.js @@ -62,7 +62,6 @@ import { paragraphs, shapeSeries, splitLinks, - attachTags, } from "../shape.js"; const content = new Hono(); @@ -167,7 +166,7 @@ function shapeEvent(row, links, cardBlocks, hosts = []) { /* The common card surface every organization has, whatever kind it is. Kind-specific fields go in `details`, attached by the caller. */ function shapeOrganization(row, links, cardBlocks, bodyBlocks) { - const { actions, socials, websites, emails, website, email, instagram } = splitLinks(links); + const { actions, socials, website, email, instagram } = splitLinks(links); return { id: row.id, @@ -184,18 +183,16 @@ function shapeOrganization(row, links, cardBlocks, bodyBlocks) { state_code: row.state_code, country: row.country, location_label: row.location_label, + is_online: asBool(row.is_online), sort_order: row.sort_order, description: paragraphs(cardBlocks), blocks: bodyBlocks, links: actions, socials, - websites, - emails, website, email, instagram, - tags: [], details: {}, leadership: [], @@ -586,10 +583,14 @@ content.get("/events/:id", (c) => { citation: r.citation, })); - const event = { ...shapeEvent(row, links, cards, hosts), blocks: body, people, awards }; - attachTags(db, "event", [event]); - - return json(c, { event }); + return json(c, { + event: { + ...shapeEvent(row, links, cards, hosts), + blocks: body, + people, + awards, + }, + }); }); /* ── Organizations ───────────────────────────────────────────── @@ -646,7 +647,6 @@ content.get("/organizations", (c) => { attachRegionDetails(db, organizations); attachGroupDetails(db, organizations); - attachTags(db, "organization", organizations); return json(c, { organizations }); }); @@ -669,7 +669,6 @@ content.get("/organizations/:id", (c) => { attachRegionDetails(db, one); attachGroupDetails(db, one); - attachTags(db, "organization", one); attachLeadership(db, one); attachTeams(db, one); attachAwards(db, one); diff --git a/server/src/seed-showcase.js b/server/src/seed-showcase.js index 8c88440..6b66af4 100644 --- a/server/src/seed-showcase.js +++ b/server/src/seed-showcase.js @@ -91,7 +91,7 @@ const SCHEDULE = [ { text: "The weekend at a glance. Tap an entry for more." }, [ { 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: "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" }, { 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: "Sunday", time: "10:00am", text: "Closing service", location: "Chapel", map: "Main Street, Halifax PA" }, @@ -165,10 +165,7 @@ const pageBody = (what) => [ ["button", { text: "Get involved", href: "/feedback" }], ]; -/* Card text: paragraphs only, shown on cards and list rows. Most - records put it in "both" (the card and the page); the series and - the past event keep it to the card, to check that it stays off - their pages. */ +/* The card slot: paragraphs only, shown on cards and list rows. */ const cardText = (what) => [ ["paragraph", { text: `Showcase ${what}: the short description that appears on its card.` }], ["paragraph", { text: "A second card paragraph, to check how two read." }], @@ -182,10 +179,6 @@ const standardLinks = (name) => [ { kind: "social", platform: "youtube", label: "YouTube", url: "https://youtube.com/@showcase" }, { kind: "website", label: "Website", url: "https://example.org" }, { kind: "email", label: "showcase@example.org", url: "mailto:showcase@example.org" }, - // A second of each, labeled unlike its address: both listed, each - // going to its own URL. - { kind: "website", label: "Our blog", url: "https://example.org/blog" }, - { kind: "email", label: "Prayer requests", url: "prayer@example.org" }, ]; /* ── Writing ───────────────────────────────────────────────── */ @@ -253,6 +246,7 @@ tx(db, () => { color: "#7a5ea8", logo: IMAGE, ...place, + is_online: 0, is_published: 1, is_listed: LISTED, sort_order: 99, @@ -262,7 +256,7 @@ tx(db, () => { insert("region_areas", { region_id: REGION, area_code: "PA", share: 0.5, edge: "top", note: "western half" }); insert("region_areas", { region_id: REGION, area_code: "OH", share: 1 }); links("organization", REGION, standardLinks("Showcase Region")); - blocks("organization", REGION, "both", cardText("region")); + blocks("organization", REGION, "card", cardText("region")); blocks("organization", REGION, "body", pageBody("region")); insert("organizations", { @@ -275,14 +269,14 @@ tx(db, () => { logo: IMAGE, ...place, venue: "Showcase Community Hall", + is_online: 1, is_published: 1, is_listed: LISTED, sort_order: 99, }); insert("groups", { id: GROUP, region_id: REGION, meets: "2nd Sundays, 6:00pm", started: "Since 2021" }); - ["in-person", "online"].forEach((tag_id, i) => insert("organization_tags", { org_id: GROUP, tag_id, sort_order: i })); links("organization", GROUP, standardLinks("Showcase Group")); - blocks("organization", GROUP, "both", cardText("group")); + blocks("organization", GROUP, "card", cardText("group")); blocks("organization", GROUP, "body", pageBody("group")); /* ── People ── */ @@ -318,7 +312,7 @@ tx(db, () => { { kind: "website", label: "Website", url: "https://example.org/person" }, { kind: "action", label: "Book a call", url: "https://example.org/call" }, ]); - blocks("person", PERSON, "both", cardText("person")); + blocks("person", PERSON, "card", cardText("person")); blocks("person", PERSON, "body", pageBody("person")); MEMBERS.forEach((id, i) => @@ -349,7 +343,7 @@ tx(db, () => { sort_order: 99, }); links("team", TEAM, [{ kind: "action", label: "Join the team", url: "https://example.org/join" }]); - blocks("team", TEAM, "both", cardText("team")); + blocks("team", TEAM, "card", cardText("team")); blocks("team", TEAM, "body", pageBody("team")); insert("affiliations", { person_id: PERSON, org_id: REGION, team_id: TEAM, title: "Showcase Team Lead", role: "lead", is_owner: 1, started_on: "2023-01-01", is_public: 1, sort_order: 0 }); @@ -370,6 +364,7 @@ tx(db, () => { ends_on: db.prepare(`SELECT date('now', '+47 days') AS d`).get().d, date_label: "Three days, six weeks from now", ...place, + is_online: 0, org_logo: IMAGE, event_logo: IMAGE, color: "#d62976", @@ -395,7 +390,7 @@ tx(db, () => { { kind: "action", platform: "discord", label: "Event Discord", url: "https://discord.com/invite/example" }, { kind: "social", platform: "instagram", label: "@showcaseretreat", url: "https://instagram.com/showcaseretreat" }, ]); - blocks("event", EVENT, "both", cardText("event")); + blocks("event", EVENT, "card", cardText("event")); blocks("event", EVENT, "body", [...pageBody("event"), ["heading", { text: "Schedule" }], SCHEDULE]); insert("events", { @@ -407,6 +402,7 @@ tx(db, () => { starts_on: db.prepare(`SELECT date('now', '-14 days') AS d`).get().d, ends_on: db.prepare(`SELECT date('now', '+90 days') AS d`).get().d, location_label: "Online", + is_online: 1, color: "#138ba0", is_series: 1, series_frequency: "weekly", @@ -420,7 +416,6 @@ tx(db, () => { is_listed: LISTED, }); insert("event_hosts", { event_id: SERIES, org_id: GROUP, sort_order: 0 }); - insert("event_tags", { event_id: SERIES, tag_id: "online" }); links("event", SERIES, [{ kind: "action", label: "Join on Zoom", url: "https://example.org/zoom" }]); blocks("event", SERIES, "card", cardText("series")); diff --git a/server/src/shape.js b/server/src/shape.js index e7d617a..51acb01 100644 --- a/server/src/shape.js +++ b/server/src/shape.js @@ -53,8 +53,7 @@ export function loadLinks(db, ownerKind, ids) { } /* ── Blocks ──────────────────────────────────────────────────── - Map of owner_id → blocks for one slot, items attached. A - "both" block (071) is in the card's and the body's. + Map of owner_id → blocks for one slot, items attached. Two queries: the blocks, then every item belonging to them. Blocks with no children come back with an empty items array @@ -69,7 +68,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") { .prepare( `SELECT id, owner_id, type, text, media, href, alt, cite, captions, team_id FROM content_blocks - WHERE owner_kind = ? AND slot IN (?, 'both') AND owner_id IN (${placeholders(ids.length)}) + WHERE owner_kind = ? AND slot = ? AND owner_id IN (${placeholders(ids.length)}) ORDER BY owner_id, sort_order`, ) .all(ownerKind, slot, ...ids); @@ -102,7 +101,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") { 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, + i.day, i.time, i.location, i.description, i.media, i.media_alt, i.map, p.id AS person_id, p.display_name AS person_name, p.photo AS person_photo, p.tagline AS person_tagline FROM content_block_items i @@ -127,7 +126,6 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") { media: row.media, media_alt: row.media_alt, map: row.map, - map_image: row.map_image, person: row.person_id ? { id: row.person_id, @@ -146,8 +144,7 @@ export function loadBlocks(db, ownerKind, ids, slot = "body") { The card slot is paragraphs by convention, so it collapses to an array of strings, desc_a and desc_b become description[0] and description[1]. A non-paragraph block in the card slot is - ignored here. Only cards show it: a record's page draws its - body blocks, "both" ones among them. + ignored here; put it in the body slot instead. ───────────────────────────────────────────────────────────── */ export function paragraphs(blocks = []) { @@ -162,42 +159,12 @@ export function paragraphs(blocks = []) { underlying rows are the same table. ───────────────────────────────────────────────────────────── */ -/* ── Tags (070_tags.sql) ─────────────────────────────────────── - Sets `tags` ([{ id, name }], in the record's order) on each of - these shaped organizations or events, in one query. */ -const TAG_TABLES = { organization: ["organization_tags", "org_id"], event: ["event_tags", "event_id"] }; - -export function attachTags(db, kind, records) { - if (records.length === 0) return; - const [table, owner] = TAG_TABLES[kind]; - const rows = db - .prepare( - `SELECT x.${owner} AS owner_id, t.id, t.name - FROM ${table} x - JOIN tags t ON t.id = x.tag_id - WHERE x.${owner} IN (${placeholders(records.length)}) - ORDER BY x.sort_order, t.sort_order, t.name`, - ) - .all(...records.map((record) => record.id)); - for (const record of records) { - record.tags = rows.filter((row) => row.owner_id === record.id).map(({ id, name }) => ({ id, name })); - } -} - export function splitLinks(links = []) { - const websites = links.filter((link) => link.kind === "website"); - // An email row's URL is the address, with or without mailto:. - const emails = links - .filter((link) => link.kind === "email") - .map((link) => ({ ...link, url: link.url.replace(/^mailto:/i, "") })); return { actions: links.filter((link) => link.kind === "action"), socials: links.filter((link) => link.kind === "social"), - // Every one, for a record's own page; the first, for cards. - websites, - emails, - website: websites[0]?.url ?? null, - email: emails[0]?.url ?? null, + website: links.find((link) => link.kind === "website")?.url ?? null, + email: links.find((link) => link.kind === "email")?.label ?? null, instagram: links.find((link) => link.platform === "instagram")?.label ?? null, }; diff --git a/src/App.tsx b/src/App.tsx index 5f3fc56..af3fa83 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -70,7 +70,6 @@ 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")) /*Admin Pages*/ const AdminLayout = lazyPage(() => import("./pages/admin/AdminLayout.tsx")) @@ -114,15 +113,6 @@ export default function App() { } /> } /> - {/* A schedule as a slideshow for a screen: full screen, no Layout. */} - - - - } - /> diff --git a/src/components/ContentBlocks.tsx b/src/components/ContentBlocks.tsx index e432181..d0f6cbf 100644 --- a/src/components/ContentBlocks.tsx +++ b/src/components/ContentBlocks.tsx @@ -62,14 +62,10 @@ export default function ContentBlocks({ blocks, accent = BRAND, className = '', - presentAt, }: { blocks?: ContentBlock[] | null accent?: string className?: string - /** An event page's presentation route: each schedule gets a Present - * button to it, `?block=` naming which schedule (from 0). */ - presentAt?: string }) { if (!blocks?.length) return null // Headings get ids so a post's contents (PostContents) and a shared @@ -85,22 +81,10 @@ export default function ContentBlocks({ return level }) - let schedules = 0 - const presentHrefs = blocks.map((block) => - presentAt && block.type === 'schedule' ? `${presentAt}?block=${schedules++}` : undefined, - ) - return (
{blocks.map((block, index) => ( - + ))}
) @@ -170,13 +154,11 @@ 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() @@ -377,7 +359,7 @@ function Block({ case 'schedule': if (!block.items?.length) return null - return + return case 'people': { const picked = (block.items ?? []) diff --git a/src/components/OrgContact.tsx b/src/components/OrgContact.tsx index 54f9189..8d2ad16 100644 --- a/src/components/OrgContact.tsx +++ b/src/components/OrgContact.tsx @@ -22,7 +22,7 @@ function PlatformName({ platform, label }: { platform?: string | null; label?: s export default function OrgContact({ org, accent }: { org: OrganizationRecord; accent: string }) { const hasAny = - org.links.length > 0 || org.socials.length > 0 || org.websites.length > 0 || org.emails.length > 0 + org.links.length > 0 || org.socials.length > 0 || org.website || org.email if (!hasAny) return null @@ -43,27 +43,28 @@ export default function OrgContact({ org, accent }: { org: OrganizationRecord; a ))} - {/* Every website and email row, each its own button with its - own label; an email's url is the bare address (splitLinks - in shape.js). */} + {/* website and email arrive as bare strings (splitLinks in + shape.js); socials are whole link rows. */} {[ - ...org.websites, - ...org.emails.map((link) => ({ ...link, url: `mailto:${link.url}` })), + org.website ? { url: org.website, label: 'Website', platform: null } : null, + org.email ? { url: `mailto:${org.email}`, label: org.email, platform: null } : null, ...org.socials, - ].map((link) => ( - - - - {link.label} - - ))} + ] + .filter((link): link is NonNullable => Boolean(link)) + .map((link) => ( + + + + {link.label} + + ))} ) } diff --git a/src/components/OrgLogo.tsx b/src/components/OrgLogo.tsx index 1632662..714dd2e 100644 --- a/src/components/OrgLogo.tsx +++ b/src/components/OrgLogo.tsx @@ -16,13 +16,10 @@ export default function OrgLogo({ org, color, size = 'h-14 w-14', - fallbackSize = size, }: { org: { logo?: string | null; name: string } color: string size?: string - /** The initials square's size, when the logo's box isn't square. */ - fallbackSize?: string }) { return (