publish now works when run as script and with 5 exports in parallel
This commit is contained in:
parent
58bdb5832e
commit
7a43939b29
1 changed files with 119 additions and 72 deletions
191
org-publish.el
191
org-publish.el
|
|
@ -2,15 +2,22 @@
|
|||
(require 'denote)
|
||||
(require 'denote-org)
|
||||
(require 'async)
|
||||
(require 'dash)
|
||||
(require 's)
|
||||
(require 'f)
|
||||
|
||||
(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"))
|
||||
(let* ((notes (--remove
|
||||
(string-match-p "\\(_draft\\|_lesson\\|_sermon\\)" it)
|
||||
(directory-files "~/docs/notes" t ".*.org$")))
|
||||
(lessons (--remove
|
||||
(s-contains? "_draft" it)
|
||||
(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")))
|
||||
(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
|
||||
|
|
@ -21,32 +28,71 @@
|
|||
(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))))
|
||||
(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))))
|
||||
(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")))))
|
||||
(let* ((files (seq-concatenate
|
||||
'list
|
||||
(directory-files "~/docs/site/content/notes" t ".*.org$")
|
||||
(directory-files "~/docs/site/content/teaching" t ".*.org$")))
|
||||
(counter 0))
|
||||
(cl-loop for file in files and index from 0
|
||||
do (let ((func `(lambda ()
|
||||
(setq lexical-binding t)
|
||||
(require 's)
|
||||
(require 'org)
|
||||
(require 'ox)
|
||||
(require 'ox-html)
|
||||
(require 'htmlize)
|
||||
(require 'denote)
|
||||
(require 'denote-org)
|
||||
(with-current-buffer (find-file ,file)
|
||||
(re-search-forward "EXPORT_FILE_NAME" nil t)
|
||||
(beginning-of-line)
|
||||
(let* ((export-line (delete-and-extract-region
|
||||
(line-beginning-position) (line-end-position)))
|
||||
(org-export-with-broken-links t)
|
||||
(org-export-with-section-numbers nil)
|
||||
(org-html-html5-fancy t)
|
||||
(org-html-validation-link nil)
|
||||
(make-backup-files nil)
|
||||
(denote-directory "/home/chris/docs/site/content")
|
||||
(org-html-head "<link rel=\"stylesheet\" href=\"../static/pico.cyan.css\">")
|
||||
(export-directory
|
||||
(concat "/home/chris/"
|
||||
"docs/site/public/"
|
||||
(if (s-contains? "content/teaching" ,file)
|
||||
"teaching/"
|
||||
"notes/")))
|
||||
(html-file (concat export-directory
|
||||
(org-export-output-file-name ".html")))
|
||||
(org-export-coding-system org-html-coding-system))
|
||||
(denote-org-convert-links-to-file-type)
|
||||
(widen)
|
||||
(org-update-all-dblocks)
|
||||
(replace-string-in-region "../site/content/" "./"
|
||||
(point-min) (point-max))
|
||||
(org-export-to-file 'html html-file)
|
||||
(insert export-line)
|
||||
(save-buffer)
|
||||
(kill-buffer))))))
|
||||
|
||||
(setq counter (+ counter 1))
|
||||
(while (> counter 5)
|
||||
(sit-for 0.5))
|
||||
(async-start
|
||||
func
|
||||
(lambda (result)
|
||||
(message "Note %s out of %s finished: %s" index (length files) file)
|
||||
(setq counter (- counter 1))))
|
||||
|
||||
)))))
|
||||
|
||||
(defun chris/website-dynamic-block ()
|
||||
"A function to load up the links on the homepage for the website"
|
||||
|
|
@ -60,53 +106,54 @@
|
|||
(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))
|
||||
;; (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 "<link rel=\"stylesheet\" href=\"pico.cyan.css\" type=\"text/css\"/>"
|
||||
:html-head "<link rel=\"stylesheet\" href=\"my.css\" type=\"text/css\"/>"
|
||||
: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 "<link rel=\"stylesheet\" href=\"../pico.cyan.css\" type=\"text/css\"/>"
|
||||
: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 "<link rel=\"stylesheet\" href=\"../pico.cyan.css\" type=\"text/css\"/>"
|
||||
: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-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 "<link rel=\"stylesheet\" href=\"pico.cyan.css\" type=\"text/css\"/>"
|
||||
;; :html-head "<link rel=\"stylesheet\" href=\"my.css\" type=\"text/css\"/>"
|
||||
;; :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 "<link rel=\"stylesheet\" href=\"../pico.cyan.css\" type=\"text/css\"/>"
|
||||
;; :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 "<link rel=\"stylesheet\" href=\"../pico.cyan.css\" type=\"text/css\"/>"
|
||||
;; :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"
|
||||
"<footer> <p>Author: %a (%e)</p></footer>")))
|
||||
;; (setq org-html-postamble t
|
||||
;; org-html-postamble-format '(("en"
|
||||
;; "<footer> <p>Author: %a (%e)</p></footer>")))
|
||||
(chris/org-publish-site)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue