ox-rss.el (org-rss-headline): Skip entries with no PUBDATE

* contrib/lisp/ox-rss.el (org-rss-headline): Skip entries with
no PUBDATE instead of throwing an error.

Thanks to OSiUX for suggesting this.
This commit is contained in:
Bastien Guerry 2014-08-22 15:38:47 +02:00
parent e7df9bc5ae
commit 6e2aed55bf
1 changed files with 19 additions and 19 deletions

View File

@ -238,13 +238,12 @@ communication channel."
(concat "sec-" (mapconcat 'number-to-string hl-number "-"))))) (concat "sec-" (mapconcat 'number-to-string hl-number "-")))))
(category (org-rss-plain-text (category (org-rss-plain-text
(or (org-element-property :CATEGORY headline) "") info)) (or (org-element-property :CATEGORY headline) "") info))
(pubdate (pubdate0 (org-element-property :PUBDATE headline))
(let ((system-time-locale "C")) (pubdate (let ((system-time-locale "C"))
(format-time-string (if pubdate0
"%a, %d %b %Y %H:%M:%S %z" (format-time-string
(org-time-string-to-time "%a, %d %b %Y %H:%M:%S %z"
(or (org-element-property :PUBDATE headline) (org-time-string-to-time pubdate0)))))
(error "Missing PUBDATE property"))))))
(title (replace-regexp-in-string (title (replace-regexp-in-string
org-bracket-link-regexp org-bracket-link-regexp
(lambda (m) (or (match-string 3 m) (lambda (m) (or (match-string 3 m)
@ -264,18 +263,19 @@ communication channel."
(org-element-property :CUSTOM_ID headline) (org-element-property :CUSTOM_ID headline)
publink) publink)
info)))) info))))
(format (if (not pubdate0) "" ;; Skip entries with no PUBDATE prop
(concat (format
"<item>\n" (concat
"<title>%s</title>\n" "<item>\n"
"<link>%s</link>\n" "<title>%s</title>\n"
"<author>%s</author>\n" "<link>%s</link>\n"
"<guid isPermaLink=\"false\">%s</guid>\n" "<author>%s</author>\n"
"<pubDate>%s</pubDate>\n" "<guid isPermaLink=\"false\">%s</guid>\n"
(org-rss-build-categories headline info) "\n" "<pubDate>%s</pubDate>\n"
"<description><![CDATA[%s]]></description>\n" (org-rss-build-categories headline info) "\n"
"</item>\n") "<description><![CDATA[%s]]></description>\n"
title publink author guid pubdate contents)))) "</item>\n")
title publink author guid pubdate contents)))))
(defun org-rss-build-categories (headline info) (defun org-rss-build-categories (headline info)
"Build categories for the RSS item." "Build categories for the RSS item."