1 ;;; blog.el --- Config file used to export blog -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2017 Peng Li
5 ;; Author: Peng Li <seudut@gmail.com>
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 ;; This is emacs config used to export Blog Org files in batch mode.
28 (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
31 (setq debug-on-error t)
34 (unless (package-installed-p 'htmlize)
35 (package-refresh-contents)
36 (package-install 'htmlize))
40 ;; (defconst root-dir "~/Private/blog/")
41 (defconst root-dir (file-name-directory (or load-file-name buffer-file-name)))
42 (defvar publish-dir (concat root-dir "_site/"))
43 (defconst css-file "../css/worg.css")
44 (defvar force-publish nil)
45 ;; (defconst css-file (concat root-dir "css/worg.css"))
47 (let ((aa (pop command-line-args-left)))
49 (setq publish-dir aa)))
52 (let ((force (pop command-line-args-left)))
53 (if (string= force "true")
54 (setq force-publish t)))
57 ;; (setq publish-dir (or (pop command-line-args-left) publish-dir))
64 (message "Org-mode version %s" (org-version))
65 (message "publish directory is %s" publish-dir)
66 (message "force %s" force-publish)
68 ;; To prevent inline-css when exporting html. will use external css
69 (setq org-html-htmlize-output-type 'css)
74 "<link rel='stylesheet' href='" css-file "' />\n"
75 ;; "<link rel='stylesheet' href='../css/main.css' />\n"
76 ;; "<link rel='stylesheet' href='../css/code.css' />"
81 ;; " <header id= "banner" > "
82 ;; "<h1><a href= '/' >Dennis Ogbe </a></h1>"
85 ;; "<li><a href= '/contact.html' >Contact</a></li>"
86 ;; "<li><a href= '/blog.html' >Blog</a></li>"
87 ;; "<li><a href= '/teaching.html' >Teaching</a></li>"
88 ;; "<li><a href= '/research.html' >Research</a></li>"
89 ;; "<li><a href= '/' >About Me</a></li>"
93 ;; don't know why setting this null in `org-publish-project-alist' doesn't work
94 ;; (setf org-html-home/up-format "")
96 (setq org-publish-project-alist
99 ;; :base-directory ,root-dir
100 ;; :base-extension "org"
101 ;; :publishing-directory ,publish-dir
103 ;; :publishing-function org-html-publish-to-html
104 ;; :headline-levels 4
105 ;; :section-numbers nil
107 ;; :auto-sitemap t ;Generate sitmap.org automagicaly...
108 ;; :sitemap-filename "sitemap.org" ;... call it sitemap.org (it's the default )...
109 ;; :sitemap-title "Sitemap"
111 ;; :html-table-of-contents nil
112 ;; :html-postamble nil ;dont export creator auto validation info in html postamble div
113 ;; :html-link-home "/"
114 ;; :html-head ,(concat "<link rel='stylesheet' href='" css-file "' />")
115 ;; :html-head-include-default-style nil
116 ;; :html-head-include-scripts nil)
119 :base-directory ,root-dir
120 :base-extension "org"
121 :publishing-directory ,publish-dir
123 :publishing-function org-html-publish-to-html
127 :html-head ,blog-extra-head
131 :base-directory ,(concat root-dir "/posts")
132 :base-extension "org"
133 :publishing-directory ,(concat publish-dir "/posts")
135 :publishing-function org-html-publish-to-html
140 :html-home/up-format ""
143 ;; don't export creator auto validation info in html postamble div
144 :html-head ,blog-extra-head
148 :base-directory ,(concat root-dir "/css")
150 :publishing-directory ,(concat publish-dir "/css")
151 :publishing-function org-publish-attachment
154 :base-directory ,(concat root-dir "/cgi-bin")
156 :publishing-directory ,(concat publish-dir "/cgi-bin")
157 :publishing-function org-publish-attachment
159 ("blog" :components ("blog-pages" "blog-posts" "blog-css" "blog-cgi"))))
161 (org-publish-project "blog" force-publish)
165 ;;; blog.el ends here