blob: 415d2f4c61a59f185961c482634a0ac660715fe0 (
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
|
/- feed=trill-feed, post=trill-post
/+ common=json-common, sr=sortug
|%
++ en
=, enjs:format
|%
++ feed-with-cursor
|= [f=feed:^feed start=(unit @da) end=(unit @da)] ^- json
%: pairs
feed+(feed f)
start+(cursor start)
end+(cursor end)
~
==
++ cursor |= c=(unit @da)
?~ c ~ (time u.c)
++ feed
|= f=feed:^feed ^- json
%- pairs
%+ turn (tap:orm:^feed f)
|= [post-id=@da p=post:post]
^- [@ta json]
:- (crip (scow:sr %ud `@ud`post-id))
(poast p)
++ poast
|= p=post:post ^- json
%- pairs
:~ id+(ud:en:common id.p)
host+(patp:en:common host.p)
author+(patp:en:common author.p)
thread+(ud:en:common thread.p)
parent+?~(parent.p ~ (ud:en:common u.parent.p))
contents+(content contents.p)
hash+(b64:en:common hash.p)
engagement+(engagement engagement.p)
children+a+(turn ~(tap in children.p) ud:en:common)
time+(time id.p)
==
++ content
|= cm=content-map:post ^- json
=/ last (pry:corm:post cm)
?~ last ~
=/ blocks=content-list:post +.u.last
:- %a %+ turn blocks en-block
++ en-block
|= b=block:post ^- json
%+ frond -.b
?- -.b
%paragraph a+(turn p.b inline)
%blockquote a+(turn p.b inline)
%table a+(turn rows.b table-row)
%heading (heading +.b)
%list (ilist +.b)
%media (media media.b)
%codeblock (codespan +.b)
%eval s+hoon.b
%ref (en-ref +.b)
%json (external +.b)
%poll ~
==
++ table-row
|= l=(list content-list:post)
:- %a %+ turn l
|= b=content-list:post
:- %a %+ turn b en-block
++ heading
|= [p=cord q=@]
%- pairs
:~ text+s+p
num+(numb q)
==
++ ilist
|= [p=(list inline:post) q=?]
%- pairs
:~ text+a+(turn p inline)
ordered+b+q
==
++ media
|= =media:post
%+ frond -.media
?- -.media
%images a+(turn p.media string)
%video s+p.media
%audio s+p.media
==
++ string
|= c=cord s+c
++ en-ref :: TODO should the backend fetch this shit
|= [type=term s=@p p=^path]
%- pairs
:~ type+s+type
ship+(patp:en:common s)
path+(path p)
==
++ external
|= [p=term q=cord]
%- pairs
:~ origin+s+p
content+s+q
==
++ inline
|= i=inline:post ^- json
%+ frond -.i
?+ -.i s+p.i
%ship (patp:en:common p.i)
%link (link +.i)
%ruby (ruby +.i)
%break ~
==
++ ruby
|= [p=@t q=@t]
%- pairs
:~ text+s+p
ruby+s+q
==
++ codespan
|= [code=cord lang=cord]
%- pairs
:~ code+s+code
lang+s+lang
==
++ link
|= [href=cord show=cord]
%- pairs
:~ href+s+href
show+s+show
==
++ engagement
|= =engagement:post ^- json
%- pairs
:~ reacts+(reacts reacts.engagement)
quoted+a+(turn ~(tap in quoted.engagement) signed-pid)
shared+a+(turn ~(tap in shared.engagement) signed-pid)
==
++ reacts
|= rs=(map @p [react:post signature:post])
^- json
%- pairs
%+ turn ~(val by rs)
|= [r=react:post s=signature:post]
^- [@ta json]
:- (scot %p q.s)
s+r
++ signed-pid
|= =signed-pid:post
^- json
%- pairs
:~ ship+(patp:en:common q.signature.signed-pid)
pid+(pid pid.signed-pid)
==
++ time-pid
|= [t=@da s=@p =id:post]
%- pairs
:~ id+(ud:en:common id)
ship+(patp:en:common s)
time+(time t)
==
++ time-ship
|= [t=@da s=@p] ^- json
%- pairs
:~ ship+(patp:en:common s)
time+(time t)
==
++ mention
|= [t=@da s=@p p=pid:post] ^- json
%- pairs
:~ pid+(pid p)
ship+(patp:en:common s)
time+(time t)
==
++ react
|= [t=@da s=@p p=pid:post react=@t] ^- json
%- pairs
:~ pid+(pid p)
ship+(patp:en:common s)
react+s+react
time+(time t)
==
++ pid
|= =pid:post
%- pairs
:~ ship+(patp:en:common ship.pid)
id+(ud:en:common id.pid)
==
++ full-node
|= p=full-node:post ^- json
%- pairs
:~ id+(ud:en:common id.p)
host+(patp:en:common host.p)
author+(patp:en:common author.p)
thread+(ud:en:common thread.p)
parent+?~(parent.p ~ (ud:en:common u.parent.p))
contents+(content contents.p)
hash+(b64:en:common hash.p)
engagement+(engagement engagement.p)
children+(internal-graph children.p)
time+(time id.p)
==
++ internal-graph
|= int=internal-graph:post ^- json
?- -.int
%empty ~
%full (full-graph +.int)
==
++ full-graph
|= f=full-graph:post
^- json
%- pairs
%+ turn (tap:form:post f)
|= [post-id=@da fn=full-node:post]
^- [@ta json]
:- (crip (scow:sr %ud `@ud`post-id))
(full-node fn)
::
--
--
|