diff options
| author | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2024-08-11 06:59:22 -0400 |
|---|---|---|
| committer | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2024-08-11 06:59:22 -0400 |
| commit | db825942fb062e4e57d19e031b983f1e2fd687c6 (patch) | |
| tree | 4817109f36159251814c65faa1311b47d4110316 /jakob | |
| parent | 391ec733bf265e3dd0a142123e021f8ab384d9b2 (diff) | |
[dynamic] Add indication that posting a comment was successful
Diffstat (limited to 'jakob')
| -rw-r--r-- | jakob/dynamic/capabilities/comments.scm | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/jakob/dynamic/capabilities/comments.scm b/jakob/dynamic/capabilities/comments.scm index d2e34dc..fe355e2 100644 --- a/jakob/dynamic/capabilities/comments.scm +++ b/jakob/dynamic/capabilities/comments.scm @@ -15,6 +15,7 @@ ;;; <http://www.gnu.org/licenses/>. (define-module (jakob dynamic capabilities comments) + #:use-module (haunt html) #:use-module (ice-9 match) #:use-module (jakob dynamic capabilities common) #:use-module (jakob dynamic captcha) @@ -23,6 +24,7 @@ #:use-module (jakob dynamic logging) #:use-module (jakob dynamic notify) #:use-module (jakob dynamic util) + #:use-module (jakob theme) #:use-module (json) #:use-module (squee) #:use-module (srfi srfi-1) @@ -148,10 +150,21 @@ This is a wrapper around `get-comments-by-slug'." (assoc-value form-data "reply-to") #f) (request-originating-network request))) - (values (build-response - #:code 307 - #:headers '((Location . "https://jakob.space"))) - (scm->json-string `((success . #t))))) + (if (equal? "application/json" (assoc-ref (request-headers request) 'accept)) + (values (build-response #:code 202 + #:headers '((content-type . (application/json)))) + (scm->json-string `((success . #t)))) + (values (build-response #:code 202 + #:headers '((content-type . (text/html)))) + (sxml->html-string + (theme #:title "Comment Posted!" + #:content + `(div (h2 "Comment successfully posted!") + (p "Thanks! Comments on this site are subject to " + (em "manual approval") + ", so it may be some time before you see your comment. " + "But if you're seeing this, we did receive it!") + (p (a (@ (href "/")) "Click here to return to the homepage.")))))))) (let ((form-data (decode-form body))) (unless (assoc "slug" form-data) (panic "missing param `slug'")) (unless (assoc "name" form-data) (panic "missing param `name'")) |