urbit/pkg/arvo/ted/graph/groupify.hoon

72 lines
1.9 KiB
Plaintext
Raw Normal View History

2020-09-10 14:36:00 +03:00
/- spider, graph-view, graph=graph-store, *metadata-store, *group, *metadata-store
/+ strandio, resource
=>
|%
++ strand strand:spider
++ poke poke:strandio
++ poke-our poke-our:strandio
::
++ check-live
|= who=ship
=/ m (strand ,~)
^- form:m
%+ (set-timeout:strandio ,~) ~s20
;< ~ bind:m
(poke [who %hood] %helm-hi !>(~))
(pure:m ~)
::
++ scry-group
|= rid=resource
=/ m (strand ,group)
^- form:m
;< ugroup=(unit group) bind:m
%+ scry:strandio (unit group)
%+ weld /gx/group-store/groups
(snoc (en-path:resource rid) %noun)
?> ?=(^ ugroup)
(pure:m u.ugroup)
::
++ scry-metadatum
|= rid=resource
2020-09-10 14:36:00 +03:00
=/ m (strand ,metadata)
^- form:m
=/ enc-path=@t (scot %t (spat (en-path:resource rid)))
2020-09-10 14:36:00 +03:00
;< umeta=(unit metadata) bind:m
%+ scry:strandio (unit metadata)
%+ weld /gx/metadata-store/metadata
/[enc-path]/graph/[enc-path]/noun
2020-09-10 14:36:00 +03:00
?> ?=(^ umeta)
(pure:m u.umeta)
--
::
^- thread:spider
|= arg=vase
=/ m (strand ,vase)
^- form:m
=+ !<([~ =action:graph-view] arg)
2020-09-10 14:36:00 +03:00
?> ?=(%groupify -.action)
;< =group bind:m (scry-group rid.action)
2020-09-11 06:08:16 +03:00
?. hidden.group
(strand-fail:strandio %bad-request ~)
;< =metadata bind:m (scry-metadatum rid.action)
2020-09-10 14:36:00 +03:00
?~ to.action
;< ~ bind:m
%+ poke-our %contact-view
:- %contact-view-action
!>([%groupify rid.action title.metadata description.metadata])
2020-09-10 14:36:00 +03:00
(pure:m !>(~))
;< new=^group bind:m (scry-group u.to.action)
?< hidden.new
=/ new-path (en-path:resource u.to.action)
=/ app-path (en-path:resource rid.action)
2020-09-10 14:36:00 +03:00
=/ add-md=metadata-action
[%add new-path graph+app-path metadata]
2020-09-10 14:36:00 +03:00
;< ~ bind:m
(poke-our %metadata-store metadata-action+!>(add-md))
;< ~ bind:m
%+ poke-our %metadata-store
metadata-action+!>([%remove app-path graph+app-path])
2020-09-10 14:36:00 +03:00
;< ~ bind:m
2020-11-05 05:02:59 +03:00
(poke-our %group-store %group-update !>([%remove-group rid.action ~]))
2020-09-10 14:36:00 +03:00
(pure:m !>(~))