From 28e52ad4fa7808eb85cf4586662998c93666343e Mon Sep 17 00:00:00 2001 From: rawleyIfowler Date: Sat, 26 Feb 2022 11:45:02 -0600 Subject: [PATCH] added post failure screen --- controllers/blog.go | 3 ++- templates/comment_post_failed.tmpl | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 templates/comment_post_failed.tmpl diff --git a/controllers/blog.go b/controllers/blog.go index c45e76e..0660dfc 100644 --- a/controllers/blog.go +++ b/controllers/blog.go @@ -113,13 +113,14 @@ func CreateComment(c *gin.Context) { a := []string{c.Request.Form.Get("author"), c.Request.Form.Get("content"), c.Request.Form.Get("url")} + if GetNumberOfRecentPosts(c) > 3 { c.HTML(http.StatusOK, "comment_post_spam.tmpl", CommentDto{Url: a[2]}) return } for _, v := range a { if len(v) == 0 { - c.Status(http.StatusNotAcceptable) + c.HTML(http.StatusNotAcceptable, "comment_post_failed.tmpl", CommentDto{Url: a[2]}) return } } diff --git a/templates/comment_post_failed.tmpl b/templates/comment_post_failed.tmpl new file mode 100644 index 0000000..530a7b0 --- /dev/null +++ b/templates/comment_post_failed.tmpl @@ -0,0 +1,11 @@ +{{ template "header.tmpl" . }} +

Your comment failed to be posted...

+

You will be redirected or, click here to return to the blog post.

+ + + +