summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob L. Kreuze <zerodaysfordays@sdf.org>2023-08-04 20:08:07 -0400
committerJakob L. Kreuze <zerodaysfordays@sdf.org>2023-08-04 20:08:07 -0400
commit78a88bcb9096f0622d23c64064128f440f53b704 (patch)
treef796b87e9eb075bc1ada475ae358fbda3409135f
parentcd852b2ec09927dd0f776504ab071a9e60bb3fb2 (diff)
Enable building the site offline
-rw-r--r--README.md2
-rw-r--r--haunt/jakob/utils/comments.scm38
-rw-r--r--haunt/pages/about.sxml6
3 files changed, 25 insertions, 21 deletions
diff --git a/README.md b/README.md
index 745fa1e..51d640c 100644
--- a/README.md
+++ b/README.md
@@ -38,6 +38,8 @@ Posts must be compiled before the website can be built (otherwise `haunt/posts`
When all of the articles have been compiled, the website can be built by running `haunt build` in the `haunt/` directory.
When `haunt build` completes, the output will be at `haunt/site/`.
+It may take a minute to fetch comments and webmentions.
+The build process can be sped up by setting the `HAUNT_SKIP_COMMENTS` environment variable.
## Deploying
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
;;; <http://www.gnu.org/licenses/>.
-(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"