blob: 7b912dd9f68e0b03dbc8bf329b462494469f3070 (
plain)
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
|
/- post=trill-post
/+ lib=boke, sr=sortug, plib=post
|%
++ node-to-full-fake
|= p=post:post ^- full-node:post
=/ fake-children=full-graph:post %- ~(rep in children.p)
|= [=id:post acc=full-graph:post]
(put:form:post acc id *full-node:post)
p(children fake-children)
++ node-to-full
|= [p=post:post f=feed:post] ^- full-node:post
p(children (convert-children children.p f))
++ convert-children
|= [children=(set id:post) f=feed:post]
^- full-graph:post
%- ~(rep in children)
|= [=id:post acc=full-graph:post]
=/ n (get:orm:post f id)
?~ n acc
=/ full-node (node-to-full u.n f)
(put:form:post acc id full-node)
++ find-mention-2
|= [our=@p l=(list inline:contents-1:post)] ^- ?
%+ roll l |= [i=inline:contents-1:post a=_|]
?. ?=(%ship -.i) a
.=(our p.i)
++ sanitize
|= c=contents:contents-1:post ^- ?
%+ roll c |= [i=block:contents-1:post acc=_&]
?. ?=(%paragraph -.i) acc
%+ roll p.i |= [ii=inline:contents-1:post iacc=_acc]
?. ?=(%link -.ii) iacc
?~ (de-purl:html href.ii) .n .y
++ post-size
|= c=contents:contents-1:post
=| count=@
|-
?~ c count
=/ lc=@
?- -.i.c
%tasklist 0 :: TODO
%paragraph (inline-size p.i.c)
%blockquote (inline-size p.i.c)
%heading (lent (trip p.i.c))
%list (inline-size p.i.c)
%media (media-size media.i.c)
%codeblock
?: (gth (lent (trip lang.i.c)) 400) 10.000
(lent (trip code.i.c))
%eval (lent (trip hoon.i.c))
%ref
?: (gth (lent (trip app.i.c)) 400) 10.000
(roll path.i.c |=([i=@t a=@] (add a (lent (trip i)))))
%json
?: (gth (lent (trip content.i.c)) 5.000) 10.000
?: (gth (lent (trip origin.i.c)) 1.000) 10.000
0
%table
%+ roll rows.i.c |= [i=(list contents:contents-1:post) a=@]
=/ inner-count=@
%+ roll i |= [ii=contents:contents-1:post ia=@]
(add ia (post-size ii))
(add inner-count a)
==
$(c t.c, count (add count lc))
++ inline-size
|= l=(list inline:contents-1:post) ^- @
=| count=@
|-
?~ l count
=/ lc=@
?+ -.i.l (lent (trip p.i.l))
%date 0 :: TODO
%note 0 :: TODO
%break 0
%ruby (lent (trip p.i.l))
%link
?: (gth (lent (trip href.i.l)) 400) 10.000
(lent (trip show.i.l))
==
$(l t.l, count (add count lc))
++ media-size
|= =media:contents-1:post ^- @
?- -.media
%video (lent (trip p.media))
%audio (lent (trip p.media))
%images %+ roll p.media
|= [[url=@t caption=@t] a=@]
%+ add a (lent (trip caption))
==
:: search
++ text-search
|= [q=@t p=post:post case=?] ^- tape
=/ t (content-to-md:lib contents.p)
=? t !case (cass t)
=/ qt ?: case (trip q) (cass (trip q))
=/ i (find qt t)
?~ i ""
=/ start ?: (lte u.i 50) 0 (sub u.i 50)
?: .=(start 0)
"{(swag [start 100] t)}..."
"...{(swag [start 100] t)}..."
++ search
|= [q=@t p=post:post] ^- ?
?~ contents.p .n
=/ latest=content-list:post val:head:(pop:corm:post contents.p)
=/ in-tags %+ roll ~(tap in tags.p) |= [i=cord a=_|]
?: (contains i q) %& a
=/ in-blocks %+ roll latest |= [i=block:contents-1:post a=_|]
?: ?- -.i
%paragraph (in-inline p.i q)
%blockquote (in-inline p.i q)
%list (in-inline p.i q)
%heading (contains p.i q)
%codeblock (contains code.i q)
%eval (contains hoon.i q)
%json (contains content.i q)
%media (in-media media.i q)
%ref %| :: TODO
%table %| :: TODO
%tasklist .n :: TODO
== %& a
?| in-tags in-blocks ==
++ contains
|= [container=cord query=cord] ^- ?
?~ (find (trip query) (trip container)) %| %&
++ in-media
|= [=media:contents-1:post q=@t] ^- ?
?. ?=(%images -.media) (contains p.media q)
%+ roll p.media |= [[url=cord caption=cord] a=_|]
?: (contains caption q) %& a
::
++ text-search2
|= [q=@t p=post:post case=?] ^- @t
?~ contents.p ''
=/ bl=(list block:contents-1:post) val:head:(pop:corm:post contents.p)
=| snippet=@t
|-
?~ bl snippet
:: TODO proper counts
?: (gth (met 3 snippet) 50) snippet
=/ ns
?+ -.i.bl snippet
%paragraph (from-inline p.i.bl q case)
%blockquote (from-inline p.i.bl q case)
%list (from-inline p.i.bl q case)
:: %heading (cfind:sr q p.i .n)
:: %codeblock (cfind:sr q code.i .n)
:: %eval (cfind:sr q hoon.i .n)
:: %json (cfind:sr q content.i .n)
:: %media (in-media2 media.i q)
%ref snippet :: TODO
%table snippet :: TODO
%tasklist snippet
==
$(bl t.bl, snippet (cat 3 snippet ns))
++ from-inline
|= [l=(list inline:contents-1:post) q=@t case=?] ^- @t
=| snippet=@t
|-
?~ l snippet
?: (gth (met 3 snippet) 50) snippet
=/ r
?+ -.i.l (cfindi:sr q p.i.l .n)
%break .n
%date .n :: TODO
%note .n ::TODO
%ship (cfindi:sr q (scot %p p.i.l) .n)
%link (cat 3 (cfindi:sr q href.i.l .n) (cfindi:sr q show.i.l .n))
%ruby (cat 3 (cfindi:sr q p.i.l .n) (cfindi:sr q q.i.l .n))
==
$(l t.l, snippet (cat 3 snippet r))
++ search2
|= [q=@t p=post:post] ^- ?
?~ contents.p .n
=/ latest=content-list:post val:head:(pop:corm:post contents.p)
=/ in-tags %+ roll ~(tap in tags.p) |= [i=cord a=_|]
?: (cfind:sr q i .n) %& a
=/ in-blocks %+ roll latest |= [i=block:contents-1:post a=_|]
?: ?- -.i
%paragraph (in-inline2 p.i q)
%blockquote (in-inline2 p.i q)
%list (in-inline2 p.i q)
%heading (cfind:sr q p.i .n)
%codeblock (cfind:sr q code.i .n)
%eval (cfind:sr q hoon.i .n)
%json (cfind:sr q content.i .n)
%media (in-media2 media.i q)
%ref %| :: TODO
%table %| :: TODO
%tasklist .n
== %& a
?| in-tags in-blocks ==
++ in-media2
|= [=media:contents-1:post q=@t] ^- ?
?. ?=(%images -.media) (cfind:sr q p.media .n)
%+ roll p.media |= [[url=cord caption=cord] a=_|]
?: (cfind:sr q url .n) %& a
++ in-inline2
|= [l=(list inline:contents-1:post) q=@t] ^- ?
|-
?~ l .n
=/ i i.l
=/ r=?
?+ -.i (cfind:sr q p.i .n)
%break .n
%date .n
%note .n
%ship (cfind:sr q (scot %p p.i) .n)
%link ?|((cfind:sr q href.i .n) (cfind:sr q show.i .n))
%ruby ?|((cfind:sr q p.i .n) (cfind:sr q q.i .n))
==
?| r $(l t.l) ==
::
++ in-inline
|= [l=(list inline:contents-1:post) q=@t] ^- ?
%+ roll l |= [i=inline:contents-1:post a=_|]
?: ?+ -.i (contains p.i q)
%break %|
%date .n
%note ?|((contains id.i q) (in-inline text.i q))
%ship (contains (scot %p p.i) q)
%link ?|((contains href.i q) (contains show.i q))
%ruby ?|((contains p.i q) (contains q.i q))
== %& a
++ is-my-reply
|= [p=post:post r=post:post our=@p] ^- ?
?~ parent.r .n
?& .=(author.r our) !.=(author.p our) ==
++ is-thread-child
|= [p=post:post r=post:post our=@p] ^- ?
?~ parent.r .n
?& .=(author.r our) .=(author.p our) ==
++ tag-search
|= [l=(list @t) =feed:post] ^- (list full-node:post)
%+ roll (tap:orm:post feed) |= [[* =post:post] acc=(list full-node:post)]
=/ found
=/ has .y
|-
?~ l has
?& has
=/ ns (~(has in tags.post) (crip (cass (trip i.l))))
$(l t.l, has ns)
==
?. found acc :_ acc
(node-to-full:plib post feed)
--
|