parsav  Diff

Differences From Artifact [5ac1497f7a]:

To Artifact [5d5ed1c86e]:


     3      3   local terra cs(s: rawstring)
     4      4   	return pstr { ptr = s, ct = lib.str.sz(s) }
     5      5   end
     6      6   
     7      7   local terra 
     8      8   render_profile(co: &lib.srv.convo, actor: &lib.store.actor)
     9      9   	var aux: lib.str.acc
    10         -	var followed = true -- FIXME
           10  +	var followed = false -- FIXME
    11     11   	if co.aid ~= 0 and co.who.id == actor.id then
    12         -		aux:compose('<a class="button" href="/conf/profile?go=/',actor.xid,'">alter</a>')
           12  +		aux:compose('<a class="button" href="/conf/profile?go=/@',actor.handle,'">alter</a>')
    13     13   	elseif co.aid ~= 0 then
    14     14   		if not followed then
    15         -			aux:compose('<button method="post" name="act" value="follow">follow</a>')
    16         -		elseif not followed then
    17         -			aux:compose('<button method="post" name="act" value="unfollow">unfollow</a>')
           15  +			aux:compose('<button method="post" class="pos" name="act" value="follow">follow</button>')
           16  +		elseif followed then
           17  +			aux:compose('<button method="post" class="neg" name="act" value="unfollow">unfollow</button>')
    18     18   		end
    19         -		aux:lpush('<a href="/'):push(actor.xid,0):lpush('/chat">chat</a>')
    20         -		if co.who.rights.powers:affect_users() then
           19  +		aux:lpush('<a class="button" href="/'):push(actor.xid,0):lpush('/chat">chat</a>')
           20  +		if co.who.rights.powers:affect_users() and co.who:overpowers(actor) then
    21     21   			aux:lpush('<a class="button" href="/'):push(actor.xid,0):lpush('/ctl">control</a>')
    22     22   		end
    23     23   	else
    24     24   		aux:compose('<a class="button" href="/', actor.xid, '/follow">remote follow</a>')
    25     25   	end
    26     26   	var auxp = aux:finalize()
    27         -	var avistr: lib.str.acc if actor.origin == 0 then
    28         -		avistr:compose('/avi/',actor.handle)
    29         -	end
    30     27   	var timestr: int8[26] lib.osclock.ctime_r(&actor.knownsince, &timestr[0])
    31     28   
    32     29   	var strfbuf: int8[28*4]
    33     30   	var stats = co.srv:actor_stats(actor.id)
    34     31   		var sn_posts     = cs(lib.math.decstr_friendly(stats.posts, &strfbuf[ [strfbuf.type.N - 1] ]))
    35     32   		var sn_follows   = cs(lib.math.decstr_friendly(stats.follows, sn_posts.ptr - 1))
    36     33   		var sn_followers = cs(lib.math.decstr_friendly(stats.followers, sn_follows.ptr - 1))
    37     34   		var sn_mutuals   = cs(lib.math.decstr_friendly(stats.mutuals, sn_followers.ptr - 1))
    38     35   	var bio = lib.str.plit "<em>tall, dark, and mysterious</em>"
    39     36   	if actor.bio ~= nil then
    40     37   		bio = lib.smackdown.html(cs(actor.bio))
    41     38   	end
    42         -	var fullname = lib.render.nym(actor,0) defer fullname:free()
           39  +	var fullname = lib.render.nym(actor,0,nil) defer fullname:free()
           40  +	var comments: lib.str.acc comments:init(64)
           41  +	-- this is really more what epithets are for, i think
           42  +	--if actor.rights.rank > 0 then comments:lpush('<li>staff member</li>') end
           43  +	if co.aid ~= 0 and actor.rights.rank ~= 0 then
           44  +		if co.who:outranks(actor) then
           45  +			comments:lpush('<li style="--co:50">underling</li>')
           46  +		elseif actor:outranks(co.who) then
           47  +			comments:lpush('<li style="--co:-50">outranks you</li>')
           48  +		end
           49  +	end
           50  +
    43     51   	var profile = data.view.profile {
    44     52   		nym = fullname;
    45     53   		bio = bio;
    46     54   		xid = cs(actor.xid);
    47         -		avatar = lib.trn(actor.origin == 0, pstr{ptr=avistr.buf,ct=avistr.sz},
    48         -			cs(lib.coalesce(actor.avatar, '/s/default-avatar.svg')));
           55  +		avatar = cs(actor.avatar);
    49     56   
    50     57   		nposts = sn_posts, nfollows = sn_follows;
    51     58   		nfollowers = sn_followers, nmutuals = sn_mutuals;
    52     59   		tweetday = cs(timestr);
    53     60   		timephrase = lib.trn(actor.origin == 0, lib.str.plit'joined', lib.str.plit'known since');
           61  +
           62  +		remarks = '';
    54     63   
    55     64   		auxbtn = auxp;
    56     65   	}
           66  +	if comments.sz > 0 then profile.remarks = comments:finalize() end
    57     67   
    58     68   	var ret = profile:tostr()
    59         -	if actor.origin == 0 then avistr:free() end
    60     69   	auxp:free() 
    61     70   	if actor.bio ~= nil then bio:free() end
           71  +	if comments.sz > 0 then profile.remarks:free() end
    62     72   	return ret
    63     73   end
    64     74   
    65     75   return render_profile