changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / emacs/lib/publish.el

changeset 698: 96958d3eb5b0
parent: c60decbaae3d
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 04 Oct 2024 22:04:59 -0400
permissions: -rw-r--r--
description: fixes
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 
30  org-html-htmlize-output-type 'css
31  org-export-htmlize-output-type 'css
32  org-export-allow-bind-keywords t
33  org-html-doctype "html5"
34  org-html-html5-fancy t
35  ;; org-html-validation-link nil
36  org-src-fontify-natively t
37  make-backup-files nil
38  debug-on-error t
39  org-id-link-to-org-use-id t
40  org-html-klipsify-src nil)
41 
42 (setq org-html-klipse-selection-script
43  "window.klipse_settings = {selector_eval_html: '.src-html',
44  selector_eval_js: '.src-js',
45  selector_eval_python_client: '.src-python',
46  selector_eval_scheme: '.src-scheme',
47  selector: '.src-clojure',
48  selector_eval_ruby: '.src-ruby',
49  selector_eval_clisp: '.src-lisp'};")
50 
51 (setq org-html-link-home url)
52 
53 (setq org-html-home/up-format "<nav id=\"org-div-home-and-up\"><a href=\"%s\" accesskey=\"h\"><button class=home>⌂</button></a><a href=\"%s\" accesskey=\"u\"><button class=up>▲</button></a>
54 <button accesskey=\"s\" class=show onclick=open_all_sections()>show</button> <button accesskey=\"x\" class=hide onclick=close_all_sections()>hide</button></nav>")
55 
56 (setq org-publish-project-alist
57  `(("compiler.company" :components ("index" "meta" "blog" "docs" "notes" "plan"))
58  ("index"
59  :base-directory ,project-dir
60  :base-extension "org"
61  :recursive nil
62  :htmlized-source t
63  :footnote-section-p t
64  :html-doctype "<!doctype html>"
65  :html-postamble ,html-foot
66  :publishing-directory ,publish-dir
67  :publishing-function org-html-publish-to-html)
68  ("meta"
69  :base-directory ,(expand-file-name "meta" project-dir)
70  :base-extension "org"
71  :recursive nil
72  :footnote-section-p t
73  :html-doctype "<!doctype html>"
74  :publishing-directory ,(expand-file-name "meta" publish-dir)
75  :publishing-function org-html-publish-to-html
76  :htmlized-source t
77  :html-postamble ,html-foot)
78  ("blog"
79  :base-directory ,(expand-file-name "blog" 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 "blog" publish-dir)
85  :publishing-function org-html-publish-to-html
86  :htmlized-source t
87  :html-postamble ,html-foot)
88  ("plan"
89  :base-directory ,(expand-file-name "plan" 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 "plan" publish-dir)
95  :publishing-function org-html-publish-to-html
96  :htmlized-source t
97  :html-postamble ,html-foot)
98  ("notes"
99  :base-directory ,(expand-file-name "notes" project-dir)
100  :recursive t
101  :base-extension "org"
102  :footnote-section-p t
103  :html-doctype "<!doctype html>"
104  :publishing-directory ,(expand-file-name "notes" publish-dir)
105  :publishing-function org-html-publish-to-html
106  :htmlized-source t
107  :html-postamble ,html-foot)
108  ("docs"
109  :base-directory ,(expand-file-name "docs" project-dir)
110  :base-extension "org"
111  :recursive t
112  :footnote-section-p t
113  :html-doctype "<!doctype html>"
114  :publishing-directory ,(expand-file-name "docs" publish-dir)
115  :publishing-function org-html-publish-to-html
116  :htmlized-source t
117  :html-postamble ,html-foot)))
118 
119 ;; (defun org-export-get-reference-title (datum info)
120 ;; "Like `org-export-get-reference', except uses heading titles instead of random numbers."
121 ;; (let ((cache (plist-get info :internal-references)))
122 ;; (or (car (rassq datum cache))
123 ;; (let* ((crossrefs (plist-get info :crossrefs))
124 ;; (cells (org-export-search-cells datum))
125 ;; ;; Preserve any pre-existing association between
126 ;; ;; a search cell and a reference, i.e., when some
127 ;; ;; previously published document referenced a location
128 ;; ;; within current file (see
129 ;; ;; `org-publish-resolve-external-link').
130 ;; ;;
131 ;; ;; However, there is no guarantee that search cells are
132 ;; ;; unique, e.g., there might be duplicate custom ID or
133 ;; ;; two headings with the same title in the file.
134 ;; ;;
135 ;; ;; As a consequence, before re-using any reference to
136 ;; ;; an element or object, we check that it doesn't refer
137 ;; ;; to a previous element or object.
138 ;; (new (or (cl-some
139 ;; (lambda (cell)
140 ;; (let ((stored (cdr (assoc cell crossrefs))))
141 ;; (when stored
142 ;; (let ((old (org-export-format-reference stored)))
143 ;; (and (not (assoc old cache)) stored)))))
144 ;; cells)
145 ;; (when (org-element-property :raw-value datum)
146 ;; ;; Heading with a title
147 ;; (org-export-new-title-reference datum cache))
148 ;; ;; NOTE: This probably breaks some Org Export
149 ;; ;; feature, but if it does what I need, fine.
150 ;; (org-export-format-reference
151 ;; (org-export-new-reference cache))))
152 ;; (reference-string new))
153 ;; ;; Cache contains both data already associated to
154 ;; ;; a reference and in-use internal references, so as to make
155 ;; ;; unique references.
156 ;; (dolist (cell cells) (push (cons cell new) cache))
157 ;; ;; Retain a direct association between reference string and
158 ;; ;; DATUM since (1) not every object or element can be given
159 ;; ;; a search cell (2) it permits quick lookup.
160 ;; (push (cons reference-string datum) cache)
161 ;; (plist-put info :internal-references cache)
162 ;; reference-string))))
163 
164 ;; (defun org-export-new-title-reference (datum cache)
165 ;; "Return new reference for DATUM that is unique in CACHE."
166 ;; (cl-macrolet ((inc-suffixf (place)
167 ;; `(progn
168 ;; (string-match (rx bos
169 ;; (minimal-match (group (1+ anything)))
170 ;; (optional "--" (group (1+ digit)))
171 ;; eos)
172 ;; ,place)
173 ;; ;; HACK: `s1' instead of a gensym.
174 ;; (-let* (((s1 suffix) (list (match-string 1 ,place)
175 ;; (match-string 2 ,place)))
176 ;; (suffix (if suffix
177 ;; (string-to-number suffix)
178 ;; 0)))
179 ;; (setf ,place (format "%s--%s" s1 (cl-incf suffix)))))))
180 ;; (let* ((title (org-element-property :raw-value datum))
181 ;; (ref (url-hexify-string (substring-no-properties title)))
182 ;; (parent (org-element-property :parent datum)))
183 ;; (while (--any (equal ref (car it))
184 ;; cache)
185 ;; ;; Title not unique: make it so.
186 ;; (if parent
187 ;; ;; Append ancestor title.
188 ;; (setf title (concat (org-element-property :raw-value parent)
189 ;; "--" title)
190 ;; ref (url-hexify-string (substring-no-properties title))
191 ;; parent (org-element-property :parent parent))
192 ;; ;; No more ancestors: add and increment a number.
193 ;; (inc-suffixf ref)))
194 ;; ref)))
195 
196 ;;;###autoload
197 (defun publish (&optional sitemap static force async)
198  "publish `compiler.company' content.
199 If STATIC is t, also publish media and static files.
200 If FORCE is t, skip checking file mod date and just publish all files.
201 If ASYNC is t, call `org-publish' asynchronously.
202 If given a prefix (C-u), set all args to t"
203  (interactive)
204  (if current-prefix-arg
205  (setq static t
206  force t
207  async t))
208  (let ((default-directory project-dir))
209  (message (format "publishing from %s" default-directory))
210  (org-publish "compiler.company" force async)))
211 
212 (provide 'publish)
213 ;;; publish.el ends here