changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > org / publish.el

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