diff options
Diffstat (limited to 'contrib/lisp/ox-rss.el')
-rw-r--r-- | contrib/lisp/ox-rss.el | 75 |
1 files changed, 42 insertions, 33 deletions
diff --git a/contrib/lisp/ox-rss.el b/contrib/lisp/ox-rss.el index 5fd2afc..4cdfe0e 100644 --- a/contrib/lisp/ox-rss.el +++ b/contrib/lisp/ox-rss.el @@ -1,6 +1,6 @@ ;;; ox-rss.el --- RSS 2.0 Back-End for Org Export Engine -;; Copyright (C) 2013, 2014 Bastien Guerry +;; Copyright (C) 2013-2015 Bastien Guerry ;; Author: Bastien Guerry <bzg@gnu.org> ;; Keywords: org, wp, blog, feed, rss @@ -42,6 +42,9 @@ ;; PUBDATE property. If `org-rss-use-entry-url-as-guid', it will also add ;; an ID property, later used as the guid for the feed's item. ;; +;; The top-level headline is used as the title of each RSS item unless +;; an RSS_TITLE property is set on the headline. +;; ;; You typically want to use it within a publishing project like this: ;; ;; (add-to-list @@ -119,7 +122,9 @@ When nil, Org will create ids using `org-icalendar-create-uid'." (if a (org-rss-export-to-rss t s v) (org-open-file (org-rss-export-to-rss nil s v))))))) :options-alist - '((:with-toc nil nil nil) ;; Never include HTML's toc + '((:description "DESCRIPTION" nil nil newline) + (:keywords "KEYWORDS" nil nil space) + (:with-toc nil nil nil) ;; Never include HTML's toc (:rss-extension "RSS_EXTENSION" nil org-rss-extension) (:rss-image-url "RSS_IMAGE_URL" nil org-rss-image-url) (:rss-categories nil nil org-rss-categories)) @@ -204,10 +209,12 @@ publishing directory. Return output file name." (let ((bf (get-file-buffer filename))) (if bf - (with-current-buffer bf - (org-rss-add-pubdate-property) - (write-file filename)) + (with-current-buffer bf + (org-icalendar-create-uid filename 'warn-user) + (org-rss-add-pubdate-property) + (write-file filename)) (find-file filename) + (org-icalendar-create-uid filename 'warn-user) (org-rss-add-pubdate-property) (write-file filename) (kill-buffer))) (org-publish-org-to @@ -222,29 +229,29 @@ communication channel." (unless (or (org-element-property :footnote-section-p headline) ;; Only consider first-level headlines (> (org-export-get-relative-level headline info) 1)) - (let* ((htmlext (plist-get info :html-extension)) + (let* ((author (and (plist-get info :with-author) + (let ((auth (plist-get info :author))) + (and auth (org-export-data auth info))))) + (htmlext (plist-get info :html-extension)) (hl-number (org-export-get-headline-number headline info)) (hl-home (file-name-as-directory (plist-get info :html-link-home))) (hl-pdir (plist-get info :publishing-directory)) (hl-perm (org-element-property :RSS_PERMALINK headline)) - (anchor - (org-export-solidify-link-text - (or (org-element-property :CUSTOM_ID headline) - (concat "sec-" (mapconcat 'number-to-string hl-number "-"))))) + (anchor (org-export-get-reference headline info)) (category (org-rss-plain-text (or (org-element-property :CATEGORY headline) "") info)) - (pubdate - (let ((system-time-locale "C")) - (format-time-string - "%a, %d %b %Y %H:%M:%S %z" - (org-time-string-to-time - (or (org-element-property :PUBDATE headline) - (error "Missing PUBDATE property")))))) - (title (replace-regexp-in-string - org-bracket-link-regexp - (lambda (m) (or (match-string 3 m) - (match-string 1 m))) - (org-element-property :raw-value headline))) + (pubdate0 (org-element-property :PUBDATE headline)) + (pubdate (let ((system-time-locale "C")) + (if pubdate0 + (format-time-string + "%a, %d %b %Y %H:%M:%S %z" + (org-time-string-to-time pubdate0))))) + (title (or (org-element-property :RSS_TITLE headline) + (replace-regexp-in-string + org-bracket-link-regexp + (lambda (m) (or (match-string 3 m) + (match-string 1 m))) + (org-element-property :raw-value headline)))) (publink (or (and hl-perm (concat (or hl-home hl-pdir) hl-perm)) (concat @@ -259,17 +266,19 @@ communication channel." (org-element-property :CUSTOM_ID headline) publink) info)))) - (format - (concat - "<item>\n" - "<title>%s</title>\n" - "<link>%s</link>\n" - "<guid isPermaLink=\"false\">%s</guid>\n" - "<pubDate>%s</pubDate>\n" - (org-rss-build-categories headline info) "\n" - "<description><![CDATA[%s]]></description>\n" - "</item>\n") - title publink guid pubdate contents)))) + (if (not pubdate0) "" ;; Skip entries with no PUBDATE prop + (format + (concat + "<item>\n" + "<title>%s</title>\n" + "<link>%s</link>\n" + "<author>%s</author>\n" + "<guid isPermaLink=\"false\">%s</guid>\n" + "<pubDate>%s</pubDate>\n" + (org-rss-build-categories headline info) "\n" + "<description><![CDATA[%s]]></description>\n" + "</item>\n") + title publink author guid pubdate contents))))) (defun org-rss-build-categories (headline info) "Build categories for the RSS item." |