urbit/app/collections.hoon

114 lines
2.6 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
::
|_ [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
|= old=(unit state)
2018-07-31 07:00:49 +03:00
^- (quip move _this)
?~ old
:_ this
2018-07-31 07:00:49 +03:00
=< ta-done
(~(ta-hall-create-circle ta ~ bol) /c 'collections')
?- -.u.old
%0
=/ mow=(list move)
=< ta-done
(~(ta-update ta ~ bol) col.u.old cols)
[mow this(sta [%0 cols])]
==
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
|= 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
|= 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]
2017-12-02 21:45:47 +03:00
--