getting the build to work, needs to update the index.org file yet
This commit is contained in:
parent
58653339ad
commit
2eff64054d
1 changed files with 164 additions and 63 deletions
227
org-publish.el
227
org-publish.el
|
|
@ -5,6 +5,7 @@
|
|||
(require 'dash)
|
||||
(require 's)
|
||||
(require 'f)
|
||||
(require 'comp-run)
|
||||
|
||||
(defun quick/async-export-function (chunk index)
|
||||
"A function to build a future that will export all it's chunk's files"
|
||||
|
|
@ -145,11 +146,54 @@
|
|||
(mapcar #'async-get futures)
|
||||
(message "Finished exporting all files"))))
|
||||
|
||||
(defun quick/org-copy-notes (plist)
|
||||
(message "%s" plist)
|
||||
(let ((files (--remove
|
||||
(string-match-p (plist-get plist :exclude) it)
|
||||
(directory-files "~/docs/notes" t ".*.org$"))))
|
||||
(dolist (file files)
|
||||
(let ((filename (concat (file-name-as-directory
|
||||
(plist-get plist :base-directory))
|
||||
(f-filename file))))
|
||||
(copy-file
|
||||
file filename t t)))))
|
||||
|
||||
(defun quick/org-copy-lessons (plist)
|
||||
(let ((files (--remove
|
||||
(string-match-p (plist-get plist :exclude) it)
|
||||
(directory-files "~/docs/notes/lessons" t ".*.org$"))))
|
||||
(dolist (file files)
|
||||
(let ((filename (concat (file-name-as-directory
|
||||
(plist-get plist :base-directory))
|
||||
(f-filename file))))
|
||||
(copy-file
|
||||
file filename t t)))))
|
||||
|
||||
(defun chris/site-index-update (plist)
|
||||
(save-excursion
|
||||
(let ((warning-minimum-level :error)
|
||||
(denote-directory "~/docs/site/content")
|
||||
(file (concat (file-name-as-directory
|
||||
(plist-get plist :base-directory)) "index.org")))
|
||||
(find-file file)
|
||||
(message "Inside update func: %s" file)
|
||||
(org-update-all-dblocks))))
|
||||
|
||||
(setq org-publish-project-alist
|
||||
`(("notes"
|
||||
:base-directory "~/docs/site/content/notes"
|
||||
:base-directory "~/docs/site/content/notes/"
|
||||
:base-extension "org"
|
||||
:exclude "\\(_draft\\|_lesson\\|_sermon\\)"
|
||||
:preparation-function quick/org-copy-notes
|
||||
:recursive nil
|
||||
:with-broken-links t
|
||||
:with-author nil
|
||||
:with-timestamps nil
|
||||
:section-numbers nil
|
||||
:html-postamble nil
|
||||
:html-validation-link nil
|
||||
:exlude-tags "revealonly\\|noexport"
|
||||
:html-head-include-default-style nil
|
||||
:html-doctype "html5"
|
||||
:html-html5-fancy t
|
||||
:html-self-link-headlines t
|
||||
|
|
@ -158,78 +202,139 @@
|
|||
:publishing-directory "~/docs/site/public/notes/"
|
||||
:publishing-function org-html-publish-to-html)
|
||||
("teaching"
|
||||
:base-directory "~/docs/site/content/teaching"
|
||||
:base-directory "~/docs/site/content/teaching/"
|
||||
:base-extension "org"
|
||||
:preparation-function quick/org-copy-lessons
|
||||
:exclude "_draft"
|
||||
:recursive nil
|
||||
:with-broken-links t
|
||||
:with-author nil
|
||||
:with-timestamps nil
|
||||
:section-numbers nil
|
||||
:html-postamble nil
|
||||
:exlude-tags "revealonly\\|noexport"
|
||||
:html-head-include-default-style nil
|
||||
:html-doctype "html5"
|
||||
:html-html5-fancy t
|
||||
:html-self-link-headlines t
|
||||
:html-validation-link nil
|
||||
:htmlized-source t
|
||||
:html-head "<link rel=\"stylesheet\" href=\"../static/pico.snazzy.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"
|
||||
:base-extension "css\\|txt\\|jpg\\|gif\\|png\\|webp\\|webm\\|mp4\\|js\\|html"
|
||||
:recursive t
|
||||
:html-doctype "html5"
|
||||
:html-html5-fancy t
|
||||
:publishing-directory "~/docs/site/public/static/"
|
||||
:publishing-function org-publish-attachment)
|
||||
("cochrun.xyz" :components ("notes" "static" "teaching"))))
|
||||
("index"
|
||||
:base-directory "~/docs/site/content"
|
||||
:base-extension "org"
|
||||
:preparation-function chris/site-index-update
|
||||
:recursive nil
|
||||
:with-broken-links t
|
||||
:with-author nil
|
||||
:with-timestamps nil
|
||||
:with-toc nil
|
||||
:section-numbers nil
|
||||
:html-postamble nil
|
||||
:html-validation-link nil
|
||||
:exlude-tags "revealonly\\|noexport"
|
||||
:html-head-include-default-style nil
|
||||
:html-doctype "html5"
|
||||
:html-html5-fancy t
|
||||
:html-self-link-headlines t
|
||||
:htmlized-source t
|
||||
:html-head "<link rel=\"stylesheet\" href=\"./static/pico.snazzy.css\" type=\"text/css\"/>"
|
||||
:publishing-directory "~/docs/site/public/"
|
||||
:publishing-function org-html-publish-to-html)
|
||||
("cochrun.xyz" :components ("index" "notes" "static" "teaching"))))
|
||||
|
||||
(defun quick/org-publish-project (project workers)
|
||||
(defun quick/org-publish-projects (projects &optional workers)
|
||||
"Publish all files belonging to the PROJECT.
|
||||
If `:auto-sitemap' is set, publish the sitemap too. If
|
||||
`:makeindex' is set, also produce a file \"theindex.org\"."
|
||||
(let ((plist (cdr project)))
|
||||
(let ((fun (org-publish-property :preparation-function project)))
|
||||
(cond
|
||||
((functionp fun) (funcall fun plist))
|
||||
((consp fun) (dolist (f fun) (funcall f plist)))))
|
||||
;; Each project uses its own cache file.
|
||||
(org-publish-initialize-cache (car project))
|
||||
(when (org-publish-property :auto-sitemap project)
|
||||
(let ((sitemap-filename
|
||||
(or (org-publish-property :sitemap-filename project)
|
||||
"sitemap.org")))
|
||||
(org-publish-sitemap project sitemap-filename)))
|
||||
;; Publish all files from PROJECT except "theindex.org". Its
|
||||
;; publishing will be deferred until "theindex.inc" is
|
||||
;; populated.
|
||||
(let ((theindex
|
||||
(expand-file-name "theindex.org"
|
||||
(org-publish-property :base-directory project))))
|
||||
(dolist (file (org-publish-get-base-files project))
|
||||
(unless (file-equal-p file theindex)
|
||||
(org-publish-file file project t)))
|
||||
;; Populate "theindex.inc", if needed, and publish
|
||||
;; "theindex.org".
|
||||
(when (org-publish-property :makeindex project)
|
||||
(org-publish-index-generate-theindex
|
||||
project (org-publish-property :base-directory project))
|
||||
(org-publish-file theindex project t)))
|
||||
(let ((fun (org-publish-property :completion-function project)))
|
||||
(cond
|
||||
((functionp fun) (funcall fun plist))
|
||||
((consp fun) (dolist (f fun) (funcall f plist)))))))
|
||||
`:makeindex' is set, also produce a file \"theindex.org\".
|
||||
|
||||
(defun quick/org-async-function (project workers))
|
||||
If the optional argument WORKERS is used, this many instances
|
||||
of emacs will be used in order to publish the files, else
|
||||
it will use the correct amount of "
|
||||
(dolist (project (org-publish-expand-projects projects))
|
||||
(let ((plist (cdr project))
|
||||
(create-lockfiles nil)
|
||||
(org-publish-timestamp-directory
|
||||
(concat (xdg-cache-home) "/org/timestamps/")))
|
||||
(let ((fun (org-publish-property :preparation-function project)))
|
||||
(cond
|
||||
((functionp fun) (funcall fun plist))
|
||||
((consp fun) (dolist (f fun) (funcall f plist)))))
|
||||
;; Each project uses its own cache file.
|
||||
(org-publish-initialize-cache (car project))
|
||||
(when (org-publish-property :auto-sitemap project)
|
||||
(let ((sitemap-filename
|
||||
(or (org-publish-property :sitemap-filename project)
|
||||
"sitemap.org")))
|
||||
(org-publish-sitemap project sitemap-filename)))
|
||||
;; Publish all files from PROJECT except "theindex.org". Its
|
||||
;; publishing will be deferred until "theindex.inc" is
|
||||
;; populated.
|
||||
;; (message "%s" (org-publish-get-base-files project))
|
||||
;; (message "%s" project)
|
||||
(let* ((theindex
|
||||
(expand-file-name "theindex.org"
|
||||
(org-publish-property :base-directory project)))
|
||||
(attachment-function? (eq #'org-publish-attachment
|
||||
(org-publish-property :publishing-function project)))
|
||||
(workers (if workers workers
|
||||
(* 2 (comp--effective-async-max-jobs))))
|
||||
(files (org-publish-get-base-files project))
|
||||
(chunks (if (> workers (length files))
|
||||
files
|
||||
(seq-split files (ceiling (/ (length files) workers)))))
|
||||
(futures (if attachment-function?
|
||||
nil
|
||||
(cl-loop for chunk in chunks
|
||||
collect (async-start
|
||||
`(lambda ()
|
||||
(require 'ox)
|
||||
(require 'ox-html)
|
||||
(require 'htmlize)
|
||||
(let ((org-publish-use-timestamps-flag t)
|
||||
(org-publish-timestamp-directory
|
||||
(concat (xdg-cache-home) "/org/timestamps/"))
|
||||
(create-lockfiles nil)
|
||||
(org-publish-cache (org-publish-initialize-cache
|
||||
(car ',project)))
|
||||
(files (if (listp ',chunk)
|
||||
',chunk
|
||||
(list ,chunk))))
|
||||
(dolist (file files)
|
||||
(unless (file-equal-p file ,theindex)
|
||||
(org-publish-file file ',project t)))))
|
||||
'ignore)))))
|
||||
|
||||
;; This might be a helper function to setup our number of workers?
|
||||
(defun quick/org-async-publisher (projects &optional workers)
|
||||
"Builds a set of workers in the project that will
|
||||
be responsible for ensuring all files are exported using
|
||||
the most efficient outcome for your machine.
|
||||
(if attachment-function?
|
||||
(dolist (file files)
|
||||
(unless (file-equal-p file theindex)
|
||||
(org-publish-file file project t)))
|
||||
(mapcar #'async-get futures))
|
||||
|
||||
When optional argument WORKERS is a number, publishing will use
|
||||
that many sub-emacs processes to build the projects, else it
|
||||
will use the amount of async workers that makes sense for your
|
||||
computer."
|
||||
(let ((workers (if workers workers
|
||||
(comp--effective-async-max-jobs))))
|
||||
(cl-loop for project in projects
|
||||
collect )))
|
||||
;; Populate "theindex.inc", if needed, and publish
|
||||
;; "theindex.org".
|
||||
(when (org-publish-property :makeindex project)
|
||||
(org-publish-index-generate-theindex
|
||||
project (org-publish-property :base-directory project))
|
||||
(org-publish-file theindex project t)))
|
||||
(let ((fun (org-publish-property :completion-function project)))
|
||||
(cond
|
||||
((functionp fun) (funcall fun plist))
|
||||
((consp fun) (dolist (f fun) (funcall f plist))))))))
|
||||
|
||||
(defun quick/org-async-function (files project theindex)
|
||||
"Publish all files with only knowing the files"
|
||||
(dolist (file files)
|
||||
(unless (file-equal-p file theindex)
|
||||
(org-publish-file file project t))))
|
||||
|
||||
(defun quick/org-publish (project &optional force async)
|
||||
"Publish PROJECT. This is a more aggressively async version of
|
||||
|
|
@ -254,20 +359,16 @@ on your machine as makes sense."
|
|||
(cond
|
||||
((not project))
|
||||
(async
|
||||
(quick/org-async-publisher project)
|
||||
(org-export-async-start (lambda (_) nil)
|
||||
`(let ((org-publish-use-timestamps-flag
|
||||
,(and (not force) org-publish-use-timestamps-flag)))
|
||||
;; Expand components right now as external process may not
|
||||
;; be aware of complete `org-publish-project-alist'.
|
||||
(org-publish-projects
|
||||
',(org-publish-expand-projects (list project))))))
|
||||
(let ((org-publish-use-timestamps-flag
|
||||
(and (not force) org-publish-use-timestamps-flag)))
|
||||
;; Expand components right now as external process may not
|
||||
;; be aware of complete `org-publish-project-alist'.
|
||||
(quick/org-publish-projects
|
||||
(org-publish-expand-projects (list project)))))
|
||||
(t (save-window-excursion
|
||||
(let ((org-publish-use-timestamps-flag
|
||||
(and (not force) org-publish-use-timestamps-flag)))
|
||||
(org-publish-projects (list project))))))))
|
||||
|
||||
(org-publish-expand-projects (list '("cochrun.xyz" :components ("notes" "static" "teaching"))))
|
||||
|
||||
(quick/org-publish "cochrun.xyz" nil t)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue