diff options
Diffstat (limited to 'desk/lib/trill')
-rw-r--r-- | desk/lib/trill/feed.hoon | 37 | ||||
-rw-r--r-- | desk/lib/trill/gate.hoon | 79 |
2 files changed, 107 insertions, 9 deletions
diff --git a/desk/lib/trill/feed.hoon b/desk/lib/trill/feed.hoon index c21feb3..721a596 100644 --- a/desk/lib/trill/feed.hoon +++ b/desk/lib/trill/feed.hoon @@ -1,14 +1,16 @@ -/- feed=trill-feed, sur=nostrill +/- feed=trill-feed, post=trill-post, sur=nostrill /+ sr=sortug, constants |% -++ latest-page |= f=feed:feed ^- fc:feed +++ latest-page +=/ count feed-page-size:constants +|= f=feed:feed ^- fc:feed =/ nodelist (tap:orm:feed f) - =/ subset (scag feed-page-size:constants nodelist) + =/ subset (scag count nodelist) ?~ subset [f ~ ~] - =/ start `id.i.subset + =/ start `-.i.subset =/ rev (flop subset) ?~ rev [f ~ ~] - =/ end `id.i.rev + =/ end `-.i.rev =/ nf (gas:orm:feed *feed:feed subset) [nf start end] :: @@ -16,20 +18,20 @@ =/ nodelist (tap:norm:sur f) =/ subset (scag feed-page-size:constants nodelist) ?~ subset [f ~ ~] - =/ start `id.i.subset + =/ start (some `@da`-.i.subset) =/ rev (flop subset) ?~ rev [f ~ ~] - =/ end `id.i.rev + =/ end (some `@da`-.i.rev) =/ nf (gas:norm:sur *nostr-feed:sur subset) [nf start end] :: :: NOTE START IS OLD, END IS NEW ++ subset +=/ count feed-page-size:constants |= [=fc:feed replies=? now=@da] ^- fc:feed ?: ?&(?=(%~ start.fc) ?=(%~ end.fc)) (latest-page feed.fc) - =/ count feed-page-size:constants =/ start ?~ start.fc 0 u.start.fc =/ end ?~ end.fc now u.end.fc =/ nodelist (tap:orm:feed feed.fc) @@ -43,9 +45,26 @@ == ?& (lte id start) (gte id end) == =/ thread-count (lent threads) - =/ result=(list [id:post post:post]) ?: newest (scag count threads) (flop (scag count (flop threads))) + :: TODO I remember something was weird about this + :: =/ result=(list [id:post post:post]) ?: newest (scag count threads) (flop (scag count (flop threads))) + =/ result=(list [id:post post:post]) (scag count threads) =/ cursors=[(unit @da) (unit @da)] ?~ result [~ ~] ?~ threads [~ ~] :- ?: .=((head result) (head threads)) ~ `id:(head result) ?: .=((rear result) (rear threads)) ~ `id:(rear result) [(gas:orm:feed *feed:feed result) -.cursors +.cursors] +:: posts +++ node-to-full +|= [p=post:post f=feed:feed] ^- full-node:post + p(children (convert-children children.p f)) +++ convert-children +|= [children=(set id:post) f=feed:feed] + ^- internal-graph:post + =/ g=full-graph:post %- ~(rep in children) + |= [=id:post acc=full-graph:post] + =/ n (get:orm:feed f id) + ?~ n acc + =/ full-node (node-to-full u.n f) + (put:form:post acc id full-node) + ?~ children [%empty ~] + :- %full g -- diff --git a/desk/lib/trill/gate.hoon b/desk/lib/trill/gate.hoon new file mode 100644 index 0000000..ebb78b8 --- /dev/null +++ b/desk/lib/trill/gate.hoon @@ -0,0 +1,79 @@ +/- gate=trill-gate +|% +++ mask-lock +|= =lock:gate ^- lock:gate + :* ?: public.rank.lock rank.lock [~ %| %|] + ?: public.luk.lock luk.lock [~ %| %|] + ?: public.ship.lock ship.lock [~ %| %|] + ?: public.tags.lock tags.lock [~ %| %|] + ?: public.custom.lock custom.lock [~ %|] + == +++ can-access +|= [=ship =lock:gate =bowl:gall] ^- ? + ?^ fn.custom.lock %- u.fn.custom.lock ship + =/ in-luk (~(has in caveats.ship.lock) ship) + =/ fu (sein:title our.bowl now.bowl ship) + =/ ye (sein:title our.bowl now.bowl fu) + =/ ze (sein:title our.bowl now.bowl ye) + =/ in-ship ?| + (~(has in caveats.luk.lock) fu) + (~(has in caveats.luk.lock) ye) + (~(has in caveats.luk.lock) ze) + == + =/ in-rank (~(has in caveats.rank.lock) (clan:title ship)) + :: =/ in-tags (~(has in (scry-pals-tags caveats.tags.lock)) ship) + =/ can |= [pit=? has=?] ^- ? ?: pit has !has + =/ as-ship (can locked.ship.lock in-ship) + =/ as-luk (can locked.ship.lock in-luk) + =/ as-rank (can locked.ship.lock in-rank) + ::=/ as-tags (can locked.ship.lock in-tags) + ?&(as-ship as-luk as-rank) + +++ scry-pals-tags +|= tags=(set @t) ^- (set @p) + :: .^() + ~ +++ apply-change +|= [=lock:gate =change:gate] ^- lock:gate + ?- -.change + %set-rank lock(rank +.change) + %set-luk lock(luk +.change) + %set-ship lock(ship +.change) + %set-tags lock(tags +.change) + %set-custom lock ::TODO + == +++ open-all +|= =lock:gate ^- lock:gate + %= lock + rank rank.lock(locked .n) + luk luk.lock(locked .n) + ship ship.lock(locked .n) + tags tags.lock(locked .n) + == +++ lock-all +|= =lock:gate ^- lock:gate +%= lock +rank rank.lock(locked .y) +luk luk.lock(locked .y) +ship ship.lock(locked .y) +tags tags.lock(locked .y) +== +++ toggle-rank +|= [r=rank:title setting=[caveats=(set rank:title) locked=? public=?]] + =/ new-caveats=(set rank:title) ?: locked.setting + (~(put in caveats.setting) r) + (~(del in caveats.setting) r) + setting(caveats new-caveats) +++ toggle-ship +|= [s=ship setting=[caveats=(set ship) locked=? public=?]] + =/ new-caveats=(set ship) ?: locked.setting + (~(put in caveats.setting) s) + (~(del in caveats.setting) s) + setting(caveats new-caveats) +++ toggle-tag +|= [t=@t setting=[caveats=(set @t) locked=? public=?]] + =/ new-caveats=(set @t) ?: locked.setting + (~(put in caveats.setting) t) + (~(del in caveats.setting) t) + setting(caveats new-caveats) +-- |