- 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>
76 lines
3.6 KiB
SQL
76 lines
3.6 KiB
SQL
-- ═══════════════════════════════════════════════════════════════
|
|
-- 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;
|