update linux note
[blog.git] / Makefile
index f1f4d12..b6ef862 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,18 +1,39 @@
 ## Makefile to export org in blog file to html
 
 emacs ?= emacs
-OUTDIR := ""
-FORCE := "no"
+OUTDIR := _site
+BLOGDIR := $(PWD)
+UPDATE :=
 
-all:
-       $(emacs) -Q --script blog.el $(OUTDIR) $(FORCE)
+# To color the code block, install htmlize package
+INIT_PACKAGES = "(progn \
+                               (require 'package) \
+                               (add-to-list 'package-archives '(\"melpa\" . \"http://melpa.org/packages/\")) \
+                               (package-initialize) \
+                               (unless (package-installed-p 'htmlize) (package-refresh-contents) (package-install 'htmlize)))"
+
+CSS := $(wildcard css/*.css)
+
+.PHONY: update publish clean
+
+publish: update temp
+       $(emacs) -Q --batch  \
+               --eval $(INIT_PACKAGES) \
+               --eval '(setq debug-on-error t)' \
+               -l my-publish.el index.org \
+               --eval '(blog-setup-project-alist "$(BLOGDIR)" "$(OUTDIR)")' \
+               --eval '(org-publish-current-project)'
 
-# used for automation on server
 update:
-       git pull && $(emacs) -Q --script blog.el "~/www/html" "true" 
+ifeq ($(UPDATE), true)
+       git pull
+endif
 
-test:
-       $(emaca) -Q --script blog.el "test" "true"
+# if the source files (css) file changed, remote the org-timestamps to 
+# re-generate all the html files
+temp: $(CSS) my-publish.el
+       rm -rf ~/.org-timestamps
+       touch temp
 
 clean:
        rm -rf _site/*