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}">
9 <strong>@{(app.get_user_by_id(post.author_id) or { app.get_unknown_user() }).get_name()}</strong>
10 </a>
11 -
12 @if replying_to_post.id == 0
13 @post.title
14 @else
15 replied to <a href="/user/@{replying_to_user.username}">@{replying_to_user.get_name()}</a>
16 @end
17 @if post.nsfw
18 <span class="nsfw-indicator">(<em>nsfw</em>)</span>
19 @end
20 </h2>
21
22 @if post.nsfw
23 <details>
24 <summary>click to show post (nsfw)</summary>
25 <pre id="post-@{post.id}">@post.body</pre>
26 </details>
27 @else
28 <pre id="post-@{post.id}">@post.body</pre>
29 @end
30
31 <p><em>likes: @{app.get_net_likes_for_post(post.id)}</em></p>
32 <p><em>posted at: @post.posted_at</em></p>
33
34 @if ctx.is_logged_in() && !user.automated
35 <p><a href="/post/@{post.id}/reply">reply</a></p>
36 <br>
37 <div>
38 <button onclick="like(@post.id)">
39 @if app.does_user_like_post(user.id, post.id)
40 liked :D
41 @else
42 like
43 @end
44 </button>
45 <button onclick="dislike(@post.id)">
46 @if app.does_user_dislike_post(user.id, post.id)
47 disliked D:
48 @else
49 dislike
50 @end
51 </button>
52 <button onclick="save(@post.id)">
53 @if app.is_post_saved_by(user.id, post.id)
54 saved!
55 @else
56 save
57 @end
58 </button>
59 <button onclick="save_for_later(@post.id)">
60 @if app.is_post_saved_for_later_by(user.id, post.id)
61 saved for later!
62 @else
63 save for later
64 @end
65 </button>
66 </div>
67 @end
68
69 @if ctx.is_logged_in() && (post.author_id == user.id || user.admin)
70 <br>
71 <div>
72
73 @if post.author_id == user.id
74 <h4>manage post:</h4>
75
76 <p><a href="/post/@{post.id}/edit">edit</a></p>
77 @end
78
79 @if user.admin
80 <details>
81 <summary>admin powers</summary>
82
83 <form action="/api/post/pin" 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="pin">
95 </form>
96
97 <form action="/api/post/delete" method="post">
98 <input
99 type="number"
100 name="id"
101 id="id"
102 placeholder="post id"
103 value="@post.id"
104 required aria-required
105 readonly aria-readonly
106 hidden aria-hidden
107 >
108 <input type="submit" value="delete">
109 </form>
110 </details>
111 @end
112
113 </div>
114 @end
115</div>
116
117<script type="module">
118 await render_body('post-@{post.id}')
119</script>
120
121@include 'partial/footer.html'