/- 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 /= board /web/board/index /= mobile /web/board/mobile-index /= thread-page /web/board/thread /= new-thread /web/board/new /= nag /web/nag /= poll /web/components/poll |_ [rl=req-line:kaji s=state:boke =bowl:gall] +* fetch ~(. fetch-lib [s bowl]) b ~(. board [s bowl mob.rl]) :: ++ eyre-bail (error-response:kaji 404) ++ manx-bail (error-page:kaji 404) :: ++ $ ^- eyre-res:kaji =/ p ?. mob.rl pat.rl [%m pat.rl] ?: ?=([%m ~] p) [%page (index ~[(mobile s bowl)] bowl)] ?: ?=([%m %ff rest=*] p) [%html (mobile-fragment rest.p)] =. p ?: ?=([%m rest=*] p) ((pole knot) rest.p) p ?: ?=([%f rest=*] p) [%html (fragment rest.p)] :- %page %- index :_ bowl :_ ~ ?+ p manx-bail :: boards ~ (main par.rl) :: these two mostly for mobile [%t tag=@t ~] (tag-index tag.p) [%b cat=@t ~] (board-index cat.p) [%all ~] all-posts :: threads [%n ~] (new-thread tags.s bowl ~) [%edit uid=@t ~] (edit-thread uid.p) [%blog rest=*] (blog-as-thread rest.p) [%p %esc uid=@t ~] (board-thread-no-path uid.p) [tag=@t title=@t rest=*] (board-thread tag.p title.p rest.p) :: [%p rest=*] (board-thread rest.p) == ++ fragment |= p=(pole knot) ?+ p ~& no-fragment=p manx-bail :: fetching categories [%boards ~] (w category-list:b) [%tags ~] (w (make-tag-list:b (scag 21 (tags-by-size:lib tags.s src.bowl)))) [%tag-search ~] (w tag-search) :: fetching posts [%page type=@t name=@t cursor=@t ~] (post-page type.p name.p cursor.p *_par.rl) [%search type=@t name=@t cursor=@t ~] (post-page type.p name.p cursor.p par.rl) :: :: fetching replies of thread [%replies thread=@t cursor=@t ~] (thread-replies thread.p cursor.p) [%snip uid=@t ~] (post-snippet uid.p) [%edit uid=@t ~] (edit-box uid.p) [%poll %new ~] new-poll == ++ mobile-fragment |= p=(pole knot) ?+ p manx-bail [%boards ~] (w category-list:mobile) [%tags ~] (w (make-tag-list:b (scag 33 (tags-by-size:lib tags.s src.bowl)))) [%tag-search ~] =/ uq (~(get by par.rl) 'query') %- w ;* ?~ uq :~(;span:"No query") %+ turn (tag-search:fetch u.uq) tag-preview:b [%snip uid=@t ~] (post-snippet uid.p) [%edit uid=@t ~] (edit-box uid.p) == ++ w wrap-marl:kaji :: Boards ++ main |= params=(map @t @t) =/ post-list =/ tag (~(get by params) 't') ?^ tag (post-page 't' u.tag '0' ~) =/ brd (~(get by params) 'b') ?^ brd (post-page 'b' u.brd '0' ~) (post-page '' '' '0' ~) (main.b post-list) ++ tag-search ^- marl =/ uq (~(get by par.rl) 'query') ;* ?~ uq :~(;span:"No query") %+ turn (tag-search:fetch u.uq) tag-preview:b +$ rq $%([%latest ~] [%board name=@t] [%tag name=@t]) ++ tag-index |= tag=@t %- post-page :^ 't' tag '0' ~ ++ board-index |= cat=@t %- post-page :^ 'b' cat '0' ~ ++ all-posts %- post-page :^ 'l' '' '0' ~ ++ post-page |= [stype=@t name=@t scursor=@t params=(map @t @t)] =/ contacts (get-contacts:cnt bowl) =/ older=(unit @) ?: .=('0' scursor) ~ (slaw:parsing:sr %uw scursor) =/ =rq ?: .=(stype 't') [%tag name] ?: .=(stype 'b') [%board name] [%latest ~] =/ query (~(get by params) 'query') =/ sort-by (~(get by params) 'sort') =/ page-req [~ older board-page-size:const] =/ filter ?~ query %- some |= =thread:tp !(~(has in tags.thread) 'blog') %- some |= =thread:tp ?: (~(has in tags.thread) 'blog') .n (cfind:sr u.query title.thread .n) =/ =tpage:tp ?- -.rq %latest (active-thread-page-all:fetch page-req filter) %tag (active-thread-page-by-tags:fetch ~[name] page-req filter) %board (active-thread-page-by-board:fetch name page-req filter) == ?: .=('0' scursor) (post-index:b tpage rq contacts query mob.rl) (previews:b tpage rq contacts query mob.rl) :: Threads ++ edit-thread |= uid=@t =/ op (thread-by-hash:fetch uid) ?~ op manx-bail (new-thread tags.s bowl op) ++ board-thread-no-path |= uid=@t =/ post (post:fetch uid) ?~ post manx-bail (serve-thread u.post) ++ blog-as-thread |= p=path =/ op (by-path:fetch p) ?~ op ~& board-blog-path-not-found=p manx-bail =/ is-op .=(thread.u.op [author.u.op id.u.op]) ?. is-op manx-bail (serve-thread u.op) ++ serve-thread |= =post:tp =/ ted (get:torm:tp threads.s thread.post) ?~ ted ~& board-ted-not-found=rl manx-bail :: =/ fn (node-to-full:plib post feed.s) =/ contacts (get-contacts:cnt bowl) :: =/ post-pid=pid:tp [author.u.post id.u.post] :: ?~ parent.post =/ =cpage:tp (thread-children:fetch u.ted) =. p.cpage [post p.cpage] ~& >> cpage=+.cpage (thread-page u.ted cpage ~ ~ contacts s bowl mob.rl) ++ thread-replies |= [ts=@t cs=@t] =/ contacts (get-contacts:cnt bowl) =/ thread (dec:kaji ts pid:tp) ?~ thread manx-bail =/ cursor (dec:kaji cs @ud) ?~ cursor manx-bail =/ ted (get:torm:tp threads.s u.thread) ?~ ted manx-bail ?~ replies.u.ted manx-bail =/ =cpage:tp (older-children:fetch u.ted +(u.cursor)) =< inline %= thread-page thread u.ted children cpage focus (some i.replies.u.ted) search ~ contacts contacts state s bowl bowl is-mobile mob.rl == ++ board-thread |= [tag=@t title=@t rest=(pole knot)] =/ post (by-path:fetch [tag title ~]) ?~ post ~& board-path-not-found=rl cant-show (serve-thread u.post) ++ cant-show html:nag :: =/ children (flatten-fn-2:plib fn) :: =/ req [~ ~ thread-page-size:const] :: =/ children (get-children-page:plib fn req) :: ~& children=+.children :: =/ par (get:gorm:tp feed.s u.parent.post) :: ?~ par ~& par-not-found=rl :: =/ children (bulk-post-by-pid:fetch replies.u.ted) :: =/ =spage:tp [children ~ ~ (lent children)] :: (thread-page title.u.ted contents.u.post spage ~ ~ contacts bowl mob.rl) :: =/ siblings (get-siblings-page-2:plib u.par) :: (thread-page title.u.ted contents.u.post siblings `post-pid ~ contacts bowl mob.rl) ++ edit-box |= uid=@t =/ up (post:fetch uid) ?~ up not-found =/ tag-string (tags-to-tape:ui tags.u.up) =/ post-text (content-to-md:ui contents.u.up) =/ action ?~ parent.u.up "add-post" "add-reply" ;form.content.edit-box =kaji "poke" =action action ;input(type "hidden", name "editing", value (trip uid)); ;input(type "hidden", name "error-div", value ".error-div"); ;input(type "hidden", name "title", value (trip title.u.up)); ;* ?~ parent.u.up ~ =/ p-string (enc:kaji [thread.u.up u.parent.u.up]) ;+ ;input(type "hidden", name "parents", value p-string); ;textarea =name "text" ; {post-text} == :: ;label :: ; Tags :: ;input(type "text", name "tags", value tag-string); :: == ;div.buttons ;input =type "submit" =value "Save" ; == ;button =kaji "poke" =action "del-reply" =name "pid" =payload (trip uid) ; Delete == ;div.error-div; == == ++ post-snippet |= uid=@t =/ up (post:fetch uid) ?~ up not-found =/ contacts (get-contacts:cnt bowl) =/ t thread-page(bowl bowl, state s, contacts contacts) (snippet:t u.up) ++ not-found ;div ; Post not found == ++ new-poll (form:poll bowl) :: ++ serve-tags :: |= tags=path :: =/ postl (search-filter-full:plib feed.s [~ ~ board-page-size:const] (tag-search:plib tags)) :: =/ tag-string %^ foldi:sr tags "" |= [i=@ud t=@t acc=tape] :: ?: .=(i (dec (lent tags))) :: "{acc}{(trip t)}" :: "{acc}{(trip t)}, " :: =/ page :: ;div#tag-search :: ;header :: ;h2.tc: Tag Search: {tag-string} :: == :: ;+ (html:post-list postl) :: == :: (index ~[title page] bowl) --