code wiki / _hdl_build / nx_cms_visual_preview.nx

nx_cms_visual_preview.nx source

↩ module page · 30 lines · 2466 B

1// nx_cms_visual_preview.nx -- emit a STANDALONE, PUBLISHABLE preview of the visual site editor (R-CANVAS v1) 2// so the operator can SEE the field-level editor on nishifamily.com via the content API without deploying the 3// daemon. Reads a .site blueprint, renders it through the same nx_cms_visual_builder form (prefilled), inside a 4// full HTML doc with a clear read-only banner (the functional Save/Preview/Publish lives in nx_siteedit_daemon). 5// usage: nx_cms_visual_preview <config.site> -> full HTML page on stdout 6// license_tier: ORIGINAL 7import "nx_syscalls.nx" 8import "nx_cms_visual_builder.nx" 9const K_MAGIC_600000: i64 = 600000 10 11func vp_w(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } 12 13func main(argc: i64, argv: *i64) -> i64 { 14 if argc < 2 { vp_w(2, "usage: nx_cms_visual_preview <config.site>\n" as *u8); return 2 } 15 let szp: *i64 = sys_mmap(16) as *i64 16 szp[0] = 0 17 let cfg: *u8 = sys_read_file(argv[1] as *u8, szp) 18 var cn: i64 = 0 19 if (cfg as i64) != 0 { cn = szp[0] } 20 let body: *u8 = sys_mmap(K_MAGIC_600000) 21 var b: i64 = 0 22 b = vp_wcat(body, b, "<!DOCTYPE html><html lang=\"en\"><meta charset=utf-8><meta name=viewport content=\"width=device-width,initial-scale=1\"><title>Visual site editor -- preview</title><body style=\"font-family:-apple-system,Segoe UI,sans-serif;max-width:900px;margin:3vh auto;padding:0 20px;color:rgb(28,28,30)\">" as *u8) 23 b = vp_wcat(body, b, "<div style=\"background:rgb(232,247,233);border:1px solid rgb(120,200,140);border-radius:9px;padding:12px 16px;margin-bottom:16px;font-size:.9rem\"><b>The functional editor is LIVE:</b> <a href=\"https://andelinwest.com/site\">andelinwest.com/site</a> (sign in with the portal account; Save/Preview/Publish run server-side with versioned rollback). This static page is a read-only preview of the same form, prefilled from andelinwest.com.</div>" as *u8) 24 b = vp_wcat(body, b, "<h2>Edit your site</h2>" as *u8) 25 b = vb_form_page(cfg, cn, "PREVIEW" as *u8, 7, body, b) 26 b = vp_wcat(body, b, "<p style=\"color:rgb(122,130,150);font-size:.8rem;margin-top:18px\">Composed by nx_cms_visual_builder &middot; zero client JavaScript &middot; the same lib the live editor uses.</p></body></html>" as *u8) 27 sys_write(1, body, b) 28 return 0 29} 30func vp_wcat(buf: *u8, off: i64, s: *u8) -> i64 { var o: i64=off; var i: i64=0; while s[i]!=(0 as u8){buf[o]=s[i]; o=o+1; i=i+1} return o }