summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2014-06-03 22:11:15 +0200
committerGravatar Tom Willemse2014-06-03 22:11:15 +0200
commit12ec5be35311f754beeccda37889e04ff3fb4d2a (patch)
tree6afd1d043516c5ded7555fec2d099991f2719c52
parentab5d3c0a5d83092e0b9ee2276b1d7a4b3f70d2f1 (diff)
downloadorgweb-12ec5be35311f754beeccda37889e04ff3fb4d2a.tar.gz
orgweb-12ec5be35311f754beeccda37889e04ff3fb4d2a.zip
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.
-rw-r--r--articles/project.el49
1 files 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"