From 78a88bcb9096f0622d23c64064128f440f53b704 Mon Sep 17 00:00:00 2001 From: Jakob L. Kreuze Date: Fri, 4 Aug 2023 20:08:07 -0400 Subject: Enable building the site offline --- haunt/jakob/utils/comments.scm | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'haunt/jakob/utils') diff --git a/haunt/jakob/utils/comments.scm b/haunt/jakob/utils/comments.scm index e41fe2c..f38bb18 100644 --- a/haunt/jakob/utils/comments.scm +++ b/haunt/jakob/utils/comments.scm @@ -223,25 +223,29 @@ (define (fetch-comments slug) "Blocking call to webmention.io to retrieve a vector of all Webmentions for `slug'" - (let ((url (format #f "https://jakob.space/api/comments?p=~a" slug))) - (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)) _))))) + (if (getenv "HAUNT_SKIP_COMMENTS") + '() + (let ((url (format #f "https://jakob.space/api/comments?p=~a" slug))) + (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/" "http://jakob.space/blog/" "https://jakob.space/blog/")) - (let* ((target-queries (map (lambda (pre) - (format #f "target[]=~a~a.html" pre slug)) - prefixes)) - (url (format #f "https://webmention.io/api/mentions.jf2?per-page=200&page=0&~a" - (string-join target-queries "&")))) - (receive (response-status response-body) - (http-request url) - (call-with-input-string (bytevector->string response-body "UTF-8") json->scm)))) + (if (getenv "HAUNT_SKIP_COMMENTS") + `(("children" . #())) + (let* ((target-queries (map (lambda (pre) + (format #f "target[]=~a~a.html" pre slug)) + prefixes)) + (url (format #f "https://webmention.io/api/mentions.jf2?per-page=200&page=0&~a" + (string-join target-queries "&")))) + (receive (response-status response-body) + (http-request url) + (call-with-input-string (bytevector->string response-body "UTF-8") json->scm))))) -- cgit v1.3