docket: revise $docket datastructures

This commit is contained in:
Liam Fitzgerald 2021-08-23 11:45:32 +10:00
parent 6a6897e009
commit 91276dd1c1
4 changed files with 172 additions and 55 deletions

View File

@ -9,6 +9,8 @@
color=(unit @ux)
glob=(unit url)
base=(unit term)
site=(unit path)
image=(unit url)
version=(unit version)
website=(unit url)
license=(unit cord)
@ -20,19 +22,23 @@
?~ title.draft ~
?~ info.draft ~
?~ color.draft ~
?~ glob.draft ~
?~ base.draft ~
?~ version.draft ~
?~ website.draft ~
?~ license.draft ~
=/ href=(unit href)
?^ site.draft `[%site u.site.draft]
?~ base.draft ~
?~ glob.draft ~
`[%glob [u.base.draft [%http u.glob]:draft]]
?~ href ~
=, draft
:- ~
:* %1
u.title
u.info
u.color
u.glob
u.base
u.href
image
u.version
u.website
u.license
@ -52,6 +58,8 @@
%color draft(color `color.clause)
%glob draft(glob `url.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)
@ -61,23 +69,28 @@
++ to-clauses
|= d=docket
^- (list clause)
:~ title+title.d
%- zing
:~ :~ title+title.d
info+info.d
color+color.d
glob+glob.d
base+base.d
version+version.d
website+website.d
license+license.d
==
?~ image.d ~ ~[image+u.image.d]
?: ?=(%site -.href.d) ~[site+path.href.d]
:~ base+base.href.d
glob+url.glob-location.href.d
==
==
::
++ spit-clause
|= =clause
^- tape
%+ weld " {(trip -.clause)}+"
?- -.clause
?(%title %info %glob %website %license %base) "'{(trip +.clause)}'"
?+ -.clause "'{(trip +.clause)}'"
%color (scow %ux color.clause)
%site (spud path.clause)
::
%version
=, version.clause
@ -98,23 +111,23 @@
=, enjs:format
|%
::
++ update
|= u=^update
++ charge-update
|= u=^charge-update
^- json
%+ frond -.u
^- json
?- -.u
%del-dock s+desk.u
%del-charge s+desk.u
::
%initial
%- pairs
%+ turn ~(tap by initial.u)
|=([=desk d=^docket] [desk (docket d)])
|=([=desk c=^charge] [desk (charge c)])
::
%add-dock
%add-charge
%- pairs
:~ desk+s+desk.u
docket+(docket docket.u)
charge+(charge charge.u)
==
==
::
@ -125,20 +138,34 @@
?> ?=(%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
%glob (pairs base+s+base.h ~)
%site s+(spat path.h)
==
::
++ charge
|= c=^charge
%+ merge (docket docket.c)
%- pairs
:~ chad+(chad chad.c)
==
::
++ docket
|= d=^docket
^- json
@ -146,30 +173,17 @@
:~ title+s+title.d
info+s+info.d
color+s+(scot %ux color.d)
glob+s+glob.d
base+s+base.d
href+(href href.d)
version+(version version.d)
license+s+license.d
website+s+website.d
==
::
++ case
|= c=^case
++ chad
|= c=^chad
%+ frond -.c
?- -.c
%da s+(scot %da p.c)
%tas s+(scot %tas p.c)
%ud (numb p.c)
==
::
++ treaty
|= t=^treaty
%+ merge (docket docket.t)
%- pairs
:~ ship+s+(scot %p ship.t)
desk+s+desk.t
cass+(case case.t)
hash+s+(scot %uv hash.t)
?+ -.c ~
%hung s+err.c
==
--
--

View File

@ -0,0 +1,81 @@
/- *treaty
/+ dock=docket
|%
++ enjs
=, enjs:format
|%
++ merge
|= [a=json b=json]
^- json
?> &(?=(%o -.a) ?=(%o -.b))
[%o (~(uni by p.a) p.b)]
::
++ treaty
|= t=^treaty
%+ merge (docket:enjs:dock docket.t)
%- pairs
:~ ship+s+(scot %p ship.t)
desk+s+desk.t
cass+(case case.t)
hash+s+(scot %uv hash.t)
==
::
++ case
|= c=^case
%+ frond -.c
?- -.c
%da s+(scot %da p.c)
%tas s+(scot %tas p.c)
%ud (numb p.c)
==
++ foreign-desk
|= [s=^ship =desk]
^- cord
(crip "{(scow %p s)}/{(trip desk)}")
::
++ alliance
|= a=^alliance
^- json
:- %a
%+ turn ~(tap in a)
|= [=^ship =desk]
^- json
s+(foreign-desk ship desk)
::
++ treaty-update
|= u=update:^treaty
^- json
%+ frond -.u
?- -.u
%add (treaty treaty.u)
%del s+(foreign-desk +.u)
::
%ini
%- pairs
%+ turn ~(tap by init.u)
|= [[s=^ship =desk] t=^treaty]
[(foreign-desk s desk) (treaty t)]
==
::
++ ally-update
|= u=update:ally
^- json
%+ frond -.u
?- -.u
?(%add %del) s+(scot %p ship.u)
::
%ini
%- pairs
%+ turn ~(tap by init.u)
|= [s=^ship a=^alliance]
[(scot %p s) (alliance a)]
::
%new
%- pairs
:~ ship+s+(scot %p ship.u)
alliance+(alliance alliance.u)
==
==
--
--

View File

@ -6,11 +6,36 @@
+$ glob (map path mime)
::
+$ url cord
:: $glob-location: How to retrieve a glob
::
+$ glob-location
$% [%http =url]
==
:: $href: Where a tile links to
::
+$ href
$% [%glob base=term =glob-location]
[%site =path]
==
:: $chad: State of a docket
::
+$ chad
$% :: Done
[%glob =glob]
[%site ~]
:: Waiting
[%install ~]
[%suspend ~]
:: Error
[%hung err=cord]
==
::
:: $charge: A realized $docket
::
+$ charge
[=glob =docket]
$: =docket
=chad
==
::
:: $clause: A key and value, as part of a docket
::
@ -21,34 +46,31 @@
[%info info=@t]
[%color color=@ux]
[%glob url=cord]
[%image =url]
[%site =path]
[%base base=term]
[%version =version]
[%website website=url]
[%license license=cord]
==
::
:: $docket: A infoion of JS bundles for a desk
:: $docket: A description of JS bundles for a desk
::
+$ docket
$: %1
title=@t
info=@t
color=@ux
glob=url
base=term
=href
image=(unit url)
=version
website=url
license=cord
==
::
:: $treaty: A foreign docket
+$ treaty
[=ship =desk =case hash=@uv =docket]
::
::
+$ update
$% [%initial initial=(map desk docket)]
[%add-dock =desk =docket]
[%del-dock =desk]
+$ charge-update
$% [%initial initial=(map desk charge)]
[%add-charge =desk =charge]
[%del-charge =desk]
==
--

View File

@ -1,5 +1,5 @@
:~ title+'Grid'
info+''
info+'Test desc'
color+0xee.5432
glob+'https://bootstrap.urbit.org/glob-0v3.fpsbi.pfo1b.ttlta.u629v.cr9m0.glob'
base+'grid'