1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
-- vim: ft=terra
local terra
render_profile(actor: &lib.store.actor)
var profile = data.view.profile {
nym = lib.coalesce(actor.nym, actor.handle);
bio = lib.coalesce(actor.bio, "tall, dark, and mysterious");
xid = actor.xid;
avatar = "/no-avatars-yet.png";
nposts = '0', nfollows = '0';
nfollowers = '0', nmutuals = '0';
tweetday = 'novembuary 67th';
}
return profile:tostr()
end
return render_profile
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
<
>
>
|
<
>
|
>
|
>
|
>
|
>
>
>
|
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
|
-- vim: ft=terra
local terra
render_profile(co: &lib.srv.convo, actor: &lib.store.actor)
var aux: lib.str.acc
var auxp: rawstring
if co.aid ~= 0 and co.who.id == actor.id then
auxp = '<a href="/conf/profile">alter</a>'
elseif co.aid ~= 0 then
aux:compose('<a href="/', actor.xid, '/follow">follow</a><a href="/',
actor.xid, '/chat">chat</a>')
if co.who.rights.powers:affect_users() then
aux:push('<a href="/',11):push(actor.xid,0):push('/ctl">control</a>',17)
end
auxp = aux.buf
else
aux:compose('<a href="/', actor.xid, '/follow">remote follow</a>')
end
var avistr: lib.str.acc if actor.origin == 0 then
avistr:compose('/avi/',actor.handle)
end
var timestr: int8[26] lib.osclock.ctime_r(&actor.knownsince, ×tr[0])
var strfbuf: int8[28*4]
var stats = co.srv:actor_stats(actor.id)
var sn_posts = lib.math.decstr_friendly(stats.posts, &strfbuf[ [strfbuf.type.N - 1] ])
var sn_follows = lib.math.decstr_friendly(stats.follows, sn_posts - 1)
var sn_followers = lib.math.decstr_friendly(stats.followers, sn_follows - 1)
var sn_mutuals = lib.math.decstr_friendly(stats.mutuals, sn_followers - 1)
var profile = data.view.profile {
nym = lib.coalesce(actor.nym, actor.handle);
bio = lib.coalesce(actor.bio, "<em>tall, dark, and mysterious</em>");
xid = actor.xid;
avatar = lib.trn(actor.origin == 0, avistr.buf,
lib.coalesce(actor.avatar, '/s/default-avatar.webp'));
nposts = sn_posts, nfollows = sn_follows;
nfollowers = sn_followers, nmutuals = sn_mutuals;
tweetday = timestr;
timephrase = lib.trn(actor.origin == 0, 'joined', 'known since');
auxbtn = auxp;
}
var ret = profile:tostr()
if actor.origin == 0 then avistr:free() end
if not (co.aid ~= 0 and co.who.id == actor.id) then aux:free() end
return ret
end
return render_profile
|