interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / apps / interplane-forge / dl / dljson.om

331 lines · 5802 bytes Raw Blame History
1note dl/dljson.om: the machine form (JSON) of the /releases pages (ForgeDownloads, docs/API.md).
2note dlrelr calls dljrels / dljrtag when fjwant is true. Each runs the same checks as its HTML handler
3note (dlrels / dlrtag) before it reads anything, and shows the same facts: the same records in the same
4note order, the same archive and asset rows, size and SHA-256 only when the HTML shows them (the cached
5note file and its sidecar exist). Links are the HTML hrefs with the base; tag and asset names passed
6note dlrefok / dlasok, so they are URL- and JSON-safe bytes. /releases/latest is a redirect in both forms.
7text tdjsrel "forge/releases/1"
8text tdjsrl1 "forge/release/1"
9text tdjrels "releases"
10text tdjrel "release"
11text tdjprev "prev"
12text tdjnext "next"
13text tdjhtml "html"
14text tdjpre "prerelease"
15text tdjlat "latest"
16text tdjtime "time"
17text tdjsha "sha"
18text tdjpath "path"
19text tdjsubj "subject"
20text tdjnote "notes"
21text tdjarch "archives"
22text tdjtgz "tar_gz"
23text tdjass "assets"
24text tdjname "name"
25text tdjsize "size"
26text tdjsha2 "sha256"
27text tdjpq "?page="
28text tdjskip "assets_not_offered"
29note dljrels: GET /releases[?page=N] as forge/releases/1 (dlrels' checks and paging: 10 per page)
30fn dljrels to long
31if not dltags
32ret 500
33end
34p = dlpageq
35s = mul sub p 1 10
36kn = get gdkn 0
37if and gt p 1 ge s kn
38ret 404
39end
40fyrhead tdjsrel
41fyk tdpage
42fnum p
43fyk tdjrels
44fputc 91
45for i ulong 10
46k = add s i
47if ge k kn
48break
49end
50if gt i 0
51fputc 44
52end
53fputc 10
54dljrel get gdkeep k false
55end
56fputc 93
57dljpager p kn
58fyend
59ret 200
60end
61note dljpager: ,"prev":<newer page link or null>,"next":<older page link or null> (dlpager's links)
62fn dljpager p ulong kn ulong to void
63fyk tdjprev
64if gt p 1
65dljpgl sub p 1
66else
67fynull
68end
69fyk tdjnext
70if lt mul p 10 kn
71dljpgl add p 1
72else
73fynull
74end
75end
76fn dljpgl n ulong to void
77fputc 34
78fputrl
79fput tdrel
80fput tdjpq
81fnum n
82fputc 34
83end
84note dljrtag: GET /releases/tag/<t> as forge/release/1 (dlrtag's checks: 404 too long or unknown,
85note 400 a refused tag name), with the release-assets/ files
86fn dljrtag to long
87if not dltags
88ret 500
89end
90if not dlrcopy len tdrtag get frestl 0
91ret 404
92end
93if not dlrefok
94ret 400
95end
96r = dlrfind
97if eq r DLNONE
98ret 404
99end
100fyrhead tdjsrl1
101fyk tdjrel
102dljrel r true
103fyend
104ret 200
105end
106note dljrel: the release object of kept record r (dlrel1's facts); full adds the assets array, else null
107fn dljrel r ulong full bool to void
108dlsn2ref r
109dlsetsha r
110fputc 123
111fyk0 tdtag
112dljref
113fyk tdjhtml
114fputc 34
115fputrl
116fput tdrtag
117dljrraw
118fputc 34
119fyk tdjpre
120fybool dlpre
121fyk tdjlat
122fybool eq get gdlat 0 r
123fyk tdjtime
124dlfld r 6
125fjiso dljnum
126dljcmt
127dljnotes r
128dljarchs
129fyk tdjass
130if full
131dljassets
132else
133fynull
134end
135fyk tdjskip
136if full
137fnum get gdaskip 0
138else
139fynull
140end
141fputc 125
142end
143note dljref: the tag name gdref as a JSON string; dljrraw: its bytes inside an open string (a link)
144fn dljref to void
145fjtb
146for i ulong get gdrefl 0
147fjtc get gdref i
148end
149fjstr
150end
151fn dljrraw to void
152for i ulong get gdrefl 0
153fputc get gdref i
154end
155end
156note dljnum: the decimal field gdtl[gdfa, gdfa + gdfn) (creatordate:unix), 0 when empty or not digits
157fn dljnum to ulong
158a = get gdfa 0
159v = ulong 0
160for i ulong get gdfn 0 bound 1048576
161c = get gdtl add a i
162if not dldig c
163ret 0
164end
165v = add mul v 10 ulong sub c 48
166end
167ret v
168end
169note dljcmt: ,"commit":{"sha":"<40 hex>","path":"<base><o>/<r>/commit/<sha>"} of gdsha
170fn dljcmt to void
171fyk tdcommit
172fputc 123
173fyk0 tdjsha
174fputc 34
175dljsha
176fputc 34
177fyk tdjpath
178fputc 34
179fputrl
180fput tdcommp
181dljsha
182fputc 34
183fputc 125
184end
185fn dljsha to void
186for i ulong 40
187fputc get gdsha i
188end
189end
190note dljnotes: ,"subject":..,"notes":.. of an annotated tag (dlmsg, as dlnotes), null when the tag is
191note lightweight or the part is empty (the HTML then shows no paragraph)
192fn dljnotes r ulong to void
193dlfld r 1
194an = dlfeq tdtag
195if an
196an = dlmsg r
197end
198fyk tdjsubj
199dljmsgf an get gdmsa 0 get gdmsn 0
200fyk tdjnote
201dljmsgf an get gdmba 0 get gdmbn 0
202end
203fn dljmsgf an bool a ulong n ulong to void
204if and an gt n 0
205fjtb
206for i ulong n bound 16777216
207fjtc get fxo add a i
208end
209fjstr
210ret
211end
212fynull
213end
214note dljarchs: ,"archives":{"zip":{..},"tar_gz":{..}} (dlarow 1 and 2)
215fn dljarchs to void
216fyk tdjarch
217fputc 123
218fyk0 tdezip
219dljarow 1
220fyk tdjtgz
221dljarow 2
222fputc 125
223end
224note dljarow: one source archive of the release in gdref / gdsha: name, path, size, sha256
225fn dljarow fmt ulong to void
226put gdfmt 0 fmt
227dlprefix
228if eq fmt 1
229dlfinal tdezip
230else
231dlfinal tdetgz
232end
233fputc 123
234fyk0 tdjname
235fjtb
236for i ulong get gdprel 0
237fjtc get gdpre i
238end
239dljext fmt
240fjstr
241fyk tdjpath
242fputc 34
243fputrl
244fput tdarht
245dljrraw
246if eq fmt 1
247fput tdzip
248else
249fput tdtgz
250end
251fputc 34
252dljsum
253fputc 125
254end
255fn dljext fmt ulong to void
256if eq fmt 1
257for i ulong len tdzip
258fjtc get tdzip i
259end
260ret
261end
262for i ulong len tdtgz
263fjtc get tdtgz i
264end
265end
266note dljsum: ,"size":<bytes>,"sha256":"<64 hex>" of gdf when it is built with its sidecar (dlsumcells),
267note else both null; never builds or hashes anything
268fn dljsum to void
269if dlexists
270if dlsumrd
271fyk tdjsize
272fnum get gdsize 0
273fyk tdjsha2
274fputc 34
275for i ulong 64
276fputc get gdhex i
277end
278fputc 34
279ret
280end
281end
282fyk tdjsize
283fynull
284fyk tdjsha2
285fynull
286end
287note dljassets: the release-assets/ files of the commit in gdsha as an array (dlassets' rows)
288fn dljassets to void
289dllsa
290c = new uchar 40 0
291for i ulong 40
292put c i get gdsha i
293end
294fputc 91
295for k ulong get gdan 0 bound 131072
296if gt k 0
297fputc 44
298end
299dljasrow k
300end
301fputc 93
302for i ulong 40
303put gdsha i get c i
304end
305end
306note dljasrow: asset k: name, path (/releases/download/<tag>/<name>), size, sha256
307fn dljasrow k ulong to void
308fputc 123
309fyk0 tdjname
310n = get gdanl k
311b = get gdano k
312fjtb
313for i ulong n
314fjtc get fxo add b i
315end
316fjstr
317fyk tdjpath
318fputc 34
319fputrl
320fput tdrdl
321dljrraw
322fputc 47
323for i ulong n
324fputc get fxo add b i
325end
326fputc 34
327dlabsha k
328dlfblob
329dljsum
330fputc 125
331end