From 12ec5be35311f754beeccda37889e04ff3fb4d2a Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 3 Jun 2014 22:11:15 +0200 Subject: Add possibility to mark posts as drafts This way they won't get included in the lists or RSS, but they'll still get exported and posted. --- articles/project.el | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/articles/project.el b/articles/project.el index 10c3354..309b983 100644 --- a/articles/project.el +++ b/articles/project.el @@ -4,7 +4,7 @@ (load "../common.el") -(cl-defstruct orgweb:post filename title date tags contents) +(cl-defstruct orgweb:post filename title date tags contents draft) (defun orgweb-get-permalink (entry) (let ((entry-date (org-date-to-gregorian (orgweb:post-date entry)))) @@ -31,6 +31,12 @@ (when (org-forward-heading-same-level 1) (org-get-tags)))) +(defun orgweb-get-draft () + (save-excursion + (goto-char (point-min)) + (org-forward-heading-same-level 1) + (org-entry-get (point) "DRAFT"))) + (defun orgweb-get-entries () (delq nil (mapcar (lambda (orgfile) @@ -45,7 +51,8 @@ :date date :tags (orgweb-get-tags) :contents (buffer-substring-no-properties - (point-min) (point-max))))))) + (point-min) (point-max)) + :draft (orgweb-get-draft)))))) (directory-files "/home/slash/projects/orgweb/articles" t "^[^.].*\\.org$")))) @@ -61,8 +68,9 @@ (defun orgweb-shortlist (entries) (with-temp-buffer (mapc (lambda (entry) - (insert "* " (orgweb-link entry "articles/") " " - (orgweb:post-date entry) "\n")) + (unless (orgweb:post-draft entry) + (insert "* " (orgweb-link entry "articles/") " " + (orgweb:post-date entry) "\n"))) entries) (write-file "shortlist.org"))) @@ -70,22 +78,23 @@ (with-temp-buffer (insert "#+TITLE:\n#+OPTIONS: toc:nil\n\n") (mapc (lambda (entry) - (insert - (with-temp-buffer - (insert (orgweb:post-contents entry)) - (org-mode) - (goto-char (point-min)) - (org-forward-heading-same-level 1) - (org-set-property "RSS_PERMALINK" - (concat "articles/" (orgweb-get-permalink entry))) - (let ((heading-start (point))) - (forward-paragraph) - (newline) - (insert (format "[[file:%s][Read more]]" - (orgweb-get-permalink entry))) - (buffer-substring-no-properties - heading-start (point)))) - "\n\n") + (unless (orgweb:post-draft entry) + (insert + (with-temp-buffer + (insert (orgweb:post-contents entry)) + (org-mode) + (goto-char (point-min)) + (org-forward-heading-same-level 1) + (org-set-property "RSS_PERMALINK" + (concat "articles/" (orgweb-get-permalink entry))) + (let ((heading-start (point))) + (forward-paragraph) + (newline) + (insert (format "[[file:%s][Read more]]" + (orgweb-get-permalink entry))) + (buffer-substring-no-properties + heading-start (point)))) + "\n\n")) (let* ((gdate (org-date-to-gregorian (orgweb:post-date entry))) (date-tree (format "_build/%s/%s/%s" -- cgit v1.2.3-54-g00ecf