diff js/feed-parser.js @ 31:76e23b361e92

Allow feed reader addons to subscribe to the currently viewed feed Add a link element to the feed preview that points to the currently viewed feed in order to allow feed reader addons to subscribe to it.
author Guido Berhoerster <guido+feed-preview@berhoerster.name>
date Tue, 22 Jan 2019 14:40:06 +0100
parents 104a1faebd43
children b68880838990
line wrap: on
line diff
--- a/js/feed-parser.js	Tue Jan 22 10:43:24 2019 +0100
+++ b/js/feed-parser.js	Tue Jan 22 14:40:06 2019 +0100
@@ -184,9 +184,10 @@
 }
 
 class Feed {
-    constructor(url, {title = browser.i18n.getMessage('defaultFeedTitle'),
+    constructor(url, type, {title = browser.i18n.getMessage('defaultFeedTitle'),
             subtitle = '', logo, entries = []} = {}) {
         this.url = url;
+        this.type = type;
         this.title = title;
         this.subtitle = subtitle;
         this.logo = logo;
@@ -431,7 +432,8 @@
             entries.push(this.parseAtom03Entry(entryElement));
         }
 
-        return new Feed(this.url, {title, subtitle, logo, entries});
+        return new Feed(this.url, 'application/atom+xml',
+                {title, subtitle, logo, entries});
     }
 
     parseAtomLogo(logoElement) {
@@ -595,7 +597,8 @@
             entries.push(this.parseAtomEntry(entryElement));
         }
 
-        return new Feed(this.url, {title, subtitle, logo, entries});
+        return new Feed(this.url, 'application/atom+xml',
+                {title, subtitle, logo, entries});
     }
 
     parseRSS1Logo(imageElement, nsPrefix) {
@@ -677,7 +680,8 @@
             }
         }
 
-        return new Feed(this.url, {title, subtitle, logo, entries});
+        return new Feed(this.url, 'application/rss+xml',
+                {title, subtitle, logo, entries});
     }
 
     parseRSS2Logo(imageElement) {
@@ -805,7 +809,8 @@
             }
         }
 
-        return new Feed(this.url, {title, subtitle, logo, entries});
+        return new Feed(this.url, 'application/rss+xml',
+                {title, subtitle, logo, entries});
     }
 
     parseFromString(xmlString, url) {