docs(examples): add the CMS proof-of-concept dogfooding artifact
A WordPress-inspired CMS whose entire backend is PiCloud Rhai scripts deployed with pic apply, plus a SvelteKit frontend. Built to dogfood the project tool, CLI, and SDK; exercises docs/kv/files/users, docs+queue+cron +pubsub triggers, the transactional-outbox notification chain, a docs before-interceptor, set_if CAS, SSE, per-app CORS, env overlays, and a durable Workflow (validate -> enrich || seo -> publish -> finalize) started with workflow::start and polled with workflow::run_status, visualized live with Svelte Flow. FINDINGS.md / SECURITY.md capture every gap, surprise, and security issue found (each tagged [PiCloud] vs [CMS]); the platform fixes for the actionable ones ship in the preceding commit. Also folds in the read-only `pic` allowlist entries added to .claude/settings.json during the session (fewer-permission-prompts). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
24
examples/cms-poc/scripts/workflow/wf_enrich.rhai
Normal file
24
examples/cms-poc/scripts/workflow/wf_enrich.rhai
Normal file
@@ -0,0 +1,24 @@
|
||||
// workflow step: enrich — auto-generate an excerpt (if missing) and a reading
|
||||
// time, and write them back onto the post. Runs in PARALLEL with `seo`.
|
||||
let b = ctx.request.body;
|
||||
let posts = docs::collection("posts");
|
||||
let post = posts.get(b.post_id);
|
||||
let d = post.data;
|
||||
let body = if d.body_md == () { "" } else { d.body_md };
|
||||
let words = if body == "" { 0 } else { body.split(" ").len() };
|
||||
let reading_time = (words / 200) + 1;
|
||||
|
||||
let excerpt = d.excerpt;
|
||||
if excerpt == () || excerpt == "" {
|
||||
let parts = body.split(" ");
|
||||
let n = if parts.len() < 24 { parts.len() } else { 24 };
|
||||
let ex = "";
|
||||
for i in 0..n { ex += parts[i] + " "; }
|
||||
ex.trim();
|
||||
excerpt = ex + "…";
|
||||
d.excerpt = excerpt;
|
||||
}
|
||||
d.reading_time = reading_time;
|
||||
posts.update(b.post_id, d);
|
||||
|
||||
#{ excerpt: excerpt, reading_time: reading_time }
|
||||
Reference in New Issue
Block a user