1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
|
/- 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)
--
|