Page features: directory and blog post tabs, image converter, version names
- Featured event badge: above the event's card from lg up, left out on phones - Version names from the tag (The Region Cards Update) in the site and admin footers - Tools -> Image converter (JPG, PNG, WebP in the browser) and Download as in Media - People directory sections take several tags, a tab each (migration 078) - Tab blocks split a blog post into tabs; contents follow the open tab (migration 079) - The side nav sun fades out as the page scrolls into the footer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a6c66d4607
commit
31afa889d6
28 changed files with 878 additions and 70 deletions
|
|
@ -152,6 +152,8 @@ export const blocksChild = (ownerKind) => ({
|
|||
"table",
|
||||
"cards",
|
||||
"people",
|
||||
// A blog post's tab (079): its text is the tab's title.
|
||||
"tab",
|
||||
],
|
||||
{ required: true },
|
||||
),
|
||||
|
|
|
|||
|
|
@ -36,12 +36,19 @@ const sectionsChild = {
|
|||
text("scope_id"),
|
||||
enumeration("event_type", ["retreat", "class", "workshop", "meeting", "other"]),
|
||||
enumeration("view", ["carousel", "grid", "map"]),
|
||||
text("tag_id"),
|
||||
// Organization cards (067): the kinds listed by themselves.
|
||||
enumeration("org_kinds", ["partner", "ministry", "partner,ministry"]),
|
||||
],
|
||||
children: [
|
||||
blocksChild("page_section"),
|
||||
{
|
||||
// A People directory's tags (078), a tab each, in order.
|
||||
key: "tags",
|
||||
table: "page_section_tags",
|
||||
owner: { column: "section_id" },
|
||||
order: "sort_order",
|
||||
columns: [text("tag_id", { required: true })],
|
||||
},
|
||||
{
|
||||
// Organization cards (067): a hand-picked list, shown instead.
|
||||
key: "orgs",
|
||||
|
|
|
|||
66
server/src/migrations/078_directory_tabs.sql
Normal file
66
server/src/migrations/078_directory_tabs.sql
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 078 DIRECTORY TABS
|
||||
--
|
||||
-- A People directory section (page_sections.preset
|
||||
-- 'people_directory') shows several People tags, a tab each, in
|
||||
-- the order picked: Community's Directories, eg. Musicians, Authors,
|
||||
-- Creators. page_section_tags holds them; each section's one tag_id
|
||||
-- becomes its first, and the column goes (page_sections is rebuilt,
|
||||
-- since a column with a REFERENCES can't be dropped in place).
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
|
||||
CREATE TABLE page_section_tags (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
section_id INTEGER NOT NULL REFERENCES page_sections (id) ON DELETE CASCADE,
|
||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||
tag_id TEXT NOT NULL REFERENCES person_tag_types (id) ON DELETE CASCADE
|
||||
) STRICT;
|
||||
|
||||
CREATE INDEX page_section_tags_section_idx ON page_section_tags (section_id, sort_order);
|
||||
|
||||
INSERT INTO page_section_tags (section_id, sort_order, tag_id)
|
||||
SELECT id, 0, tag_id FROM page_sections WHERE tag_id IS NOT NULL;
|
||||
|
||||
CREATE TABLE page_sections_new (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
page_id TEXT NOT NULL REFERENCES site_pages (id) ON DELETE CASCADE,
|
||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||
anchor TEXT NOT NULL
|
||||
CONSTRAINT "A section's URL ID can use only lowercase letters, numbers and hyphens, eg. leadership."
|
||||
CHECK (anchor <> '' AND anchor NOT GLOB '*[^a-z0-9-]*'),
|
||||
title TEXT NOT NULL
|
||||
CONSTRAINT "A section title can be 30 characters at most (it's listed in the page's side nav)."
|
||||
CHECK (length(title) <= 30),
|
||||
blurb TEXT,
|
||||
accent TEXT CHECK (accent IN ('teal', 'deep', 'green', 'amber')),
|
||||
preset TEXT CHECK (preset IN ('community_blog', 'group_map', 'region_list', 'partner_list',
|
||||
'events', 'timeline', 'people_directory')),
|
||||
-- An events preset's filter and first view.
|
||||
scope_id TEXT REFERENCES event_scopes (id) ON DELETE SET NULL,
|
||||
event_type TEXT CHECK (event_type IN ('retreat', 'class', 'workshop', 'meeting', 'other')),
|
||||
view TEXT CHECK (view IN ('carousel', 'grid', 'map')),
|
||||
-- Organization cards (067): the kinds listed by themselves.
|
||||
org_kinds TEXT CHECK (org_kinds IN ('partner', 'ministry', 'partner,ministry')),
|
||||
UNIQUE (page_id, anchor)
|
||||
) STRICT;
|
||||
|
||||
INSERT INTO page_sections_new
|
||||
(id, page_id, sort_order, anchor, title, blurb, accent, preset, scope_id, event_type, view, org_kinds)
|
||||
SELECT id, page_id, sort_order, anchor, title, blurb, accent, preset, scope_id, event_type, view, org_kinds
|
||||
FROM page_sections;
|
||||
|
||||
-- page_section_orgs, page_section_tags and content_blocks' owner
|
||||
-- trigger name page_sections; legacy mode leaves them alone through
|
||||
-- the rename.
|
||||
PRAGMA legacy_alter_table = ON;
|
||||
DROP TABLE page_sections;
|
||||
ALTER TABLE page_sections_new RENAME TO page_sections;
|
||||
PRAGMA legacy_alter_table = OFF;
|
||||
|
||||
CREATE INDEX page_sections_page_idx ON page_sections (page_id, sort_order);
|
||||
|
||||
CREATE TRIGGER page_sections_cleanup
|
||||
AFTER DELETE ON page_sections
|
||||
BEGIN
|
||||
DELETE FROM content_blocks WHERE owner_kind = 'page_section' AND owner_id = CAST(old.id AS TEXT);
|
||||
END;
|
||||
76
server/src/migrations/079_tab_blocks.sql
Normal file
76
server/src/migrations/079_tab_blocks.sql
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 079 TAB BLOCKS
|
||||
--
|
||||
-- A blog post can be split into tabs: a 'tab' block (its text the
|
||||
-- tab's title) starts a tab holding the blocks after it, up to the
|
||||
-- next one; the blocks before the first are the intro above the
|
||||
-- tabs. The post's contents follow the open tab (BlogPost.tsx).
|
||||
-- content_blocks.type's CHECK can't change in place, so the table is
|
||||
-- rebuilt, then its index and owner trigger are made again.
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
|
||||
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')),
|
||||
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, slot, sort_order, type, text, media, href, alt, cite, team_id, captions
|
||||
FROM content_blocks;
|
||||
|
||||
-- The block items and the owners' cleanup triggers 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;
|
||||
|
|
@ -49,7 +49,7 @@ sitePages.get("/site-pages/:id", (c) => {
|
|||
|
||||
const rows = db
|
||||
.prepare(
|
||||
`SELECT id, anchor, title, blurb, accent, preset, scope_id, event_type, view, tag_id, org_kinds
|
||||
`SELECT id, anchor, title, blurb, accent, preset, scope_id, event_type, view, org_kinds
|
||||
FROM page_sections WHERE page_id = ? ORDER BY sort_order, id`,
|
||||
)
|
||||
.all(id);
|
||||
|
|
@ -64,6 +64,17 @@ sitePages.get("/site-pages/:id", (c) => {
|
|||
.all(id)) {
|
||||
picked.set(section_id, [...(picked.get(section_id) ?? []), org_id]);
|
||||
}
|
||||
// A People directory's tags (078), in order.
|
||||
const tags = new Map();
|
||||
for (const { section_id, tag_id } of db
|
||||
.prepare(
|
||||
`SELECT t.section_id, t.tag_id FROM page_section_tags t
|
||||
JOIN page_sections s ON s.id = t.section_id
|
||||
WHERE s.page_id = ? ORDER BY t.section_id, t.sort_order, t.id`,
|
||||
)
|
||||
.all(id)) {
|
||||
tags.set(section_id, [...(tags.get(section_id) ?? []), tag_id]);
|
||||
}
|
||||
|
||||
// A hidden page is only for those signed in: never kept.
|
||||
const send = hidden ? (body) => c.json(body, 200, NO_STORE) : (body) => json(c, body);
|
||||
|
|
@ -74,6 +85,7 @@ sitePages.get("/site-pages/:id", (c) => {
|
|||
...section,
|
||||
blocks: blocks.get(String(sectionId)) ?? [],
|
||||
org_ids: picked.get(sectionId) ?? [],
|
||||
tag_ids: tags.get(sectionId) ?? [],
|
||||
})),
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue