From b90f239791e87e4ef8a816eb402f654ed9ba9d52 Mon Sep 17 00:00:00 2001 From: Richard Sent Date: Sat, 13 Jan 2024 23:38:09 -0500 Subject: atom/rss: Allow passing last updated date for reproducibility. --- doc/haunt.texi | 12 ++++++++++++ haunt/builder/atom.scm | 9 ++++++++- haunt/builder/rss.scm | 5 ++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/doc/haunt.texi b/doc/haunt.texi index d19cf71..6be2fb5 100644 --- a/doc/haunt.texi +++ b/doc/haunt.texi @@ -997,6 +997,7 @@ The default theme is intended only for testing purposes. @deffn {Procedure} atom-feed [#:file-name "feed.xml"] [#:subtitle "Recent Posts"] @ [#:filter posts/reverse-chronological] @ + [#:last-updated (current-date)] @ [#:max-entries 20] [#:blog-prefix ""] Return a builder procedure that renders a site's posts as an Atom feed. All arguments are optional: @@ -1012,6 +1013,9 @@ The feed subtitle. @item filter The procedure called to manipulate the posts list before rendering. +@item last-updated +The feed last updated date. Defaults to the current date. + @item max-entries The maximum number of posts to render in the feed. @@ -1025,6 +1029,7 @@ prefix and post prefix. @xref{Blog} for more information. @deffn {Procedure} atom-feeds-by-tag [#:prefix "feeds/tags"] @ [#:filter posts/reverse-chronological] @ + [#:last-updated (current-date)] @ [#:max-entries 20] [#:blog-prefix ""] Return a builder procedure that renders an atom feed for every tag used in a post. All arguments are optional: @@ -1037,6 +1042,9 @@ The directory in which to write the feeds. @item filter The procedure called to manipulate the posts list before rendering. +@item last-updated +The feed last updated date. Defaults to the current date. + @item max-entries The maximum number of posts to render in each feed. @@ -1057,6 +1065,7 @@ prefix and post prefix. @xref{Blog} for more information. @deffn {Procedure} rss-feed [#:file-name "rss-feed.xml"] [#:subtitle "Recent Posts"] @ [#:filter posts/reverse-chronological] @ + [#:publication-date (current-date)] @ [#:max-entries 20] [#:blog-prefix ""] Return a builder procedure that renders a list of posts as an RSS feed. All arguments are optional: @@ -1072,6 +1081,9 @@ The feed subtitle. @item filter The procedure called to manipulate the posts list before rendering. +@item publication-date +The feed publication date. Defaults to the current date. + @item max-entries The maximum number of posts to render in the feed. diff --git a/haunt/builder/atom.scm b/haunt/builder/atom.scm index 9a015b2..c580aaf 100644 --- a/haunt/builder/atom.scm +++ b/haunt/builder/atom.scm @@ -171,6 +171,7 @@ (file-name "feed.xml") (subtitle "Recent Posts") (filter posts/reverse-chronological) + (last-updated (current-date)) (max-entries 20) (blog-prefix "")) "Return a builder procedure that renders a list of posts as an Atom @@ -182,6 +183,8 @@ SUBTITLE: The feed subtitle. FILTER: The procedure called to manipulate the posts list before rendering. +LAST-UPDATED: The feed last updated date. + MAX-ENTRIES: The maximum number of posts to render in the feed. BLOG-PREFIX: The prefix for all post URLs, which is the combination of @@ -196,7 +199,7 @@ the blog's prefix and post prefix." (title ,(site-title site)) (id ,uri) (subtitle ,subtitle) - (updated ,(date->string* (current-date))) + (updated ,(date->string* last-updated)) (link (@ (href ,uri) (rel "self"))) (link (@ (href ,(uri->string @@ -211,6 +214,7 @@ the blog's prefix and post prefix." (define* (atom-feeds-by-tag #:key (prefix "feeds/tags") (filter posts/reverse-chronological) + (last-updated (current-date)) (max-entries 20) (blog-prefix "")) "Return a builder procedure that renders an atom feed for every tag @@ -221,6 +225,8 @@ PREFIX: The directory in which to write the feeds. FILTER: The procedure called to manipulate the posts list before rendering. +LAST-UPDATED: The feed last updated date. + MAX-ENTRIES: The maximum number of posts to render in each feed. BLOG-PREFIX: The prefix for all post URLs, which is the combination of @@ -232,6 +238,7 @@ the blog's prefix and post prefix." ((atom-feed #:file-name (string-append prefix "/" tag ".xml") #:subtitle (string-append "Tag: " tag) #:filter filter + #:last-updated last-updated #:max-entries max-entries #:blog-prefix blog-prefix) site posts))) diff --git a/haunt/builder/rss.scm b/haunt/builder/rss.scm index d614d9d..d78a26b 100644 --- a/haunt/builder/rss.scm +++ b/haunt/builder/rss.scm @@ -92,6 +92,7 @@ (subtitle "Recent Posts") (filter posts/reverse-chronological) (max-entries 20) + (publication-date (current-date)) (blog-prefix "")) "Return a builder procedure that renders a list of posts as an RSS feed. All arguments are optional: @@ -105,6 +106,8 @@ rendering. MAX-ENTRIES: The maximum number of posts to render in the feed. +PUBLICATION-DATE: The feed publication date. + BLOG-PREFIX: The prefix for all post URLs, which is the combination of the blog's prefix and post prefix." (lambda (site posts) @@ -116,7 +119,7 @@ the blog's prefix and post prefix." ;; It looks like RSS's description and atom's subtitle ;; are equivalent? (description ,subtitle) - (pubDate ,(date->rfc822-str (current-date))) + (pubDate ,(date->rfc822-str publication-date)) (link ,(string-append (symbol->string (site-scheme site)) -- cgit v1.2.3