Overview
| Comment: | finish up LP support for user outbox views |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
3f080eded4c19d163503b04791aca4e3 |
| User & Date: | lexi on 2021-01-25 13:24:48 |
| Other Links: | manifest | tags |
Context
|
2021-01-25
| ||
| 14:38 | iterating check-in: 050ce7d4fc user: lexi tags: trunk | |
| 13:24 | finish up LP support for user outbox views check-in: 3f080eded4 user: lexi tags: trunk | |
| 12:41 | commit missing file check-in: bd5794c0cc user: lexi tags: trunk | |
Changes
Modified api/lp/tweet.t from [e0805dcd2f] to [1ada03554b].
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 |
@extra
}]]
local wrap = lib.tpl.mk [[{
"\@context": "https://@+domain/s/litepub.jsonld",
"type": "@kind",
"actor": "https://@+domain/user/@^uid",
"published": "@$pubtime",
"id": "https://@+domain/api/lp/act/@^aid",
"object": @obj
}]]
local terra
lp_tweet(co: &lib.srv.convo, p: &lib.store.post, act_wrap: bool)
var tweet = (obj {
domain = co.srv.cfg.domain, uid = p.author, pid = p.id;
html = lib.smackdown.html(&co.srv.pool, p.body, false);
raw = p.body, pubtime = '', extra = '';
}):poolstr(&co.srv.pool)
if act_wrap then
return (wrap {
domain = co.srv.cfg.domain;
kind = lib.trn(p.rtdby == 0, 'Create', 'Announce');
uid = lib.trn(p.rtdby == 0, p.author, p.rtdby);
aid = lib.trn(p.rtdby == 0, p.id, p.rtact);
pubtime = '', obj = tweet;
}):poolstr(&co.srv.pool)
else
return tweet
end
end
return lp_tweet
|
| > | | | | > |
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 |
@extra
}]]
local wrap = lib.tpl.mk [[{
"\@context": "https://@+domain/s/litepub.jsonld",
"type": "@kind",
"actor": "https://@+domain/user/@^uid",
"published": "@pubtime",
"id": "https://@+domain/api/lp/act/@^aid",
"object": @obj
}]]
local terra
lp_tweet(co: &lib.srv.convo, p: &lib.store.post, act_wrap: bool)
var opdate = lib.conv.datetime(&co.srv.pool, p.posted)
var tweet = (obj {
domain = co.srv.cfg.domain, uid = p.author, pid = p.id;
html = lib.smackdown.html(&co.srv.pool, p.body, false);
raw = p.body, pubtime = opdate, extra = '';
}):poolstr(&co.srv.pool)
if act_wrap then
return (wrap {
domain = co.srv.cfg.domain, obj = tweet;
kind = lib.trn(p.rtdby == 0, 'Create', 'Announce');
uid = lib.trn(p.rtdby == 0, p.author, p.rtdby);
aid = lib.trn(p.rtdby == 0, p.id, p.rtact);
pubtime = lib.trn(p.rtdby == 0, opdate,
lib.conv.datetime(&co.srv.pool,p.rtdat));
}):poolstr(&co.srv.pool)
else
return tweet
end
end
return lp_tweet
|
Modified backend/pgsql.t from [4517a951a0] to [040ddf2134].
1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 |
p.ptr.parent = r:int(uint64,row,9) if r:null(row,11) then p.ptr.chgcount = 0 else p.ptr.chgcount = r:int(uint32,row,11) end p.ptr.accent = r:int(int16,row,12) p.ptr.rtdby = r:int(uint64,row,13) p.ptr.rtact = r:int(uint64,row,14) p.ptr.likes = r:int(uint32,row,15) p.ptr.rts = r:int(uint32,row,16) p.ptr.isreply = r:bool(row,17) p.ptr.localpost = r:bool(row,0) return p end local terra row_to_actor(r: &pqr, row: intptr): lib.mem.ptr(lib.store.actor) var a: lib.mem.ptr(lib.store.actor) var av: rawstring, avlen: intptr |
> | | | | |
1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 |
p.ptr.parent = r:int(uint64,row,9) if r:null(row,11) then p.ptr.chgcount = 0 else p.ptr.chgcount = r:int(uint32,row,11) end p.ptr.accent = r:int(int16,row,12) p.ptr.rtdby = r:int(uint64,row,13) p.ptr.rtdat = r:int(uint64,row,14) p.ptr.rtact = r:int(uint64,row,15) p.ptr.likes = r:int(uint32,row,16) p.ptr.rts = r:int(uint32,row,17) p.ptr.isreply = r:bool(row,18) p.ptr.localpost = r:bool(row,0) return p end local terra row_to_actor(r: &pqr, row: intptr): lib.mem.ptr(lib.store.actor) var a: lib.mem.ptr(lib.store.actor) var av: rawstring, avlen: intptr |
Modified backend/schema/pgsql-views.sql from [ac2cb76c4f] to [b916bb0a63].
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
...
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
edited bigint, parent bigint, convoheaduri text, chgcount integer, -- ephemeral accent smallint, rtdby bigint, -- note that these must be 0 if the record rtid bigint, -- in question does not represent an RT! n_likes integer, n_rts integer, isreply bool -- true if parent in (table posts); saves us a bunch of queries ); create or replace function pg_temp.parsavpg_translate_post(parsav_posts,bigint,bigint) returns pg_temp.parsavpg_intern_post as $$ select a.origin is null, ($1).id, ($1).author, ($1).subject,($1).acl, ($1).body, ($1).posted, ($1).discovered, ($1).edited, ($1).parent, ($1).convoheaduri,($1).chgcount, coalesce(c.value, -1)::smallint, $2 as rtdby, $3 as rtid, re.likes, re.rts, ($1).parent in (select id from parsav_posts) from parsav_actors as a left join parsav_actor_conf_ints as c on c.key = 'ui-accent' and c.uid = a.id left join pg_temp.parsavpg_post_react_counts as re ................................................................................ inner join parsav_posts as p on a.subject = p.id where a.kind = 'rt' ), content as (select * from posts union select * from rts) select pg_temp.parsavpg_translate_post(cn.orig, coalesce(cn.promoter,0), coalesce(cn.promotion,0) ) as post, cn.promotime::bigint as tltime, coalesce(cn.promoter, (cn.orig).author) as promoter from content as cn order by cn.promotime desc ); |
|
>
|
|
|
>
>
|
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
...
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
edited bigint, parent bigint, convoheaduri text, chgcount integer, -- ephemeral accent smallint, rtdby bigint, -- note that these must be 0 if the record rtdat bigint, -- in question does not represent an RT! rtid bigint, -- (this one too) n_likes integer, n_rts integer, isreply bool -- true if parent in (table posts); saves us a bunch of queries ); create or replace function pg_temp.parsavpg_translate_post(parsav_posts,bigint,bigint,bigint) returns pg_temp.parsavpg_intern_post as $$ select a.origin is null, ($1).id, ($1).author, ($1).subject,($1).acl, ($1).body, ($1).posted, ($1).discovered, ($1).edited, ($1).parent, ($1).convoheaduri,($1).chgcount, coalesce(c.value, -1)::smallint, $2 as rtdby, $3 as rtdat, $4 as rtid, re.likes, re.rts, ($1).parent in (select id from parsav_posts) from parsav_actors as a left join parsav_actor_conf_ints as c on c.key = 'ui-accent' and c.uid = a.id left join pg_temp.parsavpg_post_react_counts as re ................................................................................ inner join parsav_posts as p on a.subject = p.id where a.kind = 'rt' ), content as (select * from posts union select * from rts) select pg_temp.parsavpg_translate_post(cn.orig, coalesce(cn.promoter,0), coalesce(cn.promotime,0), coalesce(cn.promotion,0) ) as post, cn.promotime::bigint as tltime, coalesce(cn.promoter, (cn.orig).author) as promoter from content as cn order by cn.promotime desc ); |
Added conv.t version [13b89ea2d7].
> > > > > > > > > > > > > > > > > > > > > > > > > > |
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 |
-- vim: ft=terra local m={} local pstr = lib.str.t terra m.datetime(pool: &lib.mem.pool, when: lib.osclock.time_t) -- formats a unix epoch time as a dumbfuck XSD datetime spec var td: lib.osclock.tm if lib.osclock.gmtime_r(&when, &td) == nil then return pstr.null() end var tpl = [lib.tpl.mk ('@#year:-@MM@#month:-@dd@#day:T'.. '@hh@#hour::@mm@#min::@ss@#sec:Z')] { year = td.tm_year + 1900, month = td.tm_mon + 1, day = td.tm_mday; hour = td.tm_hour, min = td.tm_min, sec = td.tm_sec; MM = lib.trn(td.tm_mon+1 < 10, '0', ''); dd = lib.trn(td.tm_mday < 10, '0', ''); ss = lib.trn(td.tm_sec < 10, '0', ''); mm = lib.trn(td.tm_min < 10, '0', ''); hh = lib.trn(td.tm_min < 10, '0', ''); } return tpl:poolstr(pool) end return m |
Modified parsav.t from [1d36a792dc] to [76fc393228].
441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
lib.jc = lib.loadlib('json-c','json.h')
lib.load {
'mem', 'math', 'str', 'file', 'crypt', 'ipc';
'http', 'html', 'session', 'tpl', 'store', 'acl';
'smackdown'; -- md-alike parser
}
local be = {}
for _, b in pairs(config.backends) do
be[#be+1] = terralib.loadfile(string.format('backend/%s.t',b))()
end
lib.store.backends = global(`array([be]))
|
> |
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 |
lib.jc = lib.loadlib('json-c','json.h')
lib.load {
'mem', 'math', 'str', 'file', 'crypt', 'ipc';
'http', 'html', 'session', 'tpl', 'store', 'acl';
'smackdown'; -- md-alike parser
'conv'; -- miscellaneous conversion/munging functions
}
local be = {}
for _, b in pairs(config.backends) do
be[#be+1] = terralib.loadfile(string.format('backend/%s.t',b))()
end
lib.store.backends = global(`array([be]))
|
Modified store.t from [c7ef550a1d] to [33ecd773b1].
231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
parent: uint64
-- ephemera
localpost: bool
accent: int16
rts: uint32
likes: uint32
rtdby: uint64 -- 0 if not rt
rtact: uint64 -- 0 if not rt, id of rt action otherwise
isreply: bool
source: &m.source
-- save :: bool -> {} (defined in acl.t due to dep. hell)
}
|
> |
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
parent: uint64
-- ephemera
localpost: bool
accent: int16
rts: uint32
likes: uint32
rtdby: uint64 -- 0 if not rt
rtdat: m.timepoint -- 0 if not rt, time of promotion otherwise
rtact: uint64 -- 0 if not rt, id of rt action otherwise
isreply: bool
source: &m.source
-- save :: bool -> {} (defined in acl.t due to dep. hell)
}
|
Modified tpl.t from [2f4ebceee0] to [b153c48352].
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
str = str:gsub('%s+[\n$]','')
str = str:gsub('\n','')
str = str:gsub('</a><a ','</a> <a ') -- keep nav links from getting smooshed
str = str:gsub(tplchar .. '%?([-%w]+)', function(file)
if not docs[file] then docs[file] = data.doc[file] end
return string.format('<a href="#help-%s" class="help">?</a>', file)
end)
for start, mode, key, stop in string.gmatch(str,'()'..tplchar..'([+:!$#%^]?)([-a-zA-Z0-9_]+)()') do
if string.sub(str,start-1,start-1) ~= '\\' then
segs[#segs+1] = string.sub(str,last,start-1)
fields[#segs] = { key = key:gsub('-','_'), mode = (mode ~= '' and mode or nil) }
last = stop
end
end
segs[#segs+1] = string.sub(str,last)
|
| |
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
str = str:gsub('%s+[\n$]','')
str = str:gsub('\n','')
str = str:gsub('</a><a ','</a> <a ') -- keep nav links from getting smooshed
str = str:gsub(tplchar .. '%?([-%w]+)', function(file)
if not docs[file] then docs[file] = data.doc[file] end
return string.format('<a href="#help-%s" class="help">?</a>', file)
end)
for start, mode, key, stop in string.gmatch(str,'()'..tplchar..'([+:!$#%^]?)([-a-zA-Z0-9_]+):?()') do
if string.sub(str,start-1,start-1) ~= '\\' then
segs[#segs+1] = string.sub(str,last,start-1)
fields[#segs] = { key = key:gsub('-','_'), mode = (mode ~= '' and mode or nil) }
last = stop
end
end
segs[#segs+1] = string.sub(str,last)
|