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
|
|%
++ on-poke-noun |= a=*
?: ?=(%sqlite a) dump-to-sqlite
?: ?=(%licki a) init-lick
?: ?=(%slick a) stop-lick
?: ?=([%lick *] a) (send-lick +.a)
`this
++ init-lick
~& "init lick"
:_ this :_ ~
=/ note=note-arvo [%l %spin /'licker.sock']
[%pass /lick/init %arvo note]
++ stop-lick
:_ this :_ ~
=/ note=note-arvo [%l %shut /'licker.sock']
[%pass /lick/init %arvo note]
++ send-lick
|= a=*
:_ this :_ ~
=/ note=note-arvo [%l %spit /'licker.sock' %noun a]
[%pass /lick/init %arvo note]
++ dump-to-sqlite
=/ l (tap:gorm:tp f)
=/ l (scag 5 l)
=/ res
|-
?~ l ~
=/ poast i.l
~& >> poast=poast
$(l t.l)
:: TODO prov
:: =/ tv-chat
:: =/ tvs (~(got by here.tv) 'spandrell-tv')
:: =/ sta (~(got by schedule.tvs) started.current.tvs)
:: chat.sta
:: =/ data=dump-type [(tap:gorm:tp feed) (tap:torm:tp threads) active-threads paths tags tv-chat]
:: =/ vase !>((jam data))
:: =/ =soba:clay :_ ~ [/data/site-dump/(scot %da now.bowl)/jam %ins %noun vase]
:: =/ =nori:clay [%& soba]
:: =/ =task:clay [%info %blog nori]
:: =/ note=note-arvo [%c task]
:: [%pass /dump/[dap.bowl] %arvo note]
`this
++ user-sql |= [author=@p joined=@da avatar=@t display=(unit @t)] ^- (list card)
=/ tsn (scow:parsing:sr %ud (unm:chrono:userlib joined))
=/ id (scow:parsing:sr %ud author)
=/ ava (trip avatar)
:: if planet
?: (lth author (pow 2 32))
=/ dis ?~ display (scow %p author) (trip u.display)
=/ sql
"""
INSERT OR IGNORE INTO users(id, joined,avatar, display)
VALUES({id}, {tsn}, '{ava}', '{dis}');
"""
=/ sql2
"""
INSERT INTO claims(user_id, protocol, value, notes)
VALUES({id}, 'urbit', '{(scow %p author)}', 'Set automatically on migration to BS5');
"""
[(send-lick [%sql (crip sql)]) (send-lick [%sql sql2]) ~]
:: fooking comets
=/ dis ?~ display "NULL" "{'(trip u.display)'}"
=/ sql
"""
INSERT OR IGNORE INTO users(id, joined, avatar, display)
VALUES({id}, {tsn}, '{ava}', '{dis}');
"""
[(send-lick [%sql (crip sql)])]~
::
++ tag-sql |= tags=(set @t) ^- (list card)
%- ~(run in tags) |= tag=@t
=/ sql
"""
INSERT OR IGNORE INTO tags(tag) VALUES('{(trip tag)}')
"""
(send-lick [%sql (crip sql)])
++ tagpost-sql |= [tag=@t post-id=tape]
=/ sql
"""
INSERT OR IGNORE INTO tags_posts(tag, post_id) VALUES('{(trip tag)}', {post-id})
"""
(send-lick [%sql (crip sql)])
++ tagcomment-sql |= [tag=@t post-id=tape]
=/ sql
"""
INSERT OR IGNORE INTO tags_comments(tag, comment_id) VALUES('{(trip tag)}', {post-id})
"""
(send-lick [%sql (crip sql)])
++ post-sql |= [ted=thread:tp =post:tp] ^- (list card)
=/ tsn (scow:parsing:sr %ud (unm:chrono:userlib id.post))
=/ author-idn (scow %p author.post)
=/ title (trip title.ted)
=/ snippet (content-list-to-md:ui snip.ted)
=/ content (content-to-md:ui contents.post)
=/ url (trip (spat path.ted))
=/ sql
"""
INSERT INTO posts(ts,author_id, title, content, snippet, url)
VALUES({tsn}, {author-idn}, '{title}', '{content}', '{snippet}', '{url}');
"""
:- (send-lick [%sql (crip sql)])
(~(run in tags.ted) |=(tag=@t (tagpost-sql tag tsn)))
++ comment-sql |= =post:tp ^- (list card)
=/ tsn (scow:parsing:sr %ud (unm:chrono:userlib id.post))
=/ user-id (scow %p author.post)
=/ content (content-to-md:ui contents.post)
=/ post-id (scow:parsing:sr %ud (unm:chrono:userlib +.pid.post))
=/ parent-id ?~ parent.post "NULL" (scow:parsing:sr %ud (unm:chrono:userlib post-id))
=/ sql
"""
INSERT INTO comments(ts,user_id, content, approved, comment_type, post_id, parent_id)
VALUES({tsn}, {user-id}, {content}, {approved}, {type}, {post-id}, {parent-id});
"""
:- (send-lick [%sql (crip sql)])
(~(run in tags.ted) |=(tag=@t (tagcomment-sql tag tsn)))
++ insert-sql3
"""
INSERT INTO tags(tag)
VALUES({tsn}, {user-idn}, {content}, {approved-n}, {type}, {post-idn}, {parent-idn});
"""
++ ted-cards |= ted=thread:tp ^- (list card)
=/ post (get:gorm:tp feed pid.ted)
?~ post ~& >>> nooooo-post=ted !!
=/ user-cards (user-sql author.u.post id.u.post '' ~)
=/ tags-cards (tag-sql tags.ted)
=/ post-cards (post-sql ted u.post)
%+ weld user-cards %+ weld tags-cards post-cards
++ post-cards |= =post:tp ^- (list card)
=/ user-cards (user-sql author.post id.post '' ~)
=/ tags-cards (tag-sql tags.post)
=/ post-cards (comment-sql post)
%+ weld user-cards %+ weld tags-cards post-cards
++ on-arvo
|= [=(pole knot) =sign-arvo]
?: ?=([%lick %soak *] sign-arvo)
?+ [mark noun]:sign-arvo `this
[%connect ~] ((slog 'socket connected' ~) `this)
[%disconnected ~] ((slog 'socket disconnected' ~) `this)
[%error *] ((slog leaf+"socket error {(trip ;;(@t noun.sign-arvo))}" ~) `this)
[%noun *] ((slog leaf+"socket noun {(trip ;;(@t noun.sign-arvo))}" ~) `this)
==
`this
--
|