addons/firefox-addons/feed-preview

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 Jul 03 16:57:17 2019 +0200 (11 months ago)
parents 586eebf8efb7
children d5506fdb65f0
files js/feed-parser.js
line diff
     1.1 --- a/js/feed-parser.js	Wed Jul 03 15:51:36 2019 +0200
     1.2 +++ b/js/feed-parser.js	Wed Jul 03 16:57:17 2019 +0200
     1.3 @@ -13,6 +13,7 @@
     1.4      ATOM10: 'http://www.w3.org/2005/Atom',
     1.5      RSS09: 'http://my.netscape.com/rdf/simple/0.9/',
     1.6      RSS10: 'http://purl.org/rss/1.0/',
     1.7 +    CONTENT: 'http://purl.org/rss/1.0/modules/content/',
     1.8      XHTML: 'http://www.w3.org/1999/xhtml',
     1.9      PARSERERROR: 'http://www.mozilla.org/newlayout/xml/parsererror.xml'
    1.10  }
    1.11 @@ -75,6 +76,8 @@
    1.12              return XMLNS.RSS09;
    1.13          case 'rss10':
    1.14              return XMLNS.RSS10;
    1.15 +        case 'content':
    1.16 +            return XMLNS.CONTENT;
    1.17      }
    1.18      return null;
    1.19  }
    1.20 @@ -749,10 +752,16 @@
    1.21              date = parseDate(pubDateElement.textContent);
    1.22          }
    1.23  
    1.24 -        let descriptionElement = feedQueryXPath(this.document, itemElement,
    1.25 -                './description');
    1.26 -        if (descriptionElement !== null) {
    1.27 -            content = descriptionElement.textContent.trim();
    1.28 +        let encodedElement = feedQueryXPath(this.document, itemElement,
    1.29 +                './content:encoded');
    1.30 +        if (encodedElement !== null) {
    1.31 +            content = encodedElement.textContent.trim();
    1.32 +        } else {
    1.33 +            let descriptionElement = feedQueryXPath(this.document, itemElement,
    1.34 +                    './description');
    1.35 +            if (descriptionElement !== null) {
    1.36 +                content = descriptionElement.textContent.trim();
    1.37 +            }
    1.38          }
    1.39  
    1.40          for (let enclosureElement of