Update eltuki to work better and do more

This commit is contained in:
Tom Willemsen 2012-12-19 23:56:25 +01:00
parent adf44fafae
commit 0dc07f528f

View file

@ -163,9 +163,13 @@
(eltuki-slugify-string (eltuki-get-title))))
(defun eltuki-write-content (dir)
(let ((org-export-with-toc nil)
(filename (concat dir "/content")))
(with-current-buffer (org-export-region-as-html
(point-min) (point-max) t "*eltuki-html*")
(write-region (point-min) (point-max) (concat dir "/content"))))
(write-region (point-min) (point-max) filename)
(kill-buffer))
filename))
(defun eltuki-write-metadata (dir)
(let ((timestamp (eltuki-get-timestamp))
@ -173,7 +177,8 @@
(status (eltuki-get-status))
(title (eltuki-get-title))
(name (eltuki-slugify-string (eltuki-get-title)))
(commentstatus (eltuki-get-comment-status)))
(commentstatus (eltuki-get-comment-status))
(filename (concat dir "/metadata")))
(with-temp-buffer
(insert "timestamp: " timestamp "\n"
"tags: " tags "\n"
@ -181,17 +186,36 @@
"title: " title "\n"
"name: " name "\n"
"comment_status: " commentstatus)
(write-region (point-min) (point-max) (concat dir "/metadata")))))
(write-region (point-min) (point-max) filename))
filename))
(defun eltuki-save-org (buffer dir)
(let ((filename (concat dir "/post.org")))
(with-current-buffer buffer
(write-file filename))
filename))
(defun eltuki-git-add (file)
(shell-command (concat "cd " eltuki-blog-dir "; git add '" (expand-file-name file) "'")))
(defun eltuki-commit ()
(shell-command (concat "cd " eltuki-blog-dir "; git commit -m \"new post: \\\"" (eltuki-get-title)
"\\\"\"")))
(defun eltuki-finish ()
(interactive)
(let ((buffer (get-buffer "*eltuki*"))
(let ((buffer (or (get-buffer "*eltuki*")
(current-buffer)))
(dest (eltuki-get-directory)))
(unless (file-exists-p dest)
(mkdir dest))
(eltuki-write-content dest)
(mapc #'eltuki-git-add
(list (eltuki-write-content dest)
(eltuki-write-metadata dest)
(eltuki-save-org buffer dest)))
(eltuki-commit)
(kill-buffer buffer)))
(provide 'eltuki)