Differences From
Artifact [a405db9158]:
1 1 -- vim: ft=terra
2 2 local terra
3 -render_profile(actor: &lib.store.actor)
3 +render_profile(co: &lib.srv.convo, actor: &lib.store.actor)
4 + var aux: lib.str.acc
5 + var auxp: rawstring
6 + if co.aid ~= 0 and co.who.id == actor.id then
7 + auxp = '<a href="/conf/profile">alter</a>'
8 + elseif co.aid ~= 0 then
9 + aux:compose('<a href="/', actor.xid, '/follow">follow</a><a href="/',
10 + actor.xid, '/chat">chat</a>')
11 + if co.who.rights.powers:affect_users() then
12 + aux:push('<a href="/',11):push(actor.xid,0):push('/ctl">control</a>',17)
13 + end
14 + auxp = aux.buf
15 + else
16 + aux:compose('<a href="/', actor.xid, '/follow">remote follow</a>')
17 + end
18 + var avistr: lib.str.acc if actor.origin == 0 then
19 + avistr:compose('/avi/',actor.handle)
20 + end
21 + var timestr: int8[26] lib.osclock.ctime_r(&actor.knownsince, ×tr[0])
22 +
23 + var strfbuf: int8[28*4]
24 + var stats = co.srv:actor_stats(actor.id)
25 + var sn_posts = lib.math.decstr_friendly(stats.posts, &strfbuf[ [strfbuf.type.N - 1] ])
26 + var sn_follows = lib.math.decstr_friendly(stats.follows, sn_posts - 1)
27 + var sn_followers = lib.math.decstr_friendly(stats.followers, sn_follows - 1)
28 + var sn_mutuals = lib.math.decstr_friendly(stats.mutuals, sn_followers - 1)
29 +
4 30 var profile = data.view.profile {
5 31 nym = lib.coalesce(actor.nym, actor.handle);
6 - bio = lib.coalesce(actor.bio, "tall, dark, and mysterious");
32 + bio = lib.coalesce(actor.bio, "<em>tall, dark, and mysterious</em>");
7 33 xid = actor.xid;
8 - avatar = "/no-avatars-yet.png";
34 + avatar = lib.trn(actor.origin == 0, avistr.buf,
35 + lib.coalesce(actor.avatar, '/s/default-avatar.webp'));
36 +
37 + nposts = sn_posts, nfollows = sn_follows;
38 + nfollowers = sn_followers, nmutuals = sn_mutuals;
39 + tweetday = timestr;
40 + timephrase = lib.trn(actor.origin == 0, 'joined', 'known since');
9 41
10 - nposts = '0', nfollows = '0';
11 - nfollowers = '0', nmutuals = '0';
12 - tweetday = 'novembuary 67th';
42 + auxbtn = auxp;
13 43 }
14 44
15 - return profile:tostr()
45 + var ret = profile:tostr()
46 + if actor.origin == 0 then avistr:free() end
47 + if not (co.aid ~= 0 and co.who.id == actor.id) then aux:free() end
48 + return ret
16 49 end
17 50
18 51 return render_profile