34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
..
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
..
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
|
retweeter = co.actorcache:insert(co.srv:actor_fetch_uid(p.rtdby)).ptr
end
::foundauth::
var timestr: int8[26] lib.osclock.ctime_r(&p.posted, ×tr[0])
for i=0,26 do if timestr[i] == @'\n' then timestr[i] = 0 break end end -- 🙄
var bhtml = lib.smackdown.html([lib.mem.ptr(int8)] {ptr=p.body,ct=0},false)
defer bhtml:free()
var idbuf: int8[lib.math.shorthand.maxlen]
var idlen = lib.math.shorthand.gen(p.id, idbuf)
var permalink: lib.str.acc permalink:compose('/post/',{idbuf,idlen})
var fullname = lib.render.nym(author,0,nil, false) defer fullname:free()
var tpl = data.view.tweet {
text = bhtml;
subject = cs(lib.coalesce(p.subject,''));
nym = fullname;
when = cs(×tr[0]);
avatar = cs(author.avatar);
................................................................................
var parent = co.srv:post_fetch(p.parent) defer parent:free()
if not parent then
lib.bail('schema integrity violation - could not match post to parent')
end
var pauth = co.srv:actor_fetch_uid(parent(0).author) defer pauth:free()
var pidbuf: int8[lib.math.shorthand.maxlen]
var pidlen = lib.math.shorthand.gen(p.parent, pidbuf)
var pa: lib.str.acc pa:init(128)
pa:lpush('<small>in reply to <a class="username" href="/post/'):push(&pidbuf[0],pidlen):lpush('">')
lib.render.nym(pauth.ptr,0,&pa,true)
pa:lpush('</a></small>')
tpl.extra = pa:finalize()
end
if p.rts + p.likes > 0 then
var s: lib.str.acc s:init(128)
s:lpush('<div class="stats">')
if p.rts > 0 then s:lpush('<div class="rt">' ):dpush(p.rts ):lpush('</div>') end
if p.likes > 0 then s:lpush('<div class="like">'):dpush(p.likes):lpush('</div>') end
s:lpush('</div>')
tpl.stats = s:finalize()
end
................................................................................
attrcur = lib.str.cpy(attrcur, '"')
end
if co.aid ~= 0 and p.author == co.who.id then attrcur = lib.str.cpy(attrcur, ' data-own') end
if retweeter ~= nil then attrcur = lib.str.cpy(attrcur, ' data-rt') end
if attrcur ~= &attrbuf[0] then tpl.attr = &attrbuf[0] end
defer tpl.permalink:free()
if acc ~= nil then
if retweeter ~= nil then push_promo_header(co, acc, retweeter, p.rtact) end
tpl:append(acc)
if retweeter ~= nil then acc:lpush('</div>') end
if p.rts + p.likes > 0 then tpl.stats:free() end
if tpl.extra.ct > 0 then tpl.extra:free() end
return [lib.mem.ptr(int8)]{ptr=nil,ct=0}
end
if retweeter ~= nil then
var rta: lib.str.acc rta:init(512)
push_promo_header(co, &rta, retweeter, p.rtact)
tpl:append(&rta) rta:lpush('</div>')
if tpl.extra.ct > 0 then tpl.extra:free() end
return rta:finalize()
else
var txt = tpl:tostr()
if tpl.extra.ct > 0 then tpl.extra:free() end
if p.rts + p.likes > 0 then tpl.stats:free() end
return txt
end
end
return render_tweet
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
..
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
..
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
|
retweeter = co.actorcache:insert(co.srv:actor_fetch_uid(p.rtdby)).ptr
end
::foundauth::
var timestr: int8[26] lib.osclock.ctime_r(&p.posted, ×tr[0])
for i=0,26 do if timestr[i] == @'\n' then timestr[i] = 0 break end end -- 🙄
var bhtml = lib.smackdown.html(&co.srv.pool, [lib.mem.ptr(int8)] {ptr=p.body,ct=0},false)
--defer bhtml:free()
var idbuf: int8[lib.math.shorthand.maxlen]
var idlen = lib.math.shorthand.gen(p.id, idbuf)
var permalink: lib.str.acc permalink:pool(&co.srv.pool, 7+idlen):lpush('/post/'):push(idbuf,idlen)
var fullname = lib.render.nym(author,0,nil, false) defer fullname:free()
var tpl = data.view.tweet {
text = bhtml;
subject = cs(lib.coalesce(p.subject,''));
nym = fullname;
when = cs(×tr[0]);
avatar = cs(author.avatar);
................................................................................
var parent = co.srv:post_fetch(p.parent) defer parent:free()
if not parent then
lib.bail('schema integrity violation - could not match post to parent')
end
var pauth = co.srv:actor_fetch_uid(parent(0).author) defer pauth:free()
var pidbuf: int8[lib.math.shorthand.maxlen]
var pidlen = lib.math.shorthand.gen(p.parent, pidbuf)
var pa: lib.str.acc pa:pool(&co.srv.pool, 128)
pa:lpush('<small>in reply to <a class="username" href="/post/'):push(&pidbuf[0],pidlen):lpush('">')
lib.render.nym(pauth.ptr,0,&pa,true)
pa:lpush('</a></small>')
tpl.extra = pa:finalize()
end
if p.rts + p.likes > 0 then
var s: lib.str.acc s:pool(&co.srv.pool,128)
s:lpush('<div class="stats">')
if p.rts > 0 then s:lpush('<div class="rt">' ):dpush(p.rts ):lpush('</div>') end
if p.likes > 0 then s:lpush('<div class="like">'):dpush(p.likes):lpush('</div>') end
s:lpush('</div>')
tpl.stats = s:finalize()
end
................................................................................
attrcur = lib.str.cpy(attrcur, '"')
end
if co.aid ~= 0 and p.author == co.who.id then attrcur = lib.str.cpy(attrcur, ' data-own') end
if retweeter ~= nil then attrcur = lib.str.cpy(attrcur, ' data-rt') end
if attrcur ~= &attrbuf[0] then tpl.attr = &attrbuf[0] end
--defer tpl.permalink:free()
if acc ~= nil then
if retweeter ~= nil then push_promo_header(co, acc, retweeter, p.rtact) end
tpl:append(acc)
if retweeter ~= nil then acc:lpush('</div>') end
--if p.rts + p.likes > 0 then tpl.stats:free() end
--if tpl.extra.ct > 0 then tpl.extra:free() end
return [lib.mem.ptr(int8)]{ptr=nil,ct=0}
end
if retweeter ~= nil then
var rta: lib.str.acc rta:pool(&co.srv.pool,512)
push_promo_header(co, &rta, retweeter, p.rtact)
tpl:append(&rta) rta:lpush('</div>')
--if tpl.extra.ct > 0 then tpl.extra:free() end
return rta:finalize()
else
var txt = tpl:poolstr(&co.srv.pool)
--if tpl.extra.ct > 0 then tpl.extra:free() end
--if p.rts + p.likes > 0 then tpl.stats:free() end
return txt
end
end
return render_tweet
|