From e9795c6b134eed858ddb73c036ff5c941d7e9838 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Fri, 18 Jun 2021 17:47:12 +1000 Subject: Updated. --- publish.el | 53 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 20 deletions(-) (limited to 'publish.el') diff --git a/publish.el b/publish.el index ee580f0..664be9a 100644 --- a/publish.el +++ b/publish.el @@ -2,16 +2,20 @@ (defvar this-date-format "%Y-%m-%d") -(defun me/html-preamble-post (plist) +(defun me/html-preamble (plist) "PLIST: An entry." (if (org-export-get-date plist this-date-format) (plist-put plist - :subtitle (format "Published on %s by %s" + :subtitle (format "Published on %s" (org-export-get-date plist this-date-format) - (car (plist-get plist :author))))) + ))) ;; Preamble (with-temp-buffer - (insert-file-contents "../html-templates/post-preamble.html") (buffer-string))) + (insert-file-contents "../html-templates/preamble.html") (buffer-string))) + +(defun me/html-postamble (plist) + (with-temp-buffer + (insert-file-contents "../html-templates/postamble.html") (buffer-string))) (defun me/org-posts-sitemap-format-entry (entry style project) "Format posts with author and published data in the index page. @@ -20,11 +24,12 @@ ENTRY: file-name STYLE: PROJECT: `posts in this case." (cond ((not (directory-name-p entry)) - (format "*[[file:posts/%s][%s]]* - %s" + (format "%s - *[[file:posts/%s][%s]]*" + (format-time-string this-date-format + (org-publish-find-date entry project)) entry (org-publish-find-title entry project) - (format-time-string this-date-format - (org-publish-find-date entry project)))) + )) ((eq style 'tree) (file-name-nondirectory (directory-file-name entry))) (t entry))) @@ -57,50 +62,57 @@ STYLE: PROJECT: `posts in this case." (cond ((not (directory-name-p entry)) (format "*[[%s][%s]]* - %s\n<<%s>>\n\n%s" - (org-publish-find-title entry project) + (file-name-sans-extension entry) (format-time-string this-date-format (org-publish-find-date entry project)) (org-publish-find-title entry project) - (org-publish-find-title entry project) + (file-name-sans-extension entry) (org-publish-find-content entry project) )) ((eq style 'tree) (file-name-nondirectory (directory-file-name entry))) (t entry))) +(defun me/org-publish-microblog (plist filename pub-dir) + "Publish RSS with PLIST, only when FILENAME is '../pages/microblog.org'. +PUB-DIR is when the output will be placed." + (if (equal "../pages/microblog.org" (file-name-nondirectory filename)) + (org-html-publish-to-html plist filename pub-dir))) + (setq org-publish-project-alist '(("posts" :base-directory "posts/" :base-extension "org" :publishing-directory "site/posts" - :recursive t + :recursive nil :publishing-function org-html-publish-to-html :auto-sitemap t + :section-numbers nil :sitemap-format-entry me/org-posts-sitemap-format-entry - :sitemap-title "All posts" + :sitemap-title "Yuchen's Blog" :sitemap-sort-files anti-chronologically :sitemap-filename "../pages/blog.org" :html-head "" - :html-preamble me/html-preamble-post + :html-preamble me/html-preamble :html-self-link-headlines t :author ("Yuchen Pei") - :html-postamble "" + :html-postamble me/html-postamble ) ("microposts" :base-directory "microposts/" :base-extension "org" :publishing-directory "site/microposts" :recursive t - :publishing-function org-html-publish-to-html + :publishing-function me/org-publish-microblog :auto-sitemap t :sitemap-format-entry me/org-microposts-sitemap-format-entry :sitemap-function me/org-microposts-sitemap - :sitemap-title "Microblog" + :sitemap-title "Yuchen's Microblog" :sitemap-sort-files anti-chronologically :sitemap-filename "../pages/microblog.org" :html-head "" - :html-preamble me/html-preamble-post + :html-preamble me/html-preamble :author ("Yuchen Pei") - :html-postamble "" + :html-postamble me/html-postamble ) ("pages" :base-directory "pages/" @@ -108,10 +120,11 @@ PROJECT: `posts in this case." :publishing-directory "site/" :recursive t :publishing-function org-html-publish-to-html - :html-head "" - :html-preamble me/html-preamble-post + :html-head " + " + :html-preamble me/html-preamble :author ("Yuchen Pei") - :html-postamble "" + :html-postamble me/html-postamble :html-prefer-user-labels t ) ("css" -- cgit v1.2.3