From: Frederik Vanrenterghem Date: Fri, 22 Dec 2023 09:21:45 +0000 (+0800) Subject: Voeg werkende versie met RSS toe. X-Git-Url: http://git.vanrenterghem.biz/www2.vanrenterghem.biz.git/commitdiff_plain/3ac26c17152d2b6cb8c91222a2aa6a06a5e16d8e?hp=eac690c1a5847bbf3a11a488bf13dc0905acacd0 Voeg werkende versie met RSS toe. --- diff --git a/maak-website.el b/maak-website.el index 396bead..f9a7d05 100644 --- a/maak-website.el +++ b/maak-website.el @@ -132,7 +132,7 @@ Either the section between #+BEGIN_PREVIEW and +#END_PREVIEW is used, or the fir (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/posts/")) (title (org-publish-find-title file project-plist)) - (date (format-time-string (cdr org-time-stamp-custom-formats) (org-publish-find-date file project-plist))) + (date (format-time-string (cdr org-time-stamp-formats) (org-publish-find-date file project-plist))) (preview (my-blog-get-preview abspath)) ) ;; insert a horizontal line before every post, kill the first one @@ -140,11 +140,12 @@ Either the section between #+BEGIN_PREVIEW and +#END_PREVIEW is used, or the fir (insert "-----\n") (insert (concat "* [[file:" relpath "][" title "]]\n")) ;; add properties for `ox-rss.el' here - ;(let ((rss-permalink (concat (file-name-sans-extension relpath) ".html")) - ; (rss-pubdate date)) - ; (org-mode) - ; (org-set-property "RSS_PERMALINK" rss-permalink) - ; (org-set-property "PUBDATE" rss-pubdate)) + (let ((rss-permalink (concat (file-name-sans-extension relpath) ".html")) + (rss-pubdate date)) + (org-mode) + (org-set-property "RSS_PERMALINK" rss-permalink) + (org-set-property "PUBDATE" rss-pubdate) + (org-set-property "RSS_TITLE" title)) ;; insert the date, preview, & read more link (insert (concat "Published: " date "\n\n")) (insert preview) @@ -156,7 +157,7 @@ Either the section between #+BEGIN_PREVIEW and +#END_PREVIEW is used, or the fir (let ((kill-whole-line t)) (kill-line)) ;; insert a title and save (insert "#+OPTIONS: title:nil\n") - (insert "#+TITLE: Blog\n") + (insert "#+TITLE: Frederik Vanrenterghem's blog\n") (insert "#+AUTHOR: Frederik Vanrenterghem\n") (insert "#+EMAIL: frederik@vanrenterghem.biz\n") (insert "#+OPTIONS: ^:nil\n") ; do not use underscores as subscript @@ -182,76 +183,6 @@ 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-org-rss-publish-to-rss (plist filename pub-dir) - "Publish RSS with PLIST, only when FILENAME is 'rss.org'. -PUB-DIR is when the output will be placed." - (if (equal "rss.org" (file-name-nondirectory filename)) - (org-rss-publish-to-rss plist filename pub-dir))) - -(defun my-format-rss-feed (title list) - "Generate RSS feed, as a string. -TITLE is the title of the RSS feed. LIST is an internal -representation for the files to include, as returned by -`org-list-to-lisp'. PROJECT is the current project." - (concat "#+OPTIONS: ^:nil\n" ; do not use underscores as subscript - "#+TITLE: " title "\n\n" - (org-list-to-subtree list 0))) - -(defun my-format-rss-feed-entry (entry style project) - "Format ENTRY for the RSS feed. -ENTRY is a file name. STYLE is either 'list' or 'tree'. -PROJECT is the current project." - (cond ((not (directory-name-p entry)) - (let* ((file (org-publish--expand-file-name entry project)) - (title (org-publish-find-title entry project)) - (date (format-time-string "%Y-%m-%d" (org-publish-find-date entry project))) - (link (concat my-blog-target-url (file-name-sans-extension entry) ".html"))) - (with-temp-buffer - (org-mode) - (insert (format "* [[file:%s][%s]]\n" file title)) - (org-set-property "RSS_PERMALINK" link) - (org-set-property "PUBDATE" date) - (insert-file-contents file) - (buffer-string)))) - ((eq style 'tree) - ;; Return only last subdir. - (file-name-nondirectory (directory-file-name entry))) - (t entry))) - - -(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.") - (org-mode) - (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)) - ) - (insert "#+AUTHOR: Frederik Vanrenterghem\n") - (dolist (file filenames) - (unless (eq (file-name-base file) "rss.org") - (message "Processing %s for RSS index." file) - (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 "]]")) - (org-set-property "RSS_PERMALINK" rss-permalink) - (org-set-property "PUBDATE" date) - (org-set-property "RSS_TITLE" title) - (insert preview) - (insert "\n")))) - (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")) @@ -284,7 +215,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\\|rss.org" ;"assets*\\|sitemap.org\\|index.org" ;; regexp + :exclude "html*\\|assets*\\|index.org\\|sitemap.org" ;"assets*\\|sitemap.org\\|index.org" ;; regexp :html-content-class nil :section-numbers nil :with-toc nil @@ -334,20 +265,16 @@ representation for the files to include, as returned by ("rss" :base-directory ,my-blog-posts-folder :base-extension "org" - :exclude ,(regexp-opt '("rss.org" "index.org" "sitemap.org")) :publishing-directory ,(file-name-concat my-blog-target-folder "posts") - :publishing-function my-org-rss-publish-to-rss - ;:with-author t + :publishing-function org-rss-publish-to-rss + :with-author t + :title "Frederik Vanrenterghem's blog" :html-link-home ,my-blog-target-url :html-link-use-abs-url t - ;:html-link-org-files-as-html t - :auto-sitemap t - :sitemap-filename "rss.org" - :sitemap-title "Frederik Vanrenterghem blog" - :sitemap-style list - :sitemap-sort-files anti-chronologically - :sitemap-function my-format-rss-feed - :sitemap-format-entry my-format-rss-feed-entry + :section-numbers nil + :exclude ".*" + :include ("sitemap.org") + :table-of-contents nil ) ("website" :components ("posts" "rss" "tags" "landing" "assets"))))