From 81abca11711004f5f367c08c6521ff70207d8f21 Mon Sep 17 00:00:00 2001 From: j4nk Date: Tue, 11 Jul 2023 09:21:11 -0400 Subject: [PATCH] Put blog content in the RSS feeds now. --- Makefile | 2 +- blog/feed.xml | 21 +++++++++++++++++++++ feed.xml | 1 - md4tj.el | 29 ++++++++++++++++++----------- test_blog.html | 2 +- test_blog.md4tj | 2 +- test_file.html | 2 +- 7 files changed, 43 insertions(+), 16 deletions(-) create mode 100644 blog/feed.xml delete mode 100644 feed.xml diff --git a/Makefile b/Makefile index 95ab667..8f70060 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,6 @@ all: test_file test_blog test_file: emacs --no-site-file --batch -l ./md4tj.el --eval "(md4tj-parse \"test_file.md4tj\" \"test_file.html\")" test_blog: - emacs --no-site-file --batch -l ./md4tj.el --eval "(md4tj-parse \"test_blog.md4tj\" \"test_blog.html\")" + emacs --no-site-file --batch -l ./md4tj.el --eval "(md4tj-parse \"test_blog.md4tj\" \"./test_blog.html\")" emacs --no-site-file --batch -l ./md4tj.el --eval "(md4tj-parse \"./blog/blogpost1.md4tj\" \"blogpost1.html\")" emacs --no-site-file --batch -l ./md4tj.el --eval "(md4tj-parse \"./blog/blogpost2.md4tj\" \"blogpost2.html\")" diff --git a/blog/feed.xml b/blog/feed.xml new file mode 100644 index 0000000..fe58749 --- /dev/null +++ b/blog/feed.xml @@ -0,0 +1,21 @@ +RSS Testhttp://example.comAn example blog for testing RSS capability of md4tj.en-USTue, 10 Jun 2003 04:00:00 GMTeditor@example.comwebmaster@example.comhttps://www.rssboard.org/rss-specificationmd4tj-rss.elTue, 11 Jul 2023 09:19:23 GMTBlog Post 2https://example.com/blog/blogpost2.htmlhttps://example.com/blog/blogpost2.html + +
+ + + +

Blog post 2

+ +

blog text 2 text!

+
Thu, 02 Mar 2023 19:44:50 EST
Blog Post 1https://example.com/blog/blogpost1.htmlhttps://example.com/blog/blogpost1.html + +
+ + + +

Blog post 1

+ +

blog text 1!

+ +

[Link to example.com!](https://www.example.com ())

+
Thu, 02 Mar 2023 19:44:14 EST
\ No newline at end of file diff --git a/feed.xml b/feed.xml deleted file mode 100644 index 8aac30f..0000000 --- a/feed.xml +++ /dev/null @@ -1 +0,0 @@ -RSS Testhttp://example.comAn example blog for testing RSS capability of md4tj.en-USTue, 10 Jun 2003 04:00:00 GMTeditor@example.comwebmaster@example.comhttps://www.rssboard.org/rss-specificationmd4tj-rss.elMon, 10 Jul 2023 08:50:16 GMTBlog Post 2j4nkhttps://example.com/blog/blogpost2.htmlhttps://example.com/blog/blogpost2.htmlThu, 02 Mar 2023 19:44:50 ESTBlog Post 1j4nkhttps://example.com/blog/blogpost1.htmlhttps://example.com/blog/blogpost1.htmlThu, 02 Mar 2023 19:44:14 EST \ No newline at end of file diff --git a/md4tj.el b/md4tj.el index 831e93f..121c72a 100644 --- a/md4tj.el +++ b/md4tj.el @@ -406,22 +406,29 @@ (md4tj-rss-begin-tag "generator") "md4tj-rss.el" (md4tj-rss-end-tag "generator") (md4tj-rss-begin-tag "lastBuildDate") (format-time-string "%a, %d %b %Y %H:%M:%S GMT") (md4tj-rss-end-tag "lastBuildDate"))) -;; Elt is triple of -;; Title -;; Time -;; Link -(defun md4tj-rss-item (elt) - "Return RSS for ELT." +;; eltfilelist is a tuple of +;; File name +;; Elt, where +;; Elt is triple of +;; Title +;; Time +;; Link +;; This is really messy but the easiest way to get the filename into +;; md4tj-rss-item in order to be able to provide the entire blog post +;; in the RSS feed +(defun md4tj-rss-item (eltfilelist) + "Return RSS for ELTFILELIST." (concat (md4tj-rss-begin-tag "item") - (md4tj-rss-begin-tag "title") (nth 0 elt) (md4tj-rss-end-tag "title") - (md4tj-rss-begin-tag "link") (nth 2 elt) (md4tj-rss-end-tag "link") - (md4tj-rss-begin-tag "guid") (nth 2 elt) (md4tj-rss-end-tag "guid") - (md4tj-rss-begin-tag "pubDate") (format-time-string "%a, %d %b %Y %H:%M:%S %Z" (string-to-number (nth 1 elt))) (md4tj-rss-end-tag "pubDate") + (md4tj-rss-begin-tag "title") (nth 0 (nth 1 eltfilelist)) (md4tj-rss-end-tag "title") + (md4tj-rss-begin-tag "link") (nth 2 (nth 1 eltfilelist)) (md4tj-rss-end-tag "link") + (md4tj-rss-begin-tag "guid") (nth 2 (nth 1 eltfilelist)) (md4tj-rss-end-tag "guid") + (md4tj-rss-begin-tag "description") (md4tj-parse-to-string (nth 0 eltfilelist)) (md4tj-rss-end-tag "description") + (md4tj-rss-begin-tag "pubDate") (format-time-string "%a, %d %b %Y %H:%M:%S %Z" (string-to-number (nth 1 (nth 1 eltfilelist)))) (md4tj-rss-end-tag "pubDate") (md4tj-rss-end-tag "item"))) (defun md4tj-rss-items () "Return all RSS for all elements." - (mapconcat 'md4tj-rss-item (md4tj-blog-all-blogs-list) "")) + (mapconcat 'md4tj-rss-item (md4tj-util-zip (list (reverse (md4tj-blog-files)) (md4tj-blog-all-blogs-list))) "")) diff --git a/test_blog.html b/test_blog.html index 4bcefbb..c38d965 100644 --- a/test_blog.html +++ b/test_blog.html @@ -20,7 +20,7 @@

Blogs

-RSS icon +
RSS icon

Blog Post 2

2023 March 02 19:44
diff --git a/test_blog.md4tj b/test_blog.md4tj index ba8a0c5..4ae9a93 100644 --- a/test_blog.md4tj +++ b/test_blog.md4tj @@ -12,7 +12,7 @@ # Blogs @@RSSINSERT @@BLOGBASEURL https://example.com/blog/ -@@BLOGBASEDIR ./blog/ +@@BLOGBASEDIR ./blog @@BLOGINSERT ### Non blog text!! diff --git a/test_file.html b/test_file.html index 28c7c7d..863fdf3 100644 --- a/test_file.html +++ b/test_file.html @@ -75,7 +75,7 @@ int main() {

This is a div that has monospace text.

-

Last updated: Mon Jul 10 08:35:47 2023

+

Last updated: Tue Jul 11 09:19:23 2023