parsav  Diff

Differences From Artifact [8bee6c6ab8]:

To Artifact [0700e85db2]:


    37     37   	::foundauth::
    38     38   	var avistr: lib.str.acc if author.origin == 0 then
    39     39   		avistr:compose('/avi/',author.handle)
    40     40   	end
    41     41   	var timestr: int8[26] lib.osclock.ctime_r(&p.posted, &timestr[0])
    42     42   	for i=0,26 do if timestr[i] == @'\n' then timestr[i] = 0 break end end -- 🙄
    43     43   
    44         -	var bhtml = lib.smackdown.html([lib.mem.ptr(int8)] {ptr=p.body,ct=0})
           44  +	var bhtml = lib.smackdown.html([lib.mem.ptr(int8)] {ptr=p.body,ct=0},false)
    45     45   	defer bhtml:free()
    46     46   
    47     47   	var idbuf: int8[lib.math.shorthand.maxlen]
    48     48   	var idlen = lib.math.shorthand.gen(p.id, idbuf)
    49     49   	var permalink: lib.str.acc permalink:compose('/post/',{idbuf,idlen})
    50     50   	var fullname = lib.render.nym(author,0,nil, false) defer fullname:free()
    51     51   	var tpl = data.view.tweet {
................................................................................
    54     54   		nym = fullname;
    55     55   		when = cs(&timestr[0]);
    56     56   		avatar = cs(author.avatar);
    57     57   		acctlink = cs(author.xid);
    58     58   		permalink = permalink:finalize();
    59     59   		attr = pstr{'',0};
    60     60   		stats = pstr{'',0};
           61  +		extra = pstr{'',0};
    61     62   	}
           63  +	if p.isreply then
           64  +		var parent = co.srv:post_fetch(p.parent) defer parent:free()
           65  +		if not parent then
           66  +			lib.bail('schema integrity violation - could not match post to parent')
           67  +		end
           68  +		var pauth = co.srv:actor_fetch_uid(parent(0).author) defer pauth:free()
           69  +		var pidbuf: int8[lib.math.shorthand.maxlen]
           70  +		var pidlen = lib.math.shorthand.gen(p.parent, pidbuf)
           71  +		var pa: lib.str.acc pa:init(128)
           72  +		pa:lpush('<small>in reply to <a class="username" href="'):push(&pidbuf[0],pidlen):lpush('">')
           73  +		lib.render.nym(pauth.ptr,0,&pa,true)
           74  +		pa:lpush('</a></small>')
           75  +		tpl.extra = pa:finalize()
           76  +	end
    62     77   	if p.rts + p.likes > 0 then
    63     78   		var s: lib.str.acc s:init(128)
    64     79   		s:lpush('<div class="stats">')
    65     80   		if p.rts   > 0 then s:lpush('<div class="rt">'  ):dpush(p.rts  ):lpush('</div>') end
    66     81   		if p.likes > 0 then s:lpush('<div class="like">'):dpush(p.likes):lpush('</div>') end
    67     82   		s:lpush('</div>')
    68     83   		tpl.stats = s:finalize()
................................................................................
    85    100   
    86    101   	defer tpl.permalink:free()
    87    102   	if acc ~= nil then
    88    103   		if retweeter ~= nil then push_promo_header(co, acc, retweeter, p.rtact) end
    89    104   		tpl:append(acc)
    90    105   		if retweeter ~= nil then acc:lpush('</div>') end
    91    106   		if p.rts + p.likes > 0 then tpl.stats:free() end
          107  +		if tpl.extra.ct > 0 then tpl.extra:free() end
    92    108   		return [lib.mem.ptr(int8)]{ptr=nil,ct=0}
    93    109   	end
    94    110   
    95    111   	if retweeter ~= nil then
    96    112   		var rta: lib.str.acc rta:init(512)
    97    113   		push_promo_header(co, &rta, retweeter, p.rtact)
    98    114   		tpl:append(&rta) rta:lpush('</div>')
          115  +		if tpl.extra.ct > 0 then tpl.extra:free() end
    99    116   		return rta:finalize()
   100    117   	else
   101    118   		var txt = tpl:tostr()
          119  +		if tpl.extra.ct > 0 then tpl.extra:free() end
   102    120   		if p.rts + p.likes > 0 then tpl.stats:free() end
   103    121   		return txt
   104    122   	end
   105    123   end
   106    124   return render_tweet