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