changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / emacs/lib/publish.el

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 -*-
2 
3 ;; emacsclient -e '(load-file "publish.el")' '(publish)'
4 
5 ;;; Code:
6 (require 'ox-publish)
7 (require 'org-id)
8 (require 'dash)
9 ;; vendored
10 (require 'htmlize)
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>")
18 
19 ;; (setq org-protocol-project-alist
20 ;; '(("comp"
21 ;; :base-url url
22 ;; :working-directory project-dir
23 ;; :online-suffix ".html"
24 ;; :working-suffix ".org")))
25 
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
35  make-backup-files nil
36  debug-on-error t
37  org-id-link-to-org-use-id t)
38 
39 (setq org-html-link-up "")
40 (setq org-html-link-home url)
41 
42 (setq org-html-home/up-format "<div id=\"org-div-home-and-up\"><a accesskey=\"H\" href=\"%s\"> HOME </a></div>")
43 
44 
45 
46 (setq org-publish-project-alist
47  `(("compiler.company" :components ("index" "meta" "blog" "docs" "notes" "plan"))
48  ("index"
49  :base-directory ,project-dir
50  :base-extension "org"
51  :recursive nil
52  :htmlized-source t
53  :footnote-section-p t
54  :html-doctype "<!doctype html>"
55  :html-postamble ,html-foot
56  :publishing-directory ,publish-dir
57  :publishing-function org-html-publish-to-html)
58  ("meta"
59  :base-directory ,(expand-file-name "meta" project-dir)
60  :base-extension "org"
61  :recursive nil
62  :footnote-section-p t
63  :html-doctype "<!doctype html>"
64  :publishing-directory ,(expand-file-name "meta" publish-dir)
65  :publishing-function org-html-publish-to-html
66  :htmlized-source t
67  :html-postamble ,html-foot)
68  ("blog"
69  :base-directory ,(expand-file-name "blog" project-dir)
70  :recursive t
71  :base-extension "org"
72  :footnote-section-p t
73  :html-doctype "<!doctype html>"
74  :publishing-directory ,(expand-file-name "blog" publish-dir)
75  :publishing-function org-html-publish-to-html
76  :htmlized-source t
77  :html-postamble ,html-foot)
78  ("plan"
79  :base-directory ,(expand-file-name "plan" project-dir)
80  :recursive t
81  :base-extension "org"
82  :footnote-section-p t
83  :html-doctype "<!doctype html>"
84  :publishing-directory ,(expand-file-name "plan" publish-dir)
85  :publishing-function org-html-publish-to-html
86  :htmlized-source t
87  :html-postamble ,html-foot)
88  ("notes"
89  :base-directory ,(expand-file-name "notes" project-dir)
90  :recursive t
91  :base-extension "org"
92  :footnote-section-p t
93  :html-doctype "<!doctype html>"
94  :publishing-directory ,(expand-file-name "notes" publish-dir)
95  :publishing-function org-html-publish-to-html
96  :htmlized-source t
97  :html-postamble ,html-foot)
98  ("docs"
99  :base-directory ,(expand-file-name "docs" project-dir)
100  :base-extension "org"
101  :recursive t
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
106  :htmlized-source t
107  :html-postamble ,html-foot)))
108 
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').
120 ;; ;;
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.
124 ;; ;;
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.
128 ;; (new (or (cl-some
129 ;; (lambda (cell)
130 ;; (let ((stored (cdr (assoc cell crossrefs))))
131 ;; (when stored
132 ;; (let ((old (org-export-format-reference stored)))
133 ;; (and (not (assoc old cache)) stored)))))
134 ;; cells)
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))))
153 
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)
157 ;; `(progn
158 ;; (string-match (rx bos
159 ;; (minimal-match (group (1+ anything)))
160 ;; (optional "--" (group (1+ digit)))
161 ;; eos)
162 ;; ,place)
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)
168 ;; 0)))
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))
174 ;; cache)
175 ;; ;; Title not unique: make it so.
176 ;; (if parent
177 ;; ;; Append ancestor title.
178 ;; (setf title (concat (org-element-property :raw-value parent)
179 ;; "--" title)
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)))
184 ;; ref)))
185 
186 ;;;###autoload
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"
193  (interactive)
194  (if current-prefix-arg
195  (setq static t
196  force t
197  async t))
198  (let ((default-directory project-dir))
199  (message (format "publishing from %s" default-directory))
200  (org-publish "compiler.company" force async)))
201 
202 (provide 'publish)
203 ;;; publish.el ends here