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)))) (eltuki-slugify-string (eltuki-get-title))))
(defun eltuki-write-content (dir) (defun eltuki-write-content (dir)
(with-current-buffer (org-export-region-as-html (let ((org-export-with-toc nil)
(point-min) (point-max) t "*eltuki-html*") (filename (concat dir "/content")))
(write-region (point-min) (point-max) (concat dir "/content")))) (with-current-buffer (org-export-region-as-html
(point-min) (point-max) t "*eltuki-html*")
(write-region (point-min) (point-max) filename)
(kill-buffer))
filename))
(defun eltuki-write-metadata (dir) (defun eltuki-write-metadata (dir)
(let ((timestamp (eltuki-get-timestamp)) (let ((timestamp (eltuki-get-timestamp))
@ -173,7 +177,8 @@
(status (eltuki-get-status)) (status (eltuki-get-status))
(title (eltuki-get-title)) (title (eltuki-get-title))
(name (eltuki-slugify-string (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 (with-temp-buffer
(insert "timestamp: " timestamp "\n" (insert "timestamp: " timestamp "\n"
"tags: " tags "\n" "tags: " tags "\n"
@ -181,17 +186,36 @@
"title: " title "\n" "title: " title "\n"
"name: " name "\n" "name: " name "\n"
"comment_status: " commentstatus) "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 () (defun eltuki-finish ()
(interactive) (interactive)
(let ((buffer (get-buffer "*eltuki*")) (let ((buffer (or (get-buffer "*eltuki*")
(current-buffer)))
(dest (eltuki-get-directory))) (dest (eltuki-get-directory)))
(unless (file-exists-p dest) (unless (file-exists-p dest)
(mkdir dest)) (mkdir dest))
(eltuki-write-content dest) (mapc #'eltuki-git-add
(eltuki-write-metadata dest) (list (eltuki-write-content dest)
(eltuki-write-metadata dest)
(eltuki-save-org buffer dest)))
(eltuki-commit)
(kill-buffer buffer))) (kill-buffer buffer)))
(provide 'eltuki) (provide 'eltuki)