From 9e5650b786d4657920217a1b9ac610a34cf28fa0 Mon Sep 17 00:00:00 2001 From: Frederik Vanrenterghem Date: Fri, 22 Dec 2023 13:02:07 +0800 Subject: [PATCH] Werkt niet naar behoren. --- maak-website.el | 60 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/maak-website.el b/maak-website.el index f34847f..4cc1f9a 100644 --- a/maak-website.el +++ b/maak-website.el @@ -1,4 +1,5 @@ (require 'ox-publish) +;(require 'ox-rss) (load "~/.emacs.d/lisp/mustache-html.el") (setq org-html-doctype "html5") @@ -13,6 +14,8 @@ (setq my-blog-tags-folder (file-name-concat my-blog-source-folder "tags")) (setq my-blog-posts-folder (file-name-concat my-blog-source-folder "posts")) +(setq org-export-time-stamp-file nil) +(setq org-rss-use-entry-url-as-guid nil) (defun my-org-get-all-filetags () "Get list of filetags from all org-files in my-blog-posts-folder." @@ -117,6 +120,7 @@ Either the section between #+BEGIN_PREVIEW and +#END_PREVIEW is used, or the fir (defun my-blog-sitemap (title list) "Generate the sitemap landing page for my blog." (my-plain-publish-sitemap-default title list) ; Create additional sitemap + ;(my-blog-publish-rss-sitemap title list) ; Create RSS sitemap (with-temp-buffer ;; mangle the parsed list given to us into a plain lisp list of files (let* ((filenames (my-blog-parse-sitemap-list list)) @@ -175,6 +179,37 @@ representation for the files to include, as returned by (goto-char (point-min)) (insert "#+OPTIONS: ^:nil\n")))) ; do not use underscores as subscript +(defun my-blog-publish-rss-sitemap (title list) + "Create a simple site map, as a string. +TITLE is the title of the site map. LIST is an internal +representation for the files to include, as returned by +`org-list-to-lisp'." + (with-temp-buffer + (message "Creating RSS index.") + (let* ((filenames (my-blog-parse-sitemap-list list)) + (project-plist (assoc "posts" org-publish-project-alist)) + ;;(articles (my-blog-sort-article-list filenames project-plist)) + ) + (org-mode) + (insert "#+AUTHOR: Frederik Vanrenterghem\n") + (dolist (file filenames) + (unless (eq (file-name-base file) "rss.org") + (let* ((abspath (file-name-concat "/home/frederik/websites/stage.vanrenterghem.biz/source/posts" file)) + (relpath (file-relative-name abspath "/home/frederik/websites/stage.vanrenterghem.biz/source/")) + (title (org-publish-find-title file project-plist)) + (date (format-time-string (car org-time-stamp-custom-formats) (org-publish-find-date file project-plist))) + (rss-permalink (file-name-sans-extension relpath)) + (preview (my-blog-get-preview abspath))) + (insert (concat "* [[file:" relpath "][" title "]]\n")) + (org-set-property "RSS_PERMALINK" rss-permalink) + (org-set-property "PUBDATE" date) + (org-set-property "RSS_TITLE" title) + (insert preview)))) + (goto-char (point-min)) + (insert "#+OPTIONS: ^:nil\n") + (write-file "~/websites/stage.vanrenterghem.biz/source/posts/rss.org")))) + + (defun my-blog-cleanup-sitemaps (plist) "Clean up temporary files created in the process of publishing" (delete-file (file-name-concat my-blog-source-folder "sitemap.org")) @@ -207,7 +242,7 @@ representation for the files to include, as returned by :publishing-function org-mustache-html-publish-to-html :mustache-template ,(file-name-concat my-blog-mustache-folder "post.mustache") :preparation-function my-blog-create-tags-files - :exclude "html*\\|assets*\\|index.org" ;"assets*\\|sitemap.org\\|index.org" ;; regexp + :exclude "html*\\|assets*\\|index.org\\|rss.org" ;"assets*\\|sitemap.org\\|index.org" ;; regexp :html-content-class nil :section-numbers nil :with-toc nil @@ -222,8 +257,6 @@ representation for the files to include, as returned by :html-postamble nil :sitemap-sort-folders ignore-errors :sitemap-function my-blog-sitemap - ;:sitemap-function org-publish-sitemap-default - ;:sitemap-format-entry my-org-publish-sitemap-default-entry :sitemap-sort-files anti-chronologically :sitemap-filename "sitemap.org" ) @@ -255,5 +288,24 @@ representation for the files to include, as returned by :publishing-function org-publish-attachment :completion-function my-blog-cleanup-sitemaps ) + + ("rss" + :base-directory ,my-blog-posts-folder + :base-extension "org" + :publishing-directory ,my-blog-target-folder + :publishing-function org-rss-publish-to-rss + :with-author t - ("website" :components ("posts" "tags" "landing" "assets")))) + :html-link-home "https://www.vanrenterghem.biz/" + :html-link-use-abs-url t + + :title "Frederik Vanrenterghem" + :rss-image-url "https://test/img/feed-icon-28x28.png" + ;:my-rss-stylesheet "/res/rss.xsl" ; custom style sheet + ;:completion-function my-website-rss-postprocessor + :section-numbers nil + :exclude ".*" + :include ("rss.org") + :table-of-contents nil) + + ("website" :components ("posts" "rss" "tags" "landing" "assets")))) -- 2.39.5