Add publish make target
authorPeng Li <seudut@gmail.com>
Sun, 12 Mar 2017 11:12:39 +0000 (19:12 +0800)
committerPeng Li <seudut@gmail.com>
Sun, 12 Mar 2017 11:12:39 +0000 (19:12 +0800)
Makefile
my-publish.el

index f1f4d12..00e53a2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,9 @@
 ## Makefile to export org in blog file to html
 
 emacs ?= emacs
-OUTDIR := ""
+OUTDIR := 
 FORCE := "no"
+BLOGDIR := $(PWD)
 
 all:
        $(emacs) -Q --script blog.el $(OUTDIR) $(FORCE)
@@ -11,8 +12,17 @@ all:
 update:
        git pull && $(emacs) -Q --script blog.el "~/www/html" "true" 
 
-test:
-       $(emaca) -Q --script blog.el "test" "true"
+publish:
+       $(emacs) -Q --batch -l my-publish.el index.org \
+               --eval '(setq debug-on-error t)' \
+               --eval '(blog-setup-project-alist "$(BLOGDIR)" "$(OUTDIR)")' \
+               --eval '(org-publish-current-project)'
+
+compile:
+       $(emacs) -Q --batch -l my-publish.el index.org \
+               --eval '(setq debug-on-error t)' \
+               --eval '(blog-setup-project-alist "$(BLOGDIR)" "$(OUTDIR)")' \
+               --eval '(org-publish-current-project t)'
 
 clean:
        rm -rf _site/*
index 984bb11..cd0f340 100644 (file)
@@ -59,7 +59,11 @@ License: <a href= \"https://creativecommons.org/licenses/by-sa/4.0/\">CC BY-SA 4
 (defun blog-setup-project-alist (root-dir &optional output-dir)
   "Set project alist. `output-dir' is the directory of publish-directory.
 `root-dir' is the root directory of blog repository."
-  (unless output-dir (setq output-dir (concat root-dir "_site/")))
+  (unless (> (length output-dir) 0)
+    (setq output-dir (concat root-dir "/_site/")))
+  (message "Blog dir is: %s\nOut dir is: %s"
+          (format root-dir)
+          (format output-dir))
   (setq org-publish-project-alist
        `(
          ("blog-pages"
@@ -125,13 +129,5 @@ License: <a href= \"https://creativecommons.org/licenses/by-sa/4.0/\">CC BY-SA 4
           :recursive t)
          ("blog" :components ("blog-pages" "blog-posts" "blog-css" "blog-cgi")))))
 
-
-(defun blog-publish (out-dir force)
-  "publish the project"
-  (interactive)
-  (blog-setup-project out-dir)
-  (org-publish-project "blog" force))
-
-
 (provide 'my-publish)
 ;;; publish.el ends here