зеркало из https://github.com/mozilla/snowl.git
localize prefwindow, remove obsolete OPML import code from prefwindow, and display message about not yet having any preferences
This commit is contained in:
Родитель
7be3514624
Коммит
91b35f87d7
|
@ -38,64 +38,3 @@ const Cc = Components.classes;
|
||||||
const Ci = Components.interfaces;
|
const Ci = Components.interfaces;
|
||||||
const Cr = Components.results;
|
const Cr = Components.results;
|
||||||
const Cu = Components.utils;
|
const Cu = Components.utils;
|
||||||
|
|
||||||
Cu.import("resource://snowl/modules/service.js");
|
|
||||||
Cu.import("resource://snowl/modules/datastore.js");
|
|
||||||
Cu.import("resource://snowl/modules/feed.js");
|
|
||||||
Cu.import("resource://snowl/modules/URI.js");
|
|
||||||
|
|
||||||
let SnowlPreferences = {
|
|
||||||
onImportOPML: function() {
|
|
||||||
let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
|
|
||||||
fp.init(window, "Import", Ci.nsIFilePicker.modeOpen);
|
|
||||||
fp.appendFilter("OPML Files", "*.opml");
|
|
||||||
fp.appendFilters(Ci.nsIFilePicker.filterXML);
|
|
||||||
fp.appendFilters(Ci.nsIFilePicker.filterAll);
|
|
||||||
|
|
||||||
let rv = fp.show();
|
|
||||||
if (rv != Ci.nsIFilePicker.returnOK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
|
|
||||||
createInstance(Ci.nsIXMLHttpRequest);
|
|
||||||
request.open("GET", fp.fileURL.spec, false);
|
|
||||||
// Since the file probably ends in .opml, we have to force XHR to treat it
|
|
||||||
// as XML by overriding the MIME type it would otherwise select.
|
|
||||||
request.overrideMimeType("text/xml");
|
|
||||||
request.send(null);
|
|
||||||
let xmlDocument = request.responseXML;
|
|
||||||
|
|
||||||
let outline = xmlDocument.getElementsByTagName("body")[0];
|
|
||||||
|
|
||||||
this._importOutline(outline);
|
|
||||||
},
|
|
||||||
|
|
||||||
_importOutline: function(aOutline) {
|
|
||||||
// If this outline represents a feed, subscribe the user to the feed.
|
|
||||||
let uri = URI.get(aOutline.getAttribute("xmlUrl"));
|
|
||||||
if (uri) {
|
|
||||||
// FIXME: make sure the user isn't already subscribed to the feed
|
|
||||||
// before subscribing them.
|
|
||||||
let name = aOutline.getAttribute("title") || aOutline.getAttribute("text") || "untitled";
|
|
||||||
this._importItem(uri, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aOutline.hasChildNodes()) {
|
|
||||||
let children = aOutline.childNodes;
|
|
||||||
for (let i = 0; i < children.length; i++) {
|
|
||||||
let child = children[i];
|
|
||||||
|
|
||||||
// Only deal with "outline" elements; ignore text, etc. nodes.
|
|
||||||
if (child.nodeName != "outline")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
this._importOutline(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_importItem: function(aURL, aName) {
|
|
||||||
let subscriber = new SnowlFeedSubscriber(aURL, aName);
|
|
||||||
subscriber.subscribe();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
|
@ -38,14 +38,15 @@
|
||||||
|
|
||||||
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
|
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
|
||||||
|
|
||||||
|
<!DOCTYPE prefwindow SYSTEM "chrome://snowl/locale/preferences.dtd">
|
||||||
|
|
||||||
<prefwindow xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
<prefwindow xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
title="Snowl Preferences"
|
title="&prefwindow.title;">
|
||||||
buttons="none">
|
|
||||||
|
|
||||||
<script type="application/x-javascript" src="chrome://snowl/content/preferences.js"/>
|
<script type="application/x-javascript" src="chrome://snowl/content/preferences.js"/>
|
||||||
|
|
||||||
<prefpane label="Snowl Preferences">
|
<prefpane>
|
||||||
<button label="Import OPML" oncommand="SnowlPreferences.onImportOPML(event);"/>
|
&noPreferences.message;
|
||||||
</prefpane>
|
</prefpane>
|
||||||
|
|
||||||
</prefwindow>
|
</prefwindow>
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
<!ENTITY prefwindow.title "Snowl Preferences">
|
||||||
|
<!ENTITY noPreferences.message "Snowl does not yet have preferences.">
|
Загрузка…
Ссылка в новой задаче