7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
35
36
37
38
39
40
41
42
43
44
45
46
47
48
..
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
|
local terra
push_promo_header(co: &lib.srv.convo, acc: &lib.str.acc, rter: &lib.store.actor, rid: uint64)
acc:lpush('<div class="lede"><div class="promo"><img src="'):push(rter.avatar,0):lpush('"><a href="/')
if rter.origin ~= 0 then acc:lpush('@') end
acc:push(rter.xid,0):lpush('" class="username">')
lib.render.nym(rter, 0, acc, true)
acc:lpush('</a> retweeted</div>')
if co.who.id == rter.id then
acc:lpush('<a href="/post/'):shpush(rid):lpush('/del" class="del">✖</a>')
end
end
local terra
render_tweet(co: &lib.srv.convo, p: &lib.store.post, acc: &lib.str.acc)
var author: &lib.store.actor = nil
................................................................................
end
::foundauth::
var avistr: lib.str.acc if author.origin == 0 then
avistr:compose('/avi/',author.handle)
end
var timestr: int8[26] lib.osclock.ctime_r(&p.posted, ×tr[0])
var bhtml = lib.smackdown.html([lib.mem.ptr(int8)] {ptr=p.body,ct=0})
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})
................................................................................
permalink = permalink:finalize();
attr = pstr{'',0};
stats = pstr{'',0};
}
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">' ):ipush(p.rts ):lpush('</div>') end
if p.likes > 0 then s:lpush('<div class="like">'):ipush(p.likes):lpush('</div>') end
s:lpush('</div>')
tpl.stats = s:finalize()
end
var attrbuf: int8[48]
var attrcur = &attrbuf[0]
if p.accent ~= -1 and p.accent ~= co.ui_hue then
var hdecbuf: int8[21]
var hdec = lib.math.decstr(p.accent, &hdecbuf[20])
attrcur = lib.str.cpy(attrcur,' style="--hue:')
attrcur = lib.str.cpy(attrcur, hdec)
-- var len = &hdecbuf[20] - hdec
attrcur = lib.str.cpy(attrcur, '"')
end
if p.author == co.who.id then attrcur = lib.str.cpy(attrcur, ' data-own') 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)
|
|
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
..
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
|
local terra
push_promo_header(co: &lib.srv.convo, acc: &lib.str.acc, rter: &lib.store.actor, rid: uint64)
acc:lpush('<div class="lede"><div class="promo"><img src="'):push(rter.avatar,0):lpush('"><a href="/')
if rter.origin ~= 0 then acc:lpush('@') end
acc:push(rter.xid,0):lpush('" class="username">')
lib.render.nym(rter, 0, acc, true)
acc:lpush('</a> retweeted</div>')
if co.aid ~= 0 and co.who.id == rter.id then
acc:lpush('<a href="/post/'):shpush(rid):lpush('/del" class="del">✖</a>')
end
end
local terra
render_tweet(co: &lib.srv.convo, p: &lib.store.post, acc: &lib.str.acc)
var author: &lib.store.actor = nil
................................................................................
end
::foundauth::
var avistr: lib.str.acc if author.origin == 0 then
avistr:compose('/avi/',author.handle)
end
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})
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})
................................................................................
permalink = permalink:finalize();
attr = pstr{'',0};
stats = pstr{'',0};
}
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
var attrbuf: int8[64]
var attrcur = &attrbuf[0]
if p.accent ~= -1 and p.accent ~= co.ui_hue then
var hdecbuf: int8[21]
var hdec = lib.math.decstr(p.accent, &hdecbuf[20])
attrcur = lib.str.cpy(attrcur,' style="--hue:')
attrcur = lib.str.cpy(attrcur, hdec)
-- var len = &hdecbuf[20] - hdec
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)
|