mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 373340. atom:logo in feed reading view. r=mano
This commit is contained in:
parent
eea3888f52
commit
9c3474cffb
@ -346,7 +346,7 @@ Feed.prototype = {
|
|||||||
categories: ["categories", "dc:subject"],
|
categories: ["categories", "dc:subject"],
|
||||||
rights: ["atom03:rights","atom:rights"],
|
rights: ["atom03:rights","atom:rights"],
|
||||||
cloud: ["cloud"],
|
cloud: ["cloud"],
|
||||||
image: ["image", "rss1:image"],
|
image: ["image", "rss1:image", "atom:logo"],
|
||||||
textInput: ["textInput", "rss1:textinput"],
|
textInput: ["textInput", "rss1:textinput"],
|
||||||
skipDays: ["skipDays"],
|
skipDays: ["skipDays"],
|
||||||
skipHours: ["skipHours"],
|
skipHours: ["skipHours"],
|
||||||
@ -368,6 +368,10 @@ Feed.prototype = {
|
|||||||
if (bagHasKey(this.fields, "links"))
|
if (bagHasKey(this.fields, "links"))
|
||||||
this._atomLinksToURI();
|
this._atomLinksToURI();
|
||||||
|
|
||||||
|
// Resolve relative image links
|
||||||
|
if (this.image && bagHasKey(this.image, "url"))
|
||||||
|
this._resolveImageLink();
|
||||||
|
|
||||||
this._resetBagMembersToRawText([this.searchLists.subtitle,
|
this._resetBagMembersToRawText([this.searchLists.subtitle,
|
||||||
this.searchLists.title]);
|
this.searchLists.title]);
|
||||||
},
|
},
|
||||||
@ -376,22 +380,36 @@ Feed.prototype = {
|
|||||||
var links = this.fields.getPropertyAsInterface("links", Ci.nsIArray);
|
var links = this.fields.getPropertyAsInterface("links", Ci.nsIArray);
|
||||||
var alternates = findAtomLinks("alternate", links);
|
var alternates = findAtomLinks("alternate", links);
|
||||||
if (alternates.length > 0) {
|
if (alternates.length > 0) {
|
||||||
try {
|
var href = alternates[0].getPropertyAsAString("href");
|
||||||
var href = alternates[0].getPropertyAsAString("href");
|
var base;
|
||||||
var base;
|
if (bagHasKey(alternates[0], "xml:base"))
|
||||||
if (bagHasKey(alternates[0], "xml:base"))
|
base = alternates[0].getPropertyAsAString("xml:base");
|
||||||
base = strToURI(alternates[0].getPropertyAsAString("xml:base"),
|
this.link = this._resolveURI(href, base);
|
||||||
this.baseURI);
|
|
||||||
else
|
|
||||||
base = this.baseURI;
|
|
||||||
this.link = strToURI(alternates[0].getPropertyAsAString("href"), base);
|
|
||||||
}
|
|
||||||
catch(e) {
|
|
||||||
LOG(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_resolveImageLink: function Feed_resolveImageLink() {
|
||||||
|
var base;
|
||||||
|
if (bagHasKey(this.image, "xml:base"))
|
||||||
|
base = this.image.getPropertyAsAString("xml:base");
|
||||||
|
var url = this._resolveURI(this.image.getPropertyAsAString("url"), base);
|
||||||
|
if (url)
|
||||||
|
this.image.setPropertyAsAString("url", url.spec);
|
||||||
|
},
|
||||||
|
|
||||||
|
_resolveURI: function Feed_resolveURI(linkSpec, baseSpec) {
|
||||||
|
var uri = null;
|
||||||
|
try {
|
||||||
|
var base = baseSpec ? strToURI(baseSpec, this.baseURI) : this.baseURI;
|
||||||
|
uri = strToURI(linkSpec, base);
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
LOG(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return uri;
|
||||||
|
},
|
||||||
|
|
||||||
// reset the bag to raw contents, not text constructs
|
// reset the bag to raw contents, not text constructs
|
||||||
_resetBagMembersToRawText: function Feed_resetBagMembers(fieldLists) {
|
_resetBagMembersToRawText: function Feed_resetBagMembers(fieldLists) {
|
||||||
for (var i=0; i<fieldLists.length; i++) {
|
for (var i=0; i<fieldLists.length; i++) {
|
||||||
@ -490,6 +508,7 @@ Entry.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Entry.prototype._atomLinksToURI = Feed.prototype._atomLinksToURI;
|
Entry.prototype._atomLinksToURI = Feed.prototype._atomLinksToURI;
|
||||||
|
Entry.prototype._resolveURI = Feed.prototype._resolveURI;
|
||||||
Entry.prototype._resetBagMembersToRawText =
|
Entry.prototype._resetBagMembersToRawText =
|
||||||
Feed.prototype._resetBagMembersToRawText;
|
Feed.prototype._resetBagMembersToRawText;
|
||||||
|
|
||||||
@ -646,7 +665,12 @@ function atomGenerator(s, generator) {
|
|||||||
generator.QueryInterface(Ci.nsIFeedGenerator);
|
generator.QueryInterface(Ci.nsIFeedGenerator);
|
||||||
generator.agent = trimString(s);
|
generator.agent = trimString(s);
|
||||||
return generator;
|
return generator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// post-process atom:logo to create an RSS2-like structure
|
||||||
|
function atomLogo(s, logo) {
|
||||||
|
logo.setPropertyAsAString("url", trimString(s));
|
||||||
|
}
|
||||||
|
|
||||||
// post-process an RSS category, map it to the Atom fields.
|
// post-process an RSS category, map it to the Atom fields.
|
||||||
function rssCatTerm(s, cat) {
|
function rssCatTerm(s, cat) {
|
||||||
@ -1152,6 +1176,7 @@ function FeedProcessor() {
|
|||||||
"atom:contributor": new ElementInfo("contributors", Cc[PERSON_CONTRACTID],
|
"atom:contributor": new ElementInfo("contributors", Cc[PERSON_CONTRACTID],
|
||||||
null, true),
|
null, true),
|
||||||
"atom:link": new ElementInfo("links", null, 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],
|
"atom:entry": new ElementInfo("entries", Cc[ENTRY_CONTRACTID],
|
||||||
null, true)
|
null, true)
|
||||||
},
|
},
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
<!--
|
<!--
|
||||||
|
|
||||||
Description: atom logo works
|
Description: atom logo works
|
||||||
Expect: feed.fields.getProperty('atom:logo') == 'http://example.org/logo.jpg'
|
Expect: feed.image.getProperty('url') == 'http://example.org/logo.jpg'
|
||||||
|
|
||||||
-->
|
-->
|
||||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||||
<title>test title</title>
|
<title>test title</title>
|
||||||
<logo>http://example.org/logo.jpg</logo>
|
<logo xml:base="http://example.org/">logo.jpg</logo>
|
||||||
</feed>
|
</feed>
|
Loading…
Reference in New Issue
Block a user