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.
This commit is contained in:
Tom Willemse 2014-06-03 22:11:15 +02:00
parent ab5d3c0a5d
commit 12ec5be353

View file

@ -4,7 +4,7 @@
(load "../common.el") (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) (defun orgweb-get-permalink (entry)
(let ((entry-date (org-date-to-gregorian (orgweb:post-date entry)))) (let ((entry-date (org-date-to-gregorian (orgweb:post-date entry))))
@ -31,6 +31,12 @@
(when (org-forward-heading-same-level 1) (when (org-forward-heading-same-level 1)
(org-get-tags)))) (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 () (defun orgweb-get-entries ()
(delq nil (delq nil
(mapcar (lambda (orgfile) (mapcar (lambda (orgfile)
@ -45,7 +51,8 @@
:date date :date date
:tags (orgweb-get-tags) :tags (orgweb-get-tags)
:contents (buffer-substring-no-properties :contents (buffer-substring-no-properties
(point-min) (point-max))))))) (point-min) (point-max))
:draft (orgweb-get-draft))))))
(directory-files "/home/slash/projects/orgweb/articles" (directory-files "/home/slash/projects/orgweb/articles"
t "^[^.].*\\.org$")))) t "^[^.].*\\.org$"))))
@ -61,8 +68,9 @@
(defun orgweb-shortlist (entries) (defun orgweb-shortlist (entries)
(with-temp-buffer (with-temp-buffer
(mapc (lambda (entry) (mapc (lambda (entry)
(unless (orgweb:post-draft entry)
(insert "* " (orgweb-link entry "articles/") " " (insert "* " (orgweb-link entry "articles/") " "
(orgweb:post-date entry) "\n")) (orgweb:post-date entry) "\n")))
entries) entries)
(write-file "shortlist.org"))) (write-file "shortlist.org")))
@ -70,6 +78,7 @@
(with-temp-buffer (with-temp-buffer
(insert "#+TITLE:\n#+OPTIONS: toc:nil\n\n") (insert "#+TITLE:\n#+OPTIONS: toc:nil\n\n")
(mapc (lambda (entry) (mapc (lambda (entry)
(unless (orgweb:post-draft entry)
(insert (insert
(with-temp-buffer (with-temp-buffer
(insert (orgweb:post-contents entry)) (insert (orgweb:post-contents entry))
@ -85,7 +94,7 @@
(orgweb-get-permalink entry))) (orgweb-get-permalink entry)))
(buffer-substring-no-properties (buffer-substring-no-properties
heading-start (point)))) heading-start (point))))
"\n\n") "\n\n"))
(let* ((gdate (org-date-to-gregorian (let* ((gdate (org-date-to-gregorian
(orgweb:post-date entry))) (orgweb:post-date entry)))
(date-tree (format "_build/%s/%s/%s" (date-tree (format "_build/%s/%s/%s"