changeset 629: |
ab02408636b7 |
parent: |
5e57683a0c28
|
child: |
8a5921bf004e |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Tue, 27 Aug 2024 21:36:50 -0400 |
permissions: |
-rw-r--r-- |
description: |
elisp work, added slime-company (to be deprecated) |
1 ;;; publish.el --- the.compiler.company publishing script -*- lexical-binding:t -*- 3 ;; emacsclient -e '(load-file "publish.el")' '(publish)' 11 (defvar project-dir "~/comp/org") 12 (defvar publish-dir "/tmp/www") 13 (defvar html-theme nil) 14 (defvar url "https://compiler.company") 15 (defvar vc-url "https://vc.compiler.company") 16 (defvar packy-url "https://packy.compiler.company") 17 (defvar html-foot "<footer><p>updated %C</p></footer>") 19 ;; (setq org-protocol-project-alist 22 ;; :working-directory project-dir 23 ;; :online-suffix ".html" 24 ;; :working-suffix ".org"))) 26 (setq org-html-style-default "" 27 ;; org-html-scripts "" 28 org-html-htmlize-output-type 'css 29 org-export-htmlize-output-type 'css 30 org-export-allow-bind-keywords t 31 org-html-doctype "html5" 32 org-html-html5-fancy t 33 ;; org-html-validation-link nil 34 org-src-fontify-natively t 37 org-id-link-to-org-use-id t) 39 (setq org-html-link-up "") 40 (setq org-html-link-home url) 42 (setq org-html-home/up-format "<div id=\"org-div-home-and-up\"><a accesskey=\"H\" href=\"%s\"> HOME </a></div>") 46 (setq org-publish-project-alist 47 `(("compiler.company" :components ("index" "meta" "blog" "docs" "notes" "plan")) 49 :base-directory ,project-dir 54 :html-doctype "<!doctype html>" 55 :html-postamble ,html-foot 56 :publishing-directory ,publish-dir 57 :publishing-function org-html-publish-to-html) 59 :base-directory ,(expand-file-name "meta" project-dir) 63 :html-doctype "<!doctype html>" 64 :publishing-directory ,(expand-file-name "meta" publish-dir) 65 :publishing-function org-html-publish-to-html 67 :html-postamble ,html-foot) 69 :base-directory ,(expand-file-name "blog" project-dir) 73 :html-doctype "<!doctype html>" 74 :publishing-directory ,(expand-file-name "blog" publish-dir) 75 :publishing-function org-html-publish-to-html 77 :html-postamble ,html-foot) 79 :base-directory ,(expand-file-name "plan" project-dir) 83 :html-doctype "<!doctype html>" 84 :publishing-directory ,(expand-file-name "plan" publish-dir) 85 :publishing-function org-html-publish-to-html 87 :html-postamble ,html-foot) 89 :base-directory ,(expand-file-name "notes" project-dir) 93 :html-doctype "<!doctype html>" 94 :publishing-directory ,(expand-file-name "notes" publish-dir) 95 :publishing-function org-html-publish-to-html 97 :html-postamble ,html-foot) 99 :base-directory ,(expand-file-name "docs" project-dir) 100 :base-extension "org" 102 :footnote-section-p t 103 :html-doctype "<!doctype html>" 104 :publishing-directory ,(expand-file-name "docs" publish-dir) 105 :publishing-function org-html-publish-to-html 107 :html-postamble ,html-foot))) 109 ;; (defun org-export-get-reference-title (datum info) 110 ;; "Like `org-export-get-reference', except uses heading titles instead of random numbers." 111 ;; (let ((cache (plist-get info :internal-references))) 112 ;; (or (car (rassq datum cache)) 113 ;; (let* ((crossrefs (plist-get info :crossrefs)) 114 ;; (cells (org-export-search-cells datum)) 115 ;; ;; Preserve any pre-existing association between 116 ;; ;; a search cell and a reference, i.e., when some 117 ;; ;; previously published document referenced a location 118 ;; ;; within current file (see 119 ;; ;; `org-publish-resolve-external-link'). 121 ;; ;; However, there is no guarantee that search cells are 122 ;; ;; unique, e.g., there might be duplicate custom ID or 123 ;; ;; two headings with the same title in the file. 125 ;; ;; As a consequence, before re-using any reference to 126 ;; ;; an element or object, we check that it doesn't refer 127 ;; ;; to a previous element or object. 130 ;; (let ((stored (cdr (assoc cell crossrefs)))) 132 ;; (let ((old (org-export-format-reference stored))) 133 ;; (and (not (assoc old cache)) stored))))) 135 ;; (when (org-element-property :raw-value datum) 136 ;; ;; Heading with a title 137 ;; (org-export-new-title-reference datum cache)) 138 ;; ;; NOTE: This probably breaks some Org Export 139 ;; ;; feature, but if it does what I need, fine. 140 ;; (org-export-format-reference 141 ;; (org-export-new-reference cache)))) 142 ;; (reference-string new)) 143 ;; ;; Cache contains both data already associated to 144 ;; ;; a reference and in-use internal references, so as to make 145 ;; ;; unique references. 146 ;; (dolist (cell cells) (push (cons cell new) cache)) 147 ;; ;; Retain a direct association between reference string and 148 ;; ;; DATUM since (1) not every object or element can be given 149 ;; ;; a search cell (2) it permits quick lookup. 150 ;; (push (cons reference-string datum) cache) 151 ;; (plist-put info :internal-references cache) 152 ;; reference-string)))) 154 ;; (defun org-export-new-title-reference (datum cache) 155 ;; "Return new reference for DATUM that is unique in CACHE." 156 ;; (cl-macrolet ((inc-suffixf (place) 158 ;; (string-match (rx bos 159 ;; (minimal-match (group (1+ anything))) 160 ;; (optional "--" (group (1+ digit))) 163 ;; ;; HACK: `s1' instead of a gensym. 164 ;; (-let* (((s1 suffix) (list (match-string 1 ,place) 165 ;; (match-string 2 ,place))) 166 ;; (suffix (if suffix 167 ;; (string-to-number suffix) 169 ;; (setf ,place (format "%s--%s" s1 (cl-incf suffix))))))) 170 ;; (let* ((title (org-element-property :raw-value datum)) 171 ;; (ref (url-hexify-string (substring-no-properties title))) 172 ;; (parent (org-element-property :parent datum))) 173 ;; (while (--any (equal ref (car it)) 175 ;; ;; Title not unique: make it so. 177 ;; ;; Append ancestor title. 178 ;; (setf title (concat (org-element-property :raw-value parent) 180 ;; ref (url-hexify-string (substring-no-properties title)) 181 ;; parent (org-element-property :parent parent)) 182 ;; ;; No more ancestors: add and increment a number. 183 ;; (inc-suffixf ref))) 187 (defun publish (&optional sitemap static force async) 188 "publish `rwest-io' content. 189 If STATIC is t, also publish media and static files. 190 If FORCE is t, skip checking file mod date and just publish all files. 191 If ASYNC is t, call `org-publish' asynchronously. 192 If given a prefix (C-u), set all args to t" 194 (if current-prefix-arg 198 (let ((default-directory project-dir)) 199 (message (format "publishing from %s" default-directory)) 200 (org-publish "compiler.company" force async))) 203 ;;; publish.el ends here