diff options
-rw-r--r-- | desk/lib/nostril/mutations.hoon | 65 | ||||
-rw-r--r-- | desk/lib/nostril/post.hoon | 74 | ||||
-rw-r--r-- | desk/sur/nostril.hoon | 3 | ||||
-rw-r--r-- | desk/sur/post.hoon | 10 |
4 files changed, 87 insertions, 65 deletions
diff --git a/desk/lib/nostril/mutations.hoon b/desk/lib/nostril/mutations.hoon index 68c82d3..5383947 100644 --- a/desk/lib/nostril/mutations.hoon +++ b/desk/lib/nostril/mutations.hoon @@ -1,15 +1,18 @@ -/- sur=nostril, post +/- sur=nostril, post, gate, feed /+ shim, postlib=nostril-post, sr=sortug |_ [=state:sur =bowl:gall] ++ process-events ^- (quip card _state) - =/ l events.state - =| cards=(list card:agent:gall) - |- ?~ l [cards state] - =/ n (event-parsing i.l) - $(cards -.n, state +.n, l t.l) + :: =/ l events.state + :: =| cards=(list card:agent:gall) + :: |- ?~ l [cards state] + :: =/ n (event-parsing i.l) + :: $(cards -.n, state +.n, l t.l) + :: TODO + `state -++ event-parsing ^- (quip card _state) +++ event-parsing |= =event:sur + ^- (quip card _state) |^ :: https://nostrdata.github.io/kinds/ ?: .=(kind.event 0) :: user metadata @@ -29,8 +32,9 @@ `state ++ parse-metadata + ^- (quip card _state) =/ jstring content.event - =/ ujon=json (de:json:html jstring) + =/ ujon (de:json:html jstring) ?~ ujon !! =/ =user-meta:sur (metadata:dejs:shim u.ujon) =/ fid (~(get by following.state) pubkey.event) @@ -40,44 +44,53 @@ `state - ++ parse-poast |= =event:sur + ++ parse-poast + ^- (quip card _state) =/ fid (~(get by following.state) pubkey.event) ?~ fid `state :: don't save post if we don't follow the fucker =/ cl (tokenize:postlib content.event) =/ ts (from-unix:jikan:sr created-at.event) - =/ cm (init-content-map:postlib cl ts) + :: TODO wtf + =/ cm=content-map:post (init-content-map:postlib cl ts) - =/ =post:post :* + =/ p=post:post :* id=ts - author=pubkey.event - thread=~ + host=`@p`pubkey.event + author=`@p`pubkey.event + thread=ts parent=~ + children=~ contents=cm read=*lock:gate write=*lock:gate *engagement:post - 0 + 0v0 *signature:post tags=~ == - =/ nfid (put:orm:post u.fid ts post) - =. following.state (~(put by following.state) pubkey.event nfid) + =/ nfid (put:orm:feed +.u.fid ts p) + =. following.state (~(put by following.state) pubkey.event [-.u.fid nfid]) `state ++ parse-follow - %+ turn tags.event |= t=tag:sur - ?> .=('p' key.t) - =/ pubkey value.t - =/ relay (snag 0 rest.t) - =/ rel ?: .=(relay '') ~ (some relay) - =/ nickname (snag 1 rest.t) + ^- (quip card _state) =/ following (~(get by follow-graph.state) pubkey.event) - =/ meta [pubkey nickname rel] - =/ nfollowing ?~ following (silt ~[meta]) (~(put in u.following) meta) - =. following-graph.state (~(put by follow-graph.state) pubkey.event nfollowing) - `state + =/ follow-set ?~ following *(set follow:sur) u.following + |- ?~ tags.event `state + =/ t=tag:sur i.tags.event + ?. .=('p' key.t) $(tags.event t.tags.event) + =/ pubkeys value.t + =/ pubkey (slaw:sr %ux pubkeys) + ?~ pubkey ~& "parsing hex error" $(tags.event t.tags.event) + =/ relay (snag 0 rest.t) + =/ rel ?: .=(relay '') ~ (some relay) + =/ nickname (snag 1 rest.t) + =/ meta=follow:sur [u.pubkey nickname rel] + =. follow-set (~(put in follow-set) meta) + =. follow-graph.state (~(put by follow-graph.state) pubkey.event follow-set) + $(tags.event t.tags.event) -- -- diff --git a/desk/lib/nostril/post.hoon b/desk/lib/nostril/post.hoon index 134ed27..6ce9345 100644 --- a/desk/lib/nostril/post.hoon +++ b/desk/lib/nostril/post.hoon @@ -49,7 +49,8 @@ %emphasis (de-strong +.inl) %strong (de-strong +.inl) %link [%link (de-target target.inl) (flatten-inline contents.inl)] - %image [%img (de-target target.inl) alt-text.inl] + %image [%link (de-target target.inl) (de-target target.inl)] + :: %image [%img (de-target target.inl) alt-text.inl] %autolink [%text ''] %html [%codespan text.inl] == @@ -85,16 +86,18 @@ %block-quote [%blockquote (denest +.node)] %ol [%list (de-list contents.node) .y] %ul [%list (de-list contents.node) .n] - %tl [%tasklist (turn contents.node de-task)] + %tl [%paragraph ~] == -++ de-task |= [checked=? mde=markdown:md] ^- task:tp - :_ checked (denest mde) -++ de-list |= lmd=(list markdown:md) ^- (list li:tp) - =| res=(list li:tp) - |- ?~ lmd (flop res) - =/ nodelist i.lmd - =/ blocks %+ turn nodelist de-node - $(lmd t.lmd, res [blocks res]) +++ de-list |= lmd=(list markdown:md) ^- (list inline:tp) +:: TODO +~ + :: =| res=(list li:tp) + :: |- ?~ lmd (flop res) + :: =/ nodelist i.lmd + :: =/ blocks=(list block:tp) + :: %+ turn nodelist de-node + :: $(lmd t.lmd, res [blocks res]) + ++ denest |= mde=markdown:md ^- paragraph:tp =| res=paragraph:tp |- ?~ mde (flop res) @@ -110,7 +113,7 @@ %heading :~([%text p.block]) %codeblock :~([%text code.block]) %eval :~([%text hoon.block]) - %list (break-list p.block) + :: %list (break-list p.block) == ++ break-list |= lis=(list li:tp) ^- paragraph:tp =| res=paragraph:tp @@ -154,24 +157,25 @@ ++ manx-to-block |= =manx:hoot ^- (unit block:tp) ?+ n.g.manx ~ - heading %- some [%heading (phead n.g.manx c.manx)] + :: TODO + :: heading %- some [%heading (phead n.g.manx c.manx)] %p %- some [%paragraph (inline-list c.manx)] %blockquote %- some [%blockquote (inline-list c.manx)] %pre %- some [%codeblock (pre c.manx)] %hr %- some [%paragraph ~[[%break ~]]] - %ul %- some [%list (list-items c.manx) .n] - %ol %- some [%list (list-items c.manx) .y] + %ul %- some [%list (inline-list c.manx) .n] + %ol %- some [%list (inline-list c.manx) .y] :: %table %- some (table-rows c.manx) == -++ list-items -|= =marl:hoot ^- (list li:clist:tp) -%- flop - %+ roll marl |= [=tuna:hoot acc=(list li:clist:tp)] - ?@ -.tuna acc - ?. ?=(%li n.g.tuna) acc :_ acc (marl-to-cl c.tuna) - ++ phead - |= [h=heading c=marl:hoot] ^- [p=cord q=heading] - :- (get-tag-text c) h +:: ++ list-items +:: |= =marl:hoot ^- (list li:tp) +:: %- flop +:: %+ roll marl |= [=tuna:hoot acc=(list li:tp)] +:: ?@ -.tuna acc +:: ?. ?=(%li n.g.tuna) acc :_ acc (marl-to-cl c.tuna) +:: ++ phead +:: |= [h=heading c=marl:hoot] ^- [p=cord q=heading] +:: :- (get-tag-text c) h ++ inline-list |= c=marl:hoot ^- (list inline:tp) %- flop @@ -261,8 +265,8 @@ "{acc}{il}" "{acc}{il} " %list - %^ foldi:sr p.b "" |= [in=@ud =li:tp acc=tape] - =/ li-tape (content-list-to-md li) + %^ foldi:sr p.b "" |= [in=@ud i=inline:tp acc=tape] + =/ li-tape (inline-to-tape i) =/ line ?: ordered.b "{<+(in)>}. {li-tape}" "- {li-tape}" @@ -271,11 +275,14 @@ "{acc}{line}\0a" %media ?+ -.media.b "})" -%images %^ foldi:sr p.media.b "" |= [i=@ud [url=@t caption=@t] acc=tape] - =/ line "})" - ?: .=(+(i) (lent p.media.b)) - "{acc}{line}" - "{acc}{line}\0a" + :: TODO +%images + :: %^ foldi:sr p.media.b "" |= [i=@ud [url=@t caption=@t] acc=tape] + :: =/ line "})" + :: ?: .=(+(i) (lent p.media.b)) + :: "{acc}{line}" + :: "{acc}{line}\0a" + "" == %codeblock """ @@ -291,7 +298,7 @@ %h5 "##### " %h6 "###### " == "{dashes}{(trip p.b)}" -%tasklist "" ::TODO +:: %tasklist "" ::TODO :: :: %table acc :: %eval acc @@ -307,7 +314,7 @@ "{acc}{block-tape}\0a\0a" ++ inline-to-tape |= i=inline:tp ^- tape - ?- -.i + ?+ -.i "" %text (trip p.i) %italic "_{(trip p.i)}_" %bold "*{(trip p.i)}*" @@ -315,7 +322,7 @@ %ship (scow %p p.i) %codespan "`{(trip p.i)}`" %link "[{(trip show.i)}]({(trip href.i)})" - %img "})" + :: %img "})" %break "\0a" == ++ tags-to-tape @@ -324,6 +331,7 @@ ?: .=(+(i) ~(wyt in t)) "{acc}{(trip c)}" "{acc}{(trip c)}," + ++ init-content-map |= [cl=content-list:tp date=@da] ^- content-map:tp (put:corm:tp *content-map:tp date cl) diff --git a/desk/sur/nostril.hoon b/desk/sur/nostril.hoon index 87f6611..b22ac10 100644 --- a/desk/sur/nostril.hoon +++ b/desk/sur/nostril.hoon @@ -11,10 +11,11 @@ :: feeds own=feed:feed following=(map @ux [profile=user-meta =feed:feed]) - follow-graph=(map @ux (set [pubkey=@ux name=@t relay=(unit @t)])) + follow-graph=(map @ux (set follow)) :: TODO global feed somehow? == ++$ follow [pubkey=@ux name=@t relay=(unit @t)] +$ keys [pub=@ priv=@] ++ default ^- state-0 =/ s *state-0 s(relays (silt ~['wss://relay.damus.io' 'wss://nos.lol'])) :: NOSTR structs diff --git a/desk/sur/post.hoon b/desk/sur/post.hoon index 75f2aa3..2fa3585 100644 --- a/desk/sur/post.hoon +++ b/desk/sur/post.hoon @@ -72,16 +72,17 @@ +$ content-map ((mop time content-list) gth) ++ corm ((on time content-list) gth) -+$ content-list contents:contents-1 +:: +$ content-list contents:contents-1 ++$ content-list contents +$ li content-list -++ contents-1 -|% +$ contents (list block) ++$ paragraph (list inline) ++$ heading $?(%h1 %h2 %h3 %h4 %h5 %h6) +$ block $% [%paragraph p=(list inline)] [%blockquote p=(list inline)] [%table rows=(list (list contents))] - [%heading p=cord q=@] + [%heading p=cord q=heading] [%list p=(list inline) ordered=?] [%media =media] [%codeblock code=cord lang=cord] @@ -118,4 +119,3 @@ :: [%date p=@da] == -- --- |