From 89a798f7b0e604ad3b9796601be0889bad9159ed Mon Sep 17 00:00:00 2001 From: Peng Li Date: Sun, 12 Mar 2017 19:12:39 +0800 Subject: [PATCH] Add publish make target --- Makefile | 16 +++++++++++++--- my-publish.el | 14 +++++--------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index f1f4d12..00e53a2 100644 --- 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/* diff --git a/my-publish.el b/my-publish.el index 984bb11..cd0f340 100644 --- a/my-publish.el +++ b/my-publish.el @@ -59,7 +59,11 @@ License: 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: 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 -- 2.11.0