commit 12bd54052932f6ab148882c67df3609d1e29a3f7
parent 6331c57a8591097b6502fb4776464c35e8f4c64f
Author: Daniel Barlow <dan@telent.net>
Date: Thu, 31 Jul 2025 22:15:55 +0100
add post body to rss
Diffstat:
3 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/main.fnl b/main.fnl
@@ -254,7 +254,7 @@ href=\"https://axillae.telent.net/\">@dan@axillae.telent.net</a>
(server.headers stream
{ :content-type "application/rss+xml; charset=utf-8" })
; (print :s stream (view posts))
- (rss.feed stream "https://ww.telent.net/" posts)))
+ (rss.feed stream "https://ww.telent.net" post-index posts)))
(fn dispatch [route stream]
diff --git a/rss.fnl b/rss.fnl
@@ -1,7 +1,7 @@
(local { : to-html } (require :html))
+(local { : string-stream } (require :lib))
-(local preamble "
-<?xml version='1.0' encoding='UTF-8'?>
+(local preamble "<?xml version='1.0' encoding='UTF-8'?>
<rss version='2.0' xmlns:content='http://purl.org/rss/1.0/modules/content/' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:atom='http://www.w3.org/2005/Atom' xmlns:trackback='http://madskills.com/public/xml/rss/module/trackback/' xmlns:itunes='http://www.itunes.com/dtds/podcast-1.0.dtd'>
<channel>
<title>
@@ -17,10 +17,17 @@ Daniel Barlow's blog
")
-(fn for-post [base-url post]
+
+(fn make-cdata [body]
+ (.. "<![CDATA["
+ (string.gsub body "%]%]>" "]]]]><![CDATA[>")
+ "]]>"))
+
+(fn for-post [base-url site post]
(let [link (.. base-url post.url-path)
- body "my message to you, Rudy"
- escaped-text (.. "<![CDATA[ " body "]]>")
+ out (string-stream)
+ body (do (post:body site out) (out:to-string))
+ escaped-text (make-cdata body)
date (os.date "!%Y-%m-%dT%TZ" post.date)]
[:item
[:title post.title]
@@ -30,11 +37,11 @@ Daniel Barlow's blog
[:guid link]
["dc:date" date]]))
-(fn feed [stream base-url posts]
+(fn feed [stream base-url site posts]
(print :s stream )
(stream:write_chunk preamble)
(each [_ p (ipairs posts)]
- (stream:write_chunk (to-html (for-post base-url p))))
+ (stream:write_chunk (to-html (for-post base-url site p))))
(stream:write_chunk "</channel></rss>" true))
{ : feed }
diff --git a/site.fnl b/site.fnl
@@ -107,7 +107,8 @@
(stream:write
(translate-markdown site (f:read (if excerpt? 600 "*a")))))
(when (and excerpt? (= (f:read 0) ""))
- (to-html [[:div {:class :continuelink}] [:div [[:a { :href post.url-path}] "... continue reading"]]] stream))))))
+ (to-html [[:div {:class :continuelink}] [:div [[:a { :href post.url-path}] "... continue reading"]]] stream))
+ (stream:write "</div>")))))
(fn frontmatter [stream]