interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / server / pages.om

962 lines · 32607 bytes Raw Blame History
1note forged server/pages.om: layout (header, footer), error pages, /explore, /<owner>, /search,
2note the repo header used by every repo tab, and the stylesheet. Writes fob through util.om helpers.
3global fq uchar 256
4global fql ulong 1
5text tfpsrch "/search"
6text tfulrep "<ul class=\"repos\">\n"
7text tfempty ""
8text tfccpub "public, max-age=300"
9text tfctcss "text/css; charset=utf-8"
10text tfh1 "<!doctype html>\n<html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><meta name=\"color-scheme\" content=\"dark\"><title>"
11text tfh2 " &#183; INTERPLANE Forge</title><link rel=\"stylesheet\" href=\""
12text tfcssp "assets/forge.css"
13text tfh3 "\"><link rel=\"icon\" type=\"image/svg+xml\" href=\""
14text tficop "assets/favicon.svg"
15text tfh3i "\">"
16text tfh3b "</head>\n<body><a class=\"skip\" href=\"#main\">Skip to content</a>"
17text tfhal1 "<link rel=\"alternate\" type=\"application/json\" href=\""
18text tfhal2 "explore.json"
19text tfhal3 ".json"
20text tfhal4 "events.json"
21note ---- the site chrome: the interplane.io header and footer and their stylesheet lines are not kept
22note here. server/chromegen.om makes them at every build from the site's own source (canonical main of
23note rad:z399yKvnXcBQNkKoq86iBDgTvQ5QV, content/_layout.html and public/style.css) into the generated
24note unit .build/chrome.om (run.sh units): texts tchrhead, tchrfoot, tchrfend, tchrcss and the site commit
25note tchrsite. Every site link is absolute, so the same bytes serve the bases / and /forge/; the site's
26note Projects entry marks this section current. server/tests/sitechrome.sh checks against the source.
27note the forge's own controls, a second row under the site header
28text tfh4 "<div class=\"forge-row\"><div class=\"shell forge-bar\"><nav class=\"forge-nav\" aria-label=\"Forge\"><a href=\""
29text tfexp "explore"
30text tfh4b "\">Explore</a><a href=\""
31text tfh5 "\">Stars</a>"
32text tfh5b "</nav><form class=\"search\" method=\"get\" action=\""
33text tfsrch "search"
34text tfh6 "\" role=\"search\"><input type=\"search\" name=\"q\" maxlength=\"200\" placeholder=\"Search the forge\" aria-label=\"Search the forge\" value=\""
35text tfh7 "\"><button type=\"submit\">Search</button></form><a class=\"lang-link\" href=\"https://interplane.io/translate/\">Read in your language</a><div class=\"who\">"
36text tfsignin "\">Sign in</a>"
37text tfahref "<a href=\""
38text tfqgt "\">"
39text tfaend "</a>"
40text tfso1 "<form class=\"inline\" method=\"post\" action=\""
41text tflogout "logout"
42text tflogin "login"
43text tfso2 "\"><input type=\"hidden\" name=\"csrf\" value=\""
44text tfso3 "\"><button type=\"submit\">Sign out</button></form>"
45text tfh8 "</div></div></div>\n<main id=\"main\" tabindex=\"-1\">\n"
46text tff1 "\n</main>\n<footer class=\"site-foot\"><div class=\"shell\">\n"
47text tff2 "\">Explore</a> &#183; <a href=\""
48text tff3 "\">Search</a> &#183; <a href=\""
49text tfstars "stars"
50text tff4 "\">Stars</a> &#183; <a href=\"https://interplane.io/translate/\">Read in your language</a> &#183; <a href=\""
51text tff4q "?format=text"
52text tff4a "&amp;format=text"
53text tff4b "\" rel=\"alternate\" type=\"text/plain\">This page as plain text</a></p>\n<p class=\"foot-fine\">Translation is done by your own browser or tool, on your machine. This forge translates nothing and keeps no translated copies; the English page is the reference, and commands, fingerprints and file names are marked to stay exactly as written.</p>\n"
54text tffend "</body></html>\n"
55text tfq "q"
56note ---- error pages
57text tfe1 "<section class=\"err\"><h1>"
58text tfe2 "</h1><p>"
59text tfe3 "</p><p><a href=\""
60text tfe4 "\">Back to the forge</a></p></section>"
61text tfm400 "Bad request. The forge refused this request."
62text tfm403 "Forbidden. The form token did not match; reload the page and try again."
63text tfm404 "Not found. This page does not exist, or the repository is not public on this forge."
64text tfm405 "Method not allowed."
65text tfm413 "The request body is too large."
66text tfm429 "Too many write requests from this address. Wait a minute and try again."
67text tfm500 "The forge hit an internal error serving this page."
68text tfm501 "Coming soon. This part of the forge is being built and is not served yet; the feature list says what works today."
69text tfmoth "The forge could not serve this request."
70text tfmicut "The stored data behind this page is larger than the forge reads in one piece, so an answer built from it would have been incomplete. The forge sent this notice and no part of it. The data is whole in the repository: read it with git."
71text tfmovf "This page is too large for the forge to send in one piece (the limit is 8 MiB), so the forge sent this notice and no part of the page. The data is whole in the repository: read it with git."
72text tfctj "application/json"
73note fovf: 0, or why this response is the too-large notice (1 page, 2 JSON document); flay: the
74note lengths of the fragment, the head and the foot of a page (flayout)
75global fovf ulong 1
76global flay ulong 3
77text tft400 "Bad request"
78text tft403 "Forbidden"
79text tft404 "Not found"
80text tft405 "Method not allowed"
81text tft413 "Too large"
82text tft429 "Slow down"
83text tft500 "Server error"
84text tft501 "Coming soon"
85text tftmvg "Moving"
86text tfmmvg "This part is moving to the new Interplane store and is not available yet."
87fn ferrmsg st ulong to void
88if ne get fovf 0 0
89if ne get ficut 0 0
90fput tfmicut
91ret
92end
93fput tfmovf
94ret
95end
96if and eq st 503 ne get fmvng 0 0
97fput tfmmvg
98ret
99end
100if eq st 400
101fput tfm400
102ret
103end
104if eq st 403
105fput tfm403
106ret
107end
108if eq st 404
109fput tfm404
110ret
111end
112if eq st 405
113fput tfm405
114ret
115end
116if eq st 413
117fput tfm413
118ret
119end
120if eq st 429
121fput tfm429
122ret
123end
124if eq st 500
125fput tfm500
126ret
127end
128if eq st 501
129fput tfm501
130ret
131end
132fput tfmoth
133end
134fn ferrti st ulong to void
135if and eq st 503 ne get fmvng 0 0
136fsetti tftmvg
137ret
138end
139if eq st 400
140fsetti tft400
141ret
142end
143if eq st 403
144fsetti tft403
145ret
146end
147if eq st 404
148fsetti tft404
149ret
150end
151if eq st 405
152fsetti tft405
153ret
154end
155if eq st 413
156fsetti tft413
157ret
158end
159if eq st 429
160fsetti tft429
161ret
162end
163if eq st 501
164fsetti tft501
165ret
166end
167fsetti tft500
168end
169note fctjson: the content type a handler set starts with application/json
170fn fctjson to bool
171if lt get fctl 0 len tfctj
172ret false
173end
174for i ulong len tfctj
175if ne get fct i get tfctj i
176ret false
177end
178end
179ret true
180end
181note fovfl: the body, its layout or a Location did not fit its buffer (fobtr). Nothing of it is
182note sent. The partial body and what the handler set for it (content type, disposition, Location,
183note ETag, cache rule, Retry-After, sandbox policy) are dropped and the response becomes a whole 500:
184note forge/error/1 when the client asked for JSON or the page was a JSON document (a .json or
185note .receipt name needs no Accept header), the error page otherwise. A Set-Cookie stays: what it
186note records has already happened. 500 because the request is good and the page exists; the
187note server cannot hold this page in its 8 MiB body. Not 413 or 414 (the request is not too large),
188note not 503 (asking again gives the same), not 507 (WebDAV storage).
189fn fovfl to void
190w = ulong 1
191if eq get fkind 0 1
192if fctjson
193w = ulong 2
194end
195end
196put fovf 0 w
197put fobl 0 0
198put fobtr 0 0
199put fctl 0 0
200put fcdl 0 0
201put flocl 0 0
202put fetagl 0 0
203put fccl 0 0
204put fretry 0 0
205put fcspsb 0 0
206ferrpage 500
207if eq get fkind 0 0
208flayout
209end
210end
211note flayout: kind 0. The fragment is fob[0,L); fhead and ffoot are appended after it, before any
212note header is sent, so that an overflow in them is seen too. flay keeps L and the two lengths.
213fn flayout to void
214l = get fobl 0
215fhead
216h = sub get fobl 0 l
217ffoot
218put flay 0 l
219put flay 1 h
220put flay 2 sub sub get fobl 0 l h
221end
222note fovfany: something was dropped while this response was built
223fn fovfany to bool
224ret ne get fobtr 0 0
225end
226note ferrpage: the error page; a JSON request gets the forge/error/1 document (server/jsonp.om)
227fn ferrpage st ulong to void
228put fkind 0 0
229put fobl 0 0
230put fjalt 0 0
231if or fjwant eq get fovf 0 2
232fyerr st
233ret
234end
235ferrti st
236fput tfe1
237fnum st
238fputc 32
239for i ulong get ftil 0 bound 256
240fescc get fti i
241end
242fput tfe2
243ferrmsg st
244fput tfe3
245fputb
246fput tfe4
247end
248note ---- layout: appended AFTER the fragment; main.om sends head, fragment, foot in that order
249fn fwho to void
250if eq get fuserl 0 0
251fput tfahref
252fputb
253fput tflogin
254fput tfsignin
255ret
256end
257fput tfahref
258fputb
259for i ulong get fuserl 0 bound 64
260fescc get fuser i
261end
262fput tfqgt
263for i ulong get fuserl 0 bound 64
264fescc get fuser i
265end
266fput tfaend
267fputc 32
268fput tfso1
269fputb
270fput tflogout
271fput tfso2
272for i ulong get fcsrfl 0 bound 64
273fescc get fcsrf i
274end
275fput tfso3
276end
277fn fhead to void
278fput tfh1
279for i ulong get ftil 0 bound 256
280fescc get fti i
281end
282fput tfh2
283fputb
284fput tfcssp
285fput tfh3
286fputb
287fput tficop
288fput tfh3i
289fhalt
290fput tfh3b
291fput tchrhead
292fput tfh4
293fputb
294fput tfexp
295fput tfh4b
296fputb
297fput tfstars
298fput tfh5
299note each slice may add one entry to the forge row (its seam adds nothing)
300ohnav
301slnav
302rxnav
303evnav
304fput tfh5b
305fputb
306fput tfsrch
307fput tfh6
308fhdq
309fput tfh7
310fwho
311fput tfh8
312end
313note fhalt: the page's JSON form (docs/API.md): 1 explore, 2 the repo home, 3 the page's own URL,
314note 4 the event stream (door/ev5feed.om, the feed page)
315fn fhalt to void
316k = get fjalt 0
317if eq k 0
318ret
319end
320fput tfhal1
321if eq k 4
322fputb
323fput tfhal4
324fput tfqgt
325ret
326end
327if eq k 3
328fhself
329fput tfqgt
330ret
331end
332if eq k 1
333fputb
334fput tfhal2
335else
336fputrl
337fput tfhal3
338end
339fput tfqgt
340end
341note fhself: base, the path without its first /, and the query, escaped for the attribute
342fn fhself to void
343fputb
344n = get fpathl 0
345for k ulong sub n 1 bound 4096
346fescc get fpath add k 1
347end
348if gt get fqsl 0 0
349fputc 63
350for k ulong get fqsl 0 bound 4096
351fescc get fqs k
352end
353end
354end
355note fhdq: echo the search query into the header box on /search
356fn fhdq to void
357if not fpeq tfpsrch
358ret
359end
360for i ulong get fql 0 bound 256
361fescc get fq i
362end
363end
364fn ffoot to void
365fput tff1
366fput tchrfoot
367fput tfsf4
368fputb
369fput tfexp
370fput tff2
371fputb
372fput tfsrch
373fput tff3
374fputb
375fput tfstars
376fput tff4
377note the plain-text form of this page: its own address and query plus format=text (server/tr.om)
378fhself
379if gt get fqsl 0 0
380fput tff4a
381else
382fput tff4q
383end
384fput tff4b
385fput tchrfend
386fput tffend
387end
388note ---- the stylesheet (served at <base>assets/forge.css)
389note tchrcss (generated, see the site chrome note above): the site's :root token line, then between
390note the two marks the site's header and footer rule lines. tfcssv: the forge's own names for tokens.
391text tfcssv ":root{--bg:var(--paper);--fg:var(--ink);--mut:var(--muted);--acc:var(--orange-ink);--box:var(--white)}\n"
392note tfcss2: the forge's own rules on the site chrome: Projects marked current, the forge row, main
393text tfcss2 ".site-head nav a[aria-current]{color:var(--ink);text-decoration-color:currentColor}\n:where(.site-foot) p{margin:0;color:var(--muted)}\n.forge-row{border-bottom:1px solid var(--line)}\n.forge-bar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 24px;min-height:60px;padding-top:8px;padding-bottom:8px}\n.forge-nav{display:flex;gap:24px}.forge-nav a{display:inline-flex;align-items:center;min-height:44px;font-size:15px;font-weight:600;text-decoration:underline 2px transparent;text-underline-offset:10px}.forge-nav a:hover{text-decoration-color:currentColor;text-underline-offset:5px}\n.search{display:flex;gap:6px;flex:1;min-width:200px;max-width:460px}\n.search input{flex:1;min-width:0;min-height:44px;padding:8px 12px;border:1px solid var(--line);border-radius:var(--r2);background:var(--white);color:var(--ink);font:inherit;font-size:15px}\nbutton{padding:5px 10px;border:1px solid var(--line);border-radius:var(--r1);background:var(--white);color:var(--ink);cursor:pointer;font:inherit}button:hover{border-color:var(--ink)}\n.search button,.who button{min-height:44px;padding:8px 16px;border-radius:var(--r2);font-size:15px;font-weight:600}\n.who{margin-left:auto;display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;font-size:15px;font-weight:600}.inline{display:inline}\nmain{max-width:1200px;margin:0 auto;padding:var(--s5) 40px var(--s6);font-size:16px;line-height:1.55}\nmain a{color:var(--acc);text-decoration:none}main a:hover{text-decoration:underline}\nmain h1,main h2,main h3{font-weight:600;letter-spacing:-.03em;line-height:1.2}main h1{font-size:clamp(28px,3.4vw,40px);margin:4px 0 12px}\ncode,pre,.mono{font-size:13px}pre{background:var(--box);border:1px solid var(--line);padding:12px;overflow:auto;border-radius:var(--r2)}\ntable.md{display:block;max-width:100%;overflow-x:auto}\n@media(max-width:1000px){main{padding-left:28px;padding-right:28px}}\n@media(max-width:760px){main{padding:16px 20px var(--s5)}.forge-bar{gap:4px 20px}.search{order:3;flex-basis:100%;max-width:none}.readme{padding:12px 14px}}\n"
394text tfcss3 ".muted,.meta{color:var(--mut)}.meta{font-size:13px;margin:2px 0}\n.repos{list-style:none;padding:0;margin:0}.repos li{padding:14px 0;border-bottom:1px solid var(--line)}\n.rname{font-size:17px;font-weight:600}.desc{margin:4px 0}.stars{float:right;color:var(--mut)}\n.rhead h1{font-size:22px;margin:0 0 4px;font-weight:500}.rhead h1 b{font-weight:700}\n.tabs{display:flex;flex-wrap:wrap;gap:4px;border-bottom:1px solid var(--line);margin:14px 0 18px}\n.tabs a{padding:8px 12px;border-bottom:2px solid transparent;color:var(--fg)}.tabs a.on{border-bottom-color:var(--acc);font-weight:600}\n.clone{background:var(--box);border:1px solid var(--line);border-radius:6px;padding:6px 10px;display:inline-block}\n"
395text tfcss4 ".bar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:8px 0}\ntable{border-collapse:collapse;width:100%}td,th{padding:6px 8px;border-bottom:1px solid var(--line);text-align:left;vertical-align:top}\n.err h1{font-size:26px}.box{border:1px solid var(--line);border-radius:6px;padding:12px 16px;margin:12px 0}\n.ok{color:var(--ok)}.bad{color:var(--bad)}.hit{font-family:ui-monospace,Menlo,monospace;font-size:13px;white-space:pre-wrap;overflow-wrap:anywhere}\ninput[type=text],textarea{width:100%;padding:6px 8px;border:1px solid var(--line);border-radius:6px;background:var(--bg);color:var(--fg);font:inherit}\n@media (max-width:640px){.stars{float:none;display:block}.tabs a{padding:6px 8px}}\n"
396text tfcss5 ".releases .release{border:1px solid var(--line);border-radius:6px;padding:12px 16px;margin:12px 0}.release h3{margin:0 0 4px}\n.label{display:inline-block;padding:0 8px;border:1px solid var(--line);border-radius:10px;font-size:12px;color:var(--mut);margin-right:4px}\n.subject{font-weight:600}.notes{white-space:pre-wrap}.assets td:last-child{text-align:right;color:var(--mut)}\n.pager{display:flex;gap:12px;margin:14px 0}.empty{color:var(--mut)}\ndiv.clone{display:block;padding:10px 14px;margin:14px 0}div.clone h3{margin:0 0 6px;font-size:15px}div.clone dl{margin:0;display:grid;grid-template-columns:max-content 1fr;gap:4px 14px}div.clone dt{color:var(--mut)}div.clone dd{margin:0;overflow-wrap:anywhere}\n"
397text tfcss6 ".md{line-height:1.6;overflow-wrap:break-word}.md img{max-width:100%}.md table{width:auto}.md-l{text-align:left}.md-c{text-align:center}.md-r{text-align:right}.md blockquote{margin:0;padding:0 12px;border-left:3px solid var(--line);color:var(--mut)}\n.so-bar,.so-tabs{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:8px 0}.so-form{display:inline}.so-btn{padding:3px 10px}.so-n{color:var(--mut);margin-left:4px}.so-on{font-weight:600}\n.so-muted{color:var(--mut)}.so-err{color:var(--bad)}.so-list{list-style:none;padding:0}.so-list li{padding:6px 0;border-bottom:1px solid var(--line)}.so-cmd{display:block;white-space:pre-wrap;background:var(--box);border:1px solid var(--line);border-radius:6px;padding:8px}.so-steps li{margin:6px 0}.so-f{margin:10px 0}\n"
398text tfcss7 ".crumbs{margin:8px 0;font-size:15px}.ref{display:inline-block;padding:2px 8px;border:1px solid var(--line);border-radius:6px;background:var(--box);font-size:13px;margin-right:8px}\n.latest{border:1px solid var(--line);border-bottom:0;border-radius:6px 6px 0 0;padding:8px 12px;background:var(--box);font-size:13px;color:var(--mut)}\n.files{margin-top:0}.files .dir a{font-weight:600}.files .sz{text-align:right;color:var(--mut);white-space:nowrap}\n.readme{border:1px solid var(--line);border-radius:6px;padding:16px 24px;margin:16px 0}table.md{width:auto}table.md td,table.md th{border:1px solid var(--line)}\n.code{border:1px solid var(--line);border-radius:6px;overflow-x:auto;font-family:ui-monospace,Menlo,monospace;font-size:13px}.code td{border:0;padding:0 8px;line-height:1.5}\n.ln{text-align:right;color:var(--mut);user-select:none;-webkit-user-select:none;width:1%;white-space:nowrap}.lc{white-space:pre}.img img{max-width:100%}\n"
399text tfcss8 ".commits{list-style:none;padding:0;margin:0;border:1px solid var(--line);border-radius:6px}.commits li{padding:8px 12px;border-bottom:1px solid var(--line)}.commits li:last-child{border-bottom:0}\n.box.commit h2{margin:0 0 6px;font-size:18px}pre.msg{white-space:pre-wrap;background:none;border:0;padding:0;margin:6px 0}.stat{font-size:13px;color:var(--mut)}table.stat{width:auto}table.stat td{padding:2px 8px}\n.df{border:1px solid var(--line);border-radius:6px;margin:14px 0;overflow-x:auto}.dfh{padding:6px 12px;background:var(--box);border-bottom:1px solid var(--line);font-family:ui-monospace,Menlo,monospace;font-size:13px}\ntable.diff{font-family:ui-monospace,Menlo,monospace;font-size:13px}table.diff td{border:0;padding:0 8px}td.dc{white-space:pre}tr.da{background:rgba(0,210,148,.15)}tr.dd{background:rgba(255,101,104,.15)}tr.dh,tr.dm{background:var(--box);color:var(--mut)}\ntable.refs td{white-space:nowrap}.badge{display:inline-block;padding:0 8px;border:1px solid var(--acc);border-radius:10px;font-size:12px;color:var(--acc);margin-left:6px}\ntable.code.blame td.bl{white-space:nowrap;color:var(--mut);font-size:12px;border-right:1px solid var(--line);width:1%}tr.bs td{border-top:1px solid var(--line)}p.hit{margin:2px 0}form.inline{display:inline}\n"
400note tfcss9: the project page (server/state.om, frepohd, the "For developers" section) and the marker
401note of a README link that leaves the site (browse/b_md.om class "ext")
402text tfcss9 ".pj-head h1{font-size:34px;line-height:1.15;margin:4px 0 6px;font-weight:700}.pj-head h1 a{color:var(--ink);text-decoration:none}.pj-head h1 a.rname,.pj-by a.rname{font-size:inherit;font-weight:inherit}.pj-head .desc{font-size:19px;margin:0 0 6px;max-width:44em}.pj-by{color:var(--mut);font-size:15px;margin:0 0 10px}\n.state{margin:6px 0 2px;font-size:16px}.state b{display:inline-block;padding:1px 10px;border-radius:999px;margin-right:6px;font-size:14px}.state.ok b{background:var(--panel);color:var(--ok)}.state.no b{background:var(--panel);color:var(--ink)}.state-more{font-size:14px;color:var(--mut);margin:2px 0 8px;max-width:48em}\n.pj-get{margin:14px 0 6px}.pj-get summary{cursor:pointer}.pj-get summary::after{content:\" ▾\"}.pj-get[open] summary::after{content:\" ▴\"}.pj-get code{user-select:all;overflow-wrap:anywhere}.pj-get dd{margin-inline-start:0}.pj-btn{display:inline-flex;align-items:center;min-height:44px;padding:8px 22px;border-radius:var(--r2);background:var(--btn-dark-bg);color:var(--btn-dark-ink);font-weight:700;text-decoration:none}.pj-btn:hover{background:var(--btn-dark-hover);color:var(--btn-dark-ink)}.pj-btn:active{background:var(--btn-dark-press)}.pj-what{color:var(--mut);font-size:14px;max-width:36em}\n.pj-tabs+.readme{border:0;padding:0;margin-top:8px}.pj-tabs+.readme .md{font-size:18px;line-height:1.65}.pj-nordme{font-size:17px;margin:16px 0 8px}\n.pj-dev{margin-top:40px;padding-top:18px;border-top:2px solid var(--line)}.pj-dev h2{font-size:24px;margin:0 0 6px}.pj-terms{display:grid;grid-template-columns:max-content 1fr;gap:6px 16px;margin:10px 0 16px;font-size:15px}.pj-terms dt{font-weight:700}.pj-terms dd{margin:0;overflow-wrap:anywhere}.pj-recs{margin:16px 0}\n.repos .state{font-size:14px;margin:4px 0}.repos .meta .stars{float:none;display:inline}\n.md a.ext::after{content:\" \\2197\";content:\" \\2197\" / \" (leaves this site)\"}\n@media (max-width:640px){.pj-head h1{font-size:28px}.pj-head .desc{font-size:17px}.pj-terms{grid-template-columns:1fr}.pj-terms dd{margin-bottom:8px}}\n"
403fn fcssout to void
404put fkind 0 1
405fsetct tfctcss
406fsetcc tfccpub
407fput tchrcss
408fput tfcssv
409fput tfcss2
410fput tfcss3
411fput tfcss4
412fput tfcss5
413fput tfcss6
414fput tfcss7
415fput tfcss8
416fput tfcss9
417fput tlcss
418end
419note ---- the site icon (served at <base>assets/favicon.svg; the same drawing as interplane.io's
420note /public/favicon.svg). Named in every page head so a browser does not ask /favicon.ico.
421text tfctsvg "image/svg+xml"
422text tfico "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 64\"><rect width=\"64\" height=\"64\" rx=\"12\" fill=\"#2563eb\"/><g stroke=\"#ffffff\" stroke-width=\"5\"><path d=\"M32 10v44M10 32h44M16 16l32 32M16 48l32-32\"/></g></svg>\n"
423fn ficoout to void
424put fkind 0 1
425fsetct tfctsvg
426fsetcc tfccpub
427fput tfico
428end
429note ---- repo list item, shared by explore, profile and search: the name, the plain sentence (the
430note description), the state (server/state.om), then the last commit and the stars. The caller runs
431note fpjload first.
432text tfli1 "<li class=\"pj-row\"><a class=\"rname\" href=\""
433text tfli3 "</a><p class=\"desc\">"
434text tfli4 "</p>"
435text tfli4b "<p class=\"meta\">Last commit: "
436text tfli4c " &#183; <span class=\"stars\" title=\"stars\">&#9733; "
437text tfli5 "</span></p></li>\n"
438text tfnodesc "<span class=\"muted\">No description.</span>"
439text tfnolc "unknown"
440fn frepoli i ulong to void
441fput tfli1
442fputb
443fput tfowner
444fputc 47
445fputrn i
446fput tfqgt
447fputrn i
448fput tfli3
449if eq get fadl i 0
450fput tfnodesc
451else
452fdesc i
453end
454fput tfli4
455fpjrow i
456fput tfli4b
457if eq get falcl i 0
458fput tfnolc
459else
460fputlc i
461end
462fput tfli4c
463fnum sostarn i
464fput tfli5
465end
466note ---- /explore (also the forge home /)
467text tfex1 "<h1>Explore repositories</h1><p class=\"muted pj-intro\">"
468text tfex2 " projects. Open one to read what it is and to get it. <b>Checked</b> means someone rebuilt it from its source and published a receipt; <b>Unfinished</b> means there is no such receipt yet.</p>\n<ul class=\"repos\">\n"
469text tfulend "</ul>\n"
470text tfhome1 "<section class=\"box\"><h1>INTERPLANE Forge</h1><p>Agents express intent. The forge retains authority. Read about each project, download it, follow proposed changes and issues, and star the projects you care about.</p></section>\n"
471text tftexp "Explore"
472text tfthome "Home"
473fn fexplore home bool to void
474put fjalt 0 1
475if home
476fsetti tfthome
477fput tfhome1
478else
479fsetti tftexp
480end
481fpjload
482fput tfex1
483fnum get fan 0
484fput tfex2
485for i ulong get fan 0 bound FAMAX
486frepoli i
487end
488fput tfulend
489end
490note ---- /<owner> profile (the node delegate is the only owner)
491text tfpr1 "<section class=\"rhead\"><h1><b>"
492text tfpr2 "</b></h1><p class=\"muted mono\">did:key:"
493text tfpr3 "</p><p><a href=\""
494text tfpfol "/followers"
495text tfpr4 " followers</a> &#183; <a href=\""
496text tfpfg "/following"
497text tfpr5 " following</a> &#183; "
498text tfpr6 " stars received &#183; "
499text tfpr7 " favorites received</p><div class=\"bar\">"
500text tfpr8 "</div></section>\n<h2>Repositories ("
501text tfpr9 ")</h2>\n<ul class=\"repos\">\n"
502text tfpr10 "<h2>Starred</h2>\n"
503fn fstarsum to ulong
504s = ulong 0
505for i ulong get fan 0 bound FAMAX
506s = add s sostarn i
507end
508ret s
509end
510fn ffavsum to ulong
511s = ulong 0
512for i ulong get fan 0 bound FAMAX
513s = add s sofavn i
514end
515ret s
516end
517fn fprofile to void
518fsetti tfowner
519fput tfpr1
520fput tfowner
521fput tfpr2
522fput tfnid
523fput tfpr3
524fputb
525fput tfowner
526fput tfpfol
527fput tfqgt
528fnum sofolln
529fput tfpr4
530fputb
531fput tfowner
532fput tfpfg
533fput tfqgt
534fnum sofollg
535fput tfpr5
536fnum fstarsum
537fput tfpr6
538fnum ffavsum
539fput tfpr7
540sofolbar
541fput tfpr8
542fnum get fan 0
543fput tfpr9
544fpjload
545for i ulong get fan 0 bound FAMAX
546frepoli i
547end
548fput tfulend
549fput tfpr10
550sostarsof
551end
552note Project and owner names carry class rname: server/tr.om marks that class translate="no" when it
553note sends the page, so the page holds no hint of its own (fob sizes stay exact; server/tests/overflow.sh).
554note ---- repo header: a short friendly header (name, the plain sentence, who brought it; on the repo
555note home also the state and one action to get it), then the tabs. Words for developers (the
556note project id, the clone notice, the counts) are in the "For developers" section of the repo home
557note (fpjdev1 / fpjdev2), whose stable address is <repo>#For-developers. The id has an upper-case
558note letter, so no README heading anchor (browse/b_md.om brmslug: lower case only) can take it.
559text tfrh1 "<section class=\"rhead pj-head\"><h1><a class=\"rname\" href=\""
560text tfrh3 "</a></h1><p class=\"desc\">"
561text tfrh3n "This project has not described itself yet."
562text tfrh4 "</p><p class=\"pj-by\">Brought by <a class=\"rname\" href=\""
563text tfrh4b "</a></p>\n"
564text tfrh5 "<div class=\"bar\">"
565text tfrh6b "</div></section>\n<nav class=\"tabs pj-tabs\" aria-label=\"Project\">"
566text tfrh7 "</nav>\n"
567text tfton "\" class=\"on\" aria-current=\"page\">"
568text tfabout "About"
569text tffiles "Files"
570text tfcomm "History"
571text tfrel "Releases"
572text tfpat "Proposed changes"
573text tfiss "Issues"
574text tfdevt "For developers"
575text tfptree "/tree/"
576text tfpcom "/commits"
577text tfpbr "/branches"
578text tfptag "/tags"
579text tfprel "/releases"
580text tfppat "/patches"
581text tfpiss "/issues"
582text tfpdev "#For-developers"
583text tfpjson ".json"
584text tfpzip "/archive/refs/heads/"
585text tfpzipx ".zip"
586text tfget4 "<p class=\"pj-get pj-what\">Nothing to download yet.</p>\n"
587note fpjempty: set by frepohome: the page has no files to offer (no zip link)
588global fpjempty ulong 1
589fn ftab me ulong on ulong p view uchar * t view uchar * to void
590fput tfahref
591fputrl
592fput p
593if eq me on
594fput tfton
595else
596fput tfqgt
597end
598fput t
599fput tfaend
600end
601fn frepohd tab ulong to void
602i = get fridx 0
603ok = lt i get fan 0
604home = and eq tab 0 eq get frestl 0 0
605fput tfrh1
606fputrl
607fput tfqgt
608fputrnm
609fput tfrh3
610if and ok gt get fadl i 0
611fdesc i
612else
613fput tfrh3n
614end
615fput tfrh4
616fputb
617fputown
618fput tfqgt
619fputown
620fput tfrh4b
621if and home ok
622put fjalt 0 2
623fpjload
624fpjfull i
625if ne get fpjempty 0 0
626fput tfget4
627else
628dlclone
629end
630end
631fput tfrh5
632sobar
633fput tfrh6b
634on = tab
635if and eq tab 0 not home
636on = 10
637end
638if or eq tab 2 eq tab 3
639on = 20
640end
641ftab 0 on tfempty tfabout
642fput tfahref
643fputrl
644fput tfptree
645if ne get fpin 0 0
646fputpin
647else
648if ok
649fputbr i
650end
651end
652if eq on 10
653fput tfton
654else
655fput tfqgt
656end
657fput tffiles
658fput tfaend
659ftab 1 on tfpcom tfcomm
660ftab 4 on tfprel tfrel
661ftab 5 on tfppat tfpat
662ftab 6 on tfpiss tfiss
663ftab 20 on tfpdev tfdevt
664fput tfrh7
665end
666note ---- the "For developers: proof and records" section of the repo home. fpjdev1 opens it: the
667note words that are kept off the top of the page, each with one line of explanation, then the counts
668note (server/counts.om fzhtml). The caller adds the branch bar, the clone panel, the newest commit and
669note the file list, then fpjdev2 closes it with a link to every record page.
670text tfdv1 "<section class=\"pj-dev\" id=\"For-developers\" tabindex=\"-1\" aria-labelledby=\"pj-dev-h\"><h2 id=\"pj-dev-h\">For developers: proof and records</h2>\n<p class=\"pj-lead\">The full record of this project. Words that are used only here are explained once:</p>\n<dl class=\"pj-terms\">\n"
671text tfdv6 "\">Proposed changes</a>.</dd>\n<dt>Receipt</dt><dd>A public record that someone checked a claim, with the fingerprint of its evidence file. The state at the top of this page is read from the list at <a href=\"https://interplane.io/receipts/\">interplane.io/receipts</a>. "
672text tfdv6b "</dd>\n</dl>"
673text tfdv7 "<p class=\"pj-recs\">Every record: <a href=\""
674text tfdv8 "\">History (commits)</a> &#183; <a href=\""
675text tfdv9 "\">Branches</a> &#183; <a href=\""
676text tfdv10 "\">Tags</a> &#183; <a href=\""
677text tfdv11 "\">Releases, with the SHA-256 of each download</a> &#183; <a href=\""
678text tfdv12 "\">Patches</a> &#183; <a href=\""
679text tfdv13 "\">Issues</a> &#183; <a href=\""
680text tfdv14 "\">This project as JSON</a></p>\n</section>\n"
681text tfdvnl "\n"
682fn fpjdev1 to void
683i = get fridx 0
684fput tfdv1
685fpjterms
686fputrl
687fput tfppat
688fput tfdv6
689fpjrcpt
690fput tfdv6b
691if lt i get fan 0
692fzhtml i
693else
694fput tfdvnl
695end
696end
697fn fpjdev2 to void
698fput tfdv7
699fputrl
700fput tfpcom
701fput tfdv8
702fputrl
703fput tfpbr
704fput tfdv9
705fputrl
706fput tfptag
707fput tfdv10
708fputrl
709fput tfprel
710fput tfdv11
711fputrl
712fput tfppat
713fput tfdv12
714fputrl
715fput tfpiss
716fput tfdv13
717fputrl
718fput tfpjson
719fput tfdv14
720end
721note frepohome: the server's repo home when no slice claimed it (browse seam, or a repository whose
722note default branch cannot be read)
723text tfrhm0 "<p class=\"pj-nordme\">No files to show here yet.</p>\n"
724text tfrhm1 "<p class=\"meta\">Default branch <code>"
725text tfrhm2 "</code> &#183; last commit "
726text tfrhm3 "</p>\n"
727fn frepohome to void
728i = get fridx 0
729put ftil 0 0
730ftirepo
731put fpjempty 0 1
732frepohd 0
733put fpjempty 0 0
734fput tfrhm0
735fpjdev1
736fput tfrhm1
737fputbr i
738fput tfrhm2
739fputlc i
740fput tfrhm3
741fpjdev2
742end
743note ---- /search?q=: repo names and descriptions (case-insensitive), then code via git grep
744text tfsr1 "<h1>Search</h1>\n"
745text tfsr2 "<p class=\"muted\">Type a word in the search box: repository names and descriptions are matched, and code is searched with git grep on each public repository's default branch.</p>\n"
746text tfsr3 "<h2>Repositories ("
747text tfsr4 ")</h2>\n"
748text tfsr5 "<p class=\"muted\">No repository name or description matches.</p>\n"
749text tftsrch "Search"
750fn flow c uchar to uchar
751if and ge c 65 le c 90
752ret uchar add c 32
753end
754ret c
755end
756fn fqcap to void
757n = fqget tfq
758if lt n 0
759n = 0
760end
761m = ulong n
762if gt m 200
763m = 200
764end
765for i ulong m bound 256
766put fq i get fval i
767end
768put fql 0 m
769end
770fn fsubat src ulong o ulong l ulong to bool
771q = get fql 0
772if or eq q 0 gt q l
773ret false
774end
775for s ulong add sub l q 1 bound 70000
776if fsubeq src add o s
777ret true
778end
779end
780ret false
781end
782fn fsubeq src ulong o ulong to bool
783for k ulong get fql 0 bound 256
784c = fsubb src add o k
785if ne flow c flow get fq k
786ret false
787end
788end
789ret true
790end
791fn fsubb src ulong k ulong to uchar
792if eq src 0
793ret get fanm k
794end
795ret get fadesc k
796end
797fn fsrmatch i ulong to bool
798if fsubat 0 get fano i get fanl i
799ret true
800end
801ret fsubat 1 get fado i get fadl i
802end
803fn fsearch to void
804fsetti tftsrch
805fput tfsr1
806if eq get fql 0 0
807fput tfsr2
808ret
809end
810n = ulong 0
811for i ulong get fan 0 bound FAMAX
812if fsrmatch i
813n = add n 1
814end
815end
816fput tfsr3
817fnum n
818fput tfsr4
819if eq n 0
820fput tfsr5
821else
822fpjload
823fput tfulrep
824for i ulong get fan 0 bound FAMAX
825if fsrmatch i
826frepoli i
827end
828end
829fput tfulend
830end
831fcodesr
832end
833note ---- code search: git grep -I -n -i -F --max-count=5 -e <q> <default ref> per repo, at most 100 hits
834text tfcs1 "<h2>Code</h2>\n"
835text tfcs2 "<p class=\"muted\">No code matches.</p>\n"
836text tfcs3 "<div class=\"box\"><p><a href=\""
837text tfcs4 "</a></p>\n"
838text tfcs5 "</div>\n"
839text tfcs6 "<p class=\"hit\"><a href=\""
840text tfcs7 "</a> "
841text tfcs8 "</p>\n"
842text tfcsblob "/blob/"
843text tfcsl "#L"
844text tfgrep "grep"
845text tfgI "-I"
846text tfgn "-n"
847text tfgi "-i"
848text tfgF "-F"
849text tfgmax "--max-count=5"
850text tfge "-e"
851text tfcsmore "<p class=\"muted\">Showing the first 100 code matches.</p>\n"
852global fhits ulong 1
853fn fcodesr to void
854fput tfcs1
855put fhits 0 0
856nscodesr
857if eq get fhits 0 0
858fput tfcs2
859end
860if ge get fhits 0 100
861fput tfcsmore
862end
863end
864fn fgreparg i ulong to void
865fkgiti i
866fka tfgrep
867fka tfgI
868fka tfgn
869fka tfgi
870fka tfgF
871fka tfgmax
872fka tfge
873fkopen
874for k ulong get fql 0 bound 256
875fkc get fq k
876end
877fkopen
878fkt tfrh
879o = get fabo i
880for k ulong get fabl i bound 64
881fkc get fabr add o k
882end
883end
884note fcsrepo: render repo i's git grep output (already in fxo, read by nodes/srch.om nsrun)
885fn fcsrepo i ulong to void
886ln = get fxol 0
887if eq ln 0
888ret
889end
890fput tfcs3
891fputb
892fput tfowner
893fputc 47
894fputrn i
895fput tfqgt
896fput tfowner
897fputc 47
898fputrn i
899fput tfcs4
900p = ulong 0
901for it ulong 100000
902if ge p ln
903break
904end
905if ge get fhits 0 100
906break
907end
908e = fleol p ln
909fcshit i p e
910p = add e 1
911end
912fput tfcs5
913end
914note fcshit: one line "refs/heads/<b>:<path>:<line>:<text>"; skip the ref prefix (len 11 + branch + 1)
915fn fcshit i ulong p ulong e ulong to void
916a = add add p 12 get fabl i
917if ge a e
918ret
919end
920c1 = fcolon a e
921if ge c1 e
922ret
923end
924c2 = fcolon add c1 1 e
925if ge c2 e
926ret
927end
928put fhits 0 add get fhits 0 1
929fput tfcs6
930fputb
931fput tfowner
932fputc 47
933fputrn i
934fput tfcsblob
935fputbr i
936fputc 47
937fxesc a sub c1 a
938fput tfcsl
939fxesc add c1 1 sub sub c2 c1 1
940fput tfqgt
941fxesc a sub c1 a
942fputc 58
943fxesc add c1 1 sub sub c2 c1 1
944fput tfcs7
945m = sub sub e c2 1
946if gt m 300
947m = 300
948end
949fxesc add c2 1 m
950fput tfcs8
951end
952fn fcolon a ulong e ulong to ulong
953note the bound is the size of fxo: a path in a search hit can be longer than 100,000 bytes
954j = a
955while lt j e bound 16777216
956if eq get fxo j 58
957ret j
958end
959j = add j 1
960end
961ret e
962end