More style alignment for feed processor

This commit is contained in:
J. Ryan Stinnett 2021-05-07 17:45:01 +01:00
parent 088483b776
commit a210f1fbde

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-disable quote-props */
function LOG(str) {
dump("*** " + str + "\n");
}
@ -218,8 +220,13 @@ function Feed() {
Feed.prototype = {
searchLists: {
title: ["title", "rss1:title", "atom03:title", "atom:title"],
subtitle: ["description", "dc:description", "rss1:description",
"atom03:tagline", "atom:subtitle"],
subtitle: [
"description",
"dc:description",
"rss1:description",
"atom03:tagline",
"atom:subtitle",
],
items: ["items", "atom03_entries", "entries"],
id: ["atom:id", "rdf:about"],
generator: ["generator"],
@ -233,8 +240,14 @@ Feed.prototype = {
textInput: ["textInput", "rss1:textinput"],
skipDays: ["skipDays"],
skipHours: ["skipHours"],
updated: ["pubDate", "lastBuildDate", "atom03:modified", "dc:date",
"dcterms:modified", "atom:updated"],
updated: [
"pubDate",
"lastBuildDate",
"atom03:modified",
"dc:date",
"dcterms:modified",
"atom:updated",
],
},
normalize: function Feed_normalize() {
@ -309,10 +322,8 @@ Feed.prototype = {
if (entries_with_enclosures == this.items.length && other_count == 0) {
if (audio_count > 0 && !video_count && !image_count) {
feedtype = Ci.nsIFeed.TYPE_AUDIO;
} else if (image_count > 0 && !audio_count && !video_count) {
feedtype = Ci.nsIFeed.TYPE_IMAGE;
} else if (video_count > 0 && !audio_count && !image_count) {
feedtype = Ci.nsIFeed.TYPE_VIDEO;
}
@ -396,17 +407,31 @@ Entry.prototype = {
searchLists: {
title: ["title", "rss1:title", "atom03:title", "atom:title"],
link: [["link", strToURI], ["rss1:link", strToURI]],
id: [["guid", makePropGetter("guid")], "rdf:about",
"atom03:id", "atom:id"],
id: [
["guid", makePropGetter("guid")],
"rdf:about",
"atom03:id",
"atom:id",
],
authors: ["authors"],
contributors: ["contributors"],
summary: ["description", "rss1:description", "dc:description",
"atom03:summary", "atom:summary"],
summary: [
"description",
"rss1:description",
"dc:description",
"atom03:summary",
"atom:summary",
],
content: ["content:encoded", "atom03:content", "atom:content"],
rights: ["atom03:rights", "atom:rights"],
published: ["pubDate", "atom03:issued", "dcterms:issued", "atom:published"],
updated: ["pubDate", "atom03:modified", "dc:date", "dcterms:modified",
"atom:updated"],
updated: [
"pubDate",
"atom03:modified",
"dc:date",
"dcterms:modified",
"atom:updated",
],
},
normalize: function Entry_normalize() {
@ -588,7 +613,7 @@ Entry.prototype = {
Entry.prototype._atomLinksToURI = Feed.prototype._atomLinksToURI;
Entry.prototype._resolveURI = Feed.prototype._resolveURI;
Entry.prototype._resetBagMembersToRawText =
Feed.prototype._resetBagMembersToRawText;
Feed.prototype._resetBagMembersToRawText;
// TextConstruct represents and element that could contain (X)HTML
function TextConstruct() {
@ -657,8 +682,8 @@ Generator.prototype = {
set attributes(value) {
this._attributes = value;
this.version = this._attributes.getValueFromName("", "version");
var uriAttribute = this._attributes.getValueFromName("", "uri") ||
this._attributes.getValueFromName("", "url");
var uriAttribute = this._attributes.getValueFromName("", "uri")
|| this._attributes.getValueFromName("", "url");
this.uri = strToURI(uriAttribute, this.baseURI);
// RSS1
@ -969,7 +994,6 @@ ExtensionHandler.prototype = {
// if we descend into another element, we won't send text
this._hasChildElements = (this._depth > 1);
},
endElement: function EH_endElement(uri, localName, qName) {
--this._depth;
@ -1040,21 +1064,23 @@ function FeedProcessor() {
// These elements can contain (X)HTML or plain text.
// We keep a table here that contains their default treatment
this._textConstructs = {"atom:title": "text",
"atom:summary": "text",
"atom:rights": "text",
"atom:content": "text",
"atom:subtitle": "text",
"description": "html",
"rss1:description": "html",
"dc:description": "html",
"content:encoded": "html",
"title": "text",
"rss1:title": "text",
"atom03:title": "text",
"atom03:tagline": "text",
"atom03:summary": "text",
"atom03:content": "text"};
this._textConstructs = {
"atom:title": "text",
"atom:summary": "text",
"atom:rights": "text",
"atom:content": "text",
"atom:subtitle": "text",
"description": "html",
"rss1:description": "html",
"dc:description": "html",
"content:encoded": "html",
"title": "text",
"rss1:title": "text",
"atom03:title": "text",
"atom03:tagline": "text",
"atom03:summary": "text",
"atom03:content": "text"
};
this._stack = [];
this._trans = {
@ -1080,33 +1106,24 @@ function FeedProcessor() {
"IN_CHANNEL": {
"item": new ElementInfo("items", Cc[ENTRY_CONTRACTID], null, true),
"managingEditor": new ElementInfo("authors", Cc[PERSON_CONTRACTID],
rssAuthor, true),
"dc:creator": new ElementInfo("authors", Cc[PERSON_CONTRACTID],
rssAuthor, true),
"dc:author": new ElementInfo("authors", Cc[PERSON_CONTRACTID],
rssAuthor, true),
"dc:contributor": new ElementInfo("contributors", Cc[PERSON_CONTRACTID],
rssAuthor, true),
"managingEditor": new ElementInfo("authors", Cc[PERSON_CONTRACTID], rssAuthor, true),
"dc:creator": new ElementInfo("authors", Cc[PERSON_CONTRACTID], rssAuthor, true),
"dc:author": new ElementInfo("authors", Cc[PERSON_CONTRACTID], rssAuthor, true),
"dc:contributor": new ElementInfo("contributors", Cc[PERSON_CONTRACTID], rssAuthor, true),
"category": new ElementInfo("categories", null, rssCatTerm, true),
"cloud": new ElementInfo("cloud", null, null, false),
"image": new ElementInfo("image", null, null, false),
"textInput": new ElementInfo("textInput", null, null, false),
"skipDays": new ElementInfo("skipDays", null, null, false),
"skipHours": new ElementInfo("skipHours", null, null, false),
"generator": new ElementInfo("generator", Cc[GENERATOR_CONTRACTID],
atomGenerator, false),
"generator": new ElementInfo("generator", Cc[GENERATOR_CONTRACTID], atomGenerator, false),
},
"IN_ITEMS": {
"author": new ElementInfo("authors", Cc[PERSON_CONTRACTID],
rssAuthor, true),
"dc:creator": new ElementInfo("authors", Cc[PERSON_CONTRACTID],
rssAuthor, true),
"dc:author": new ElementInfo("authors", Cc[PERSON_CONTRACTID],
rssAuthor, true),
"dc:contributor": new ElementInfo("contributors", Cc[PERSON_CONTRACTID],
rssAuthor, true),
"author": new ElementInfo("authors", Cc[PERSON_CONTRACTID], rssAuthor, true),
"dc:creator": new ElementInfo("authors", Cc[PERSON_CONTRACTID], rssAuthor, true),
"dc:author": new ElementInfo("authors", Cc[PERSON_CONTRACTID], rssAuthor, true),
"dc:contributor": new ElementInfo("contributors", Cc[PERSON_CONTRACTID], rssAuthor, true),
"category": new ElementInfo("categories", null, rssCatTerm, true),
"enclosure": new ElementInfo("enclosure", null, null, false),
"media:content": new ElementInfo("mediacontent", null, null, true),
@ -1138,62 +1155,42 @@ function FeedProcessor() {
},
"IN_RDF_CHANNEL": {
"admin:generatorAgent": new ElementInfo("generator",
Cc[GENERATOR_CONTRACTID],
null, false),
"dc:creator": new ElementInfo("authors", Cc[PERSON_CONTRACTID],
rssAuthor, true),
"dc:author": new ElementInfo("authors", Cc[PERSON_CONTRACTID],
rssAuthor, true),
"dc:contributor": new ElementInfo("contributors", Cc[PERSON_CONTRACTID],
rssAuthor, true),
"admin:generatorAgent": new ElementInfo("generator", Cc[GENERATOR_CONTRACTID], null, false),
"dc:creator": new ElementInfo("authors", Cc[PERSON_CONTRACTID], rssAuthor, true),
"dc:author": new ElementInfo("authors", Cc[PERSON_CONTRACTID], rssAuthor, true),
"dc:contributor": new ElementInfo("contributors", Cc[PERSON_CONTRACTID], rssAuthor, true),
},
/** ******* ATOM 1.0 **********/
"IN_ATOM": {
"atom:author": new ElementInfo("authors", Cc[PERSON_CONTRACTID],
null, true),
"atom:generator": new ElementInfo("generator", Cc[GENERATOR_CONTRACTID],
atomGenerator, false),
"atom:contributor": new ElementInfo("contributors", Cc[PERSON_CONTRACTID],
null, true),
"atom:author": new ElementInfo("authors", Cc[PERSON_CONTRACTID], null, true),
"atom:generator": new ElementInfo("generator", Cc[GENERATOR_CONTRACTID], atomGenerator, false),
"atom:contributor": new ElementInfo("contributors", Cc[PERSON_CONTRACTID], null, true),
"atom:link": new ElementInfo("links", null, null, true),
"atom:logo": new ElementInfo("atom:logo", null, atomLogo, false),
"atom:entry": new ElementInfo("entries", Cc[ENTRY_CONTRACTID],
null, true),
"atom:entry": new ElementInfo("entries", Cc[ENTRY_CONTRACTID], null, true),
},
"IN_ENTRIES": {
"atom:author": new ElementInfo("authors", Cc[PERSON_CONTRACTID],
null, true),
"atom:contributor": new ElementInfo("contributors", Cc[PERSON_CONTRACTID],
null, true),
"atom:author": new ElementInfo("authors", Cc[PERSON_CONTRACTID], null, true),
"atom:contributor": new ElementInfo("contributors", Cc[PERSON_CONTRACTID], null, true),
"atom:link": new ElementInfo("links", null, null, true),
},
/** ******* ATOM 0.3 **********/
"IN_ATOM03": {
"atom03:author": new ElementInfo("authors", Cc[PERSON_CONTRACTID],
null, true),
"atom03:contributor": new ElementInfo("contributors",
Cc[PERSON_CONTRACTID],
null, true),
"atom03:author": new ElementInfo("authors", Cc[PERSON_CONTRACTID], null, true),
"atom03:contributor": new ElementInfo("contributors", Cc[PERSON_CONTRACTID], null, true),
"atom03:link": new ElementInfo("links", null, null, true),
"atom03:entry": new ElementInfo("atom03_entries", Cc[ENTRY_CONTRACTID],
null, true),
"atom03:generator": new ElementInfo("generator", Cc[GENERATOR_CONTRACTID],
atomGenerator, false),
"atom03:entry": new ElementInfo("atom03_entries", Cc[ENTRY_CONTRACTID], null, true),
"atom03:generator": new ElementInfo("generator", Cc[GENERATOR_CONTRACTID], atomGenerator, false),
},
"IN_ATOM03_ENTRIES": {
"atom03:author": new ElementInfo("authors", Cc[PERSON_CONTRACTID],
null, true),
"atom03:contributor": new ElementInfo("contributors",
Cc[PERSON_CONTRACTID],
null, true),
"atom03:author": new ElementInfo("authors", Cc[PERSON_CONTRACTID], null, true),
"atom03:contributor": new ElementInfo("contributors", Cc[PERSON_CONTRACTID], null, true),
"atom03:link": new ElementInfo("links", null, null, true),
"atom03:entry": new ElementInfo("atom03_entries", Cc[ENTRY_CONTRACTID],
null, true),
"atom03:entry": new ElementInfo("atom03_entries", Cc[ENTRY_CONTRACTID], null, true),
},
};
}
@ -1504,7 +1501,6 @@ FeedProcessor.prototype = {
// its member nsIPropertyBag instead.
if (isIFeedContainer(obj))
newProp = obj.fields;
} else {
// If it doesn't, set it.
if (!prop) {
@ -1722,13 +1718,23 @@ FeedProcessor.prototype = {
// XPCOM stuff
classID: FP_CLASSID,
QueryInterface: ChromeUtils.generateQI(
[Ci.nsIFeedProcessor, Ci.nsISAXContentHandler, Ci.nsISAXErrorHandler,
Ci.nsIStreamListener, Ci.nsIRequestObserver]
),
QueryInterface: ChromeUtils.generateQI([
Ci.nsIFeedProcessor,
Ci.nsISAXContentHandler,
Ci.nsISAXErrorHandler,
Ci.nsIStreamListener,
Ci.nsIRequestObserver,
]),
};
var components = [FeedProcessor, FeedResult, Feed, Entry,
TextConstruct, Generator, Person];
var components = [
FeedProcessor,
FeedResult,
Feed,
Entry,
TextConstruct,
Generator,
Person,
];
this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components);