interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / collab / co3view.om

544 lines · 9410 bytes Raw Blame History
1note collab/co3view.om (ForgePatches): shared rendering for patch and issue pages, and the list pages.
2note Class names come from server/forge.css only (box meta muted mono ok bad hit repos rname bar rhead).
3text tcah "<a href=\""
4text tcqg "\">"
5text tcae "</a>"
6text tcpatp "/patches/"
7text tcissp "/issues/"
8text tcpats "/patches"
9text tcisss "/issues"
10text tcdidk "did:key:"
11text tcutc " UTC"
12text tcsp1 "<span class=\"muted mono\">"
13text tcspe "</span>"
14text tcnot "(no title)"
15text tcmidd " &#183; "
16text tcstq "?state="
17text tcstn "state"
18text tcopen "open"
19text tcmerged "merged"
20text tcall "all"
21text tcsopen "Open"
22text tcsdraft "Draft"
23text tcsclos "Closed"
24text tcsmerg "Merged"
25text tcsarch "Archived"
26text tcsall "All"
27text tcpat "Patches"
28text tciss "Issues"
29text tcbon "<b>"
30text tcboff "</b>"
31text tcopar " ("
32text tccpar ")"
33note list summaries (at most 200 COBs per list page)
34global gcss ulong 256
35global gcsu ulong 256
36global gcsc ulong 256
37global gcsk ulong 256
38global gcsr ulong 256
39global gcst ulong 512
40global gclp uchar 262144
41global gclpl ulong 1
42global gcsv uchar 32768
43global gcsvl ulong 256
44global gcsau uchar 16384
45global gcsal ulong 256
46global gcsn ulong 1
47global gccnt ulong 8
48note ---- byte output helpers
49fn copool o ulong n ulong to void
50for i ulong n bound 4194304
51fescc get gcpool add o i
52end
53end
54fn copoolm k ulong to void
55o = get gcm k
56n = get gcm add k 1
57copool o n
58end
59fn coidh n ulong to void
60for k ulong n bound 40
61fputc get gcid k
62end
63end
64fn corhex r ulong n ulong to void
65for k ulong n bound 40
66fputc get gcrv add mul r 40 k
67end
68end
69fn cobhex r ulong n ulong to void
70for k ulong n bound 40
71fputc get gcrb add mul r 40 k
72end
73end
74fn cohhex r ulong n ulong to void
75for k ulong n bound 40
76fputc get gcro add mul r 40 k
77end
78end
79fn comhex m ulong n ulong to void
80for k ulong n bound 40
81fputc get gcmc add mul m 40 k
82end
83end
84fn cochex ci ulong n ulong to void
85for k ulong n bound 40
86fputc get gcch add mul ci 40 k
87end
88end
89fn cosp to void
90fputc 32
91end
92note coisown: change ci was written by the node delegate (owner drakestapleton)
93fn coisown ci ulong to bool
94if ne get gccal ci len tfnid
95ret false
96end
97for i ulong len tfnid
98if ne get gccau add mul ci 64 i get tfnid i
99ret false
100end
101end
102ret true
103end
104fn codid ci ulong to void
105fput tcdidk
106for i ulong get gccal ci bound 64
107fescc get gccau add mul ci 64 i
108end
109end
110note coauth: the author of change ci: the owner name when it is the delegate, and the DID
111fn coauth ci ulong to void
112if coisown ci
113fput tcah
114fputb
115fput tfowner
116fput tcqg
117fput tfowner
118fput tcae
119cosp
120end
121fput tcsp1
122codid ci
123fput tcspe
124end
125note ---- dates: seconds since 1970 to YYYY-MM-DD HH:MM UTC (days to civil date, proleptic Gregorian)
126fn co2d v ulong to void
127if lt v 10
128fputc 48
129end
130fnum v
131end
132fn codate t ulong to void
133cociv div t 86400
134cosp
135s = rem t 86400
136co2d div s 3600
137fputc 58
138co2d div rem s 3600 60
139fput tcutc
140end
141fn codateo t ulong to void
142cociv div t 86400
143end
144fn cociv dy ulong to void
145z = add dy 719468
146era = div z 146097
147doe = sub z mul era 146097
148coymd doe era
149end
150fn coymd doe ulong era ulong to void
151yoe = div sub add sub doe div doe 1460 div doe 36524 div doe 146096 365
152y = add yoe mul era 400
153doy = sub doe sub add mul 365 yoe div yoe 4 div yoe 100
154mp = div add mul 5 doy 2 153
155dd = add sub doy div add mul 153 mp 2 5 1
156mm = ulong 0
157if lt mp 10
158mm = add mp 3
159else
160mm = sub mp 9
161end
162if le mm 2
163y = add y 1
164end
165fnum y
166fputc 45
167co2d mm
168fputc 45
169co2d dd
170end
171note ---- links
172fn copatl to void
173fputrl
174fput tcpatp
175end
176fn coissl to void
177fputrl
178fput tcissp
179end
180note coplink kd: href of the current COB gcid
181fn coplink kd ulong to void
182if eq kd 1
183copatl
184else
185coissl
186end
187coidh 40
188end
189note coqeq t: the value of the last fqget (fval[0,n)) equals t
190fn coqeq n long t view uchar * to bool
191if ne ulong n len t
192ret false
193end
194for i ulong len t
195if ne get fval i get t i
196ret false
197end
198end
199ret true
200end
201note coqstate kd: the state filter, 0 open 1 draft 2 closed 3 merged 9 all (default open)
202fn coqstate kd ulong to ulong
203n = fqget tcstn
204if lt n 0
205ret ulong 0
206end
207if coqeq n tcdraft
208ret ulong 1
209end
210if or coqeq n tcclosed coqeq n tcarch
211ret ulong 2
212end
213if coqeq n tcmerged
214ret ulong 3
215end
216if coqeq n tcall
217ret ulong 9
218end
219ret ulong 0
220end
221note costname kd s: the visible name of a state
222fn costname kd ulong s ulong to void
223if eq s 9
224fput tcsall
225ret
226end
227if eq s 0
228fput tcsopen
229ret
230end
231if eq s 1
232fput tcsdraft
233ret
234end
235if eq s 3
236fput tcsmerg
237ret
238end
239if eq kd 1
240fput tcsarch
241ret
242end
243fput tcsclos
244end
245text tcbok "<b class=\"ok\">"
246text tcbbad "<b class=\"bad\">"
247text tcbmut "<b class=\"muted\">"
248fn costbadge kd ulong s ulong to void
249if or eq s 0 eq s 3
250fput tcbok
251else
252if eq s 1
253fput tcbmut
254else
255fput tcbbad
256end
257end
258costname kd s
259fput tcboff
260end
261note ---- list pages
262fn cosumm kd ulong to void
263i = get gcsn 0
264if ge i 200
265ret
266end
267s = get gcm 2
268if eq kd 1
269s = costate
270end
271put gcss i s
272put gccnt s add get gccnt s 1
273put gcsc i get gcrn 0
274put gcsk i add get gcqn 0 get gcwn 0
275put gcsu i colast
276cosumt i
277cosumv i
278cosuma i
279put gcsn 0 add i 1
280end
281fn colast to ulong
282t = ulong 0
283for ci ulong get gccn 0
284if gt get gccts ci t
285t = get gccts ci
286end
287end
288ret t
289end
290fn cosumt i ulong to void
291o = get gcm 0
292n = get gcm 1
293if gt n 300
294n = ulong 300
295end
296p = get gclpl 0
297if gt add p n 262144
298n = ulong 0
299end
300for k ulong n
301put gclp add p k get gcpool add o k
302end
303put gcst mul i 2 p
304put gcst add mul i 2 1 n
305put gclpl 0 add p n
306end
307fn cosumv i ulong to void
308put gcsvl i 0
309r = get gcrn 0
310if eq r 0
311ret
312end
313r = sub r 1
314n = get gcrvl r
315if gt n 128
316n = ulong 128
317end
318for k ulong n
319put gcsv add mul i 128 k get gcrvd add mul r 256 k
320end
321put gcsvl i n
322end
323fn cosuma i ulong to void
324n = get gccal 0
325for k ulong n bound 64
326put gcsau add mul i 64 k get gccau k
327end
328put gcsal i n
329end
330text tclh1 "<h2>"
331text tclh2 "</h2>\n<p class=\"bar\">"
332text tclh3 "</p>\n"
333text tclul "<ul class=\"repos\">\n"
334text tcluln "</ul>\n"
335text tclnone "<p class=\"muted\">Nothing here in this state.</p>\n"
336text tclcap "<p class=\"muted\">Only the 200 most recently updated are listed.</p>\n"
337text tcpnote "<p class=\"muted\">Patches are stored in this repository and read from it. Opening a new patch from a clone is closed for now: Interplane does not accept pushes yet.</p>\n"
338text tcinote "<p class=\"muted\">Issues are stored in this repository and read from it. Opening a new issue is closed for now: Interplane does not accept issues yet.</p>\n"
339note cotab f s nm v: one filter link (kind in gcm 9); v is the query value
340fn cotab f ulong s ulong nm view uchar * v view uchar * to void
341kd = get gcm 9
342fput tcah
343fputrl
344if eq kd 1
345fput tcpats
346else
347fput tcisss
348end
349fput tcstq
350fput v
351fput tcqg
352if eq f s
353fput tcbon
354end
355fput nm
356fput tcopar
357cotabn kd s
358fput tccpar
359if eq f s
360fput tcboff
361end
362fput tcae
363cosp
364end
365fn cotabn kd ulong s ulong to void
366if eq s 9
367fnum get gcsn 0
368ret
369end
370fnum get gccnt s
371end
372fn cotabs kd ulong f ulong to void
373cotab f 0 tcsopen tcopen
374if eq kd 1
375cotab f 1 tcsdraft tcdraft
376cotab f 3 tcsmerg tcmerged
377cotab f 2 tcsarch tcarch
378else
379cotab f 2 tcsclos tcclosed
380end
381cotab f 9 tcsall tcall
382end
383text tcli1 "<li><a class=\"rname\" href=\""
384text tcli2 "</a> "
385text tcli3 "<p class=\"meta\"><code>"
386text tcli4 "</code> &#183; opened by "
387text tcli5 " &#183; updated "
388text tcli6 " revision"
389text tcli6b " comment"
390text tcli7 "</p>"
391text tcli8 "<p class=\"meta\">Linked verdict: <b>"
392text tcli9 "</b></p>"
393text tcli10 "</li>\n"
394fn corow kd ulong i ulong to void
395coidref get gcsr i
396fput tcli1
397coplink kd
398fput tcqg
399n = get gcst add mul i 2 1
400if eq n 0
401fput tcnot
402end
403o = get gcst mul i 2
404for k ulong n
405fescc get gclp add o k
406end
407fput tcli2
408costbadge kd get gcss i
409fput tcli3
410coidh 7
411fput tcli4
412corowa i
413fput tcmidd
414corowc kd i
415fput tcli5
416codate get gcsu i
417fput tcli7
418corowv i
419fput tcli10
420end
421fn corowa i ulong to void
422n = get gcsal i
423if eq n len tfnid
424if cosaown i
425fput tfowner
426ret
427end
428end
429fput tcdidk
430for k ulong n bound 64
431fescc get gcsau add mul i 64 k
432end
433end
434fn cosaown i ulong to bool
435for k ulong len tfnid
436if ne get gcsau add mul i 64 k get tfnid k
437ret false
438end
439end
440ret true
441end
442fn corowc kd ulong i ulong to void
443if eq kd 1
444fnum get gcsc i
445fput tcli6
446if ne get gcsc i 1
447fputc 115
448end
449fput tcmidd
450end
451fnum get gcsk i
452fput tcli6b
453if ne get gcsk i 1
454fputc 115
455end
456end
457fn corowv i ulong to void
458n = get gcsvl i
459if eq n 0
460ret
461end
462fput tcli8
463for k ulong n
464fescc get gcsv add mul i 128 k
465end
466fput tcli9
467end
468note colist kd: the patch (1) or issue (2) list page of the current repo
469fn colist kd ulong to long
470if eq coldata kd false
471ret 500
472end
473colistp kd
474ret 200
475end
476note coldata kd: load the summaries of the first 200 COBs of kind kd (HTML and JSON list); false = 500
477fn coldata kd ulong to bool
478if eq corefs kd false
479ret false
480end
481put gcsn 0 0
482put gclpl 0 0
483for s ulong 8
484put gccnt s 0
485end
486n = get gcun 0
487if gt n 200
488n = ulong 200
489end
490for i ulong n
491coidref get gcui i
492if coload kd
493put gcsr get gcsn 0 get gcui i
494cosumm kd
495end
496end
497ret true
498end
499fn colistp kd ulong to void
500put gcm 9 kd
501f = coqstate kd
502if and eq kd 2 or eq f 1 eq f 3
503f = ulong 0
504end
505put ftil 0 0
506if eq kd 1
507fsetti tcpat
508frepohd 5
509else
510fsetti tciss
511frepohd 6
512end
513ftic 32
514ftirepo
515fput tclh1
516costname kd f
517fput tclh2
518cotabs kd f
519fput tclh3
520colrows kd f
521if gt get gcun 0 200
522fput tclcap
523end
524if eq kd 1
525fput tcpnote
526else
527fput tcinote
528end
529conewl kd
530end
531fn colrows kd ulong f ulong to void
532m = ulong 0
533fput tclul
534for i ulong get gcsn 0
535if or eq f 9 eq f get gcss i
536corow kd i
537m = add m 1
538end
539end
540fput tcluln
541if eq m 0
542fput tclnone
543end
544end