changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / emacs/lib/publish.el

changeset 637: b88bf15f60d0
parent: 8a5921bf004e
child: 6c0e4a44c082
author: Richard Westhaver <ellis@rwest.io>
date: Wed, 04 Sep 2024 22:02:21 -0400
permissions: -rw-r--r--
description: parquet tweaks, import ox-man
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 (require 'ox-man)
10 ;; vendored
11 (require 'htmlize)
12 (defvar project-dir "~/comp/org")
13 (defvar publish-dir "/tmp/www")
14 (defvar html-theme nil)
15 (defvar url "https://compiler.company")
16 (defvar vc-url "https://vc.compiler.company")
17 (defvar packy-url "https://packy.compiler.company")
18 (defvar html-foot "<footer><p>updated %C</p></footer>")
19 
20 ;; (setq org-protocol-project-alist
21 ;; '(("comp"
22 ;; :base-url url
23 ;; :working-directory project-dir
24 ;; :online-suffix ".html"
25 ;; :working-suffix ".org")))
26 
27 (setq org-html-style-default ""
28  ;; org-html-scripts ""
29  org-html-htmlize-output-type 'css
30  org-export-htmlize-output-type 'css
31  org-export-allow-bind-keywords t
32  org-html-doctype "html5"
33  org-html-html5-fancy t
34  ;; org-html-validation-link nil
35  org-src-fontify-natively t
36  make-backup-files nil
37  debug-on-error t
38  org-id-link-to-org-use-id t)
39 
40 (setq org-html-link-up "")
41 (setq org-html-link-home url)
42 
43 (setq org-html-home/up-format "<div id=\"org-div-home-and-up\"><a href=\"%s\" accesskey=\"h\"><button class=home>~</button></a>
44 <button accesskey=\"s\" class=show onclick=open_all_sections()>show</button> <button accesskey=\"x\" class=hide onclick=close_all_sections()>hide</button></div>")
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