Add ability to ban ips

This commit is contained in:
Dominic Ferrando
2025-04-23 20:47:23 -04:00
parent c5453ed50a
commit 807ac94cc6
6 changed files with 126 additions and 4 deletions
+36
View File
@@ -22,11 +22,44 @@ templ PostAdminDialog(post database.Post) {
_="on htmx:afterRequest trigger refreshPosts on body"
hx-confirm="Are you sure you wish to delete this post?"
>Delete</button>
<button
class="link-button"
_={ fmt.Sprintf(`on click call #%s-dialog-2.showModal()`, elPostId) }
>IP ban</button>
<button
class="admin-dialog-close-btn link-button"
_={ fmt.Sprintf("on click call #%s-dialog.close()", elPostId) }
>Close</button>
</dialog>
<dialog
id={ elPostId + "-dialog-2" }
class="admin-dialog"
>
<h1>Ban info</h1>
<form
hx-post={ fmt.Sprintf("/admin/ban/%d", post.Id) }
hx-swap="none"
_="on htmx:afterRequest trigger refreshPosts on body"
hx-confirm="Are you sure you wish to ban this post's ip?"
>
<div style="margin-bottom: 5px;">
<span>Reason: </span>
<input name="reason"/>
</div>
<div>
<span>Days: </span>
<input type="datetime-local" name="expiration"/>
</div>
<button
type="submit"
class="link-button"
>Ban</button>
</form>
<button
class="admin-dialog-close-btn link-button"
_={ fmt.Sprintf("on click call #%s-dialog-2.close()", elPostId) }
>Cancel</button>
</dialog>
}
templ PostOriginal(post database.Post, thread database.Thread) {
@@ -130,6 +163,9 @@ templ PostReply(post database.Post, threadContext ThreadContext) {
}
<p class="post-body">
@templ.Raw(util.EnrichPost(post.Body))
if post.Banned {
<strong class="post-banned-message">(USER WAS BANNED FOR THIS POST)</strong>
}
</p>
@PostAdminDialog(post)
</article>