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() && !user.automated
21 <p><a href="/post/@{post.id}/reply">reply</a></p>
22 <br>
23 <div>
24 <button onclick="like(@post.id)">
25 @if app.does_user_like_post(user.id, post.id)
26 liked :D
27 @else
28 like
29 @end
30 </button>
31 <button onclick="dislike(@post.id)">
32 @if app.does_user_dislike_post(user.id, post.id)
33 disliked D:
34 @else
35 dislike
36 @end
37 </button>
38 <button onclick="save(@post.id)">
39 @if app.is_post_saved_by(user.id, post.id)
40 saved!
41 @else
42 save
43 @end
44 </button>
45 <button onclick="save_for_later(@post.id)">
46 @if app.is_post_saved_for_later_by(user.id, post.id)
47 saved for later!
48 @else
49 save for later
50 @end
51 </button>
52 </div>
53 @end
54
55 @if ctx.is_logged_in() && (post.author_id == user.id || user.admin)
56 <br>
57 <div>
58
59 @if post.author_id == user.id
60 <h4>manage post:</h4>
61
62 <p><a href="/post/@{post.id}/edit">edit</a></p>
63 @end
64
65 @if user.admin
66 <details>
67 <summary>admin powers</summary>
68
69 <form action="/api/post/pin" method="post">
70 <input
71 type="number"
72 name="id"
73 id="id"
74 placeholder="post id"
75 value="@post.id"
76 required aria-required
77 readonly aria-readonly
78 hidden aria-hidden
79 >
80 <input type="submit" value="pin">
81 </form>
82
83 <form action="/api/post/delete" method="post">
84 <input
85 type="number"
86 name="id"
87 id="id"
88 placeholder="post id"
89 value="@post.id"
90 required aria-required
91 readonly aria-readonly
92 hidden aria-hidden
93 >
94 <input type="submit" value="delete">
95 </form>
96 </details>
97 @end
98
99 </div>
100 @end
101</div>
102
103<script type="module">
104 await render_body('post-@{post.id}')
105</script>
106
107@include 'partial/footer.html'