don't force publish project
[blog.git] / blog.el
1 ;;; blog.el --- Config file used to export blog      -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2017  Peng Li
4
5 ;; Author: Peng Li <seudut@gmail.com>
6 ;; Keywords: lisp
7
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.
12
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.
17
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/>.
20
21 ;;; Commentary:
22
23 ;; This is emacs config used to export Blog Org files in batch mode.
24
25 ;;; Code:
26
27 (require 'package)
28 (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
29 (package-initialize)
30
31 (setq debug-on-error t)
32
33 ;; package initialise
34 (unless (package-installed-p 'htmlize)
35   (package-refresh-contents)
36   (package-install 'htmlize))
37
38
39 ;; constants
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 ;; (defconst css-file (concat root-dir "css/worg.css"))
45
46 (let ((aa (pop command-line-args-left)))
47   (if (>  (length aa) 0)
48       (setq publish-dir aa)))
49
50 ;; (setq publish-dir (or (pop command-line-args-left) publish-dir))
51 (message publish-dir)
52
53 (require 'org)
54 (require 'ox-publish)
55 (require 'htmlize)
56
57 (message "Org-mode version %s" (org-version))
58 (message "publish directory is %s" publish-dir)
59
60 ;; To prevent inline-css when exporting html. will use external css
61 (setq org-html-htmlize-output-type 'css)
62
63 (setq org-publish-project-alist
64       `(
65         ("org-notes"
66          :base-directory ,root-dir
67          :base-extension "org"
68          :publishing-directory ,publish-dir
69          :recursive t
70          :publishing-function org-html-publish-to-html
71          :headline-levels 4
72          :section-numbers nil
73          :auto-preamble t
74          :auto-sitemap t          ;Generate sitmap.org automagicaly...
75          :sitemap-filename "sitemap.org" ;... call it sitemap.org (it's the default )...
76          :sitemap-title "Sitemap"
77
78          :html-table-of-contents nil
79          :html-postamble nil ;dont export creator auto validation info in html postamble div
80          :html-link-home "/"
81          :html-head  ,(concat  "<link rel='stylesheet' href='" css-file  "' />")
82          :html-head-include-default-style nil
83          :html-head-include-scripts nil)
84         ("org-static"
85          :base-directory ,root-dir
86          :base-extension "css\\|js\\|png\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|el"
87          :publishing-directory ,publish-dir
88          :recursive t
89          :publishing-function org-publish-attachment
90          :table-of-contents nil)
91         ("org" :components ("org-notes" "org-static"))))
92
93
94 (org-publish-project "org")
95
96 ;; (provide 'blog)
97 (kill-emacs 0)
98 ;;; blog.el ends here