parsav  Diff

Differences From Artifact [ad592d16bd]:

To Artifact [005ba03599]:


     1      1   -- vim: ft=terra
     2      2   local pstr = lib.mem.ptr(int8)
     3      3   local pref = lib.mem.ref(int8)
     4      4   local terra cs(s: rawstring)
     5      5   	return pstr { ptr = s, ct = lib.str.sz(s) }
     6      6   end
            7  +
            8  +local terra 
            9  +render_tweet_replies(
           10  +	co: &lib.srv.convo,
           11  +	acc: &lib.str.acc,
           12  +	id: uint64
           13  +): {}
           14  +	var replies = co.srv:post_enum_parent(id)
           15  +	if replies.ct == 0 then return end
           16  +	acc:lpush('<div class="thread">')
           17  +	for i=0, replies.ct do
           18  +		var post = replies(i).ptr
           19  +		lib.render.tweet(co, post, acc)
           20  +		render_tweet_replies(co, acc, post.id)
           21  +	end
           22  +	acc:lpush('</div>')
           23  +end
     7     24   
     8     25   local terra 
     9     26   render_tweet_page(
    10     27   	co: &lib.srv.convo,
    11     28   	path: lib.mem.ptr(pref),
    12     29   	p: &lib.store.post
    13     30   ): {}
           31  +	var livetime = co.srv:thread_latest_arrival_calc(p.id)
           32  +
    14     33   	var pg: lib.str.acc pg:init(256)
    15     34   	lib.render.tweet(co, p, &pg)
    16         -	pg:lpush('<form class="action-bar" method="post">')
    17     35   
    18     36   	if co.aid ~= 0 then
           37  +		pg:lpush('<form class="action-bar" method="post">')
    19     38   		var liked = false -- FIXME
    20     39   		var rtd = false
    21     40   		if not liked
    22     41   			then pg:lpush('<button class="pos" name="act" value="like">like</button>')
    23     42   			else pg:lpush('<button class="neg" name="act" value="dislike">dislike</button>')
    24     43   		end
    25     44   		if not rtd
................................................................................
    28     47   		end
    29     48   		if p.author == co.who.id then
    30     49   			pg:lpush('<a class="button" href="/post/'):rpush(path(1)):lpush('/edit">edit</a><a class="neg button" href="/post/'):rpush(path(1)):lpush('/del">delete</a>')
    31     50   		end
    32     51   		-- TODO list user's chosen reaction emoji
    33     52   		pg:lpush('</form>')
    34     53   
    35         -		if co.who.rights.powers.post() then
    36         -			lib.render.compose(co, nil, &pg)
    37         -		end
           54  +	end
           55  +	pg:lpush('<div id="convo" data-live="10">')
           56  +	render_tweet_replies(co, &pg, p.id)
           57  +	pg:lpush('</div>')
           58  +
           59  +	if co.aid ~= 0 and co.who.rights.powers.post() then
           60  +		lib.render.compose(co, nil, &pg)
    38     61   	end
    39     62   
    40     63   	var ppg = pg:finalize() defer ppg:free()
    41         -	co:stdpage([lib.srv.convo.page] {
           64  +	co:livepage([lib.srv.convo.page] {
    42     65   		title = lib.str.plit 'post'; cache = false;
    43     66   		class = lib.str.plit 'post'; body = ppg;
    44         -	})
           67  +	}, livetime)
    45     68   
    46     69   	-- TODO display conversation
    47     70   	-- perhaps display descendant nodes here, and have a link to the top of the whole tree?
    48     71   end
    49     72   
    50     73   return render_tweet_page