code wiki / _hdl_build / nx_site_handoff.nx
nx_site_handoff.nx source
↩ module page · 109 lines · 5288 B
1// nx_site_handoff.nx -- R-HANDOFF of the SITE FACTORY: turn a factory archetype + its .req brief into a
2// PROD-CUSTOMIZABLE handoff artifact = a valid `.site` BLUEPRINT that the EXISTING production editor stack
3// (nx_siteedit_daemon /site: config -> save-validated -> preview -> publish, andelinwest's live loop) and the
4// whole-site emitter (nx_site_build sb_build_site) consume as-is. This is the "pass it along wholesale, then
5// customize in prod via the data layer" contract: the factory generates; the admin owns a plain data file and
6// a WYSIWYG-backed editor from day one -- no lock-in, no regeneration dependency on the factory.
7// usage: nx_site_handoff <reqfile> <archname> <out.site>
8// Emits the blueprint grammar nx_site_build parses (title| header|brand|cta|href hero|headline|sub
9// search|action|placeholder card|title|body step| sig| footer|). Content comes from the SAME .req brief the
10// factory composes from (sa_req_load / sa_ritem / sa_s), defaults where the brief is silent. license_tier: ORIGINAL
11import "nx_site_archetype.nx"
12const K_MAGIC_32768: i64 = 32768
13
14// archname -> code (reverse of ti_arch_name); 0 = unknown (fail-closed)
15func sh_arch_code(nm: *u8) -> i64 {
16 let buf: *u8 = sys_mmap(32)
17 var c: i64 = 1
18 while c <= 10 {
19 ti_arch_name(c, buf)
20 var i: i64 = 0
21 var eq: i64 = 1
22 while eq == 1 {
23 if (buf[i] as i64) != (nm[i] as i64) { eq = 0 } else {
24 if buf[i] == (0 as u8) { return c }
25 i = i + 1
26 }
27 }
28 c = c + 1
29 }
30 return 0
31}
32// the archetype's main 6-item grid section id, or 0 -> use the 3 generic capability cards
33func sh_mainsec(arch: i64) -> *u8 {
34 if arch == 2 { return "products" as *u8 }
35 if arch == 4 { return "library" as *u8 }
36 if arch == 5 { return "work" as *u8 }
37 if arch == 6 { return "apps" as *u8 }
38 if arch == 8 { return "work" as *u8 }
39 if arch == 9 { return "gallery" as *u8 }
40 return 0 as *u8
41}
42
43func sh_line(buf: *u8, o: i64, s: *u8) -> i64 { return sa_cat(buf, o, s) }
44
45func main(argc: i64, argv: *i64) -> i64 {
46 if argc < 4 { sa_w("usage: nx_site_handoff <reqfile> <archname> <out.site>\n" as *u8); return 2 }
47 let reqfile: *u8 = argv[1] as *u8
48 let archnm: *u8 = argv[2] as *u8
49 let outp: *u8 = argv[3] as *u8
50 let arch: i64 = sh_arch_code(archnm)
51 if arch == 0 { sa_w("site-handoff: unknown archetype " as *u8); sa_w(archnm); sa_w("\n" as *u8); return 2 }
52 let rl: i64 = sa_req_load(reqfile)
53 if rl < 0 { sa_w("site-handoff: cannot read reqfile " as *u8); sa_w(reqfile); sa_w("\n" as *u8); return 3 }
54
55 let buf: *u8 = sys_mmap(K_MAGIC_32768)
56 var o: i64 = 0
57 // title
58 o = sh_line(buf, o, "title|" as *u8)
59 o = sh_line(buf, o, sa_disp(arch))
60 o = sh_line(buf, o, " -- generated by the Nishi Site Factory\n" as *u8)
61 // header: brand | cta-label | cta-href
62 o = sh_line(buf, o, "header|Nishi|" as *u8)
63 o = sh_line(buf, o, sa_s(arch, 5))
64 o = sh_line(buf, o, "|/\n" as *u8)
65 // hero: headline | sub
66 o = sh_line(buf, o, "hero|" as *u8)
67 o = sh_line(buf, o, sa_headline(arch))
68 o = sh_line(buf, o, "|" as *u8)
69 o = sh_line(buf, o, sa_s(arch, 3))
70 o = sh_line(buf, o, "\n" as *u8)
71 // onsite search (conversion floor)
72 o = sh_line(buf, o, "search|/search|Search this site\n" as *u8)
73 // cards: the archetype's grid items (req-filled) or 3 generic capability cards
74 let sec: *u8 = sh_mainsec(arch)
75 if (sec as i64) != 0 {
76 var i: i64 = 1
77 while i <= 6 {
78 o = sh_line(buf, o, "card|" as *u8)
79 o = sh_line(buf, o, sa_ritem(arch, sec, i, "t" as *u8, "A section" as *u8))
80 o = sh_line(buf, o, "|" as *u8)
81 o = sh_line(buf, o, sa_ritem(arch, sec, i, "b" as *u8, "Composed by the factory; edit me in the site editor." as *u8))
82 o = sh_line(buf, o, "\n" as *u8)
83 i = i + 1
84 }
85 } else {
86 o = sh_line(buf, o, "card|Fast|Static-fast pages with no framework tax.\n" as *u8)
87 o = sh_line(buf, o, "card|Accessible|WCAG-AAA contrast and keyboard-first navigation.\n" as *u8)
88 o = sh_line(buf, o, "card|Sovereign|No third-party CSS, JS, or trackers.\n" as *u8)
89 }
90 // 3-step funnel + trust signals (the conversion floor the emitter enforces)
91 o = sh_line(buf, o, "step|Tell us what you need\n" as *u8)
92 o = sh_line(buf, o, "step|We compose it from the consumed corpus\n" as *u8)
93 o = sh_line(buf, o, "step|Publish with rollback -- customize any time\n" as *u8)
94 o = sh_line(buf, o, "sig|WCAG-AAA by construction\n" as *u8)
95 o = sh_line(buf, o, "sig|Zero JS, zero trackers\n" as *u8)
96 o = sh_line(buf, o, "sig|Never-brick publish with backup\n" as *u8)
97 // footer
98 o = sh_line(buf, o, "footer|" as *u8)
99 o = sh_line(buf, o, sa_s(arch, 8))
100 o = sh_line(buf, o, "\n" as *u8)
101
102 let fd: i64 = sys_openat_wr(outp, 0x1a4)
103 if fd < 0 { sa_w("site-handoff: cannot write " as *u8); sa_w(outp); sa_w("\n" as *u8); return 1 }
104 sys_write(fd, buf, o)
105 sys_close(fd)
106 sa_w("SITE-HANDOFF OK: " as *u8); sa_w(archnm); sa_w(" -> " as *u8); sa_w(outp)
107 sa_w(" (editable .site blueprint; serve with nx_siteedit_daemon, rebuild with nx_site_build)\n" as *u8)
108 return 0
109}