changelog shortlog graph tags branches changeset file revisions annotate raw help

Mercurial > org / publish.el

revision 13: d0daa407ec13
child 14: 06842841bf42
     1.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2+++ b/publish.el	Mon Nov 20 19:02:47 2023 -0500
     1.3@@ -0,0 +1,97 @@
     1.4+;;; publish.el --- the.compiler.company publishing script  -*- lexical-binding: t; -*-
     1.5+
     1.6+;;; Code:
     1.7+(require 'ox-publish)
     1.8+(require 'org-id)
     1.9+;; vendored
    1.10+(require 'htmlize)
    1.11+(defvar project-dir "~/dev/comp/org")
    1.12+(defvar publish-dir "/mnt/w/compiler.company")
    1.13+(defvar html-theme nil)
    1.14+(defvar url "https://compiler.company")
    1.15+(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>")
    1.16+
    1.17+(defvar html-foot "<footer>updated %C</footer>")
    1.18+
    1.19+(setq org-html-style-default ""
    1.20+      org-html-scripts ""
    1.21+      org-html-htmlize-output-type 'css
    1.22+      org-export-htmlize-output-type 'css
    1.23+      org-html-doctype "html5"
    1.24+      org-html-html5-fancy t
    1.25+      org-html-validation-link nil
    1.26+      org-src-fontify-natively t
    1.27+      make-backup-files nil
    1.28+      debug-on-error t)
    1.29+
    1.30+(setq org-publish-project-alist
    1.31+      `(("compiler.company" :components ("index" "blog" "docs"))
    1.32+        ("index"
    1.33+         :base-directory ,project-dir
    1.34+         :base-extension "org"
    1.35+         :recursive nil
    1.36+         :htmlized-source t
    1.37+	 :html-preamble ,html-nav
    1.38+         :publishing-directory ,publish-dir
    1.39+         :publishing-function org-html-publish-to-html
    1.40+         :html-postamble ,html-foot)
    1.41+        ("blog"
    1.42+         :base-directory ,(expand-file-name "blog" project-dir)
    1.43+         :base-extension "org"
    1.44+	 :publishing-directory ,(expand-file-name "blog" publish-dir)
    1.45+	 :publishing-function org-html-publish-to-html
    1.46+	 :htmlized-source t
    1.47+	 :html-preamble ,html-nav
    1.48+         :html-postamble ,html-foot)
    1.49+        ("docs"
    1.50+         :base-directory ,(expand-file-name "docs" project-dir)
    1.51+         :base-extension "org"
    1.52+         :recursive t
    1.53+         :publishing-directory ,(expand-file-name "docs" publish-dir)
    1.54+	 :publishing-function org-html-publish-to-html
    1.55+	 :htmlized-source t
    1.56+         :html-preamble ,html-nav
    1.57+         :html-postamble ,html-foot)))
    1.58+
    1.59+(defun org-custom-id-get (&optional pom create prefix)
    1.60+  "Get the CUSTOM_ID property of the entry at point-or-marker POM.
    1.61+   If POM is nil, refer to the entry at point. If the entry does
    1.62+   not have an CUSTOM_ID, the function returns nil. However, when
    1.63+   CREATE is non nil, create a CUSTOM_ID if none is present
    1.64+   already. PREFIX will be passed through to `org-id-new'. In any
    1.65+   case, the CUSTOM_ID of the entry is returned."
    1.66+  (interactive)
    1.67+(org-with-point-at pom
    1.68+  (let ((id (org-entry-get nil "CUSTOM_ID"))
    1.69+	;; use CUSTOM_ID for links
    1.70+	(org-id-link-to-org-use-id 'create-if-interactive-and-no-custom-id))
    1.71+      (cond
    1.72+       ((and id (stringp id) (string-match "\\S-" id))
    1.73+        id)
    1.74+       (create
    1.75+        (setq id (org-id-new prefix))
    1.76+        (org-entry-put pom "CUSTOM_ID" id)
    1.77+        (org-id-add-location id (buffer-file-name (buffer-base-buffer)))
    1.78+        id)))))
    1.79+;;;###autoload
    1.80+(defun org-id-add-to-headlines-in-file ()
    1.81+  "Add CUSTOM_ID properties to all headlines in the
    1.82+   current file which do not already have one."
    1.83+  (interactive)
    1.84+  (org-map-entries (lambda () (org-custom-id-get (point) 'create))))
    1.85+
    1.86+;;;###autoload
    1.87+(defun publish (&optional sitemap static force async)
    1.88+  "publish `rwest-io' content.
    1.89+If STATIC is t, also publish media and static files.
    1.90+If FORCE is t, skip checking file mod date and just publish all files.
    1.91+If ASYNC is t, call `org-publish' asynchronously.
    1.92+If given a prefix (C-u), set all args to t"
    1.93+  (interactive)
    1.94+  (if current-prefix-arg
    1.95+      (setq static t
    1.96+	    force t
    1.97+            async t))
    1.98+  (let ((default-directory project-dir))
    1.99+    (message (format "publishing from %s" default-directory))    
   1.100+    (org-publish "compiler.company" force async)))