added post failure screen

This commit is contained in:
rawleyIfowler
2022-02-26 11:45:02 -06:00
parent 2980011a16
commit 28e52ad4fa
2 changed files with 13 additions and 1 deletions

View File

@@ -113,13 +113,14 @@ func CreateComment(c *gin.Context) {
a := []string{c.Request.Form.Get("author"), a := []string{c.Request.Form.Get("author"),
c.Request.Form.Get("content"), c.Request.Form.Get("content"),
c.Request.Form.Get("url")} c.Request.Form.Get("url")}
if GetNumberOfRecentPosts(c) > 3 { if GetNumberOfRecentPosts(c) > 3 {
c.HTML(http.StatusOK, "comment_post_spam.tmpl", CommentDto{Url: a[2]}) c.HTML(http.StatusOK, "comment_post_spam.tmpl", CommentDto{Url: a[2]})
return return
} }
for _, v := range a { for _, v := range a {
if len(v) == 0 { if len(v) == 0 {
c.Status(http.StatusNotAcceptable) c.HTML(http.StatusNotAcceptable, "comment_post_failed.tmpl", CommentDto{Url: a[2]})
return return
} }
} }

View File

@@ -0,0 +1,11 @@
{{ template "header.tmpl" . }}
<h2>Your comment <u>failed</u> to be posted...</h2>
<p>You will be redirected or, click <a href="/blog/post/{{ .Url }}">here</a> to return to the blog post.</p>
<input value="{{ .Url }}" readonly style="display: none;" id="url"/>
<script>
setTimeout(() => {
window.location.replace("/blog/post/" + document.getElementById("url").value)
}, 1500)
</script>
</body>
</html>