changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > org / publish.el

changeset 17: cf198cee80c6
parent: ab1f674742a8
child: dd3f4ca8a58a
author: ellis <ellis@rwest.io>
date: Tue, 28 Nov 2023 21:45:46 -0500
permissions: -rw-r--r--
description: pub update
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 ;; vendored
9 (require 'htmlize)
10 (defvar project-dir "~/dev/comp/org")
11 (defvar publish-dir "/mnt/w/compiler.company")
12 (defvar html-theme nil)
13 (defvar url "https://compiler.company")
14 (defvar html-nav "<div class=\"nav\"> <a href = \"https://compiler.company\">~/</a> ( <a href = \"https://compiler.company/blog\">blog</a> <a href = \"https://compiler.company/docs\">docs</a> <a href = \"https://vc.compiler.company/comp\">code</a> ) </div>")
15 
16 (defvar html-foot "<footer>updated %C</footer>")
17 
18 (setq org-html-style-default ""
19  org-html-scripts ""
20  org-html-htmlize-output-type 'css
21  org-export-htmlize-output-type 'css
22  org-html-doctype "html5"
23  org-html-html5-fancy t
24  org-html-validation-link nil
25  org-src-fontify-natively t
26  make-backup-files nil
27  debug-on-error t
28  org-id-link-to-org-use-id t)
29 
30 (setq org-publish-project-alist
31  `(("compiler.company" :components ("index" "blog" "docs"))
32  ("index"
33  :base-directory ,project-dir
34  :base-extension "org"
35  :recursive nil
36  :htmlized-source t
37  :footnote-section-p t
38  :html-doctype "<!doctype html>"
39  :html-preamble ,html-nav
40  :publishing-directory ,publish-dir
41  :publishing-function org-html-publish-to-html
42  :html-postamble ,html-foot)
43  ("blog"
44  :base-directory ,(expand-file-name "blog" project-dir)
45  :base-extension "org"
46  :footnote-section-p t
47  :html-doctype "<!doctype html>"
48  :publishing-directory ,(expand-file-name "blog" publish-dir)
49  :publishing-function org-html-publish-to-html
50  :htmlized-source t
51  :html-preamble ,html-nav
52  :html-postamble ,html-foot)
53  ("docs"
54  :base-directory ,(expand-file-name "docs" project-dir)
55  :base-extension "org"
56  :recursive t
57  :footnote-section-p t
58  :html-doctype "<!doctype html>"
59  :publishing-directory ,(expand-file-name "docs" publish-dir)
60  :publishing-function org-html-publish-to-html
61  :htmlized-source t
62  :html-preamble ,html-nav
63  :html-postamble ,html-foot)))
64 
65 (defun org-custom-id-get (&optional pom create prefix)
66  "Get the CUSTOM_ID property of the entry at point-or-marker POM.
67  If POM is nil, refer to the entry at point. If the entry does
68  not have an CUSTOM_ID, the function returns nil. However, when
69  CREATE is non nil, create a CUSTOM_ID if none is present
70  already. PREFIX will be passed through to `org-id-new'. In any
71  case, the CUSTOM_ID of the entry is returned."
72  (interactive)
73 (org-with-point-at pom
74  (let ((id (org-entry-get nil "CUSTOM_ID"))
75  ;; use CUSTOM_ID for links
76  (org-id-link-to-org-use-id 'create-if-interactive-and-no-custom-id))
77  (cond
78  ((and id (stringp id) (string-match "\\S-" id))
79  id)
80  (create
81  (setq id (org-id-new prefix))
82  (org-entry-put pom "CUSTOM_ID" id)
83  (org-id-add-location id (buffer-file-name (buffer-base-buffer)))
84  id)))))
85 ;;;###autoload
86 (defun org-id-add-to-headlines-in-file ()
87  "Add CUSTOM_ID properties to all headlines in the
88  current file which do not already have one."
89  (interactive)
90  (org-map-entries (lambda () (org-custom-id-get (point) 'create))))
91 
92 ;;;###autoload
93 (defun publish (&optional sitemap static force async)
94  "publish `rwest-io' content.
95 If STATIC is t, also publish media and static files.
96 If FORCE is t, skip checking file mod date and just publish all files.
97 If ASYNC is t, call `org-publish' asynchronously.
98 If given a prefix (C-u), set all args to t"
99  (interactive)
100  (if current-prefix-arg
101  (setq static t
102  force t
103  async t))
104  (let ((default-directory project-dir))
105  (message (format "publishing from %s" default-directory))
106  (org-publish "compiler.company" force async)))