1 ;;; publish.el --- Publish blog with org-mode -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2017 Peng Li
5 ;; Author: Peng Li <seudut@gmail.com>
6 ;; Keywords: lisp, abbrev
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
23 ;; Using this emacs script to publish the blog org file
27 ;; (defconst root-dir "~/Private/blog/")
32 (defconst root-dir (file-name-directory (or load-file-name buffer-file-name)))
33 (defvar publish-dir (concat root-dir "_site/"))
34 (defconst css-file "../css/worg.css")
35 (defvar force-publish nil)
37 ;; To prevent inline-css when exporting html. will use external css
38 (setq org-html-htmlize-output-type 'css)
43 ;; "<link rel='stylesheet' href='" css-file "' />\n"
44 "<link rel='stylesheet' href='../css/main.css' />\n"
45 "<link rel='stylesheet' href='../css/code.css' />"
50 " <header id= 'banner' > "
51 "<h1><a href= '/' >Peng Li</a></h1>"
54 "<li><a href= '/' >About</a></li>"
55 "<li><a href= '/blog.html' >Blog</a></li>"
56 "<li><a href= '/home.html' >Home</a></li>"
62 <p><span style=\"float: left;\"><a href= \"/blog.xml\">RSS</a></span>
63 License: <a href= \"https://creativecommons.org/licenses/by-sa/4.0/\">CC BY-SA 4.0</a></p\n")
65 (defun blog-setup-project (output-dir)
67 (setq publish-dir output-dir)
68 (setq org-publish-project-alist
72 :base-directory ,root-dir
74 :publishing-directory ,publish-dir
76 :publishing-function org-html-publish-to-html
80 ;; disable home/up div
81 :html-home/up-format ""
86 :html-head-include-default-style nil
87 :html-head-include-scripts nil
88 :html-head-extra ,blog-extra-head
89 :html-preamble ,blog-header
90 :html-postamble ,blog-footer)
94 :base-directory ,(concat root-dir "/posts")
96 :publishing-directory ,(concat publish-dir "/posts")
98 :publishing-function org-html-publish-to-html
103 :html-home/up-format ""
106 ;; Add css file, preamble and posamble
108 :html-head-include-default-style nil
109 :html-head-include-scripts nil
110 :html-head-extra ,blog-extra-head
111 :html-preamble ,blog-header
112 :html-postamble ,blog-footer
116 :sitemap-filename "sitemap.org"
117 :sitemap-title "Sitemap")
120 :base-directory ,(concat root-dir "/css")
122 :publishing-directory ,(concat publish-dir "/css")
123 :publishing-function org-publish-attachment
126 :base-directory ,(concat root-dir "/cgi-bin")
128 :publishing-directory ,(concat publish-dir "/cgi-bin")
129 :publishing-function org-publish-attachment
131 ("blog" :components ("blog-pages" "blog-posts" "blog-css" "blog-cgi")))))
133 (blog-setup-project publish-dir)
135 (defun blog-publish (out-dir force)
136 "publish the project"
138 (blog-setup-project out-dir)
139 (org-publish-project "blog" force))
143 ;;; publish.el ends here