From: Frederik Vanrenterghem Date: Fri, 22 Dec 2023 08:28:21 +0000 (+0800) Subject: Werkt enigszins. X-Git-Url: http://git.vanrenterghem.biz/www2.vanrenterghem.biz.git/commitdiff_plain/eac690c1a5847bbf3a11a488bf13dc0905acacd0?hp=372278160939f3119c273dd968a7f0a40a95bd3d Werkt enigszins. --- diff --git a/maak-website.el b/maak-website.el index b5c8826..396bead 100644 --- a/maak-website.el +++ b/maak-website.el @@ -1,3 +1,5 @@ +(require 'cl-lib) +(require 'org) (require 'ox-publish) (require 'ox-rss) (load "~/.emacs.d/lisp/mustache-html.el") @@ -10,6 +12,7 @@ (setq my-blog-base-folder "~/websites/stage.vanrenterghem.biz") (setq my-blog-source-folder "~/websites/stage.vanrenterghem.biz/source") (setq my-blog-target-folder "~/websites/stage.vanrenterghem.biz/target") +(setq my-blog-target-url "https://www.vanrenterghem.biz/posts/") (setq my-blog-mustache-folder (file-name-concat my-blog-base-folder "html")) (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")) @@ -120,7 +123,6 @@ 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)) @@ -138,10 +140,11 @@ 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-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)) ;; insert the date, preview, & read more link (insert (concat "Published: " date "\n\n")) (insert preview) @@ -179,6 +182,43 @@ 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 @@ -294,21 +334,21 @@ representation for the files to include, as returned by ("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 - - :html-link-home "https://www.vanrenterghem.biz/" + :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 + :html-link-home ,my-blog-target-url :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) + ;: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 + ) ("website" :components ("posts" "rss" "tags" "landing" "assets"))))