changeset 47:b68880838990

Add support for the RSS Content module to the RSS 2.0 feed parser
author Guido Berhoerster <guido+feed-preview@berhoerster.name>
date Wed, 03 Jul 2019 16:57:17 +0200
parents 586eebf8efb7
children d5506fdb65f0
files js/feed-parser.js
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/js/feed-parser.js	Wed Jul 03 15:51:36 2019 +0200
+++ b/js/feed-parser.js	Wed Jul 03 16:57:17 2019 +0200
@@ -13,6 +13,7 @@
     ATOM10: 'http://www.w3.org/2005/Atom',
     RSS09: 'http://my.netscape.com/rdf/simple/0.9/',
     RSS10: 'http://purl.org/rss/1.0/',
+    CONTENT: 'http://purl.org/rss/1.0/modules/content/',
     XHTML: 'http://www.w3.org/1999/xhtml',
     PARSERERROR: 'http://www.mozilla.org/newlayout/xml/parsererror.xml'
 }
@@ -75,6 +76,8 @@
             return XMLNS.RSS09;
         case 'rss10':
             return XMLNS.RSS10;
+        case 'content':
+            return XMLNS.CONTENT;
     }
     return null;
 }
@@ -749,10 +752,16 @@
             date = parseDate(pubDateElement.textContent);
         }
 
-        let descriptionElement = feedQueryXPath(this.document, itemElement,
-                './description');
-        if (descriptionElement !== null) {
-            content = descriptionElement.textContent.trim();
+        let encodedElement = feedQueryXPath(this.document, itemElement,
+                './content:encoded');
+        if (encodedElement !== null) {
+            content = encodedElement.textContent.trim();
+        } else {
+            let descriptionElement = feedQueryXPath(this.document, itemElement,
+                    './description');
+            if (descriptionElement !== null) {
+                content = descriptionElement.textContent.trim();
+            }
         }
 
         for (let enclosureElement of