code wiki / (root) / nx_site_chrome.nx

nx_site_chrome.nx source

↩ module page · 336 lines · 23694 B

1// nx_site_chrome.nx -- SOVEREIGN site-wide navigation authority. Reads knowledge/site/surfaces.reg 2// (SSOT of every visitor surface: route|section|title|icon|scope|order|desc) and emits, per mode: 3// gate -- self-test + liar-kill (surfaces>=1, sections present, required fields non-empty) 4// header -- global responsive nav bar fragment (brand + primary links + pure-CSS hamburger mega-menu) 5// footer -- grouped footer sitemap fragment 6// sitemapxml -- real sitemap.xml (sitemaps.org 0.9 urlset, public surfaces) 7// page -- complete human /sitemap page (chrome + full grouped index of EVERY surface) 8// This makes ALL assets discoverable from one place, on desktop and mobile, ZERO JavaScript 9// (checkbox-hack menu), a11y (skip-link, aria, focus-visible, >=44px touch targets), light/dark. 10// nx_cc traps honored: no '#'/'!' in string literals -> wc(35)/wc(33); w2 turns ' into " for attrs; 11// CSS uses class selectors (no id '#'); no else-if chains. license_tier: ORIGINAL expect_exit:0 12import "nx_syscalls.nx" 13const K_MAGIC_1024: i64 = 1024 14const K_MAGIC_65536: i64 = 65536 15 16func 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 } 17func wc(fd: i64, code: i64) -> i64 { let t: *u8 = sys_mmap(2); t[0] = code as u8; sys_write(fd, t, 1); return 0 } 18func wn(fd: i64, v: i64) -> i64 { 19 var m: i64 = v; if m < 0 { w(fd, "-" as *u8); m = 0 - m } 20 let t: *u8 = sys_mmap(24); var k: i64 = 0; if m == 0 { t[0] = 48 as u8; k = 1 } 21 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 22 let o: *u8 = sys_mmap(24); var i: i64 = 0; while i < k { o[i] = t[k-1-i]; i = i + 1 } sys_write(fd, o, k); return 0 23} 24func streq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if b[i] != (0 as u8) { return 0 } return 1 } 25func c_read(path: *u8, buf: *u8, cap: i64) -> i64 { 26 let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 - 1 } 27 var tot: i64 = 0 28 while tot < cap { let r: i64 = sys_read(fd, (buf as i64 + tot) as *u8, cap - tot); if r <= 0 { break } tot = tot + r } 29 sys_close(fd); return tot 30} 31// w2: emit a literal, converting apostrophe(39)->doublequote(34) so HTML attrs live in nishilang 32// string literals (which cannot contain the " byte). Text with a literal apostrophe must use w(). 33func w2(fd: i64, s: *u8) -> i64 { 34 var i: i64 = 0 35 while s[i] != (0 as u8) { if (s[i] as i64) == 39 { wc(fd, 34) } else { wc(fd, s[i] as i64) } i = i + 1 } 36 return 0 37} 38// field: extract |-delimited field `idx` (0-based) from buf[ls,le) into out, trimming ASCII spaces. 39// UTF-8 glyphs pass through (continuation/lead bytes are never 0x20 or 0x7C). Empty if idx absent. 40func field(buf: *u8, ls: i64, le: i64, idx: i64, out: *u8) -> i64 { 41 var cur: i64 = 0; var s: i64 = ls; var i: i64 = ls 42 while i < le { if cur == idx { break } if buf[i] == (124 as u8) { cur = cur + 1; s = i + 1 } i = i + 1 } 43 if cur < idx { out[0] = 0 as u8; return 0 } 44 var e: i64 = s 45 while e < le { if buf[e] == (124 as u8) { break } e = e + 1 } 46 var a: i64 = s 47 while a < e { if buf[a] != (32 as u8) { break } a = a + 1 } 48 var b: i64 = e 49 while b > a { if buf[b-1] != (32 as u8) { break } b = b - 1 } 50 var o: i64 = 0 51 while a < b { out[o] = buf[a]; o = o + 1; a = a + 1 } 52 out[o] = 0 as u8 53 return o 54} 55// brand diamond as inline SVG (proven-safe: no '#'/'!'/glyph-escape; inherits currentColor) 56func mark_svg(fd: i64) -> i64 { 57 w2(fd, "<svg class='nxmark' viewBox='0 0 24 24' width='17' height='17' aria-hidden='true'><path d='M12 2l10 10-10 10L2 12z' fill='currentColor'/></svg>" as *u8) 58 return 0 59} 60// health_of: scan link_health.tsv (route \t class \t ...) -> 1 healthy, 0 down (class DEAD), -1 unknown. 61func health_of(led: *u8, ln: i64, route: *u8) -> i64 { 62 var i: i64 = 0 63 while i < ln { 64 var j: i64 = i 65 while j < ln { if led[j] == (10 as u8) { break } j = j + 1 } 66 if j > i { 67 var k: i64 = i; var m: i64 = 0; var hit: i64 = 1 68 while k < j { if led[k] == (9 as u8) { break } if route[m] != led[k] { hit = 0 } if route[m] == (0 as u8) { hit = 0 } k = k + 1; m = m + 1 } 69 if hit == 1 { if route[m] == (0 as u8) { if k < j { if led[k] == (9 as u8) { 70 if led[k+1] == (68 as u8) { return 0 } 71 return 1 72 } } } } 73 } 74 i = j + 1 75 } 76 return 0 - 1 77} 78func sec_name(i: i64) -> *u8 { 79 if i == 0 { return "Family" as *u8 } 80 if i == 1 { return "Create" as *u8 } 81 if i == 2 { return "Media" as *u8 } 82 if i == 3 { return "Explore" as *u8 } 83 return "Play" as *u8 84} 85// primary top-bar links (always visible on wide screens): route|label pairs, by index 86func prim_route(i: i64) -> *u8 { 87 if i == 0 { return "/compare" as *u8 } 88 if i == 1 { return "/gallery" as *u8 } 89 if i == 2 { return "/library" as *u8 } 90 return "/research" as *u8 91} 92func prim_label(i: i64) -> *u8 { 93 if i == 0 { return "Compare" as *u8 } 94 if i == 1 { return "Gallery" as *u8 } 95 if i == 2 { return "Library" as *u8 } 96 return "Research" as *u8 97} 98 99// ---- shared CSS blocks (emitted into <style>) ---- 100func css_nav(fd: i64) -> i64 { 101 w2(fd, ".nxnav{position:sticky;top:0;z-index:50;display:flex;align-items:center;gap:10px;flex-wrap:wrap;background:linear-gradient(90deg,rgb(42,77,143),rgb(9,58,136));color:rgb(255,255,255);padding:9px clamp(12px,4vw,26px);font-family:-apple-system,Segoe UI,Roboto,sans-serif;box-shadow:0 2px 12px rgba(9,20,40,.28)}\n" as *u8) 102 w2(fd, ".nxnav a{color:rgb(255,255,255);text-decoration:none}.nxbrand{font-weight:800;font-size:1.05rem;display:inline-flex;align-items:center;gap:8px;min-height:44px;padding:0 6px}.nxmark{font-size:1.25rem}\n" as *u8) 103 w2(fd, ".nxlinks{display:flex;gap:3px;margin-left:4px}.nxlinks a{padding:10px 12px;border-radius:9px;font-weight:600;min-height:44px;display:inline-flex;align-items:center}.nxlinks a:hover{background:rgba(255,255,255,.16)}\n" as *u8) 104 w2(fd, ".nxtgl{position:absolute;opacity:0;width:1px;height:1px}.nxburger{margin-left:auto;display:inline-flex;flex-direction:column;justify-content:center;gap:5px;width:46px;height:46px;padding:12px;border-radius:10px;cursor:pointer}.nxburger span{height:2px;background:rgb(255,255,255);border-radius:2px;display:block}.nxburger:hover{background:rgba(255,255,255,.16)}.nxtgl:focus-visible ~ .nxburger{outline:3px solid rgb(255,255,255);outline-offset:2px}\n" as *u8) 105 w2(fd, ".nxpanel{display:none;flex-basis:100%;order:9;margin-top:8px;background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.18);border-radius:14px;padding:8px}.nxtgl:checked ~ .nxpanel{display:grid;grid-template-columns:repeat(auto-fit,minmax(215px,1fr));gap:4px}\n" as *u8) 106 w2(fd, ".nxgrp{padding:8px}.nxgrp h2{font-size:.72rem;letter-spacing:.09em;text-transform:uppercase;opacity:.72;margin:4px 6px 8px}.nxgrp a{display:flex;gap:10px;align-items:flex-start;padding:9px 10px;border-radius:10px;min-height:44px}.nxgrp a:hover{background:rgba(255,255,255,.14)}.nxgrp .gi{font-size:1.05rem;line-height:1.45;width:1.4rem;text-align:center;flex:none}.nxgrp b{display:block;font-size:.94rem}.nxgrp em{font-style:normal;opacity:.72;font-size:.77rem;line-height:1.35}\n" as *u8) 107 w2(fd, ".nxscope{font-size:.6rem;background:rgba(255,255,255,.22);padding:1px 6px;border-radius:20px;margin-left:6px;vertical-align:middle;letter-spacing:.03em}.nxall{grid-column:1/-1;text-align:center;padding:11px;font-weight:700;border-top:1px solid rgba(255,255,255,.18);margin-top:2px}@media(max-width:640px){.nxlinks{display:none}}\n" as *u8) 108 return 0 109} 110func css_foot(fd: i64) -> i64 { 111 w2(fd, ".nxfoot{margin-top:48px;background:rgb(16,20,32);color:rgb(214,220,236);border-radius:16px 16px 0 0;padding:26px clamp(16px,5vw,34px) 30px;font-family:-apple-system,Segoe UI,Roboto,sans-serif}.nxfoot a{color:rgb(190,205,240);text-decoration:none;display:block;padding:5px 0;min-height:32px}.nxfoot a:hover{color:rgb(255,255,255);text-decoration:underline}\n" as *u8) 112 w2(fd, ".nxfwrap{display:grid;grid-template-columns:1.5fr repeat(5,1fr);gap:18px;max-width:1120px;margin:0 auto}.nxfbrand{font-weight:800}.nxfbrand span{display:block;font-weight:400;opacity:.6;font-size:.8rem;margin-top:8px;line-height:1.5}.nxfcol h3{font-size:.72rem;letter-spacing:.08em;text-transform:uppercase;opacity:.55;margin:0 0 6px}.nxfsm{grid-column:1/-1;text-align:center;border-top:1px solid rgba(255,255,255,.1);margin-top:12px;padding-top:14px;font-weight:700}@media(max-width:760px){.nxfwrap{grid-template-columns:1fr 1fr}}\n" as *u8) 113 return 0 114} 115 116// ---- NAV FRAGMENT (header mode): brand + primary links + hamburger mega-panel ---- 117func emit_nav(sbuf: *u8, sn: i64) -> i64 { 118 let route: *u8 = sys_mmap(512); let section: *u8 = sys_mmap(256); let title: *u8 = sys_mmap(256) 119 let icon: *u8 = sys_mmap(64); let scope: *u8 = sys_mmap(64); let desc: *u8 = sys_mmap(K_MAGIC_1024) 120 w2(1, "<style>\n" as *u8); css_nav(1); w2(1, "</style>" as *u8) 121 w2(1, "<nav class='nxnav' aria-label='Primary navigation'><a class='nxbrand' href='/'>" as *u8) 122 mark_svg(1) 123 w2(1, " Nishi Family</a><div class='nxlinks'>" as *u8) 124 var p: i64 = 0 125 while p < 4 { w2(1, "<a href='" as *u8); w(1, prim_route(p)); w2(1, "'>" as *u8); w(1, prim_label(p)); w2(1, "</a>" as *u8); p = p + 1 } 126 w2(1, "</div><input class='nxtgl' type='checkbox' id='nxtgl' aria-label='Open full menu'><label class='nxburger' for='nxtgl' aria-hidden='true'><span></span><span></span><span></span></label><div class='nxpanel'>" as *u8) 127 var s: i64 = 0 128 while s < 5 { 129 let sname: *u8 = sec_name(s) 130 w2(1, "<div class='nxgrp'><h2>" as *u8); w(1, sname); w2(1, "</h2>" as *u8) 131 var i: i64 = 0 132 while i < sn { 133 var j: i64 = i 134 while j < sn { if sbuf[j] == (10 as u8) { break } j = j + 1 } 135 if sbuf[i] != (35 as u8) { if j > i { 136 field(sbuf, i, j, 1, section) 137 if streq(section, sname) == 1 { 138 field(sbuf, i, j, 0, route); field(sbuf, i, j, 2, title); field(sbuf, i, j, 3, icon) 139 field(sbuf, i, j, 4, scope); field(sbuf, i, j, 6, desc) 140 w2(1, "<a href='" as *u8); w(1, route); w2(1, "'><span class='gi' aria-hidden='true'>" as *u8); w(1, icon) 141 w2(1, "</span><span><b>" as *u8); w(1, title) 142 if streq(scope, "gated" as *u8) == 1 { w2(1, "<span class='nxscope'>sign in</span>" as *u8) } 143 if streq(scope, "machine" as *u8) == 1 { w2(1, "<span class='nxscope'>API</span>" as *u8) } 144 w2(1, "</b><em>" as *u8); w(1, desc); w2(1, "</em></span></a>" as *u8) 145 } 146 } } 147 i = j + 1 148 } 149 w2(1, "</div>" as *u8) 150 s = s + 1 151 } 152 w2(1, "<a class='nxall' href='/sitemap'>View the full sitemap &rarr;</a></div></nav>\n" as *u8) 153 return 0 154} 155 156// ---- FOOTER FRAGMENT (footer mode): grouped sitemap columns ---- 157func emit_foot(sbuf: *u8, sn: i64) -> i64 { 158 let route: *u8 = sys_mmap(512); let section: *u8 = sys_mmap(256); let title: *u8 = sys_mmap(256) 159 w2(1, "<style>\n" as *u8); css_foot(1); w2(1, "</style>" as *u8) 160 w2(1, "<footer class='nxfoot' aria-label='Site map'><div class='nxfwrap'><div class='nxfbrand'>" as *u8) 161 mark_svg(1); w2(1, " Nishi Family<span>The sovereign family ecosystem &mdash; served bits-up over TLS 1.3, no third-party web server, no trackers.</span></div>" as *u8) 162 var s: i64 = 0 163 while s < 5 { 164 let sname: *u8 = sec_name(s) 165 w2(1, "<nav class='nxfcol' aria-label='" as *u8); w(1, sname); w2(1, "'><h3>" as *u8); w(1, sname); w2(1, "</h3>" as *u8) 166 var i: i64 = 0 167 while i < sn { 168 var j: i64 = i 169 while j < sn { if sbuf[j] == (10 as u8) { break } j = j + 1 } 170 if sbuf[i] != (35 as u8) { if j > i { 171 field(sbuf, i, j, 1, section) 172 if streq(section, sname) == 1 { 173 field(sbuf, i, j, 0, route); field(sbuf, i, j, 2, title) 174 w2(1, "<a href='" as *u8); w(1, route); w2(1, "'>" as *u8); w(1, title); w2(1, "</a>" as *u8) 175 } 176 } } 177 i = j + 1 178 } 179 w2(1, "</nav>" as *u8) 180 s = s + 1 181 } 182 w2(1, "<a class='nxfsm' href='/sitemap'>Full sitemap &rarr;</a></div></footer>\n" as *u8) 183 return 0 184} 185 186// ---- sitemap.xml (sitemapxml mode): public surfaces only (gated -> 302 login, not crawlable) ---- 187func emit_xml(sbuf: *u8, sn: i64) -> i64 { 188 let route: *u8 = sys_mmap(512); let scope: *u8 = sys_mmap(64) 189 w2(1, "<?xml version='1.0' encoding='UTF-8'?>\n<urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'>\n" as *u8) 190 var i: i64 = 0 191 while i < sn { 192 var j: i64 = i 193 while j < sn { if sbuf[j] == (10 as u8) { break } j = j + 1 } 194 if sbuf[i] != (35 as u8) { if j > i { 195 field(sbuf, i, j, 0, route); field(sbuf, i, j, 4, scope) 196 if streq(scope, "public" as *u8) == 1 { 197 w2(1, " <url><loc>https://nishifamily.com" as *u8); w(1, route); w2(1, "</loc>" as *u8) 198 if streq(route, "/" as *u8) == 1 { w2(1, "<changefreq>daily</changefreq><priority>1.0</priority>" as *u8) } else { w2(1, "<changefreq>weekly</changefreq><priority>0.7</priority>" as *u8) } 199 w2(1, "</url>\n" as *u8) 200 } 201 } } 202 i = j + 1 203 } 204 w2(1, " <url><loc>https://nishifamily.com/sitemap</loc><changefreq>weekly</changefreq><priority>0.5</priority></url>\n</urlset>\n" as *u8) 205 return 0 206} 207 208// ---- /sitemap human page (page mode): full standalone doc, chrome + grouped index of every surface ---- 209func emit_doc(sbuf: *u8, sn: i64, is_home: i64) -> i64 { 210 let route: *u8 = sys_mmap(512); let section: *u8 = sys_mmap(256); let title: *u8 = sys_mmap(256) 211 let icon: *u8 = sys_mmap(64); let scope: *u8 = sys_mmap(64); let desc: *u8 = sys_mmap(K_MAGIC_1024) 212 // link health ledger (from nx_link_sentinel) -> down surfaces get an 'offline' badge, never a silent orphan 213 // dual-path: repo layout, else CWD (NAS: knowledge/ is root-owned so the sentinel writes ./link_health.tsv) 214 let led: *u8 = sys_mmap(K_MAGIC_65536); var ln: i64 = c_read("knowledge/site/link_health.tsv" as *u8, led, K_MAGIC_65536) 215 if ln <= 0 { ln = c_read("link_health.tsv" as *u8, led, K_MAGIC_65536) } 216 if ln < 0 { ln = 0 } 217 w2(1, "<" as *u8); wc(1, 33); w2(1, "DOCTYPE html>\n<html lang='en'><head><meta charset='utf-8'><meta name='viewport' content='width=device-width, initial-scale=1'>\n" as *u8) 218 if is_home == 1 { w2(1, "<title>Nishi Family &mdash; the sovereign ecosystem</title>\n<meta name='description' content='Home of the Nishi sovereign ecosystem: create, watch, read, compare and play. Every surface served bits-up over TLS 1.3, no third-party web server.'>\n<style>\n" as *u8) } else { w2(1, "<title>Sitemap &mdash; every Nishi surface</title>\n<meta name='description' content='The complete map of the Nishi sovereign ecosystem: create, media, explore, play and family surfaces.'>\n<style>\n" as *u8) } 219 w2(1, ":root{--bg:rgb(252,252,254);--fg:rgb(22,22,34);--ac:rgb(42,77,143);--line:rgb(228,228,236);--soft:rgb(246,247,251);--mut:rgb(104,104,118)}*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;background:var(--bg);color:var(--fg);font-family:-apple-system,Segoe UI,Roboto,sans-serif;line-height:1.6}\n" as *u8) 220 w2(1, "main{max-width:1000px;margin:0 auto;padding:0 clamp(16px,5vw,26px) 8vh}.skip{position:absolute;left:-999px;background:var(--ac);color:rgb(255,255,255);padding:12px 16px;border-radius:0 0 8px 0;z-index:99}.skip:focus{left:0}\n" as *u8) 221 w2(1, ".hero{margin:26px 0 8px}.hero h1{font-size:clamp(1.9rem,6vw,2.6rem);margin:0 0 6px;background:linear-gradient(90deg,var(--ac),rgb(130,80,223));-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent;color:transparent}.hero p{color:var(--mut);margin:0;font-size:clamp(1rem,2vw,1.1rem);max-width:640px}\n" as *u8) 222 w2(1, ".cta{display:flex;flex-wrap:wrap;gap:10px;margin-top:18px}.cta a{display:inline-flex;align-items:center;min-height:48px;padding:12px 22px;border-radius:12px;font-weight:700;text-decoration:none}.cta .p{background:var(--ac);color:rgb(255,255,255)}.cta .s{background:var(--soft);color:var(--ac);border:1px solid var(--line)}.cta a:hover{filter:brightness(1.07)}\n" as *u8) 223 w2(1, ".sec{margin:30px 0 6px;padding-top:6px;border-top:2px solid var(--line)}.sec h2{font-size:1.15rem;margin:8px 0 2px;color:var(--ac)}.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:12px;margin:14px 0}\n" as *u8) 224 w2(1, ".it{display:flex;gap:12px;align-items:flex-start;border:1px solid var(--line);border-radius:13px;padding:13px 15px;background:var(--soft);color:inherit;text-decoration:none;transition:border-color .15s,box-shadow .15s}.it:hover{border-color:var(--ac);box-shadow:0 4px 14px rgba(42,77,143,.14)}.it .gi{font-size:1.3rem;width:1.7rem;text-align:center;flex:none;color:var(--ac)}\n" as *u8) 225 w2(1, ".it b{display:block;font-size:1.02rem}.it em{font-style:normal;color:var(--mut);font-size:.85rem;line-height:1.4}.sc{font-size:.62rem;background:var(--ac);color:rgb(255,255,255);padding:1px 7px;border-radius:20px;margin-left:6px;vertical-align:middle}.sc.off{background:rgb(179,38,30)}.it.dn{opacity:.6}:focus-visible{outline:3px solid var(--ac);outline-offset:2px}\n" as *u8) 226 w2(1, "@media(prefers-color-scheme:dark){:root{--bg:rgb(14,14,19);--fg:rgb(231,231,239);--line:rgb(38,38,48);--soft:rgb(22,22,30);--mut:rgb(156,156,168)}}\n" as *u8) 227 w2(1, "</style></head><body>\n<a class='skip' href='" as *u8); wc(1, 35); w2(1, "main'>Skip to content</a>\n" as *u8) 228 emit_nav(sbuf, sn) 229 var pubn: i64 = 0 230 var i0: i64 = 0 231 while i0 < sn { 232 var j0: i64 = i0 233 while j0 < sn { if sbuf[j0] == (10 as u8) { break } j0 = j0 + 1 } 234 if sbuf[i0] != (35 as u8) { if j0 > i0 { field(sbuf, i0, j0, 0, route); if route[0] != (0 as u8) { pubn = pubn + 1 } } } 235 i0 = j0 + 1 236 } 237 w2(1, "<main id='main'><div class='hero'>" as *u8) 238 if is_home == 1 { 239 w2(1, "<h1>Nishi Family</h1><p>Welcome to the sovereign ecosystem &mdash; create, watch, read, compare and play, all served bits-up on our own hardware. " as *u8) 240 wn(1, pubn); w2(1, " surfaces, TLS 1.3, no third-party web server.</p><div class='cta'><a class='p' href='/sitemap'>Explore everything &rarr;</a><a class='s' href='/compare'>See the comparisons</a></div></div>\n" as *u8) 241 } else { 242 w2(1, "<h1>Sitemap</h1><p>Every surface in the Nishi sovereign ecosystem, in one place. " as *u8) 243 wn(1, pubn); w2(1, " surfaces across five sections.</p></div>\n" as *u8) 244 } 245 var s: i64 = 0 246 while s < 5 { 247 let sname: *u8 = sec_name(s) 248 w2(1, "<section class='sec'><h2>" as *u8); w(1, sname); w2(1, "</h2><div class='grid'>" as *u8) 249 var i: i64 = 0 250 while i < sn { 251 var j: i64 = i 252 while j < sn { if sbuf[j] == (10 as u8) { break } j = j + 1 } 253 if sbuf[i] != (35 as u8) { if j > i { 254 field(sbuf, i, j, 1, section) 255 if streq(section, sname) == 1 { 256 field(sbuf, i, j, 0, route); field(sbuf, i, j, 2, title); field(sbuf, i, j, 3, icon) 257 field(sbuf, i, j, 4, scope); field(sbuf, i, j, 6, desc) 258 let hlth: i64 = health_of(led, ln, route) 259 w2(1, "<a class='it" as *u8) 260 if hlth == 0 { w2(1, " dn" as *u8) } 261 w2(1, "' href='" as *u8); w(1, route); w2(1, "'><span class='gi' aria-hidden='true'>" as *u8); w(1, icon) 262 w2(1, "</span><span><b>" as *u8); w(1, title) 263 if hlth == 0 { w2(1, "<span class='sc off'>offline</span>" as *u8) } else { 264 if streq(scope, "gated" as *u8) == 1 { w2(1, "<span class='sc'>sign in</span>" as *u8) } 265 if streq(scope, "machine" as *u8) == 1 { w2(1, "<span class='sc'>API</span>" as *u8) } 266 } 267 w2(1, "</b><em>" as *u8); w(1, desc); w2(1, "</em></span></a>" as *u8) 268 } 269 } } 270 i = j + 1 271 } 272 w2(1, "</div></section>\n" as *u8) 273 s = s + 1 274 } 275 w2(1, "</main>\n" as *u8) 276 emit_foot(sbuf, sn) 277 w2(1, "</body></html>\n" as *u8) 278 return 0 279} 280func emit_page(sbuf: *u8, sn: i64) -> i64 { emit_doc(sbuf, sn, 0); return 0 } 281func emit_home(sbuf: *u8, sn: i64) -> i64 { emit_doc(sbuf, sn, 1); return 0 } 282 283func main(argc: i64, argv: *i64) -> i64 { 284 var mode: i64 = 0 285 if argc >= 2 { 286 if streq(argv[1] as *u8, "header" as *u8) == 1 { mode = 1 } 287 if streq(argv[1] as *u8, "footer" as *u8) == 1 { mode = 2 } 288 if streq(argv[1] as *u8, "sitemapxml" as *u8) == 1 { mode = 3 } 289 if streq(argv[1] as *u8, "page" as *u8) == 1 { mode = 4 } 290 if streq(argv[1] as *u8, "home" as *u8) == 1 { mode = 5 } 291 } 292 let cap: i64 = K_MAGIC_65536 293 let sbuf: *u8 = sys_mmap(cap) 294 var sn: i64 = c_read("knowledge/site/surfaces.reg" as *u8, sbuf, cap) 295 if sn <= 0 { sn = c_read("surfaces.reg" as *u8, sbuf, cap) } 296 297 if mode == 1 { emit_nav(sbuf, sn); sys_exit(0); return 0 } 298 if mode == 2 { emit_foot(sbuf, sn); sys_exit(0); return 0 } 299 if mode == 3 { emit_xml(sbuf, sn); sys_exit(0); return 0 } 300 if mode == 4 { emit_page(sbuf, sn); sys_exit(0); return 0 } 301 if mode == 5 { emit_home(sbuf, sn); sys_exit(0); return 0 } 302 303 // gate / console -- count surfaces + sections, verify required fields, liar-kill 304 w(1, "=== NX-SITE-CHROME -- global navigation from knowledge/site/surfaces.reg ===\n" as *u8) 305 let route: *u8 = sys_mmap(512); let section: *u8 = sys_mmap(256); let title: *u8 = sys_mmap(256) 306 var n: i64 = 0; var bad: i64 = 0 307 let seen: *u8 = sys_mmap(8) 308 var z: i64 = 0; while z < 5 { seen[z] = 0 as u8; z = z + 1 } 309 var i: i64 = 0 310 while i < sn { 311 var j: i64 = i 312 while j < sn { if sbuf[j] == (10 as u8) { break } j = j + 1 } 313 if sbuf[i] != (35 as u8) { if j > i { 314 field(sbuf, i, j, 0, route); field(sbuf, i, j, 1, section); field(sbuf, i, j, 2, title) 315 if route[0] != (0 as u8) { 316 n = n + 1 317 if title[0] == (0 as u8) { bad = bad + 1 } 318 var s: i64 = 0 319 while s < 5 { if streq(section, sec_name(s)) == 1 { seen[s] = 1 as u8 } s = s + 1 } 320 w(1, " surface: " as *u8); w(1, route); w(1, " [" as *u8); w(1, section); w(1, "] " as *u8); w(1, title); w(1, "\n" as *u8) 321 } 322 } } 323 i = j + 1 324 } 325 var secn: i64 = 0; var s2: i64 = 0 326 while s2 < 5 { if seen[s2] == (1 as u8) { secn = secn + 1 } s2 = s2 + 1 } 327 w(1, " surfaces=" as *u8); wn(1, n); w(1, " sections=" as *u8); wn(1, secn); w(1, "/5 bad-rows=" as *u8); wn(1, bad); w(1, "\n" as *u8) 328 let liar_have: i64 = (n >= 1) as i64 329 let liar_sec: i64 = (secn >= 1) as i64 330 let liar_clean: i64 = (bad == 0) as i64 331 w(1, " LIAR-KILL: have-surfaces=" as *u8); wn(1, liar_have); w(1, " sections-present=" as *u8); wn(1, liar_sec); w(1, " all-titled=" as *u8); wn(1, liar_clean); w(1, "\n" as *u8) 332 let ok: i64 = liar_have & liar_sec & liar_clean 333 w(1, "NX-SITE-CHROME surfaces=" as *u8); wn(1, n); w(1, " verdict=" as *u8) 334 if ok == 1 { w(1, "GREEN -- modes: header footer sitemapxml page\n" as *u8); sys_exit(0); return 0 } 335 w(1, "RED (empty registry or untitled rows)\n" as *u8); sys_exit(1); return 1 336}