Content display, requests and Google Workspace (v1.9.5 to v1.9.11-content-display) #15

Merged
ngu-git-admin merged 20 commits from content-display into main 2026-09-30 02:34:53 +01:00
2 changed files with 78 additions and 16 deletions
Showing only changes of commit 0e582c236b - Show all commits

View file

@ -1,20 +1,12 @@
-- ═══════════════════════════════════════════════════════════════
-- 044 TABLE AND CARD BLOCKS
-- 044 TABLE BLOCKS
--
-- Two content block types:
--
-- table a grid of text, for comparison charts and the like (a
-- blog post imported from Word, say). The grid is the
-- block's text, one row per line, cells split by "|", the
-- first row the header; cells take the same inline
-- formatting as a paragraph (**bold**, *italic*,
-- [link](url)).
-- cards link cards, one per item, like a link shared in a chat:
-- the item's text is the title, detail the description,
-- url the link and media the picture (all as today's item
-- columns). Fetch preview in the admin fills them.
--
-- ContentBlocks.tsx draws both.
-- A content block of type 'table': a grid of text, for comparison
-- charts and the like (a blog post imported from Word, say). The
-- grid is the block's text, one row per line, cells split by "|",
-- the first row the header; cells take the same inline formatting as
-- a paragraph (**bold**, *italic*, [link](url)). ContentBlocks.tsx
-- draws it.
--
-- Only the type's CHECK changes, and SQLite can't alter a CHECK, so
-- the table is rebuilt the way 031, 032 and 034 did it
@ -33,7 +25,7 @@ CREATE TABLE content_blocks_new (
type TEXT NOT NULL
CHECK (type IN ('heading', 'subheading', 'paragraph',
'list', 'links', 'quote', 'image', 'divider',
'video', 'button', 'callout', 'schedule', 'table', 'cards')),
'video', 'button', 'callout', 'schedule', 'table')),
text TEXT,
media TEXT,
href TEXT,

View file

@ -0,0 +1,70 @@
-- ═══════════════════════════════════════════════════════════════
-- 045 LINK CARD BLOCKS
--
-- A content block of type 'cards': link cards, one per item, like a
-- link shared in a chat. The item's text is the title, detail the
-- description, url the link and media the picture (the item columns
-- there already are); Fetch preview in the admin fills them.
-- ContentBlocks.tsx draws it.
--
-- Only the type's CHECK changes, so the table is rebuilt as 044 did
-- (legacy_alter_table around the rename, then its index and owner
-- trigger 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')),
owner_id TEXT NOT NULL,
slot TEXT NOT NULL DEFAULT 'body' CHECK (slot IN ('card', 'body')),
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')),
text TEXT,
media TEXT,
href TEXT,
alt TEXT,
cite TEXT
) STRICT;
INSERT INTO content_blocks_new
(id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite)
SELECT id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite
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);
-- ── Triggers last (see CLAUDE.md, Migrations) ──
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')
END;
END;