mirror of
https://github.com/urbit/shrub.git
synced 2024-11-24 04:58:08 +03:00
parent
2e52df974f
commit
ef15e468ed
9
pkg/shrub/desk.docket-0
Normal file
9
pkg/shrub/desk.docket-0
Normal file
@ -0,0 +1,9 @@
|
||||
:~ title+'Sky'
|
||||
info+'Shrubbery namespace browser.'
|
||||
color+0xdd.dddd
|
||||
image+'https://storage.googleapis.com/tlon-prod-memex-assets/simsur-ronbet/2024.6.19..16.56.27..5ced.9168.72b0.20c4-sky-icon.png'
|
||||
site+/neo/sky
|
||||
version+[0 0 1]
|
||||
website+'https://github.com/urbit/shrub'
|
||||
license+'MIT'
|
||||
==
|
223
pkg/shrub/lib/docket.hoon
Normal file
223
pkg/shrub/lib/docket.hoon
Normal file
@ -0,0 +1,223 @@
|
||||
/- *docket
|
||||
|%
|
||||
::
|
||||
++ mime
|
||||
|%
|
||||
+$ draft
|
||||
$: title=(unit @t)
|
||||
info=(unit @t)
|
||||
color=(unit @ux)
|
||||
glob-http=(unit [=url hash=@uvH])
|
||||
glob-ames=(unit [=ship hash=@uvH])
|
||||
base=(unit term)
|
||||
site=(unit path)
|
||||
image=(unit url)
|
||||
version=(unit version)
|
||||
website=(unit url)
|
||||
license=(unit cord)
|
||||
==
|
||||
::
|
||||
++ finalize
|
||||
|= =draft
|
||||
^- (unit docket)
|
||||
?~ title.draft ~
|
||||
?~ info.draft ~
|
||||
?~ color.draft ~
|
||||
?~ version.draft ~
|
||||
?~ website.draft ~
|
||||
?~ license.draft ~
|
||||
=/ href=(unit href)
|
||||
?^ site.draft `[%site u.site.draft]
|
||||
?~ base.draft ~
|
||||
?^ glob-http.draft
|
||||
`[%glob u.base hash.u.glob-http %http url.u.glob-http]:draft
|
||||
?~ glob-ames.draft
|
||||
~
|
||||
`[%glob u.base hash.u.glob-ames %ames ship.u.glob-ames]:draft
|
||||
?~ href ~
|
||||
=, draft
|
||||
:- ~
|
||||
:* %1
|
||||
u.title
|
||||
u.info
|
||||
u.color
|
||||
u.href
|
||||
image
|
||||
u.version
|
||||
u.website
|
||||
u.license
|
||||
==
|
||||
::
|
||||
++ from-clauses
|
||||
=| =draft
|
||||
|= cls=(list clause)
|
||||
^- (unit docket)
|
||||
=* loop $
|
||||
?~ cls (finalize draft)
|
||||
=* clause i.cls
|
||||
=. draft
|
||||
?- -.clause
|
||||
%title draft(title `title.clause)
|
||||
%info draft(info `info.clause)
|
||||
%color draft(color `color.clause)
|
||||
%glob-http draft(glob-http `[url hash]:clause)
|
||||
%glob-ames draft(glob-ames `[ship hash]:clause)
|
||||
%base draft(base `base.clause)
|
||||
%site draft(site `path.clause)
|
||||
%image draft(image `url.clause)
|
||||
%version draft(version `version.clause)
|
||||
%website draft(website `website.clause)
|
||||
%license draft(license `license.clause)
|
||||
==
|
||||
loop(cls t.cls)
|
||||
::
|
||||
++ to-clauses
|
||||
|= d=docket
|
||||
^- (list clause)
|
||||
%- zing
|
||||
:~ :~ title+title.d
|
||||
info+info.d
|
||||
color+color.d
|
||||
version+version.d
|
||||
website+website.d
|
||||
license+license.d
|
||||
==
|
||||
?~ image.d ~ ~[image+u.image.d]
|
||||
?: ?=(%site -.href.d) ~[site+path.href.d]
|
||||
=/ ref=glob-reference glob-reference.href.d
|
||||
:~ base+base.href.d
|
||||
?- -.location.ref
|
||||
%http [%glob-http url.location.ref hash.ref]
|
||||
%ames [%glob-ames ship.location.ref hash.ref]
|
||||
== == ==
|
||||
::
|
||||
++ spit-clause
|
||||
|= =clause
|
||||
^- tape
|
||||
%+ weld " {(trip -.clause)}+"
|
||||
?+ -.clause "'{(trip +.clause)}'"
|
||||
%color (scow %ux color.clause)
|
||||
%site (spud path.clause)
|
||||
::
|
||||
%glob-http
|
||||
"['{(trip url.clause)}' {(scow %uv hash.clause)}]"
|
||||
::
|
||||
%glob-ames
|
||||
"[{(scow %p ship.clause)} {(scow %uv hash.clause)}]"
|
||||
::
|
||||
%version
|
||||
=, version.clause
|
||||
"[{(scow %ud major)} {(scow %ud minor)} {(scow %ud patch)}]"
|
||||
==
|
||||
::
|
||||
++ spit-docket
|
||||
|= dock=docket
|
||||
^- tape
|
||||
;: welp
|
||||
":~\0a"
|
||||
`tape`(zing (join "\0a" (turn (to-clauses dock) spit-clause)))
|
||||
"\0a=="
|
||||
==
|
||||
--
|
||||
::
|
||||
++ enjs
|
||||
=, enjs:format
|
||||
|%
|
||||
::
|
||||
++ charge-update
|
||||
|= u=^charge-update
|
||||
^- json
|
||||
%+ frond -.u
|
||||
^- json
|
||||
?- -.u
|
||||
%del-charge s+desk.u
|
||||
::
|
||||
%initial
|
||||
%- pairs
|
||||
%+ turn ~(tap by initial.u)
|
||||
|=([=desk c=^charge] [desk (charge c)])
|
||||
::
|
||||
%add-charge
|
||||
%- pairs
|
||||
:~ desk+s+desk.u
|
||||
charge+(charge charge.u)
|
||||
==
|
||||
==
|
||||
::
|
||||
++ num
|
||||
|= a=@u
|
||||
^- ^tape
|
||||
=/ p=json (numb a)
|
||||
?> ?=(%n -.p)
|
||||
(trip p.p)
|
||||
::
|
||||
++ version
|
||||
|= v=^version
|
||||
^- json
|
||||
:- %s
|
||||
%- crip
|
||||
"{(num major.v)}.{(num minor.v)}.{(num patch.v)}"
|
||||
::
|
||||
++ merge
|
||||
|= [a=json b=json]
|
||||
^- json
|
||||
?> &(?=(%o -.a) ?=(%o -.b))
|
||||
[%o (~(uni by p.a) p.b)]
|
||||
::
|
||||
++ href
|
||||
|= h=^href
|
||||
%+ frond -.h
|
||||
?- -.h
|
||||
%site s+(spat path.h)
|
||||
%glob
|
||||
%- pairs
|
||||
:~ base+s+base.h
|
||||
glob-reference+(glob-reference glob-reference.h)
|
||||
==
|
||||
==
|
||||
::
|
||||
++ glob-reference
|
||||
|= ref=^glob-reference
|
||||
%- pairs
|
||||
:~ hash+s+(scot %uv hash.ref)
|
||||
location+(glob-location location.ref)
|
||||
==
|
||||
::
|
||||
++ glob-location
|
||||
|= loc=^glob-location
|
||||
^- json
|
||||
%+ frond -.loc
|
||||
?- -.loc
|
||||
%http s+url.loc
|
||||
%ames s+(scot %p ship.loc)
|
||||
==
|
||||
::
|
||||
++ charge
|
||||
|= c=^charge
|
||||
%+ merge (docket docket.c)
|
||||
%- pairs
|
||||
:~ chad+(chad chad.c)
|
||||
==
|
||||
::
|
||||
++ docket
|
||||
|= d=^docket
|
||||
^- json
|
||||
%- pairs
|
||||
:~ title+s+title.d
|
||||
info+s+info.d
|
||||
color+s+(scot %ux color.d)
|
||||
href+(href href.d)
|
||||
image+?~(image.d ~ s+u.image.d)
|
||||
version+(version version.d)
|
||||
license+s+license.d
|
||||
website+s+website.d
|
||||
==
|
||||
::
|
||||
++ chad
|
||||
|= c=^chad
|
||||
%+ frond -.c
|
||||
?+ -.c ~
|
||||
%hung s+err.c
|
||||
==
|
||||
--
|
||||
--
|
25
pkg/shrub/mar/docket-0.hoon
Normal file
25
pkg/shrub/mar/docket-0.hoon
Normal file
@ -0,0 +1,25 @@
|
||||
/+ dock=docket
|
||||
|_ =docket:dock
|
||||
++ grow
|
||||
|%
|
||||
++ mime
|
||||
^- ^mime
|
||||
[/text/x-docket (as-octt:mimes:html (spit-docket:mime:dock docket))]
|
||||
++ noun docket
|
||||
++ json (docket:enjs:dock docket)
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
::
|
||||
++ mime
|
||||
|= [=mite len=@ud tex=@]
|
||||
^- docket:dock
|
||||
%- need
|
||||
%- from-clauses:mime:dock
|
||||
!<((list clause:dock) (slap !>(~) (ream tex)))
|
||||
|
||||
::
|
||||
++ noun docket:dock
|
||||
--
|
||||
++ grad %noun
|
||||
--
|
82
pkg/shrub/sur/docket.hoon
Normal file
82
pkg/shrub/sur/docket.hoon
Normal file
@ -0,0 +1,82 @@
|
||||
|%
|
||||
::
|
||||
+$ version
|
||||
[major=@ud minor=@ud patch=@ud]
|
||||
::
|
||||
+$ glob (map path mime)
|
||||
::
|
||||
+$ url cord
|
||||
:: $glob-location: How to retrieve a glob
|
||||
::
|
||||
+$ glob-reference
|
||||
[hash=@uvH location=glob-location]
|
||||
::
|
||||
+$ glob-location
|
||||
$% [%http =url]
|
||||
[%ames =ship]
|
||||
==
|
||||
:: $href: Where a tile links to
|
||||
::
|
||||
+$ href
|
||||
$% [%glob base=term =glob-reference]
|
||||
[%site =path]
|
||||
==
|
||||
:: $chad: State of a docket
|
||||
::
|
||||
+$ chad
|
||||
$~ [%install ~]
|
||||
$% :: Done
|
||||
[%glob =glob]
|
||||
[%site ~]
|
||||
:: Waiting
|
||||
[%install ~]
|
||||
[%suspend glob=(unit glob)]
|
||||
:: Error
|
||||
[%hung err=cord]
|
||||
==
|
||||
::
|
||||
:: $charge: A realized $docket
|
||||
::
|
||||
+$ charge
|
||||
$: =docket
|
||||
=chad
|
||||
==
|
||||
::
|
||||
:: $clause: A key and value, as part of a docket
|
||||
::
|
||||
:: Only used to parse $docket
|
||||
::
|
||||
+$ clause
|
||||
$% [%title title=@t]
|
||||
[%info info=@t]
|
||||
[%color color=@ux]
|
||||
[%glob-http url=cord hash=@uvH]
|
||||
[%glob-ames =ship hash=@uvH]
|
||||
[%image =url]
|
||||
[%site =path]
|
||||
[%base base=term]
|
||||
[%version =version]
|
||||
[%website website=url]
|
||||
[%license license=cord]
|
||||
==
|
||||
::
|
||||
:: $docket: A description of JS bundles for a desk
|
||||
::
|
||||
+$ docket
|
||||
$: %1
|
||||
title=@t
|
||||
info=@t
|
||||
color=@ux
|
||||
=href
|
||||
image=(unit url)
|
||||
=version
|
||||
website=url
|
||||
license=cord
|
||||
==
|
||||
::
|
||||
+$ charge-update
|
||||
$% [%initial initial=(map desk charge)]
|
||||
[%add-charge =desk =charge]
|
||||
[%del-charge =desk]
|
||||
==
|
||||
--
|
Loading…
Reference in New Issue
Block a user