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 +++++++++++++++++++++----------------- haunt/pages/about.sxml | 6 ++---- 2 files changed, 23 insertions(+), 21 deletions(-) (limited to 'haunt') 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))))) diff --git a/haunt/pages/about.sxml b/haunt/pages/about.sxml index 067d72e..8d59ea8 100644 --- a/haunt/pages/about.sxml +++ b/haunt/pages/about.sxml @@ -16,12 +16,10 @@ ;;; along with this program. If not, see ;;; . -(use-modules (ice-9 match) - (jakob theme) +(use-modules (jakob theme) (jakob utils sxml) (srfi srfi-1) - (srfi srfi-19) - (sxml simple)) + (srfi srfi-19)) (theme #:title "About" -- cgit v1.3