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

74 lines
1.8 KiB
Plaintext
Raw Normal View History

/- spider, graph-view, graph=graph-store,
met=metadata-store, *group, *metadata-store
2020-09-10 14:36:00 +03:00
/+ 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
=/ m (strand ,metadatum:met)
2020-09-10 14:36:00 +03:00
^- form:m
=/ enc-path=@t (scot %t (spat (en-path:resource rid)))
;< umeta=(unit metadatum:met) bind:m
%+ scry:strandio (unit metadatum:met)
2020-09-10 14:36:00 +03:00
%+ 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 ~)
;< =metadatum:met 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.metadatum description.metadatum])
2020-09-10 14:36:00 +03:00
(pure:m !>(~))
;< new=^group bind:m (scry-group u.to.action)
?< hidden.new
;< ~ bind:m
%+ poke-our %metadata-store
:- %metadata-action
!> ^- action:met
[%add u.to.action [%graph rid.action] metadatum]
2020-09-10 14:36:00 +03:00
;< ~ bind:m
%+ poke-our %metadata-store
:- %metadata-action
!> ^- action:met
[%remove rid.action [%graph rid.action]]
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 !>(~))