37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
..
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
..
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
::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})
var fullname = lib.render.nym(author,0,nil, false) defer fullname:free()
var tpl = data.view.tweet {
................................................................................
nym = fullname;
when = cs(×tr[0]);
avatar = cs(author.avatar);
acctlink = cs(author.xid);
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()
................................................................................
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
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>')
return rta:finalize()
else
var txt = tpl:tostr()
if p.rts + p.likes > 0 then tpl.stats:free() end
return txt
end
end
return render_tweet
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
..
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
...
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
|
::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},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 {
................................................................................
nym = fullname;
when = cs(×tr[0]);
avatar = cs(author.avatar);
acctlink = cs(author.xid);
permalink = permalink:finalize();
attr = pstr{'',0};
stats = pstr{'',0};
extra = pstr{'',0};
}
if p.isreply then
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="'):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()
................................................................................
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
|