diff options
| author | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2022-11-19 12:42:09 -0500 |
|---|---|---|
| committer | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2022-11-19 12:42:09 -0500 |
| commit | ebeeb7518241bea945b6c372fe07fb20abf020f3 (patch) | |
| tree | 04fb96d93883044f138fa59e77fcbe6d2d369ab3 /haunt | |
| parent | 9cc0a68d9646ede2af1b96fb6d9c9670d8f9acf7 (diff) | |
[dynamic] Prettify success response
Diffstat (limited to 'haunt')
| -rw-r--r-- | haunt/jakob/dynamic/capabilities/comment-form.scm | 11 | ||||
| -rw-r--r-- | haunt/jakob/dynamic/capabilities/comments.scm | 10 |
2 files changed, 18 insertions, 3 deletions
diff --git a/haunt/jakob/dynamic/capabilities/comment-form.scm b/haunt/jakob/dynamic/capabilities/comment-form.scm index f1cbd9e..6937d15 100644 --- a/haunt/jakob/dynamic/capabilities/comment-form.scm +++ b/haunt/jakob/dynamic/capabilities/comment-form.scm @@ -18,6 +18,7 @@ #:use-module (gcrypt base64) #:use-module (haunt html) #:use-module (ice-9 match) + #:use-module (jakob builder blog) #:use-module (jakob dynamic captcha) #:use-module (jakob dynamic util) #:use-module (jakob theme) @@ -28,7 +29,10 @@ #:use-module (web request) #:use-module (web response) #:use-module (web uri) - #:export (get-comment-form)) + #:export (render-comment-form-success + render-comment-form-failure + + get-comment-form)) (define (render-comment-form slug) (let-values (((captcha-id captcha-image) (new-captcha!))) @@ -64,6 +68,11 @@ (input (@ (type "submit") (id "submit-form") (value "Submit"))))) ,(script "proof-of-work.js"))))) +(define (render-comment-form-success slug) + `((div (h1 "Success!") + (meta (@ (http-equiv "refresh") + (content "1; url=https://jakob.space")))))) + (define (get-comment-form request body) "API endpoint handler for querying for the comments on a particular post diff --git a/haunt/jakob/dynamic/capabilities/comments.scm b/haunt/jakob/dynamic/capabilities/comments.scm index 54e1846..d3cb812 100644 --- a/haunt/jakob/dynamic/capabilities/comments.scm +++ b/haunt/jakob/dynamic/capabilities/comments.scm @@ -15,9 +15,12 @@ ;;; <http://www.gnu.org/licenses/>. (define-module (jakob dynamic capabilities comments) + #:use-module (haunt html) #:use-module (ice-9 match) #:use-module (jakob dynamic captcha) + #:use-module (jakob dynamic capabilities comment-form) #:use-module (jakob dynamic util) + #:use-module (jakob theme) #:use-module (json) #:use-module (squee) #:use-module (web request) @@ -103,8 +106,11 @@ This is a wrapper around `get-comments-by-slug'." (assoc-value form-data "email") (assoc-value form-data "url") (assoc-value form-data "comment"))) - (values '((content-type . (application/json))) - (scm->json-string `((success . #t))))) + (values '((content-type . (text/html))) + (sxml->html-string + (theme + #:content (render-comment-form-success (assoc-value form-data "slug")) + #:title "Success!")))) (let ((form-data (decode-form body))) (if (valid-comment? form-data) (insert-comment form-data) |