From 1d6a9213cbfa2d192e8ae305f33bfcdd1f75f2b0 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 25 Jul 2023 11:45:22 -0700 Subject: [PATCH] =?UTF-8?q?Extract=20=E2=80=98publish-get-summary-from-fil?= =?UTF-8?q?e=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish.el | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/publish.el b/publish.el index 11aca3d..1b3bac2 100644 --- a/publish.el +++ b/publish.el @@ -52,6 +52,20 @@ time (if (= time 1) "" "s"))) +(defun publish-get-summary-from-file (file props) + (format "* %s\n:PROPERTIES:\n:CUSTOM_ID: %s\n:PUBDATE: %s\n:RSS_PERMALINK: %s\n:END:\n\n%s\n\n[[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))) + (defun publish-generate-index (props) "Generate an index from my posts. Argument PROPS @@ -62,19 +76,7 @@ Argument PROPS (insert "#+options: num:nil\n") (insert "\n") (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\n\n[[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))) + (mapcar (lambda (file) (publish-get-summary-from-file file props)) (take 30 (reverse files)))) (write-file "posts/index.org"))))