interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / server / chromegen.om

607 lines · 14559 bytes Raw Blame History
1om2
2note server/chromegen.om: makes the forge's copy of the interplane.io site chrome from the site's own
3note source, at every build (run.sh units runs it), so a site change never needs a hand copy.
4note stdin: content/_layout.html, a 0 byte, public/style.css, a 0 byte, the site commit (40 hex).
5note stdout: one Omega unit (texts tchrsite, tchrhead, tchrfoot, tchrfend, tchrcss) that server/pages.om writes:
6note tchrhead <header class="site-head"> .. </header> of the layout, release build: {{#flag}} and
7note {{/flag}} marks dropped (the optional data is present on interplane.io), every
8note site-relative href or src made absolute (https://interplane.io/...), and the one link
9note to https://interplane.io/explore marked aria-current="true": that link is the forge's
10note entry in the site nav whatever its label (Forge until 2026-11-19, Projects since), and
11note the forge's own rule .site-head nav a[aria-current] (server/pages.om) shows it;
12note translate="no" attributes left out: forged adds its hints when it sends a page
13note (server/tr.om, class brand and others), so a page in fob holds none and its size is exact
14note tchrfoot the footer lines after <footer class="site-foot"><div class="shell"> up to the first
15note <p class="foot-fine"> line (the forge writes its own fine print), the same way; since
16note the 2026-11-19 layout this ends inside <div class="foot-base">, after the SI line
17note tchrfend what the layout has after its fine-print line(s) up to </footer>: the </div> lines that
18note close what tchrfoot left open, so the forge footer closes the way the site's does
19note tchrcss the site's :root line, then between the marks of server/tests/sitechrome.sh every
20note style.css rule line that styles the header or footer (the rule below, the same one
21note sitechrome.sh checks) inside its @-block, in the site's order
22note Not copied: what the layout has between </header> and <footer (main, and since 2026-11-22 the
23note <div class="rope-band rope-sm foot-rope"> strand picture above the footer). The rope band is page
24note decoration, neither header nor footer, and its picture is a site file the forge does not serve, so
25note its rule .foot-rope is left out too although the name starts with foot-.
26note Chrome rule: a line that starts with a base selector (*, html, body, a, a:hover, a:active,
27note a:focus-visible,summary:focus-visible, code,pre,.mono) and "{", or names one of the classes
28note site-head head-inner brand site-foot foot-<a-z> si-line skip shell btn btn-primary btn-sm (not
29note followed by a-z or -); left out: nav.short, .foot-rope, main p:where, .invite .button,
30note .actions .button, .hop-stage (page rules), a one-line @media print rule, and @-blocks naming
31note prefers-reduced-motion.
32note Refusals (stderr names the reason, stdout is empty): exit 2 input shape, 3 header or footer
33note not found, 4 a {{ mark other than {{#..}} or {{/..}} in them, 5 no single link to the forge
34note (https://interplane.io/explore) in the header, 6 no :root first line, 7 a control byte other than
35note a line feed, 8 fewer than 30 chrome lines, 9 output, 10 the footer has something other than
36note </div> lines after its fine print, 11 unsupported or unbalanced stylesheet block structure.
37note The input and output buffers are 16 MiB each (the largest pool omc allows); the site files are
38note about 100 KB. A larger input is refused with exit 2, never cut.
39global cgi uchar 16777216
40global cgn ulong 1
41global cgo uchar 16777216
42global cgl ulong 1
43note the parts of the input: layout [0, cgp 1), a 0 byte, style (cgp 1, cgp 2), a 0 byte, the commit
44global cgp ulong 5
45note the current @-block: its line (start, end) and whether it was written yet
46global cgb ulong 3
47global cgcur ulong 1
48text thd "<header class=\"site-head\">"
49text the "</header>"
50text tfo "<footer class=\"site-foot\"><div class=\"shell\">"
51text tff "<p class=\"foot-fine\">"
52text tfe "</footer>"
53text tdivc "</div>"
54text tpend "</p>"
55text thref "href=\"/"
56text tsrc "src=\"/"
57text tsite "https://interplane.io"
58text tforge "<a href=\"https://interplane.io/explore\""
59text tcur " aria-current=\"true\""
60text thint " translate=\"no\""
61text troot ":root{"
62text tm1 "/* site chrome: copied from interplane.io public/style.css */\n"
63text tm2 "/* end site chrome */\n"
64text tqe "\"\n"
65text tn1 "note server/chrome.om: GENERATED by server/chromegen.om at build (run.sh units) from interplane.io\n"
66text tn2 "note content/_layout.html and public/style.css at the site commit in tchrsite. Not in git; do not edit.\n"
67text ts1 "text tchrsite \""
68text ts2 "text tchrhead \""
69text ts3 "text tchrfoot \""
70text ts4 "text tchrcss \""
71text ts5 "text tchrfend \""
72text tbs1 "*{"
73text tbs2 "html{"
74text tbs3 "body{"
75text tbs4 "a{"
76text tbs5 "a:hover{"
77text tbs6 "a:active{"
78text tbs7 "a:focus-visible,summary:focus-visible{"
79text tbs8 "code,pre,.mono{"
80text tcl1 "site-head"
81text tcl2 "head-inner"
82text tcl3 "brand"
83text tcl4 "site-foot"
84text tcl5 "si-line"
85text tcl6 "skip"
86text tcl7 "shell"
87text tcl8 "foot-"
88text tcl9 "btn"
89text tcl10 "btn-primary"
90text tcl11 "btn-sm"
91text tsk1 "nav.short"
92text tsk2 "main p:where"
93text tsk3 ".invite .button"
94text tsk4 ".actions .button"
95text tsk5 ".hop-stage "
96text tsk6 "@media print"
97text tsk7 ".foot-rope"
98text tskin "prefers-reduced-motion"
99text te2 "chromegen: input is not layout, NUL, style, NUL, commit (or larger than 16 MiB)\n"
100text te3 "chromegen: the layout has no <header class=\"site-head\"> .. </header>, or no footer line <footer class=\"site-foot\"><div class=\"shell\"> followed by a <p class=\"foot-fine\"> line\n"
101text te4 "chromegen: the site header or footer holds a {{ mark other than {{#name}} or {{/name}}; teach server/chromegen.om what the release build does with it\n"
102text te5 "chromegen: the site header does not hold exactly one <a href=\"https://interplane.io/explore\"> (the forge's entry in the site nav, marked current on forge pages)\n"
103text te6 "chromegen: the first line of public/style.css is not the :root token line\n"
104text te7 "chromegen: a control byte other than a line feed in the copied header, footer or stylesheet lines\n"
105text te8 "chromegen: fewer than 30 chrome rule lines found in public/style.css; the rule above no longer fits the site\n"
106text te9 "chromegen: the output did not fit or could not be written\n"
107text te10 "chromegen: the footer has something other than </div> lines between its fine print and </footer>; the forge cannot close the footer the way the site does\n"
108text te11 "chromegen: unsupported or unbalanced stylesheet block structure\n"
109fn cgdie code ulong t view uchar * to void
110w = write 2 t 0 len t
111exit int code
112end
113fn cgc c uchar to void
114n = get cgl 0
115if ge n len cgo
116cgdie 9 te9
117end
118put cgo n c
119put cgl 0 add n 1
120end
121fn cgt t view uchar * to void
122for i ulong len t bound 4096
123cgc get t i
124end
125end
126note cge: one byte of an Omega text literal
127fn cge c uchar to void
128if eq c 10
129cgc 92
130cgc 110
131ret
132end
133if eq c 9
134cgc 92
135cgc 116
136ret
137end
138if lt c 32
139cgdie 7 te7
140end
141if eq c 127
142cgdie 7 te7
143end
144if or eq c 34 eq c 92
145cgc 92
146end
147cgc c
148end
149note cgat: cgi[p, e) starts with t
150fn cgat p ulong e ulong t view uchar * to bool
151if gt add p len t e
152ret false
153end
154for i ulong len t bound 4096
155if ne get cgi add p i get t i
156ret false
157end
158end
159ret true
160end
161note cgfind: the first p in [a, e) where t starts, or e
162fn cgfind a ulong e ulong t view uchar * to ulong
163p = a
164while lt p e bound 16777216
165if cgat p e t
166ret p
167end
168p = add p 1
169end
170ret e
171end
172fn cglow c uchar to bool
173ret and ge c 97 le c 122
174end
175fn cgname c uchar to bool
176ret or cglow c eq c 45
177end
178note ---- the layout parts
179note cgmark: at cgi[p] a {{ mark; returns its end (after the }}) for {{#name}} or {{/name}}, refuses others
180fn cgmark p ulong e ulong to ulong
181q = add p 2
182if ge q e
183cgdie 4 te4
184end
185c = get cgi q
186if and ne c 35 ne c 47
187cgdie 4 te4
188end
189q = add q 1
190s = q
191while lt q e bound 16777216
192c = get cgi q
193if not or cglow c eq c 95
194break
195end
196q = add q 1
197end
198if or eq q s gt add q 2 e
199cgdie 4 te4
200end
201if or ne get cgi q 125 ne get cgi add q 1 125
202cgdie 4 te4
203end
204ret add q 2
205end
206note cgpart: cgi[a, e) as the release build writes it, escaped into the output; returns the count of
207note Forge links it marked current (when cur)
208fn cgpart a ulong e ulong cur bool to ulong
209n = ulong 0
210p = a
211while lt p e bound 16777216
212if and eq get cgi p 123 lt add p 1 e
213if eq get cgi add p 1 123
214p = cgmark p e
215continue
216end
217end
218if cgat p e thint
219p = add p len thint
220continue
221end
222if and cur cgat p e tforge
223for i ulong len tforge
224cge get tforge i
225end
226for i ulong len tcur
227cge get tcur i
228end
229p = add p len tforge
230n = add n 1
231continue
232end
233k = ulong 0
234if cgat p e thref
235k = len thref
236end
237if cgat p e tsrc
238k = len tsrc
239end
240if gt k 0
241r = sub add p k 1
242if or ge add r 1 e ne get cgi add r 1 47
243for i ulong sub k 1
244cge get cgi add p i
245end
246for i ulong len tsite
247cge get tsite i
248end
249p = r
250continue
251end
252end
253cge get cgi p
254p = add p 1
255end
256ret n
257end
258note ---- the stylesheet
259note cglst: [s, e) is a line of the stylesheet; true when it is a block line "@..{" with no "}"
260fn cgopen s ulong e ulong to bool
261if or ge s e ne get cgi s 64
262ret false
263end
264if ne get cgi sub e 1 123
265ret false
266end
267for i ulong sub e s bound 16777216
268if eq get cgi add s i 125
269ret false
270end
271end
272ret true
273end
274fn cgclose s ulong e ulong to bool
275if ge s e
276ret false
277end
278for i ulong sub e s bound 16777216
279if ne get cgi add s i 125
280ret false
281end
282end
283ret true
284end
285note cgcls: at p a class name t followed by a byte that is not a-z or -, or the line end
286fn cgcls p ulong e ulong t view uchar * to bool
287if not cgat p e t
288ret false
289end
290q = add p len t
291if ge q e
292ret true
293end
294ret not cgname get cgi q
295end
296fn cgfoot p ulong e ulong to bool
297if not cgat p e tcl8
298ret false
299end
300q = add p len tcl8
301s = q
302while lt q e bound 16777216
303if not cglow get cgi q
304break
305end
306q = add q 1
307end
308if eq q s
309ret false
310end
311if ge q e
312ret true
313end
314ret ne get cgi q 45
315end
316fn cgbase s ulong e ulong to bool
317if or cgat s e tbs1 or cgat s e tbs2 cgat s e tbs3
318ret true
319end
320if or cgat s e tbs4 or cgat s e tbs5 cgat s e tbs6
321ret true
322end
323ret or cgat s e tbs7 cgat s e tbs8
324end
325note cgsel: the rule line [s, e) styles the header or footer (the chrome rule in the notes above)
326fn cgsel s ulong e ulong to bool
327if lt cgfind s e tsk1 e
328ret false
329end
330if or cgat s e tsk2 or cgat s e tsk3 or cgat s e tsk4 cgat s e tsk5
331ret false
332end
333if or cgat s e tsk6 cgat s e tsk7
334ret false
335end
336if cgbase s e
337ret true
338end
339p = s
340while lt p e bound 16777216
341if eq get cgi p 46
342q = add p 1
343if or cgcls q e tcl1 or cgcls q e tcl2 or cgcls q e tcl3 cgcls q e tcl4
344ret true
345end
346if or cgcls q e tcl5 or cgcls q e tcl6 or cgcls q e tcl7 cgfoot q e
347ret true
348end
349if or cgcls q e tcl9 or cgcls q e tcl10 cgcls q e tcl11
350ret true
351end
352end
353p = add p 1
354end
355ret false
356end
357fn cgline s ulong e ulong to void
358for i ulong sub e s bound 16777216
359cge get cgi add s i
360end
361cge 10
362end
363note cgcss: the :root line, the marks and the chrome rule lines; returns the count of rule lines
364fn cgcss a ulong e ulong to ulong
365x = a
366while lt x e bound 16777216
367if eq get cgi x 10
368break
369end
370x = add x 1
371end
372if not cgat a x troot
373cgdie 6 te6
374end
375cgline a x
376for i ulong len tm1
377cge get tm1 i
378end
379note copied rules stay in their original single-level @-block
380put cgcur 0 0
381put cgb 2 0
382n = ulong 0
383s = add x 1
384while lt s e bound 16777216
385l = s
386while lt l e bound 16777216
387if eq get cgi l 10
388break
389end
390l = add l 1
391end
392if cgopen s l
393if eq get cgcur 0 1
394cgdie 11 te11
395end
396put cgb 0 s
397put cgb 1 l
398put cgb 2 0
399put cgcur 0 1
400else
401if cgclose s l
402if eq get cgcur 0 0
403cgdie 11 te11
404end
405if and eq get cgcur 0 1 eq get cgb 2 1
406cgline s l
407end
408put cgcur 0 0
409put cgb 2 0
410else
411if cgsel s l
412sk = false
413if eq get cgcur 0 1
414sk = lt cgfind get cgb 0 get cgb 1 tskin get cgb 1
415end
416if not sk
417if and eq get cgcur 0 1 eq get cgb 2 0
418cgline get cgb 0 get cgb 1
419put cgb 2 1
420end
421cgline s l
422n = add n 1
423end
424end
425end
426end
427s = add l 1
428end
429if eq get cgcur 0 1
430cgdie 11 te11
431end
432for i ulong len tm2
433cge get tm2 i
434end
435ret n
436end
437fn main to int
438cgreadin
439cgsplit
440cgsha
441cghead
442cgfootp
443cgt ts4
444m = cgcss add get cgp 1 1 get cgp 2
445cgt tqe
446if lt m 30
447cgdie 8 te8
448end
449w = write 1 cgo 0 get cgl 0
450if ne w long get cgl 0
451cgdie 9 te9
452end
453ret 0
454end
455fn cgreadin to void
456n = ulong 0
457while lt n len cgi bound 16777216
458r = read 0 cgi n sub len cgi n
459if lt r 0
460if eq r -4
461continue
462end
463cgdie 2 te2
464end
465if eq r 0
466break
467end
468n = add n ulong r
469end
470if ge n len cgi
471cgdie 2 te2
472end
473put cgn 0 n
474end
475note cgsplit: the two 0 bytes into cgp 1 and cgp 2
476fn cgsplit to void
477n = get cgn 0
478k = ulong 0
479for i ulong n bound 16777216
480if eq get cgi i 0
481if ge k 2
482cgdie 2 te2
483end
484put cgp add k 1 i
485k = add k 1
486end
487end
488if ne k 2
489cgdie 2 te2
490end
491end
492fn cgisx c uchar to bool
493if and ge c 48 le c 57
494ret true
495end
496ret and ge c 97 le c 102
497end
498note cgsha: the third part is 40 lowercase hex (a trailing line feed allowed); writes tchrsite and the notes
499fn cgsha to void
500ha = add get cgp 2 1
501he = get cgn 0
502while gt he ha bound 16777216
503if ne get cgi sub he 1 10
504break
505end
506he = sub he 1
507end
508if ne sub he ha 40
509cgdie 2 te2
510end
511for i ulong 40
512if not cgisx get cgi add ha i
513cgdie 2 te2
514end
515end
516cgt tn1
517cgt tn2
518cgt ts1
519for i ulong 40
520cgc get cgi add ha i
521end
522cgt tqe
523end
524note cghead: from the header's opening tag to the end of </header>
525fn cghead to void
526lz = get cgp 1
527h0 = cgfind 0 lz thd
528h1 = cgfind h0 lz the
529if or ge h0 lz ge h1 lz
530cgdie 3 te3
531end
532cgt ts2
533m = cgpart h0 add h1 len the true
534cge 10
535cgt tqe
536if ne m 1
537cgdie 5 te5
538end
539end
540note cgfootp: the lines after the footer opening line, before the first fine-print line
541fn cgfootp to void
542lz = get cgp 1
543f0 = cgfind 0 lz tfo
544if ge f0 lz
545cgdie 3 te3
546end
547f1 = cgfind f0 lz tff
548fa = add f0 len tfo
549if or ge f1 lz ge fa lz
550cgdie 3 te3
551end
552if ne get cgi fa 10
553cgdie 3 te3
554end
555fa = add fa 1
556if or le f1 fa ne get cgi sub f1 1 10
557cgdie 3 te3
558end
559cgt ts3
560m = cgpart fa f1 false
561cgt tqe
562cgfend f1 lz
563end
564note The site's closing div lines belong to its footer structure, not to the forge's fine print.
565fn cgfend a ulong e ulong to void
566z = cgfind a e tfe
567if eq z e
568cgdie 3 te3
569end
570p = a
571while lt p z bound 16777216
572if not cgat p z tff
573break
574end
575p = cgfind p z tpend
576if eq p z
577cgdie 10 te10
578end
579p = add p len tpend
580while lt p z bound 16777216
581if ne get cgi p 10
582break
583end
584p = add p 1
585end
586end
587cgt ts5
588while lt p z bound 16777216
589if cgat p z tdivc
590for i ulong len tdivc
591cge get tdivc i
592end
593p = add p len tdivc
594else
595if ne get cgi p 10
596cgdie 10 te10
597end
598cge 10
599p = add p 1
600end
601end
602for i ulong len tfe
603cge get tfe i
604end
605cge 10
606cgt tqe
607end