a mini social media app for small communities
1@include 'partial/header.html'
2
3<script src="/static/js/post.js"></script>
4<script src="/static/js/render_body.js"></script>
5
6<div class="post post-full">
7 <h2>
8 <a href="/user/@{(app.get_user_by_id(post.author_id) or { app.get_unknown_user() }).username}"><strong>@{(app.get_user_by_id(post.author_id) or { app.get_unknown_user() }).get_name()}</strong></a>
9 -
10 @if replying_to_post.id == 0
11 @post.title
12 @else
13 replied to <a href="/user/@{replying_to_user.username}">@{replying_to_user.get_name()}</a>
14 @end
15 </h2>
16 <pre id="post-@{post.id}">@post.body</pre>
17 <p><em>likes: @{app.get_net_likes_for_post(post.id)}</em></p>
18 <p><em>posted at: @post.posted_at</em></p>
19
20 @if ctx.is_logged_in()
21 <p><a href="/post/@{post.id}/reply">reply</a></p>
22 @end
23
24 @if ctx.is_logged_in() && post.author_id == user.id
25 <p><a href="/post/@{post.id}/edit">edit post</a></p>
26 @end
27
28 @if ctx.is_logged_in()
29 <br>
30 <div>
31 <button onclick="like(@post.id)">
32 @if app.does_user_like_post(user.id, post.id)
33 liked :D
34 @else
35 like
36 @end
37 </button>
38 <button onclick="dislike(@post.id)">
39 @if app.does_user_dislike_post(user.id, post.id)
40 disliked D:
41 @else
42 dislike
43 @end
44 </button>
45 </div>
46 @end
47
48 @if ctx.is_logged_in() && (post.author_id == user.id || user.admin)
49 <br>
50 <div>
51
52 @if post.author_id == user.id
53 <h4>manage post:</h4>
54 @else if user.admin
55 <h4>admin powers:</h4>
56 @end
57
58 <form action="/api/post/delete" method="post">
59 <input
60 type="number"
61 name="id"
62 id="id"
63 placeholder="post id"
64 value="@post.id"
65 required
66 readonly
67 hidden
68 aria-hidden
69 >
70 <input type="submit" value="delete">
71 </form>
72
73 <form action="/api/post/pin" method="post">
74 <input
75 type="number"
76 name="id"
77 id="id"
78 placeholder="post id"
79 value="@post.id"
80 required
81 readonly
82 hidden
83 aria-hidden
84 >
85 <input type="submit" value="pin">
86 </form>
87
88 </div>
89 @end
90</div>
91
92<script type="module">
93 await render_body('post-@{post.id}')
94</script>
95
96@include 'partial/footer.html'