summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2022-07-05 20:19:26 -0400
committerDavid Thompson <dthompson2@worcester.edu>2022-07-07 22:00:06 -0400
commit2ac650f5be1d9e5f826145c32a8c82dbfb4b7e29 (patch)
treefc2db1a4c6e957065b96054d2035bf23ffab4086
parent7e8ceb197e3024b20469a08d529985e989e8eba3 (diff)
builder: atom: Refactor using site-url.
-rw-r--r--haunt/builder/atom.scm25
1 files changed, 7 insertions, 18 deletions
diff --git a/haunt/builder/atom.scm b/haunt/builder/atom.scm
index 1f90d24..9d03b2d 100644
--- a/haunt/builder/atom.scm
+++ b/haunt/builder/atom.scm
@@ -37,7 +37,6 @@
#:use-module (haunt utils)
#:use-module (haunt html)
#:use-module (haunt serve mime-types)
- #:use-module (web uri)
#:export (make-enclosure
enclosure?
enclosure-title
@@ -140,21 +139,16 @@
(define* (post->atom-entry site slug->file-name post)
"Convert POST into an Atom <entry> XML node."
- (let ((uri (uri->string
- (build-uri (site-scheme site)
- #:host (site-domain site)
- #:path (string-append "/"
- (slug->file-name
- (site-post-slug site post)))))))
+ (let ((url (site-url site (slug->file-name (site-post-slug site post)))))
`(entry
(title ,(post-ref post 'title))
- (id ,uri)
+ (id ,url)
(author
(name ,(post-ref post 'author))
,(let ((email (post-ref post 'email)))
(if email `(email ,email) '())))
(updated ,(date->string* (post-date post)))
- (link (@ (href ,uri) (rel "alternate")))
+ (link (@ (href ,url) (rel "alternate")))
(summary (@ (type "html"))
,(sxml->html-string (post-sxml post)))
,@(map (lambda (enclosure)
@@ -191,20 +185,15 @@ MAX-ENTRIES: The maximum number of posts to render in the feed"
(make-compat-slug->file-name blog-prefix))))
(lambda (site posts)
- (let ((uri (uri->string
- (build-uri (site-scheme site)
- #:host (site-domain site)
- #:path (string-append "/" file-name)))))
+ (let ((feed-url (site-url site file-name)))
(serialized-artifact file-name
`(feed (@ (xmlns "http://www.w3.org/2005/Atom"))
(title ,(site-title site))
- (id ,uri)
+ (id ,feed-url)
(subtitle ,subtitle)
(updated ,(date->string* (current-date)))
- (link (@ (href ,(string-append (site-domain site)
- "/" file-name))
- (rel "self")))
- (link (@ (href ,(site-domain site))))
+ (link (@ (href ,feed-url) (rel "self")))
+ (link (@ (href ,(site-url site "/"))))
,@(map (cut post->atom-entry site slug->file-name* <>)
(take-up-to max-entries (filter posts))))
sxml->xml*))))