/- boke, cnt=contact, tp=trill-post /+ kaji, fetch-lib=fetch, plib=trill-utils, const=constants, sr=sortug, lib=boke, ui=trill-ui /= index /web/index /= post-list /web/blog/post-list /= post-show /web/blog/post /= title /web/blog/title /= user /web/components/user |_ [rl=req-line:kaji s=state:boke =bowl:gall] +* fetch ~(. fetch-lib [s bowl]) ++ eyre-bail (error-response:kaji 404) ++ manx-bail (error-page:kaji 404) :: ++ $ ^- eyre-res:kaji =/ p pat.rl ::?. mob.rl pat.rl [%m pat.rl] ?+ p ~& >>> path-not-found=`path`p eyre-bail ~ (serve-page par.rl) [%snip pid=@ ~] (post-snippet pid.p) :: [%f rest=*] (fragment rest.p) [%b rest=*] (threads rest.p) == ++ serve-index :- %page :: =/ paginated (get-tag-page:plib feed.s tags.s ~['blog'] [~ ~ page-size]) =/ paginated (thread-page-by-tags:fetch ~['blog'] [~ ~ blog-page-size:const] ~) :: =/ paginated ~> %bout (get-tag-page:plib feed.s tags.s ~['blog'] [~ ~ page-size]) =/ main=manx (html:post-list paginated ~) (index ~[title main] bowl) ++ serve-page |= params=(map @t @t) :- %page ^- manx =/ tags =/ ptags (~(get by params) 't') ?~ ptags ~['blog'] =/ parsed (parse-tags:ui u.ptags) ?~ parsed ~['blog'] :: TODO some error here ~(tap in u.parsed) =/ older =/ pcursor (~(get by params) 'cursor') ?~ pcursor ~ (slaw:parsing:sr %uw u.pcursor) =/ req [~ older blog-page-size:const] =/ paginated (thread-page-by-tags:fetch tags req ~) =/ tag-title =/ ptags (~(get by params) 't') ?~ ptags ~ ;+ ;h3.tag-title:"Posts tagged as {(trip u.ptags)}" =/ main=manx (html:post-list paginated tag-title) (index ~[title main] bowl) ++ show :- %page =/ dat (op-by-path:fetch pat.rl) ?~ dat manx-bail =/ main=manx ~(html post-show [u.dat bowl mob.rl]) (index ~[main] bowl) ++ threads |= p=(pole knot) :- %page =/ dat (op-by-path:fetch p) ?~ dat manx-bail =/ main=manx ~(html post-show [u.dat bowl mob.rl]) (index ~[main] bowl) :: don't think we're using this now ++ post-snippet |= [ss=@] :- %html =/ pid (dec:kaji ss pid:tp) ?~ pid manx-bail :: =/ post (get:gorm:tp feed.s u.pid) =/ thread (get:torm:tp threads.s u.pid) ?~ thread manx-bail :: =/ fn (node-to-full:plib u.post feed.s) (post-snippet:post-list u.thread) :: ?+ pat bail :: [type=@t name=@t cursor=@t ~] :: :: TODO %feed type at some point? :: =/ older (slaw:parsing:sr %uw cursor.pat) ?~ older inline-error :: ?. ?=(?(%b %t) type.pat) inline-error :: ?: ?=(%b type.pat) :: =/ page (board-to-page:lib name.pat tags.s feed.s [~ older board-page-size:cns]) :: ?~ page inline-error :: (serve-post-page name.pat u.page .n) :: :: single tag :: =/ page (tag-to-page:lib name.pat tags.s feed.s [~ older board-page-size:cns]) ?~ page inline-error :: (serve-post-page name.pat u.page .y) :: == :: ++ serve-post-page :: |= [name=@t =page:tp is-tag=?] :: ~& >> serving-page=+.page :: =/ previews ?: ?=(%blog name) :: (turn p.page post-snippet:post-list) :: :: :: =/ contacts (get-contacts:cnt bowl) :: %+ turn p.page |= fn=full-node:tp (thread-preview fn contacts bowl) :: ;div :: ;* %+ snoc previews :: (cursor:cm older.page "Older" name is-tag) :: == ++ fragment |= p=(pole knot) :- %html ?+ p manx-bail ~ blog-page [%comments uid=@t ~] (blog-comments uid.p) [%subthread uid=@t ~] (subthread uid.p) [%reply uid=@t ~] (reply-box uid.p) == ++ blog-page =/ params=(map @t @t) par.rl =/ tags =/ ptags (~(get by params) 't') ?~ ptags ~['blog'] =/ parsed (parse-tags:ui u.ptags) ?~ parsed ~['blog'] ~(tap in u.parsed) =/ older =/ pcursor (~(get by params) 'cursor') ?~ pcursor ~ (slaw:parsing:sr %uw u.pcursor) =/ req=page-req:tp [~ older blog-page-size:const] :: =/ paginated (get-tag-page-2:plib feed.s tags.s tags req) =/ paginated (thread-page-by-tags:fetch tags req ~) (html:post-list paginated ~) ++ blog-comments |= hash=@t =/ op (op-by-hash:fetch hash) ?~ op manx-bail ~(comment-list post-show [u.op bowl mob.rl]) ++ subthread |= hash=@t =/ both (dec:kaji hash ,[op=pid:tp sub=pid:tp]) ?~ both manx-bail =/ op (op-by-pid:fetch op.u.both) ?~ op manx-bail =/ sub-op (fn-by-pid:fetch sub.u.both) ?~ sub-op manx-bail =/ core ~(. post-show [u.op bowl mob.rl]) (comment-subthread:core u.sub-op) ++ reply-box |= hash=@t ?: .=(%pawn (clan:^title src.bowl)) ;div#reply-box ;p:"You must login with an Urbit ID to comment" == =/ usr (user src.bowl *whoms:cnt 30) :: TODO ;div ;div#reply-box ;span =id "cancel-reply" =class "fl" =kaji "destroy" =targ "#reply-box" ; Cancel reply == ;form#reply-form =kaji "poke" =action "add-reply" ;textarea#comment =name "text" =cols "45" =rows "8" =maxlength "6552" =autocomplete "off" ; == ;div.author-data ;div.as.flex ;span:"Posting as " ;div.flex.ml1 ;+ avatar.usr ;+ name.usr == == ;input#submit-comment(type "submit", value "Poast"); == ;input(type "hidden", name "parents", value (trip hash)); ;input(type "hidden", name "is-blog", value ".y"); ;span#error-div; == == == --