From 0dc07f528ff1545aa70bed57724da7279faec895 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Wed, 19 Dec 2012 23:56:25 +0100 Subject: Update eltuki to work better and do more --- .emacs.d/site-lisp/eltuki.el | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) (limited to '.emacs.d/site-lisp/eltuki.el') diff --git a/.emacs.d/site-lisp/eltuki.el b/.emacs.d/site-lisp/eltuki.el index 4815108..80400a9 100644 --- a/.emacs.d/site-lisp/eltuki.el +++ b/.emacs.d/site-lisp/eltuki.el @@ -163,9 +163,13 @@ (eltuki-slugify-string (eltuki-get-title)))) (defun eltuki-write-content (dir) - (with-current-buffer (org-export-region-as-html - (point-min) (point-max) t "*eltuki-html*") - (write-region (point-min) (point-max) (concat dir "/content")))) + (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) 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) - (eltuki-write-metadata 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) -- cgit v1.2.3-54-g00ecf From 1be69078ad8c1af62de79b80345a72d2b8490b04 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Fri, 4 Jan 2013 00:01:52 +0100 Subject: eltuki: Add post skeleton and use it for new posts --- .emacs.d/site-lisp/eltuki.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to '.emacs.d/site-lisp/eltuki.el') diff --git a/.emacs.d/site-lisp/eltuki.el b/.emacs.d/site-lisp/eltuki.el index 80400a9..224e9ab 100644 --- a/.emacs.d/site-lisp/eltuki.el +++ b/.emacs.d/site-lisp/eltuki.el @@ -46,10 +46,20 @@ :group 'eltuki :type 'string) +(define-skeleton eltuki-post + "Create a post template for eltuki." + "" + "#+TITLE: " (skeleton-read "Title: ") "\n" + "#+TIMESTAMP: \n" + "#+TAGS: " (skeleton-read "Tags (comma separated): ") "\n" + "\n" + _) + (defun eltuki-new-post () (interactive) (switch-to-buffer (get-buffer-create "*eltuki*")) - (org-mode)) + (org-mode) + (eltuki-post)) (defun eltuki-get-title () (save-excursion -- cgit v1.2.3-54-g00ecf