urbit/app/collections.hoon

312 lines
5.9 KiB
Plaintext
Raw Normal View History

::
:::: /app/collections/hoon
::
2018-07-31 07:00:49 +03:00
/? 309
/- hall
/+ collections
::
:: cols:
::
:: run collections-item renderer on children of /web/collections
2018-09-07 02:39:02 +03:00
:: combine with a bunted config in a +collection structure defined in
:: /lib/collections because the top level collection has no config file
::
2018-09-07 02:39:02 +03:00
:: whenever any of the clay files that compose this renderer change, this app
:: will recompile and the +prep arm will fire. we then check which files
:: changed and notify the corresponding hall circle of that change
::
2018-07-31 07:00:49 +03:00
/= cols
/^ collection:collections
/; |= a=(map knot item:collections)
[*config:collections a]
2018-08-01 02:31:30 +03:00
/: /===/web/collections /_ /collections-item/
2017-12-02 21:45:47 +03:00
::
2018-07-31 07:00:49 +03:00
=, collections
=, space:userlib
2017-12-02 21:45:47 +03:00
::
:: state:
::
2018-09-07 02:39:02 +03:00
:: stores the collection built by above by :cols so that we can compare old
:: and new versions whenever the rendered data changes
::
~% %landscape ..^is ~
|_ [bol=bowl:gall sta=state]
2017-12-14 03:04:45 +03:00
::
:: +this: app core subject
::
2018-07-31 07:00:49 +03:00
++ this .
2017-12-02 21:45:47 +03:00
::
:: +prep:
::
:: on initial boot, create top level hall circle for collections, called %c
::
:: on subsequent compiles, call +ta-update:ta on the old collection data,
:: then update state to store the new collection data
::
2018-07-31 07:00:49 +03:00
++ prep
~/ %land-prep
|= old=(unit state)
2018-07-31 07:00:49 +03:00
^- (quip move _this)
?~ old
:_ this
;: welp
=< ta-done
(~(ta-hall-create-circle ta ~ bol) /c 'collections')
::
:~ [ost.bol %peer /circles [our.bol %hall] /circles/[(scot %p our.bol)]]
[ost.bol %peer /inbox [our.bol %hall] /circle/inbox/config/grams]
[ost.bol %peer /invites [our.bol %hall] /circle/i/grams]
==
==
?- -.u.old
%0
=/ mow=(list move)
=< ta-done
(~(ta-update ta ~ bol) col.u.old cols)
:- mow
%= this
sta [%0 cols str.u.old]
==
==
2017-12-02 21:45:47 +03:00
::
2018-09-07 02:39:02 +03:00
:: +mack:
::
:: recieve acknowledgement for permissions changes, print error if it failed
2017-12-02 21:45:47 +03:00
::
2018-07-31 07:00:49 +03:00
++ mack
|= [wir=wire err=(unit tang)]
^- (quip move _this)
?~ err
[~ this]
(mean u.err)
2018-03-06 04:35:33 +03:00
::
:: +coup: recieve acknowledgement for poke, print error if it failed
::
++ coup
|= [wir=wire err=(unit tang)]
^- (quip move _this)
?~ err
[~ this]
(mean u.err)
::
:: +poke-collections-action:
2018-07-31 07:00:49 +03:00
::
2018-09-07 03:31:06 +03:00
:: the main interface for creating and deleting collections and items
2018-07-31 07:00:49 +03:00
::
++ poke-collections-action
~/ %coll-poke-collections-action
|= act=action
2018-07-31 07:00:49 +03:00
^- (quip move _this)
2018-08-21 00:16:57 +03:00
?: =(who.act our.bol)
:_ this
=< ta-done
(~(ta-act ta ~ bol) act)
2018-08-21 00:16:57 +03:00
:: forward poke if its not meant for us
::
2018-08-21 00:16:57 +03:00
:_ this
:_ ~
:* ost.bol %poke
/forward-collections-action
[who.act %collections]
%collections-action act
2017-12-02 21:45:47 +03:00
==
2018-07-31 07:00:49 +03:00
::
2018-11-07 09:36:03 +03:00
:: +poke-json
2018-09-05 04:01:17 +03:00
::
:: utility for setting whether or not to display the onboarding page
::
2018-11-07 09:36:03 +03:00
++ poke-json
~/ %coll-poke-json
2018-11-07 09:36:03 +03:00
|= jon=json
2018-09-05 04:01:17 +03:00
^- (quip move _this)
2018-11-07 09:36:03 +03:00
?: ?=([%o [[%onboard %b ?] ~ ~]] jon)
:_ this
2018-11-07 09:36:03 +03:00
=< ta-done
(~(ta-write ta ~ bol) /web/landscape/onboard/json [%json !>(jon)])
2018-11-07 09:36:03 +03:00
[~ this]
::
::
::
::
::
++ peer
|= wir=wire
^- (quip move _this)
[~ this]
::
:: +reap: recieve acknowledgement for peer, retry on failure
::
++ reap
|= [wir=wire err=(unit tang)]
^- (quip move _this)
?~ err
[~ this]
?~ wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
?+ i.wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
::
%circles
:_ this
[ost.bol %peer /circles [our.bol %hall] /circles/[(scot %p our.bol)]]~
::
%inbox
:_ this
[ost.bol %peer /inbox [our.bol %hall] /circle/inbox/config/grams]~
::
%invites
:_ this
[ost.bol %peer /invites [our.bol %hall] /circle/i/grams]~
::
%our
[~ this]
::
%sub
[~ this]
==
:: :~ [ost.bol %peer /circles [our.bol %hall] /circles/[(scot %p our.bol)]]
:: [ost.bol %peer /inbox [our.bol %hall] /circle/inbox/config/grams]
:: [ost.bol %peer /invites [our.bol %hall] /circle/i/grams]
:: ==
::
:: +quit:
::
++ quit
|= [wir=wire err=(unit tang)]
^- (quip move _this)
?~ err
[~ this]
?~ wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
?+ i.wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
::
%circles
:_ this
[ost.bol %peer /circles [our.bol %hall] /circles/[(scot %p our.bol)]]~
::
%inbox
:_ this
[ost.bol %peer /inbox [our.bol %hall] /circle/inbox/config/grams]~
::
%invites
:_ this
[ost.bol %peer /invites [our.bol %hall] /circle/i/grams]~
::
%our
[~ this]
::
%sub
[~ this]
==
::
:: +diff-hall-prize:
::
::
::
++ diff-hall-prize
|= [wir=wire piz=prize:hall]
^- (quip move _this)
?~ wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
?+ i.wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
::
:: %circles: subscribe to the configuration of each of our circles
::
%circles
?> ?=(%circles -.piz)
=/ circs=(set name:hall) (~(dif in cis.piz) (sy ~[%inbox %i %public]))
::
:_ this
^- (list move)
%+ turn ~(tap in circs)
|= circ=name:hall
^- move
[ost.bol %peer /our/[circ] [our.bol %hall] /circle/[circ]/config]
::
:: %inbox:
::
%inbox
[~ this]
::
:: %invites
::
%invites
[~ this]
::
%our
[~ this]
::
%sub
[~ this]
==
:: :~ [ost.bol %peer /circles [our.bol %hall] /circles/[(scot %p our.bol)]]
:: [ost.bol %peer /inbox [our.bol %hall] /circle/inbox/config/grams]
:: [ost.bol %peer /invites [our.bol %hall] /circle/i/grams]
:: ==
::
:: +diff-hall-rumor
::
::
::
++ diff-hall-rumor
|= [wir=wire rum=rumor:hall]
^- (quip move _this)
?~ wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
?+ i.wir
(mean [leaf+"invalid wire for diff: {(spud wir)}"]~)
::
%circles
[~ this]
::
%inbox
[~ this]
::
%invites
[~ this]
::
%our
[~ this]
::
%sub
[~ this]
==
2017-12-02 21:45:47 +03:00
--