shrub/pkg/arvo/app/link-store.hoon

149 lines
3.2 KiB
Plaintext
Raw Normal View History

:: link [landscape]:
::
/- *link, gra=graph-store, *resource
/+ store=link-store, graph-store, default-agent, verb, dbug
::
|%
+$ spore-any $%(spore-1 state-0)
+$ state-any $%(state-1 state-0)
+$ spore-1 [%1 cards=*]
2020-09-25 03:03:07 +03:00
+$ state-1 [%1 cards=(list card)]
+$ state-0
$: %0
by-group=(map path links)
by-site=(map site (list [path submission]))
discussions=(per-path-url discussion)
==
::
+$ links
$: ::NOTE all lists by recency
=submissions
ours=pages
2020-02-07 23:49:16 +03:00
seen=(set url)
==
::
+$ discussion
$: =comments
ours=notes
==
::
+$ card card:agent:gall
--
::
=| state-1
=* state -
::
2020-01-29 21:21:40 +03:00
%- agent:dbug
%+ verb |
^- agent:gall
|_ =bowl:gall
+* this .
do ~(. +> bowl)
def ~(. (default-agent this %|) bowl)
::
++ on-init on-init:def
++ on-save !>(state)
++ on-load
|= old=vase
^- (quip card _this)
2020-09-25 03:03:07 +03:00
::
=/ s !<(spore-any old)
?: ?=(%1 -.s)
[~ this(state s(cards ~))]
2020-09-25 03:03:07 +03:00
:: defer card emission to later event
::
=; [cards=(list card) that=_this]
:_ that(state [%1 cards])
[%pass /load %arvo %b %wait now.bowl]~
::
:_ this(state *state-1)
=/ orm orm:graph-store
|^ ^- (list card)
2020-09-01 20:57:19 +03:00
%- zing
%+ turn ~(tap by by-group.s)
|= [=path =links]
2020-09-01 20:57:19 +03:00
^- (list card)
2020-09-25 03:03:07 +03:00
?. ?=([@ ~] path)
(on-bad-path path links)
2020-09-25 03:03:07 +03:00
=/ =resource [our.bowl i.path]
2020-09-01 20:57:19 +03:00
:_ [(archive-graph resource)]~
%+ add-graph resource
^- graph:gra
%+ gas:orm ~
=/ comments (~(gut by discussions.s) path *(map url discussion))
%+ turn submissions.links
|= sub=submission
^- [atom node:gra]
:- time.sub
=/ contents ~[text+title.sub url+url.sub]
=/ parent-hash `@ux`(sham ~ ship.sub time.sub contents)
:- ^- post:gra
:* author=ship.sub
index=~[time.sub]
time-sent=time.sub
contents
hash=`parent-hash
signatures=~
==
^- internal-graph:gra
=/ dis (~(get by comments) url.sub)
?~ dis
[%empty ~]
:- %graph
^- graph:gra
%+ gas:orm ~
%+ turn comments.u.dis
|= [=ship =time udon=@t]
^- [atom node:gra]
:- time
:_ `internal-graph:gra`[%empty ~]
=/ contents ~[text+udon]
:* author=ship
index=~[time.sub time]
time-sent=time
contents
hash=``@ux`(sham `parent-hash ship time contents)
signatures=~
==
::
++ on-bad-path
|= [=path =links]
^- (list card)
2020-09-25 03:03:07 +03:00
~& discarding-malformed-links+[path links]
~
::
++ add-graph
|= [=resource =graph:gra]
^- card
2020-09-01 20:57:19 +03:00
%- poke-graph-store
[%0 now.bowl %add-graph resource graph `%graph-validator-link %.y]
2020-09-01 20:57:19 +03:00
::
++ archive-graph
|= =resource
^- card
%- poke-graph-store
[%0 now.bowl %archive-graph resource]
::
++ poke-graph-store
|= =update:gra
^- card
:* %pass /migrate-link %agent [our.bowl %graph-store]
%poke %graph-update !>(update)
==
--
::
2020-09-25 03:08:52 +03:00
++ on-poke on-poke:def
++ on-peek on-peek:def
++ on-watch on-watch:def
++ on-leave on-leave:def
++ on-agent on-agent:def
2020-09-25 03:03:07 +03:00
++ on-arvo
|= [=wire =sign-arvo]
^- (quip card _this)
?+ sign-arvo (on-arvo:def wire sign-arvo)
[%b %wake *]
[cards.state this]
==
++ on-fail on-fail:def
--