From 58bdb5832e7945c399bf03c7d9e1762ec5be0502 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Fri, 20 Mar 2026 17:10:15 -0500 Subject: [PATCH] org publish trying to async --- org-publish.el | 112 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/org-publish.el b/org-publish.el index e69de29b..3b8b4fa0 100644 --- a/org-publish.el +++ b/org-publish.el @@ -0,0 +1,112 @@ +(require 'ox-publish) +(require 'denote) +(require 'denote-org) +(require 'async) + +(defun chris/org-publish-site () + "Publish my website by pushing files to specific locations" + (interactive) + (let* ((notes (directory-files "~/docs/notes" t ".*.org")) + (lessons (directory-files "~/docs/notes/lessons" t ".*.org")) + (denote-directory "~/docs/site/content") + (current-notes (directory-files "~/docs/site/content/notes" t ".*.org")) + (current-lessons (directory-files "~/docs/site/content/teaching" t ".*.org"))) + + (message "Starting site build") + (cl-loop for file in current-notes + do (delete-file file t)) + (message "Removed all notes") + (cl-loop for file in current-lessons + do (delete-file file t)) + (message "Removed all lessons") + (cl-loop for file in notes + do (let ((filename (f-filename file))) + (if (not + (string-match-p "\\(_draft\\|_lesson\\|_sermon\\)" filename)) + (copy-file + file (concat "~/docs/site/content/notes/" filename) t)))) + (message "Copied all notes") + (cl-loop for file in lessons + do (let ((filename (f-filename file))) + (if (not + (string-match-p "\\(_draft\\)" filename)) + (copy-file + file (concat "~/docs/site/content/teaching/" filename) t)))) + (message "Copied all lessons") + + (async-start + (lambda () + (require 'org) + (require 'denote) + (require 'denote-org) + (find-file "~/docs/site/content/index.org") + (with-current-buffer (current-buffer) + (org-update-all-dblocks) + (save-buffer)) + (org-publish "cochrun.xyz")) + (lambda (result) + ;; (message result) + (message "Finished publishing site"))))) + +(defun chris/website-dynamic-block () + "A function to load up the links on the homepage for the website" + (let (files (directory-files "~/docs/site/content/notes/" t ".*.org")) + (cl-loop for file in files + do (insert (denote--link-get-description file))))) + +(defun org-dblock-write:chris-site-notes () + "A function to load up the links on the homepage for the website" + (let (files (directory-files "~/docs/site/content/notes/" t ".*.org")) + (cl-loop for file in files + do (insert (denote--link-get-description file))))) + +(add-to-list 'org-dynamic-block-alist '("chris-site-notes" . chris/website-dynamic-block)) + +(setq org-publish-project-alist + `(("home" + :base-directory "~/docs/site/content" + :base-extension "org" + :recursive nil + :html-doctype "html5" + :html-html5-fancy t + :html-self-link-headlines t + :html-head "" + :html-head "" + :publishing-directory "~/docs/notes/site/public/" + :publishing-function org-html-publish-to-html) + ("posts" + :base-directory "~/docs/site/content/notes" + :base-extension "org" + :recursive nil + :html-doctype "html5" + :html-html5-fancy t + :html-self-link-headlines t + :htmlized-source t + :html-head "" + :publishing-directory "~/docs/site/public/notes/" + :publishing-function org-html-publish-to-html) + ("teaching" + :base-directory "~/docs/site/content/teaching" + :base-extension "org" + :recursive nil + :html-doctype "html5" + :html-html5-fancy t + :html-self-link-headlines t + :htmlized-source t + :html-head "" + :publishing-directory "~/docs/site/public/teaching/" + :publishing-function org-html-publish-to-html) + ("static" + :base-directory "~/docs/site/assets/" + :base-extension "css\\|txt\\|jpg\\|gif\\|png" + :recursive t + :html-doctype "html5" + :html-html5-fancy t + :publishing-directory "~/docs/site/public/static/" + :publishing-function org-publish-attachment) + ("cochrun.xyz" :components ("home" "posts" "static" "teaching")))) + +(setq org-html-postamble t + org-html-postamble-format '(("en" + ""))) +