build.el (3347B)
1 ;; -*- lexical-binding: t; -*- 2 (require 'ox-publish) 3 (require 'cl-lib) 4 5 ;; Always build from scratch, so files whose source was removed don't linger in 6 ;; public/ (and, through deploy.sh's rsync --delete, on the server). 7 (when (file-directory-p "public") 8 (delete-directory "public" t)) 9 10 (cl-labels 11 ((read-file-to-string (file) 12 (with-temp-buffer 13 (insert-file-contents file) 14 (buffer-string))) 15 (sitemap-format-entry-html (entry style project) 16 (let ((filename (org-publish-find-title entry project))) 17 (if (= (length filename) 0) 18 (format "*%s*" entry) 19 (format "{{{indexformat(%s, %s)}}}" 20 (format "[[file:%s][%s]]" entry filename) 21 (format-time-string 22 "%d %B\\, %Y /Anno Domini/ - %R" 23 (org-publish-find-date entry project))))))) 24 (let ((org-export-html-header (read-file-to-string "header.html"))) 25 (let ((org-export-global-macros 26 '(("indexformat" . "@@html:<h2>@@$1@@html:</h2><p>@@$2@@html:</p>@@"))) 27 28 (org-export-date-timestamp-format "%d %B, %Y /Anno Domini/ - %R") 29 (org-html-html5-fancy t) 30 (org-html-validation-link nil) 31 (org-html-head-include-scripts nil) 32 (org-html-head-include-default-style nil) 33 (org-html-head (read-file-to-string "head.html")) 34 (org-export-with-author nil) 35 (org-export-with-creator nil) 36 (org-export-with-toc nil) 37 (org-export-with-section-numbers nil) 38 (org-export-with-date t) 39 (org-html-preamble 40 (lambda (info) 41 (format org-export-html-header 42 (or 43 (org-export-get-date info "%d %B, %Y <i>Anno Domini</i> - %R") 44 "")))) 45 (org-html-postamble (read-file-to-string "footer.html")) 46 47 (org-publish-project-alist 48 (list 49 (list "base" 50 :recursive nil 51 :base-directory "." 52 :publishing-directory "./public/" 53 :publishing-function #'org-html-publish-to-html 54 :time-stamp-file nil) 55 (list "static" 56 :recursive t 57 :base-directory "./static/" 58 :publishing-directory "./public/static/" 59 :publishing-function #'org-publish-attachment 60 :base-extension ".*") 61 (list "literature" 62 :recursive nil 63 :base-directory "./literature" 64 :publishing-directory "./public/literature/" 65 :publishing-function #'org-html-publish-to-html 66 :time-stamp-file nil 67 :sitemap-sort-files 'anti-chronologically 68 :sitemap-filename "index.html" 69 :sitemap-title "My literary work" 70 :sitemap-format-entry #'sitemap-format-entry-html 71 :auto-sitemap t) 72 (list "posts" 73 :recursive nil 74 :base-directory "./posts" 75 :publishing-directory "./public/posts/" 76 :publishing-function #'org-html-publish-to-html 77 :time-stamp-file nil 78 :sitemap-sort-files 'anti-chronologically 79 :sitemap-filename "index.html" 80 :sitemap-title 81 "Thoughts on computing, philosophy, games, etc" 82 :sitemap-format-entry #'sitemap-format-entry-html 83 :auto-sitemap t) 84 (list "projects" 85 :recursive nil 86 :base-directory "./projects" 87 :publishing-directory "./public/projects/" 88 :publishing-function #'org-html-publish-to-html 89 :time-stamp-file nil 90 :sitemap-sort-files 'anti-chronologically 91 :sitemap-filename "index.html" 92 :sitemap-title "The computing projects I did that I actually like" 93 :sitemap-format-entry #'sitemap-format-entry-html 94 :auto-sitemap t)))) 95 (org-publish-all t) 96 (message "Build complete!"))))