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 @else if user.admin 62 <h4>admin powers:</h4> 63 @end 64 65 @if post.author_id == user.id 66 <p><a href="/post/@{post.id}/edit">edit</a></p> 67 @end 68 69 @if user.admin 70 <form action="/api/post/pin" method="post"> 71 <input 72 type="number" 73 name="id" 74 id="id" 75 placeholder="post id" 76 value="@post.id" 77 required aria-required 78 readonly aria-readonly 79 hidden aria-hidden 80 > 81 <input type="submit" value="pin"> 82 </form> 83 @end 84 85 </div> 86 @end 87</div> 88 89<script type="module"> 90 await render_body('post-@{post.id}') 91</script> 92 93@include 'partial/footer.html'