mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-02 20:15:27 +03:00
link: rudimentary comments
As of yet largely untested. The "urls in paths" might bring trouble.
This commit is contained in:
parent
beb783808c
commit
9f18877c0a
@ -17,8 +17,11 @@
|
||||
:: whatever's returned by the scry at that path, but perhaps that should
|
||||
:: become part of the stores standard anyway.
|
||||
::
|
||||
/- *link, group-store
|
||||
/+ default-agent, verb
|
||||
:: when adding support for new paths, the only things you'll likely want
|
||||
:: to touch are +permitted, +initial-response, & maybe +handle-group-update.
|
||||
::
|
||||
/- group-store
|
||||
/+ *link, default-agent, verb
|
||||
|%
|
||||
+$ state-0
|
||||
$: %0
|
||||
@ -95,9 +98,10 @@
|
||||
++ permitted
|
||||
|= [who=ship =path]
|
||||
^- ?
|
||||
:: we only expose /local-pages, and only to ships in the relevant group
|
||||
:: we only expose /local-pages and /annotations,
|
||||
:: and only to ships in the relevant group
|
||||
::
|
||||
?. ?=([%local-pages ^] path) |
|
||||
?. ?=([?(%local-pages %annotations) ^] path) |
|
||||
=; group
|
||||
?& ?=(^ group)
|
||||
(~(has in u.group) who)
|
||||
@ -135,7 +139,6 @@
|
||||
%fact
|
||||
=* mark p.cage.sign
|
||||
=* vase q.cage.sign
|
||||
~& [dap.bowl %fact mark]
|
||||
?+ mark ~|([dap.bowl %unexpected-mark mark] !!)
|
||||
%group-initial [~ state]
|
||||
%group-update (handle-group-update !<(group-update:group-store vase))
|
||||
@ -154,11 +157,14 @@
|
||||
::
|
||||
?: =(our.bowl i.whos)
|
||||
$(whos t.whos)
|
||||
:_ $(whos t.whos)
|
||||
%+ weld $(whos t.whos)
|
||||
::NOTE this depends kind of unfortunately on the fact that we only accept
|
||||
:: subscriptions to /local-pages/* paths. it'd be more correct if we
|
||||
:: "just" looked at all paths in the map, and found the matching ones.
|
||||
(kick-proxy i.whos [%local-pages pax.upd])
|
||||
::TODO what exactly did i mean by this?
|
||||
:~ (kick-proxy i.whos [%local-pages pax.upd])
|
||||
(kick-proxy i.whos [%annotations pax.upd])
|
||||
==
|
||||
::
|
||||
:: proxy subscriptions
|
||||
::
|
||||
@ -197,9 +203,16 @@
|
||||
++ initial-response
|
||||
|= =path
|
||||
^- card
|
||||
=/ initial=update
|
||||
=; initial=update
|
||||
[%give %fact ~ %link-update !>(initial)]
|
||||
?+ path !!
|
||||
[%local-pages ^]
|
||||
[%local-pages path .^(pages %gx path)]
|
||||
[%give %fact ~ %link-update !>(initial)]
|
||||
::
|
||||
[%annotations @ ^]
|
||||
=+ (split-discussion-path t.path)
|
||||
[%annotations path url .^(notes %gx path)]
|
||||
==
|
||||
::
|
||||
++ start-proxy
|
||||
|= [who=ship =path]
|
||||
|
@ -204,6 +204,15 @@
|
||||
%+ turn
|
||||
(get-local-pages t.t.site.request-line p)
|
||||
page:en-json
|
||||
:: comments by recency as json
|
||||
::
|
||||
[[[~ %json] [%'~link' %discussions @ ^]] *]
|
||||
%- json-response:gen
|
||||
%- json-to-octs ::TODO include in +json-response:gen
|
||||
:- %a
|
||||
%+ turn
|
||||
(get-discussions t.t.site.request-line p)
|
||||
comment:en-json
|
||||
==
|
||||
::
|
||||
++ include-cors-headers
|
||||
@ -262,6 +271,19 @@
|
||||
(snoc path %noun)
|
||||
==
|
||||
::
|
||||
++ get-discussions
|
||||
|= [=path p=(unit @ud)]
|
||||
^- comments
|
||||
=- (get-paginated - p)
|
||||
.^ comments
|
||||
%gx
|
||||
(scot %p our.bowl)
|
||||
%link-store
|
||||
(scot %da now.bowl)
|
||||
%discussions
|
||||
(snoc path %noun)
|
||||
==
|
||||
::
|
||||
++ get-file-at
|
||||
|= [base=path file=path ext=@ta]
|
||||
^- (unit octs)
|
||||
|
@ -5,10 +5,17 @@
|
||||
:: links, arbitrary paths are probably fair game, but could trip up
|
||||
:: primitive ui implementations.
|
||||
::
|
||||
:: see link-listen-hook to see what's synced in, and similarly
|
||||
:: see link-proxy-hook to see what's exposed.
|
||||
::
|
||||
:: scry and subscription paths:
|
||||
::
|
||||
:: /local-pages/[some-group] all pages we saved by recency
|
||||
:: /submissions/[some-group] all submissions by recency
|
||||
:: urls
|
||||
:: /local-pages/[some-group] all pages we saved by recency
|
||||
:: /submissions/[some-group] all submissions by recency
|
||||
:: comments
|
||||
:: /annotations/[some-group]/[url] all our comments on url by recency
|
||||
:: /discussions/[some-group]/[url] all known comments on url by recency
|
||||
::
|
||||
/+ *link, default-agent, verb
|
||||
::
|
||||
@ -17,6 +24,7 @@
|
||||
$: %0
|
||||
by-group=(map path links)
|
||||
by-site=(map site (list [path submission]))
|
||||
discussions=(map path (map url discussion))
|
||||
==
|
||||
::
|
||||
+$ links
|
||||
@ -25,6 +33,11 @@
|
||||
ours=pages
|
||||
==
|
||||
::
|
||||
+$ discussion
|
||||
$: =comments
|
||||
ours=notes
|
||||
==
|
||||
::
|
||||
+$ card card:agent:gall
|
||||
--
|
||||
::
|
||||
@ -70,6 +83,20 @@
|
||||
::
|
||||
[%x %submissions ^]
|
||||
``noun+!>((get-submissions:do t.t.path))
|
||||
::
|
||||
[%y ?(%annotations %discussions) ~]
|
||||
``noun+!>(~(key by discussions))
|
||||
::
|
||||
[%y ?(%annotations %discussions) ^]
|
||||
=/ urls (~(get by discussions) t.t.path)
|
||||
?~ urls ~
|
||||
``noun+!>(~(key by u.urls))
|
||||
::
|
||||
[%x %annotations @ ^]
|
||||
``noun+!>((get-annotations:do t.t.path))
|
||||
::
|
||||
[%x %discussions @ ^]
|
||||
``noun+!>((get-discussions:do t.t.path))
|
||||
==
|
||||
::
|
||||
++ on-watch
|
||||
@ -85,6 +112,14 @@
|
||||
[%submissions ^]
|
||||
%+ give %link-update
|
||||
[%submissions t.path (get-submissions:do t.path)]
|
||||
::
|
||||
[%annotations @ ^]
|
||||
%+ give %link-update
|
||||
[%annotations t.path (get-annotations:do t.path)]
|
||||
::
|
||||
[%discussions @ ^]
|
||||
%+ give %link-update
|
||||
[%discussions t.path (get-discussions:do t.path)]
|
||||
==
|
||||
::
|
||||
++ give
|
||||
@ -108,7 +143,10 @@
|
||||
^- (quip card _state)
|
||||
?- -.action
|
||||
%save (save-page +.action)
|
||||
%note (note-note +.action)
|
||||
::
|
||||
%hear (hear-submission +.action)
|
||||
%read (read-comment +.action)
|
||||
==
|
||||
:: +save-page: save a page ourselves
|
||||
::
|
||||
@ -134,6 +172,34 @@
|
||||
:+ `[%local-pages path]
|
||||
%link-update
|
||||
!>([%local-pages path [page]~])
|
||||
:: +note-note: save a note for a url
|
||||
::
|
||||
++ note-note
|
||||
|= [=path =url udon=@t]
|
||||
^- (quip card _state)
|
||||
:: add note to discussion ours
|
||||
::
|
||||
=/ urls (~(gut by discussions) path *(map ^url discussion))
|
||||
=/ =discussion (~(gut by urls) url *discussion)
|
||||
=/ =note [now.bowl udon]
|
||||
=. ours.discussion [note ours.discussion]
|
||||
=. urls (~(put by urls) url discussion)
|
||||
=. discussions (~(put by discussions) path urls)
|
||||
:: do generic comment logic
|
||||
::
|
||||
=^ cards state
|
||||
(read-comment path url [our.bowl note])
|
||||
:: send updates to subscribers
|
||||
::
|
||||
:_ state
|
||||
^- (list card)
|
||||
=/ fact
|
||||
:- %link-update
|
||||
!>([%annotations path url [note]~])
|
||||
:* [%give %fact `[%annotations (snoc path url)] fact]
|
||||
[%give %fact `[%annotations path] fact]
|
||||
cards
|
||||
==
|
||||
:: +hear-submission: record page someone else saved
|
||||
::
|
||||
++ hear-submission
|
||||
@ -157,6 +223,28 @@
|
||||
:+ `[%submissions path]
|
||||
%link-update
|
||||
!>([%submissions path [submission]~])
|
||||
:: +read-comment: record a comment someone else made
|
||||
::
|
||||
++ read-comment
|
||||
|= [=path =url =comment]
|
||||
^- (quip card _state)
|
||||
:: add comment to url's discussion
|
||||
::
|
||||
=/ urls (~(gut by discussions) path *(map ^url discussion))
|
||||
=/ =discussion (~(gut by urls) url *discussion)
|
||||
=. comments.discussion [comment comments.discussion]
|
||||
=. urls (~(put by urls) url discussion)
|
||||
=. discussions (~(put by discussions) path urls)
|
||||
:: send updates to subscribers
|
||||
::
|
||||
:_ state
|
||||
^- (list card)
|
||||
=/ fact
|
||||
:- %link-update
|
||||
!>([%discussions path url [comment]~])
|
||||
:~ [%give %fact `[%discussions (snoc path url)] fact]
|
||||
[%give %fact `[%discussions path] fact]
|
||||
==
|
||||
::
|
||||
:: reading
|
||||
::
|
||||
@ -169,4 +257,22 @@
|
||||
|= =path
|
||||
^- submissions
|
||||
submissions:(~(gut by by-group) path *links)
|
||||
::
|
||||
++ get-annotations
|
||||
|= =path
|
||||
^- notes
|
||||
ours:(get-discussion path)
|
||||
::
|
||||
++ get-discussions
|
||||
|= =path
|
||||
^- comments
|
||||
comments:(get-discussion path)
|
||||
::
|
||||
++ get-discussion
|
||||
|= =path
|
||||
^- discussion
|
||||
=+ (split-discussion-path path) ::TODO =/ [=path =url]
|
||||
=- (~(gut by -) url *discussion)
|
||||
%+ ~(gut by discussions) path
|
||||
*(map ^url discussion)
|
||||
--
|
||||
|
@ -22,6 +22,14 @@
|
||||
%| (rsh 3 1 (scot %if p.host))
|
||||
==
|
||||
::
|
||||
++ split-discussion-path
|
||||
|= =path
|
||||
^- [=^path =url]
|
||||
~| [%path-too-short path]
|
||||
?> (gth (lent path) 1) ::TODO ?= would TMI
|
||||
=/ end=@ud (dec (lent path))
|
||||
[(scag end path) (snag end path)]
|
||||
::
|
||||
++ en-json
|
||||
=, enjs:format
|
||||
|%
|
||||
@ -40,17 +48,40 @@
|
||||
'url'^s+url.page
|
||||
'timestamp'^(time time.page)
|
||||
==
|
||||
::
|
||||
++ comment
|
||||
|= =^comment
|
||||
^- json
|
||||
%- pairs
|
||||
:~ 'ship'^(ship ship.comment)
|
||||
'time'^(time time.comment)
|
||||
'udon'^s+udon.comment ::TODO convert?
|
||||
==
|
||||
--
|
||||
::
|
||||
++ de-json
|
||||
=, dejs:format
|
||||
|%
|
||||
:: +action: json into action
|
||||
::
|
||||
:: formats:
|
||||
:: {save: {path: '/path', title: 'title', url: 'url'}}
|
||||
:: {note: {path: '/path', url: 'url', udon: 'text, maybe udon'}}
|
||||
::
|
||||
++ action
|
||||
|= =json
|
||||
^- ^action
|
||||
?> ?=([%o [%save *] ~ ~] json)
|
||||
:- %save ::TODO +of doesn't please type system?
|
||||
%. q.n.p.json
|
||||
(ot 'path'^pa 'title'^so 'url'^so ~)
|
||||
::TODO the type system doesn't like +of here?
|
||||
?+ json ~|(json !!)
|
||||
[%o [%save *] ~ ~]
|
||||
:- %save
|
||||
%. q.n.p.json
|
||||
(ot 'path'^pa 'title'^so 'url'^so ~)
|
||||
::
|
||||
[%o [%note *] ~ ~]
|
||||
:- %note
|
||||
%. q.n.p.json
|
||||
(ot 'path'^pa 'url'^so 'udon'^so ~)
|
||||
==
|
||||
--
|
||||
--
|
||||
|
@ -22,23 +22,52 @@
|
||||
$: =ship
|
||||
page
|
||||
==
|
||||
:: +note: a comment on some url
|
||||
+$ note
|
||||
$: =time
|
||||
udon=@t
|
||||
==
|
||||
:: +comment: a comment by a ship on some url
|
||||
::
|
||||
+$ comment
|
||||
$: =ship
|
||||
note
|
||||
==
|
||||
:: lists, reverse chronological / newest first
|
||||
::
|
||||
+$ pages (list page)
|
||||
+$ submissions (list submission)
|
||||
+$ notes (list note)
|
||||
+$ comments (list comment)
|
||||
::
|
||||
:: +action: local actions
|
||||
::
|
||||
+$ action
|
||||
$% [%save =path title=@t =url]
|
||||
[%hear =path from=ship =page] ::TODO just =submission?
|
||||
$% :: user actions
|
||||
::
|
||||
:: %save: save page to path on our ship
|
||||
::
|
||||
[%save =path title=@t =url]
|
||||
:: %note: save a note for a url
|
||||
::
|
||||
[%note =path =url udon=@t]
|
||||
:: hook actions
|
||||
::
|
||||
:: %hear: hear about page at path on other ship
|
||||
::
|
||||
[%hear =path submission]
|
||||
:: %read: hear about note on url from ship
|
||||
::
|
||||
[%read =path =url comment]
|
||||
==
|
||||
:: +update: local updates
|
||||
::
|
||||
::NOTE we include paths explicitly to support the "subscribed to all" case
|
||||
::NOTE we include paths/urls to support the "subscribed to all" case
|
||||
::
|
||||
+$ update
|
||||
$% [%local-pages =path =pages]
|
||||
[%submissions =path =submissions]
|
||||
[%annotations =path =url =notes]
|
||||
[%discussions =path =url =comments]
|
||||
==
|
||||
--
|
||||
|
Loading…
Reference in New Issue
Block a user