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