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