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