code wiki / _hdl_build / nx_wiki_skin_lib.nx
nx_wiki_skin_lib.nx source
↩ module page · 70 lines · 6930 B
1// nx_wiki_skin_lib.nx -- ONE shared design shell for every nishifamily.com/wiki page (GitBook-style:
2// fixed left sidebar nav, single theme, consistent typography/tables/code). Every page = skin_open(...)
3// + its content + skin_close(...), so pages can never drift into one-off formats again. Reusable across
4// the whole wiki. Sovereign: nx_syscalls only. license_tier: ORIGINAL
5import "nx_syscalls.nx"
6
7func sk_cat(dst: *u8, off: i64, s: *u8) -> i64 { var o: i64 = off; var i: i64 = 0; while s[i] != (0 as u8) { dst[o] = s[i]; o = o + 1; i = i + 1 } return o }
8func sk_catn(dst: *u8, off: i64, v: i64) -> i64 {
9 var o: i64 = off; var m: i64 = v
10 if m == 0 { dst[o] = 48 as u8; return o + 1 }
11 let t: *u8 = sys_mmap(32); var k: i64 = 0
12 while m > 0 { t[k] = ((48 + (m % 10)) as u8); m = m / 10; k = k + 1 }
13 while k > 0 { dst[o] = t[k - 1]; o = o + 1; k = k - 1 }
14 return o
15}
16func sk_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 }
17
18// one nav row; highlights when this_slug == active.
19func sk_nav(buf: *u8, off: i64, href: *u8, label: *u8, this_slug: *u8, active: *u8) -> i64 {
20 var o: i64 = off
21 o = sk_cat(buf, o, "<a href=\"" as *u8); o = sk_cat(buf, o, href)
22 if sk_streq(this_slug, active) == 1 { o = sk_cat(buf, o, "\" class=\"active\">" as *u8) } else { o = sk_cat(buf, o, "\">" as *u8) }
23 o = sk_cat(buf, o, label); o = sk_cat(buf, o, "</a>" as *u8)
24 return o
25}
26
27// emit doctype + head (the ONE stylesheet) + body + sidebar + open the content container.
28func skin_open(buf: *u8, off: i64, title: *u8, active: *u8) -> i64 {
29 var o: i64 = off
30 o = sk_cat(buf, o, "<!doctype html>\n<html lang=\"en\"><head><meta charset=\"utf-8\">\n" as *u8)
31 o = sk_cat(buf, o, "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n<title>" as *u8)
32 o = sk_cat(buf, o, title); o = sk_cat(buf, o, " · Nishi Wiki</title>\n<style>\n" as *u8)
33 o = sk_cat(buf, o, ":root{--nx-color-ink:#3b454e;--nx-color-head:#1a1f24;--nx-color-primary:#3884ff;--nx-color-line:#e6ecf1;--nx-color-muted:#9aa7b1;--nx-color-side:#fafbfc}\n" as *u8)
34 o = sk_cat(buf, o, "*{box-sizing:border-box}body{margin:0;font:15px/1.65 -apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;color:var(--nx-color-ink);background:#fff}\n" as *u8)
35 o = sk_cat(buf, o, ".skip-link{position:absolute;left:-999px}.skip-link:focus{left:8px;top:8px;background:var(--nx-color-primary);color:#fff;padding:8px 12px;border-radius:6px;z-index:10}:focus-visible{outline:2px solid var(--nx-color-primary);outline-offset:2px}@media(prefers-reduced-motion:reduce){*{transition:none}}\n" as *u8)
36 o = sk_cat(buf, o, ".side{position:fixed;top:0;left:0;width:262px;height:100vh;overflow:auto;background:#fafbfc;border-right:1px solid #e6ecf1;padding:20px 0}\n" as *u8)
37 o = sk_cat(buf, o, ".side .brand{font-weight:700;font-size:15px;color:#1a1f24;padding:4px 22px 16px;display:block;text-decoration:none}\n" as *u8)
38 o = sk_cat(buf, o, ".side a{display:block;padding:7px 22px;color:#5c6975;text-decoration:none;font-size:14px;border-left:2px solid transparent}\n" as *u8)
39 o = sk_cat(buf, o, ".side a:hover{color:#1a1f24;background:#eef2f6}.side a.active{color:#3884ff;border-left-color:#3884ff;font-weight:600}\n" as *u8)
40 o = sk_cat(buf, o, ".side .sec{font-size:11px;text-transform:uppercase;letter-spacing:.07em;color:#9aa7b1;padding:18px 22px 4px}\n" as *u8)
41 o = sk_cat(buf, o, ".content{margin-left:262px;max-width:860px;padding:36px 48px 30px}\n" as *u8)
42 o = sk_cat(buf, o, ".content h1{font-size:28px;color:#1a1f24;margin:0 0 4px}.content h2{font-size:19px;color:#1a1f24;border-bottom:1px solid #eef1f4;padding-bottom:7px;margin-top:36px}\n" as *u8)
43 o = sk_cat(buf, o, ".content h3{font-size:16px;color:#1a1f24;margin:18px 0 4px}.content a{color:#3884ff;text-decoration:none}.content a:hover{text-decoration:underline}\n" as *u8)
44 o = sk_cat(buf, o, ".sub{color:#9aa7b1;font-size:14px;margin:2px 0 16px}\n" as *u8)
45 o = sk_cat(buf, o, "table{width:100%;border-collapse:collapse;font-size:13.5px;margin:14px 0}th,td{text-align:left;padding:9px 11px;border-bottom:1px solid #eef1f4;vertical-align:top}th{color:#9aa7b1;font-weight:600}\n" as *u8)
46 o = sk_cat(buf, o, "tr.floating{background:#fff7ed}.warn{color:#c2410c;font-weight:600}\n" as *u8)
47 o = sk_cat(buf, o, "code{background:#f4f6f8;padding:1px 6px;border-radius:4px;color:#476582;font-size:12.5px;font-family:ui-monospace,Consolas,monospace}\n" as *u8)
48 o = sk_cat(buf, o, "ul.feed{list-style:none;padding:0;margin:0;max-height:320px;overflow:auto;border:1px solid #eef1f4;border-radius:7px}ul.feed li{padding:6px 11px;border-bottom:1px solid #f4f6f8;font-size:12.5px;font-family:ui-monospace,Consolas,monospace;color:#476582}\n" as *u8)
49 o = sk_cat(buf, o, ".card{display:block;border:1px solid #e6ecf1;border-radius:9px;padding:16px 18px;margin:10px 0;text-decoration:none;color:#3b454e}.card:hover{border-color:#3884ff;text-decoration:none}.card b{color:#1a1f24;font-size:15px}.card span{display:block;color:#9aa7b1;font-size:13px;margin-top:3px}\n" as *u8)
50 o = sk_cat(buf, o, ".lock{max-width:460px;margin:8vh auto;text-align:center;border:1px solid #e6ecf1;border-radius:12px;padding:38px 30px}.lock .ico{font-size:34px}\n" as *u8)
51 o = sk_cat(buf, o, ".foot{margin-left:262px;max-width:860px;padding:18px 48px 60px;color:#9aa7b1;font-size:12px;border-top:1px solid #eef1f4}\n" as *u8)
52 o = sk_cat(buf, o, "@media(max-width:740px){.side{position:static;width:auto;height:auto;border-right:0;border-bottom:1px solid #e6ecf1}.content,.foot{margin-left:0;padding-left:24px;padding-right:24px}}\n" as *u8)
53 o = sk_cat(buf, o, "</style></head><body>\n<a class=\"skip-link\" href=\"#wikimain\">Skip to content</a>\n<nav class=\"side\"><a class=\"brand\" href=\"index.html\">Nishi · West Industrial</a>\n" as *u8)
54 o = sk_cat(buf, o, "<div class=\"sec\">Navigate</div>" as *u8)
55 o = sk_nav(buf, o, "index.html" as *u8, "Map / Home" as *u8, "home" as *u8, active)
56 o = sk_nav(buf, o, "board.html" as *u8, "Work Board" as *u8, "board" as *u8, active)
57 o = sk_cat(buf, o, "<div class=\"sec\">Reference</div>" as *u8)
58 o = sk_nav(buf, o, "start.html" as *u8, "AI front door" as *u8, "start" as *u8, active)
59 o = sk_nav(buf, o, "charter.html" as *u8, "Charter & telos" as *u8, "charter" as *u8, active)
60 o = sk_cat(buf, o, "</nav>\n<main id=\"wikimain\" class=\"content\">\n" as *u8)
61 return o
62}
63
64func skin_close(buf: *u8, off: i64, epoch: i64) -> i64 {
65 var o: i64 = off
66 o = sk_cat(buf, o, "</main>\n<footer class=\"foot\">Generated sovereignly — no nginx, no libc. One design shell (nx_wiki_skin). Freshness epoch " as *u8)
67 o = sk_catn(buf, o, epoch)
68 o = sk_cat(buf, o, ".</footer>\n</body></html>\n" as *u8)
69 return o
70}