changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > org / publish.el

changeset 14: 06842841bf42
parent: d0daa407ec13
child: 27795b18326b
author: ellis <ellis@rwest.io>
date: Mon, 20 Nov 2023 21:13:44 -0500
permissions: -rw-r--r--
description: hello-world 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> <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 
29 (setq org-publish-project-alist
30  `(("compiler.company" :components ("index" "blog" "docs"))
31  ("index"
32  :base-directory ,project-dir
33  :base-extension "org"
34  :recursive nil
35  :htmlized-source t
36  :html-preamble ,html-nav
37  :publishing-directory ,publish-dir
38  :publishing-function org-html-publish-to-html
39  :html-postamble ,html-foot)
40  ("blog"
41  :base-directory ,(expand-file-name "blog" project-dir)
42  :base-extension "org"
43  :publishing-directory ,(expand-file-name "blog" publish-dir)
44  :publishing-function org-html-publish-to-html
45  :htmlized-source t
46  :html-preamble ,html-nav
47  :html-postamble ,html-foot)
48  ("docs"
49  :base-directory ,(expand-file-name "docs" project-dir)
50  :base-extension "org"
51  :recursive t
52  :publishing-directory ,(expand-file-name "docs" publish-dir)
53  :publishing-function org-html-publish-to-html
54  :htmlized-source t
55  :html-preamble ,html-nav
56  :html-postamble ,html-foot)))
57 
58 (defun org-custom-id-get (&optional pom create prefix)
59  "Get the CUSTOM_ID property of the entry at point-or-marker POM.
60  If POM is nil, refer to the entry at point. If the entry does
61  not have an CUSTOM_ID, the function returns nil. However, when
62  CREATE is non nil, create a CUSTOM_ID if none is present
63  already. PREFIX will be passed through to `org-id-new'. In any
64  case, the CUSTOM_ID of the entry is returned."
65  (interactive)
66 (org-with-point-at pom
67  (let ((id (org-entry-get nil "CUSTOM_ID"))
68  ;; use CUSTOM_ID for links
69  (org-id-link-to-org-use-id 'create-if-interactive-and-no-custom-id))
70  (cond
71  ((and id (stringp id) (string-match "\\S-" id))
72  id)
73  (create
74  (setq id (org-id-new prefix))
75  (org-entry-put pom "CUSTOM_ID" id)
76  (org-id-add-location id (buffer-file-name (buffer-base-buffer)))
77  id)))))
78 ;;;###autoload
79 (defun org-id-add-to-headlines-in-file ()
80  "Add CUSTOM_ID properties to all headlines in the
81  current file which do not already have one."
82  (interactive)
83  (org-map-entries (lambda () (org-custom-id-get (point) 'create))))
84 
85 ;;;###autoload
86 (defun publish (&optional sitemap static force async)
87  "publish `rwest-io' content.
88 If STATIC is t, also publish media and static files.
89 If FORCE is t, skip checking file mod date and just publish all files.
90 If ASYNC is t, call `org-publish' asynchronously.
91 If given a prefix (C-u), set all args to t"
92  (interactive)
93  (if current-prefix-arg
94  (setq static t
95  force t
96  async t))
97  (let ((default-directory project-dir))
98  (message (format "publishing from %s" default-directory))
99  (org-publish "compiler.company" force async)))