2020-03-19 08:11:07 +01:00
|
|
|
|
;;; publish.el --- Publishing configuration for ryuslash.org -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
|
|
;; Copyright (C) 2020 Tom Willemse
|
|
|
|
|
|
|
|
|
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
|
|
|
|
;; Keywords:
|
|
|
|
|
|
|
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2020-03-20 04:23:17 +01:00
|
|
|
|
(require 'dockerfile-mode)
|
2020-09-10 10:34:32 +02:00
|
|
|
|
(require 'ob-dot)
|
|
|
|
|
(require 'ox-publish)
|
2020-03-20 07:16:08 +01:00
|
|
|
|
(require 'rainbow-delimiters)
|
2020-09-10 10:34:32 +02:00
|
|
|
|
(require 'subr-x)
|
2020-03-20 07:16:08 +01:00
|
|
|
|
|
2020-11-21 19:17:11 +01:00
|
|
|
|
(defconst publish-root
|
|
|
|
|
(file-name-directory
|
|
|
|
|
(or load-file-name
|
|
|
|
|
(buffer-file-name)))
|
|
|
|
|
"The directory where ‘oni-org’ was loaded from.")
|
|
|
|
|
|
2020-03-20 07:16:08 +01:00
|
|
|
|
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
|
2020-03-19 08:11:07 +01:00
|
|
|
|
|
|
|
|
|
(defun publish-calculate-reading-time (buffer)
|
|
|
|
|
"Calculate the amount of minutes it would take to read the contents of BUFFER."
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(max 1 (/ (count-words (point-min) (point-max)) 228))))
|
|
|
|
|
|
|
|
|
|
(defun publish-format-reading-time (time)
|
|
|
|
|
"Return a string describing TIME."
|
|
|
|
|
(format "%d minute%s"
|
|
|
|
|
time
|
|
|
|
|
(if (= time 1) "" "s")))
|
|
|
|
|
|
|
|
|
|
(setq org-export-exclude-tags '("noexport" "draft"))
|
|
|
|
|
|
2020-09-10 10:34:32 +02:00
|
|
|
|
(setq org-confirm-babel-evaluate nil)
|
|
|
|
|
|
2021-07-03 10:29:43 +02:00
|
|
|
|
(setq org-html-head-include-default-style nil)
|
2020-09-10 10:34:32 +02:00
|
|
|
|
|
2020-03-20 04:23:37 +01:00
|
|
|
|
(setq org-html-htmlize-output-type 'css)
|
|
|
|
|
|
2020-03-20 04:37:22 +01:00
|
|
|
|
(setq org-publish-timestamp-directory
|
|
|
|
|
(concat default-directory "/.org-timestamps/"))
|
|
|
|
|
|
2020-10-11 03:04:47 +02:00
|
|
|
|
(setq org-html-html5-fancy t)
|
|
|
|
|
|
|
|
|
|
(setq org-html-doctype "html5")
|
|
|
|
|
|
2020-03-19 08:11:07 +01:00
|
|
|
|
(setq org-publish-project-alist
|
2020-11-23 00:42:12 +01:00
|
|
|
|
`(("index"
|
2020-09-10 10:34:32 +02:00
|
|
|
|
:base-directory "."
|
2020-03-19 08:11:07 +01:00
|
|
|
|
:base-extension "org"
|
|
|
|
|
:publishing-directory "public/"
|
|
|
|
|
:recursive t
|
2020-11-23 00:42:12 +01:00
|
|
|
|
:exclude ,(rx string-start
|
|
|
|
|
(or "posts/"
|
|
|
|
|
(and "README.org" string-end)))
|
2020-03-19 08:11:07 +01:00
|
|
|
|
:publishing-function org-html-publish-to-html
|
2020-09-10 10:34:32 +02:00
|
|
|
|
:html-head "<link rel=\"stylesheet\" href=\"/assets/css/main.css\" type=\"text/css\"/>")
|
|
|
|
|
("posts"
|
|
|
|
|
:base-directory "posts/"
|
|
|
|
|
:base-extension "org"
|
|
|
|
|
:publishing-directory "public/posts/"
|
|
|
|
|
:recursive t
|
|
|
|
|
:publishing-function org-html-publish-to-html
|
|
|
|
|
:html-head "<link rel=\"stylesheet\" href=\"/assets/css/main.css\" type=\"text/css\"/>"
|
2020-03-19 08:11:07 +01:00
|
|
|
|
:html-preamble (lambda (project)
|
|
|
|
|
(let ((buffer (find-file-noselect (buffer-file-name))))
|
|
|
|
|
(unless (string= "ryuslash.org"
|
|
|
|
|
(car (org-publish-find-property (buffer-file-name) :title project)))
|
|
|
|
|
(publish-format-reading-time
|
2020-09-10 10:34:32 +02:00
|
|
|
|
(publish-calculate-reading-time buffer))))))
|
|
|
|
|
("assets"
|
|
|
|
|
:base-directory "."
|
|
|
|
|
:recursive t
|
|
|
|
|
:exclude "^public/"
|
|
|
|
|
:base-extension "svg"
|
|
|
|
|
:publishing-function org-publish-attachment
|
|
|
|
|
:publishing-directory "public/")
|
|
|
|
|
("all" :components ("index" "posts" "assets"))))
|
2020-03-19 08:11:07 +01:00
|
|
|
|
|
2020-11-21 19:17:11 +01:00
|
|
|
|
(defvar publish-feed-url-format
|
|
|
|
|
;"https://gitlab.com/ryuslash/ryuslash.org/-/commits/master/%s?feed_token=Rf8otgpS8YEiYakJN4NR&format=atom"
|
|
|
|
|
"https://code.ryuslash.org/new-ryuslash.org/atom/%s?h=master"
|
|
|
|
|
"Format string for the URL to the page’s atom feed.")
|
|
|
|
|
|
2020-03-19 08:11:07 +01:00
|
|
|
|
(provide 'publish)
|
|
|
|
|
;;; publish.el ends here
|