From 30a4eda7d3127db443aa96d7fb752a7e8bd23bc8 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 25 Jul 2023 00:58:42 -0700 Subject: [PATCH] Add function that generates index.org before publishing rss --- .gitignore | 1 + ...556-switch-todo-state-when-clocking-in.org | 3 ++- posts/index.org | 10 ------- publish.el | 26 +++++++++++++++++++ 4 files changed, 29 insertions(+), 11 deletions(-) delete mode 100644 posts/index.org diff --git a/.gitignore b/.gitignore index f6bf352..c00e0b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /.cask /public /.org-timestamps +/posts/index.org # Added automatically by `eldev init'. /.eldev diff --git a/posts/20230610-0556-switch-todo-state-when-clocking-in.org b/posts/20230610-0556-switch-todo-state-when-clocking-in.org index 87602da..65f2b51 100644 --- a/posts/20230610-0556-switch-todo-state-when-clocking-in.org +++ b/posts/20230610-0556-switch-todo-state-when-clocking-in.org @@ -5,7 +5,8 @@ #+comment_status: closed #+status: publish #+UPDATE_URL: /admin/modify-post/2023%252f07%252f10%252fswitch-todo-state-when-clocking-in -#+DATE: Mon, 10 Jul 2023 05:56:39 GMT +# #+DATE: Mon, 10 Jul 2023 05:56:39 GMT +#+DATE: [2023-07-10 Mon 05:56] #+exclude_tags: summary This Emacs configuration snippet for org-mode changes a task's state from whatever “head” state it's in into the next state in its sequence when you clock in to a task. I do this by setting the =org-clock-in-switch-to-state= variable. diff --git a/posts/index.org b/posts/index.org deleted file mode 100644 index 11b867a..0000000 --- a/posts/index.org +++ /dev/null @@ -1,10 +0,0 @@ -#+title: posts -#+select_tags: summary -#+options: tags:nil num:nil - -#+include: "./20230610-0556-switch-todo-state-when-clocking-in.org::*Switch TODO state when clocking in" -#+include: "./20230412-0702-paredit-and-ielm.org::*IELM & Paredit" -#+include: "./20200223-1828-a-very-important-blog-post.org::*A very important blog post" -#+include: "./20191006-1818-my-new-emacs-configuration.org::*My new Emacs configuration" -#+include: "./20191006-1255-new-blog.org::*New Blog" -#+include: "./20160221-0000-wdocker-compose.org::*Making docker-compose easier with wdocker" diff --git a/publish.el b/publish.el index 2458992..a7a2f0f 100644 --- a/publish.el +++ b/publish.el @@ -52,6 +52,29 @@ time (if (= time 1) "" "s"))) +(defun publish-generate-index (props) + "Generate an index from my posts. +Argument PROPS +." + (let ((files (directory-files "posts/" t (rx bos (= 8 digit) "-" (= 4 digit) "-" (one-or-more nonl) (not "~") eos)))) + (with-temp-buffer + (apply 'insert + (mapcar (lambda (file) + (format "* %s\n:PROPERTIES:\n:CUSTOM_ID: %s\n:PUBDATE: %s\n:RSS_PERMALINK: %s\n:END:\n\n%s[[file:%s][Read More]]\n\n" + (car (org-publish-find-property file :title props)) + (file-name-nondirectory file) + (format-time-string "[%Y-%m-%d %a %H:%M]" (org-timestamp-to-time (car (org-publish-find-property file :date props)))) + (file-name-nondirectory file) + (car (org-map-entries (lambda () (let ((element-data (cadr (org-element-at-point)))) + (buffer-substring-no-properties + (map-elt element-data :contents-begin) + (map-elt element-data :contents-end)))) + "summary" + (list file))) + (file-name-nondirectory file))) + (take 30 (reverse files)))) + (write-file "posts/index.org")))) + (setq org-export-exclude-tags '("noexport" "draft")) (setq org-confirm-babel-evaluate nil) @@ -99,8 +122,11 @@ :base-directory "posts/" :base-extension "org" :rss-extension "xml" + :preparation-function publish-generate-index :publishing-directory "public/posts/" :publishing-function (org-rss-publish-to-rss) + :html-link-home "https://ryuslash.org/posts/" + :html-link-use-abs-url t :section-numbers nil :exclude ".*" :include ("index.org")