X-Git-Url: https://git.shemshak.org/~bandali/bndl.org/blobdiff_plain/ed891db307af229f6179c8613d7017c14a52a570..caf3b78c74be4c0d1e53904aa258fda50e512ef0:/publish.el diff --git a/publish.el b/publish.el deleted file mode 100644 index 7acc4a5..0000000 --- a/publish.el +++ /dev/null @@ -1,114 +0,0 @@ -;; Inspiration: https://gitlab.com/ambrevar/ambrevar.gitlab.io. - -;; TODO: use git time-stamps - -(require 'ox-publish) - -(add-to-list 'load-path ".") - -(defun aminb--readfile (filepath) - "Return filepath's content." - (with-temp-buffer - (insert-file-contents filepath) - (buffer-string))) - -(defun aminb--find-replace (match-with replace-with string) - "Return the string resulting from replacing `match-with' with - `replace-with' in `string'." - (when (string-match match-with string) - (replace-match replace-with nil nil string))) - -(defun aminb--my-html-body-light-filter (output backend info) - "Make adjustments needed for dark/light mode tag to work." - (when (eq backend 'html) - (aminb--find-replace - "\n" - "\n\n" - (aminb--find-replace - "\n" - "\n\n
" - output)))) - -(add-to-list 'org-export-filter-final-output-functions - 'aminb--my-html-body-light-filter) - -;; re-defining this (originally in `ox-html.el') to add `?g' -(defun org-html-format-spec (info) - "Return format specification for preamble and postamble. -INFO is a plist used as a communication channel." - (let ((timestamp-format (plist-get info :html-metadata-timestamp-format)) - (git-repo "@%s") - (git-rev (shell-command-to-string "git rev-parse HEAD")) - (git-rev-short (shell-command-to-string "git rev-parse --short HEAD"))) - `((?t . ,(org-export-data (plist-get info :title) info)) - (?s . ,(org-export-data (plist-get info :subtitle) info)) - (?d . ,(org-export-data (org-export-get-date info timestamp-format) - info)) - (?T . ,(format-time-string timestamp-format)) - (?a . ,(org-export-data (plist-get info :author) info)) - (?e . ,(mapconcat - (lambda (e) (format "%s" e e)) - (split-string (plist-get info :email) ",+ *") - ", ")) - (?g . ,(format git-repo git-rev git-rev-short)) - (?c . ,(plist-get info :creator)) - (?C . ,(let ((file (plist-get info :input-file))) - (format-time-string timestamp-format - (and file (nth 5 (file-attributes file)))))) - (?v . ,(or (plist-get info :html-validation-link) ""))))) - -;; timestamps can be used to avoid rebuilding everything -;; should probably be put inside the public/ directory -(setq org-publish-use-timestamps-flag t - org-publish-timestamp-directory "./") - -;; get rid of index.html~ and other backup files that may be created during generation -(setq make-backup-files nil) - -(setq org-export-with-section-numbers nil - org-export-with-smart-quotes t - org-export-with-email t - org-export-with-date t - org-export-with-tags 'not-in-toc - org-export-with-toc t) - -(setq org-html-divs '((preamble "header" "preamble") - (content "main" "content") - (postamble "footer" "postamble")) - ;; TODO: link last update to commit history of file - org-html-preamble t - org-html-postamble t - org-html-preamble-format `(("en" ,(aminb--readfile "partials/preamble.html"))) - org-html-postamble-format `(("en" ,(aminb--readfile "partials/postamble.html"))) - org-html-container-element "section" - org-html-metadata-timestamp-format "%Y-%m-%d" - org-html-checkbox-type 'html - org-html-html5-fancy t - ;; use custom css - ;; this removes the dependency on `htmlize', - ;; but we also lose syntax highlighting. - org-html-htmlize-output-type nil - org-html-validation-link nil - org-html-doctype "html5") - -(setq org-publish-project-alist - (list - (list "site-org" - :base-directory "./source/" - :exclude "macros.org" - :recursive t - :publishing-function '(org-html-publish-to-html) - :publishing-directory "./public/" - :html-head-include-default-style nil - :html-head-include-scripts nil) - (list "site-static" - :base-directory "source/" - :exclude "\\.org\\'" - :base-extension 'any - :publishing-directory "./public" - :publishing-function 'org-publish-attachment - :recursive t) - (list "site" :components '("site-org")))) - -(defun aminb/publish () - (org-publish-all))