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)
(insert "* " (orgweb-link entry "articles/") " " (unless (orgweb:post-draft entry)
(orgweb:post-date entry) "\n")) (insert "* " (orgweb-link entry "articles/") " "
(orgweb:post-date entry) "\n")))
entries) entries)
(write-file "shortlist.org"))) (write-file "shortlist.org")))
@ -70,22 +78,23 @@
(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)
(insert (unless (orgweb:post-draft entry)
(with-temp-buffer (insert
(insert (orgweb:post-contents entry)) (with-temp-buffer
(org-mode) (insert (orgweb:post-contents entry))
(goto-char (point-min)) (org-mode)
(org-forward-heading-same-level 1) (goto-char (point-min))
(org-set-property "RSS_PERMALINK" (org-forward-heading-same-level 1)
(concat "articles/" (orgweb-get-permalink entry))) (org-set-property "RSS_PERMALINK"
(let ((heading-start (point))) (concat "articles/" (orgweb-get-permalink entry)))
(forward-paragraph) (let ((heading-start (point)))
(newline) (forward-paragraph)
(insert (format "[[file:%s][Read more]]" (newline)
(orgweb-get-permalink entry))) (insert (format "[[file:%s][Read more]]"
(buffer-substring-no-properties (orgweb-get-permalink entry)))
heading-start (point)))) (buffer-substring-no-properties
"\n\n") heading-start (point))))
"\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"