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
|
/- 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;
==
==
==
--
|