diff options
Diffstat (limited to 'desk/lib/json.hoon')
-rw-r--r-- | desk/lib/json.hoon | 179 |
1 files changed, 179 insertions, 0 deletions
diff --git a/desk/lib/json.hoon b/desk/lib/json.hoon new file mode 100644 index 0000000..37ecb03 --- /dev/null +++ b/desk/lib/json.hoon @@ -0,0 +1,179 @@ +/+ sortug +|% +++ de +=, dejs:format +|% +++ boardpost +%- ar %- ot +:~ author+so + op+so + thread+de-date + date+de-date + title+so + content+(ar content) + id+ni + tid+ni +== +++ comment +%- ar %- ot +:~ author+so + date+de-date + content+(ar content) + pa+so + parent+de-date + post+de-date + title+so +== +++ soo +|= jon=json +?~ jon '' +?>(?=([%s *] jon) p.jon) +++ poast +%- ar +%- ot +:~ title+so + url+de-url + content+(ar content) + date+di + tags+de-tags + id+ni +== +++ de-tags +|= j=json ^- (set @t) +?> ?=(%s -.j) +=/ ret (rush +.j (split:parsing:sortug hep)) +%- sy +?~ ret ~[+.j] %+ roll u.ret |= [=tape acc=(list @t)] ?~ tape acc [(crip tape) acc] +++ de-date :: just use di? +|= j=json ^- @da +?> ?=(%n -.j) +=/ n (rash +.j dem) +(from-unix-ms:chrono:userlib n) +++ off +|* wer=(pole [cord fist]) + |= jon=json + ?> ?=([%o [@ *] ~ ~] jon) + |- + ?- wer + :: [[key=@t wit=*] t=*] + [[key=@t *] t=*] + => .(wer [[* wit] *]=wer) + ?: =(key.wer p.n.p.jon) + [key.wer ~|(key+key.wer (wit.wer q.n.p.jon))] + ?~ t.wer ~|(bad-key+p.n.p.jon !!) + ((of t.wer) jon) + == +++ content +%- of +:~ paragraph+(ar inline) + blockquote+(ar inline) + heading+heading + list+clists + media+media + codeblock+dcode + tasklist+(ar de-task) + eval+so + ref+ref + json+external +== +++ inline +|= jon=json %. jon +%- of +:~ text+so + italic+so + bold+so + strike+so + ship+(se %p) + date+di + note+de-note + codespan+so + link+link + break+ul + underline+so + sup+so + sub+so + ruby+de-ruby +== +++ de-task +%- ot +:~ text+(ar inline) + done+bo +== +++ de-note +%- ot +:~ id+so + text+(ar inline) +== +++ de-ruby +%- ot +:~ p+so + q+so +== +++ dcode +%- ot +:~ code+so + lang+so +== +++ link +%- ot +:~ href+so + show+so +== +++ heading +%- ot +:~ text+so + :- %num + |= j=json + ?> ?=(%n -.j) + =/ n (rash +.j dem) + ?: .=(1 n) %h1 + ?: .=(2 n) %h2 + ?: .=(3 n) %h3 + ?: .=(4 n) %h4 + ?: .=(5 n) %h5 + ?: .=(6 n) %h6 %h6 +== +++ clists +|= jon=json +%. jon +%- ot +:~ :- %text + |= j=json =/ i ((ar inline) j) + ~[~[[%paragraph i]]] + ordered+bo +== +++ media +%- of +:~ images+(ar de-image) + video+so + audio+so +== +++ de-image +%- ot +:~ url+so + caption+so +== +++ ref +%- ot +:~ type+(se %tas) + ship+(se %p) + path+dpath +== +++ external +%- ot +:~ origin+(se %tas) + content+so +== +++ dpath :: from resource +%- su +%+ cook +|= l=(list @t) `path`+.l +(more fas urs:ab) +++ de-url :: from resource +%- su +%+ cook +|= l=(list @t) `path`l +=/ f (cook |=(a=tape (crip a)) (star ;~(less fas next))) +(more fas f) +-- +-- |