Add global (saved) embed components
Add global (saved) embed components
#57 in Riparion/riparion-cms — merged 2026-06-03
Summary
Extends the existing embed system so any embed type can have saved, centrally-managed instances, referenced from post/page bodies by id — [[/name id=N]]. The id prop is mutually exclusive with all other props (props come from the stored definition), so editing a saved component updates every reference at once. Adds no new widget types.
What's included
- Data + resolution: new
global_embedstable (sqlite + postgres) storing the frozen prop bag as JSON;resolve_global_embedsis a batched async post-parse pass wired intoget_post,assemble_page_detail, andhighlight_block. Unknown ids fall back to a gracefulmissing_globalnotice; bodies with noiddo zero DB work. - Authoring: a typed
PropSpec/PropKindschema on everySMART_TAGSentry powers a per-prop admin form with a live preview at/admin/components, gated by a newcomponents:writetoken (added toALL_TOKENS, nav, breadcrumbs, audit vocabulary). - Delete = convert to inline: deleting a component rewrites every reference into an equivalent inline embed with the frozen props baked in, then removes the row — all in one transaction, and stamps
pages.updated_atso sitemaplastmodstays correct. No page breaks. - Discoverability: saved components appear in the editor's
[[/autocomplete and the "+ Smart tag" menu, inserting[[/name id=N]]; Live preview resolves them server-side. - Help: new
/help/componentsarticle + admin deep-link.
Review hardening (applied)
highlight_blocknow requires an author token (posts:write/pages:write) — it reads admin-managed config when resolving references, so it can't be an unauthenticated read.- Prop values reject
"/newlines so they round-trip safely when inlined on delete. - Inline-on-delete is transactional;
missing_globalid bound to a local before rsx.
Verification
cargo fmt --check; clippy-D warningson server (sqlite + postgres) and wasm/web — all clean.cargo test --features server,sqlite— 47 pass (incl. newmdxround-trip tests).- Manual end-to-end steps appended to
TODO_VERIFICATION.md.
🤖 Generated with Claude Code
Last updated 2026-06-04
Links to this note
Credits
Merged pull requests, newest first.