Update eltuki to work better and do more
This commit is contained in:
parent
adf44fafae
commit
0dc07f528f
1 changed files with 32 additions and 8 deletions
|
@ -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)
|
||||||
|
(let ((org-export-with-toc nil)
|
||||||
|
(filename (concat dir "/content")))
|
||||||
(with-current-buffer (org-export-region-as-html
|
(with-current-buffer (org-export-region-as-html
|
||||||
(point-min) (point-max) t "*eltuki-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)
|
(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
|
||||||
|
(list (eltuki-write-content dest)
|
||||||
(eltuki-write-metadata dest)
|
(eltuki-write-metadata dest)
|
||||||
|
(eltuki-save-org buffer dest)))
|
||||||
|
|
||||||
|
(eltuki-commit)
|
||||||
(kill-buffer buffer)))
|
(kill-buffer buffer)))
|
||||||
|
|
||||||
(provide 'eltuki)
|
(provide 'eltuki)
|
||||||
|
|
Loading…
Reference in a new issue