diff options
Diffstat (limited to 'jakob/utils')
| -rw-r--r-- | jakob/utils/comments.scm | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/jakob/utils/comments.scm b/jakob/utils/comments.scm index 2779e67..f9228bd 100644 --- a/jakob/utils/comments.scm +++ b/jakob/utils/comments.scm @@ -32,7 +32,10 @@ #:use-module (srfi-197) #:use-module (web client) #:use-module (web response) - #:export (render-comment-view fetch-comments fetch-webmentions)) + #:export (render-comment-view + fetch-comments + fetch-recent-comments + fetch-webmentions)) (define (gravatar-url email) "Return the gravatar.com URL for user identified by EMAIL" @@ -111,7 +114,10 @@ (if (webmention? comment) '() (internal-comment-reactions comment))) - `(article (@ (class "comment-block")) + `(article (@ ,@(if (not (webmention? comment)) + `((id ,(format #f "comment-~a" (internal-comment-id comment)))) + '()) + (class "comment-block")) (header (@ (class "comment-meta")) (img (@ (class "comment-avatar") (src ,(comment-photo comment)) @@ -239,6 +245,20 @@ (map scm->json-string _) (map (lambda (x) (call-with-input-string x json->internal-comment)) _)))))) +(define (fetch-recent-comments) + "Blocking call to retrieve a vector of the three most recent comments" + (if (getenv "HAUNT_SKIP_COMMENTS") + '() + (let ((url "https://jakob.space/api/all-comments?limit=3")) + (receive (response-status response-body) + (http-request url) + (chain response-body + (bytevector->string _ "UTF-8") + (json-string->scm _) + (vector->list _) + (map scm->json-string _) + (map (lambda (x) (call-with-input-string x json->internal-comment)) _)))))) + (define (fetch-webmentions slug) "Blocking call to webmention.io to retrieve a vector of all Webmentions for `slug'" (define prefixes '("http://jakob.space/" "https://jakob.space/" |