[Pkg-mozext-commits] [sage-extension] 10/20: localization updates
David Prévot
taffit at moszumanska.debian.org
Fri May 1 03:10:26 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to tag sage_1_2
in repository sage-extension.
commit 21169049e0ded05593e51b6554efcf13d48bfe33
Author: Peter Andrews <petea at jhu.edu>
Date: Fri Jul 16 22:59:20 2004 +0000
localization updates
---
src/sage/content/discover_feeds.js | 67 +++++++++++++++++++++++------------
src/sage/content/discover_feeds.xul | 7 ++--
src/sage/content/feedlib.js | 46 +++++++++++++++++-------
src/sage/content/opml/opml.js | 4 +--
src/sage/content/opml/opml.xul | 5 ++-
src/sage/content/sage.js | 4 +--
src/sage/locale/en-US/sage.dtd | 2 +-
src/sage/locale/en-US/sage.properties | 4 ++-
src/sage/locale/fr-FR/sage.properties | 4 ++-
9 files changed, 97 insertions(+), 46 deletions(-)
diff --git a/src/sage/content/discover_feeds.js b/src/sage/content/discover_feeds.js
index b18e9d4..af60644 100644
--- a/src/sage/content/discover_feeds.js
+++ b/src/sage/content/discover_feeds.js
@@ -3,7 +3,6 @@ var strRes;
var feedTree;
var dataSource;
var rdf;
-var feeds;
var ds;
var rdfService;
var schema;
@@ -16,8 +15,11 @@ var statusDeck;
var statusMessage;
var feeds_found_local;
var feeds_found_external;
+var possibleFeeds;
function init() {
+ var discoveryMode = CommonFunc.getPrefValue(CommonFunc.FEED_DISCOVERY_MODE, "str", "exhaustive");
+
initServices();
initBMService();
@@ -30,7 +32,7 @@ function init() {
dataSource = Components.classes["@mozilla.org/rdf/datasource;1?name=in-memory-datasource"];
rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"];
- rdfService = rdf.getService(Components.interfaces.nsIRDFService);
+ rdfService = rdf.getService(Components.interfaces.nsIRDFService);
ds = dataSource.createInstance(Components.interfaces.nsIRDFInMemoryDataSource);
feedTree.database.AddDataSource(ds);
@@ -49,22 +51,37 @@ function init() {
var current_document = browserWindow.contentDocument;
document_host = current_document.location.host;
+ if(document_host.match(/^www\./i)) {
+ document_host = document_host.substring(4, document_host.length - 1);
+ }
logMessage("host: " + document_host);
- var possible_feeds = new Object();
+ possibleFeeds = new Array();
- var links = current_document.getElementsByTagName("link");
- for(var c = 0; c < links.length; c++) {
- if(links[c].rel == "alternate" && (links[c].type == "text/xml" || links[c].type == "application/atom+xml" || links[c].type == "application/rss+xml")) {
- possible_feeds[links[c].href] = links[c].href;
- logMessage("Found: " + links[c].href);
+ var links, c;
+
+ if(discoveryMode == "exhaustive") {
+ links = current_document.getElementsByTagName("a");
+ for(c = 0; c < links.length; c++) {
+ if(links[c].href.match(/xml$|rss|rdf|atom/i)) {
+ possibleFeeds[links[c].href] = Array(links[c].href, "implicit");
+ logMessage("Found: " + links[c].href);
+ }
+ }
+ } else {
+ links = current_document.getElementsByTagName("a");
+ for(c = 0; c < links.length; c++) {
+ if(links[c].href.match(/xml$|rss|rdf|atom/i) && links[c].href.match(new RegExp(document_host, "i"))) {
+ possibleFeeds[links[c].href] = Array(links[c].href, "implicit");
+ logMessage("Found: " + links[c].href);
+ }
}
}
- links = current_document.getElementsByTagName("a");
+ links = current_document.getElementsByTagName("link");
for(c = 0; c < links.length; c++) {
- if(links[c].href.match(/xml$|rss|rdf|atom/i)) {
- possible_feeds[links[c].href] = links[c].href;
+ if(links[c].rel == "alternate" && (links[c].type == "text/xml" || links[c].type == "application/atom+xml" || links[c].type == "application/rss+xml")) {
+ possibleFeeds[links[c].href] = Array(links[c].href, "explicit");
logMessage("Found: " + links[c].href);
}
}
@@ -74,7 +91,7 @@ function init() {
feeds_found_local = 0;
feeds_found_external = 0;
- for(url in possible_feeds) {
+ for(entry in possibleFeeds) {
fetch_total++;
}
@@ -84,16 +101,15 @@ function init() {
logMessage("found " + fetch_total + " potential feed URI(s) in " + current_document.location);
- feeds = new Array();
var httpReq;
- for(url in possible_feeds) {
+ for(entry in possibleFeeds) {
httpReq = new XMLHttpRequest();
httpReq.onload = httpLoaded;
httpReq.onerror = httpError;
- httpReq.open("GET", url, true);
- httpReq.setRequestHeader("User-Agent", CommonFunc.USER_AGENT);
- httpReq.overrideMimeType("application/xml");
try {
+ httpReq.open("GET", possibleFeeds[entry][0], true);
+ httpReq.setRequestHeader("User-Agent", CommonFunc.USER_AGENT);
+ httpReq.overrideMimeType("application/xml");
httpReq.send(null);
} catch(e) {
httpReq.abort();
@@ -133,11 +149,13 @@ function doAddFeed() {
var sage_folder = rdfService.GetResource(CommonFunc.getPrefValue(CommonFunc.RSS_READER_FOLDER_ID, "str", "NC:BookmarksRoot"));
BMSVC.createBookmarkInContainer(title, url, null, "updated", null, null, sage_folder, null);
logMessage("added feed: '" + title + "' " + url);
+
+ // select new feed in sibebar
+ var bm_index = bookmarksTree.treeBoxObject.view.rowCount - 1;
+ bookmarksTree.treeBoxObject.ensureRowIsVisible(bm_index);
+ bookmarksTree.treeBoxObject.selection.select(bm_index);
}
}
- var bm_index = bookmarksTree.treeBoxObject.view.rowCount - 1;
- bookmarksTree.treeBoxObject.ensureRowIsVisible(bm_index);
- bookmarksTree.treeBoxObject.selection.select(bm_index);
return true;
}
@@ -161,7 +179,7 @@ function httpLoaded(e) {
function addDiscoveredFeed(uri, feed) {
var feedClass, lastPubDate, itemCount;
- if(uri.host == document_host) { // feed is local
+ if(uri.host.match(new RegExp(document_host, "i"))) { // feed is local
if(feeds_found_local == 0) {
//ds.Assert(rdfService.GetResource(schema + "Feeds"), rdfService.GetResource(schema + "child"), rdfService.GetResource(schema + "LocalFeeds"), true);
//ds.Assert(rdfService.GetResource(schema + "LocalFeeds"), rdfService.GetResource(schema + "Title"), rdfService.GetLiteral("Site Feeds"), true);
@@ -188,8 +206,9 @@ function addDiscoveredFeed(uri, feed) {
// feed valuation
var valuation = 0;
- if(feedClass == "Feeds") valuation += 1000;
- if(feed.hasLastPubDate()) valuation += 100;
+ if(possibleFeeds[uri.spec][1] == "explicit") valuation += 100;
+ if(feedClass == "Feeds") valuation += 10;
+ if(feed.hasLastPubDate()) valuation += 1;
ds.Assert(rdfService.GetResource(schema + feedClass), rdfService.GetResource(schema + "child"), rdfService.GetResource(schema + uri.spec), true);
@@ -200,5 +219,7 @@ function addDiscoveredFeed(uri, feed) {
ds.Assert(rdfService.GetResource(schema + uri.spec), rdfService.GetResource(schema + "ItemCount"), rdfService.GetLiteral(itemCount), true);
ds.Assert(rdfService.GetResource(schema + uri.spec), rdfService.GetResource(schema + "Valuation"), rdfService.GetIntLiteral(valuation), true);
+ feedTree.builder.rebuild();
+
logMessage("discovered feed: " + uri.spec);
}
\ No newline at end of file
diff --git a/src/sage/content/discover_feeds.xul b/src/sage/content/discover_feeds.xul
index 26417ac..bb696a2 100644
--- a/src/sage/content/discover_feeds.xul
+++ b/src/sage/content/discover_feeds.xul
@@ -3,7 +3,8 @@
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<!DOCTYPE page SYSTEM "chrome://sage/locale/sage.dtd">
-<dialog id="sage_discover_feeds" title="Do Nothing"
+
+<dialog id="sage_discover_feeds" title="&menu.discoverFeeds;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
buttons="cancel"
onload="init();"
@@ -53,7 +54,7 @@
<splitter class="tree-splitter"/>
<treecol id="url" label="&discovery.header.url;" flex="1" hidden="true" persist="width ordinal hidden"/>
<splitter class="tree-splitter"/>
- <treecol id="valuation" label="Value" flex="1" hidden="true" persist="width ordinal hidden" sort="rdf:http://sage.mozdev.org/FeedData#Valuation" sortDirection="descending" sortActive="true" class="sortDirectionIndicator"/>
+ <treecol id="valuation" label="Value" flex="1" hidden="true" ignoreincolumnpicker="true" persist="width ordinal hidden" sort="rdf:http://sage.mozdev.org/FeedData#Valuation" sortDirection="descending" sortActive="true" class="sortDirectionIndicator"/>
</treecols>
<template>
@@ -74,7 +75,7 @@
</template>
</tree>
-
+ <spacer height="10"/>
<hbox align="center" flex="1">
<spacer flex="1"/>
<button label="&discovery.button.addFeed;" oncommand="doAddFeed()"/>
diff --git a/src/sage/content/feedlib.js b/src/sage/content/feedlib.js
index 6201209..0effde9 100644
--- a/src/sage/content/feedlib.js
+++ b/src/sage/content/feedlib.js
@@ -1,5 +1,10 @@
-function Feed(feedXML) {
+/**
+ * Feed class
+ *
+ */
+
+function Feed(feedXML) {
this.feedXML = feedXML;
this.feedFormat = null;
@@ -27,26 +32,36 @@ Feed.prototype.parseRSS = function() {
var feedXML = this.feedXML;
- first_element = feedXML.documentElement;
+ var firstElement = feedXML.documentElement;
- if(first_element.localName.toLowerCase() == "rdf") {
+ if(firstElement.localName.toLowerCase() == "rdf") {
this.feedFormat = "RSS (1.0)";
- } else if(first_element.localName.toLowerCase() == "rss") {
- if(first_element.hasAttribute("version")) {
- this.feedFormat = "RSS (" + first_element.getAttribute("version") + ")";
+ } else if(firstElement.localName.toLowerCase() == "rss") {
+ if(firstElement.hasAttribute("version")) {
+ this.feedFormat = "RSS (" + firstElement.getAttribute("version") + ")";
} else {
this.feedFormat = "RSS (?)";
}
}
var channelNode;
+ for(var i = firstElement.firstChild; i != null; i = i.nextSibling) {
+ if(i.nodeType != i.ELEMENT_NODE) continue;
+ if(i.localName.toLowerCase() == "channel") {
+ channelNode = i;
+ }
+ }
+ if(!channelNode) {
+ throw "No channel element where expected";
+ }
+
if(feedXML.getElementsByTagName("channel").length != 0) {
channelNode = feedXML.getElementsByTagName("channel")[0];
} else {
throw "No elements in channel tag";
}
- for(var i = channelNode.firstChild; i != null; i = i.nextSibling) {
+ for(i = channelNode.firstChild; i != null; i = i.nextSibling) {
if(i.nodeType != i.ELEMENT_NODE) continue;
switch(i.localName) {
case "title":
@@ -121,10 +136,10 @@ Feed.prototype.parseATOM = function() {
var feedXML = this.feedXML;
- first_element = feedXML.documentElement;
+ var firstElement = feedXML.documentElement;
- if(first_element.hasAttribute("version")) {
- this.feedFormat = "ATOM (" + first_element.getAttribute("version") + ")";
+ if(firstElement.hasAttribute("version")) {
+ this.feedFormat = "ATOM (" + firstElement.getAttribute("version") + ")";
} else {
this.feedFormat = "ATOM (?)";
}
@@ -277,6 +292,11 @@ Feed.prototype.getSignature = function() {
+/**
+ * FeedItem class
+ *
+ */
+
function FeedItem(title, link, content, pubDate) {
this.title = title;
this.link = link;
@@ -346,8 +366,10 @@ FeedItem.prototype.getPubDate = function() {
-/* -------------- Utility Functions ---------------- */
-
+/**
+ * Utility functions
+ *
+ */
// Parses an ISO 8601 formatted date string and returns a JavaScript Date object, returns null on parse error
// Example inputs: 2004-06-17T18:00Z 2004-06-17T18:34:12+02:00
diff --git a/src/sage/content/opml/opml.js b/src/sage/content/opml/opml.js
index 9ae04d6..4f0c3ce 100755
--- a/src/sage/content/opml/opml.js
+++ b/src/sage/content/opml/opml.js
@@ -51,8 +51,8 @@ function browseImportFile() {
function browseExportFile() {
var fpicker = Components.classes["@mozilla.org/filepicker;1"].createInstance(Components.interfaces.nsIFilePicker);
- fpicker.init(window, "Select OPML File", fpicker.modeSave);
- fpicker.appendFilter("OPML File(*.xml, *.opml)", "*.xml;*.opml");
+ fpicker.init(window, strRes.getString("opml_select_file"), fpicker.modeSave);
+ fpicker.appendFilter(strRes.getString("opml_opml_file") + "(*.xml, *.opml)", "*.xml;*.opml");
fpicker.appendFilters(fpicker.filterAll);
fpicker.defaultString = "export.opml";
diff --git a/src/sage/content/opml/opml.xul b/src/sage/content/opml/opml.xul
index 58613bb..44f34ea 100755
--- a/src/sage/content/opml/opml.xul
+++ b/src/sage/content/opml/opml.xul
@@ -1,9 +1,12 @@
<?xml version="1.0" encoding="Shift_JIS"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+
<!DOCTYPE wizard SYSTEM "chrome://sage/locale/opml.dtd">
-<wizard id="winMain" title="OPML Import/Export Wizard"
+
+<wizard id="winMain" title="&pageStart.label;"
onload="init()" onwizardfinish="return finish()"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
<script type="application/x-javascript" src="chrome://browser/content/bookmarks/bookmarks.js"></script>
<script type="application/x-javascript" src="chrome://sage/content/commonfunc.js"></script>
<script type="application/x-javascript" src="chrome://sage/content/opml/opml.js"></script>
diff --git a/src/sage/content/sage.js b/src/sage/content/sage.js
index b5894c4..ec3128c 100755
--- a/src/sage/content/sage.js
+++ b/src/sage/content/sage.js
@@ -269,9 +269,9 @@ function rssTitleLabelClick(aNode, aEvent){
function setStatusLoading(label) {
rssStatusImage.setAttribute("loading", "true");
if(label) {
- rssStatusLabel.value = "Loading: " + label;
+ rssStatusLabel.value = strRes.getString("RESULT_LOADING") + ": " + label;
} else {
- rssStatusLabel.value = "Loading: " + lastResource.name;
+ rssStatusLabel.value = strRes.getString("RESULT_LOADING") + ": " + lastResource.name;
}
}
diff --git a/src/sage/locale/en-US/sage.dtd b/src/sage/locale/en-US/sage.dtd
index bd0d131..053b28c 100755
--- a/src/sage/locale/en-US/sage.dtd
+++ b/src/sage/locale/en-US/sage.dtd
@@ -34,7 +34,7 @@
<!ENTITY settings.autoFeedTitle.label "Automatically update feed titles">
<!ENTITY settings.renderFeeds.label "Render feeds in contents area">
<!ENTITY settings.twelveHourClock.label "Use 12 hour clock">
-<!ENTITY settings.feedItemOrder.label "Feed Item Order">
+<!ENTITY settings.feedItemOrder.label "Feed item order">
<!ENTITY settings.feedItemOrder.chrono "Chronological">
<!ENTITY settings.feedItemOrder.source "Source">
<!ENTITY settings.feedDiscoveryMode.label "Feed discovery mode">
diff --git a/src/sage/locale/en-US/sage.properties b/src/sage/locale/en-US/sage.properties
index 49256f9..74335de 100755
--- a/src/sage/locale/en-US/sage.properties
+++ b/src/sage/locale/en-US/sage.properties
@@ -4,6 +4,7 @@ RESULT_NOT_RSS_STR = Feed Parse Error
RESULT_NOT_FOUND_STR = File Not Found
RESULT_NOT_AVAILABLE_STR = URL Not Available
RESULT_ERROR_FAILURE_STR = Load Failure
+RESULT_LOADING = Loading
CHECK_UPDATE = Check Feeds
GET_RSS_TITLE= Get Feed Title
@@ -36,7 +37,8 @@ opml_path_invalid = Invalid file path.
opml_import_fail = Load Failure
opml_import_badfile = This does not appear to be an OPML file.
opml_export_nocreate = File creation error
-
+opml_select_file = Select OPML File
+opml_opml_file = OPML File
# Date rendering values
diff --git a/src/sage/locale/fr-FR/sage.properties b/src/sage/locale/fr-FR/sage.properties
index 5520b5f..841f546 100644
--- a/src/sage/locale/fr-FR/sage.properties
+++ b/src/sage/locale/fr-FR/sage.properties
@@ -4,6 +4,7 @@ RESULT_NOT_RSS_STR = Ce fichier XML n'est pas un fichier RSS
RESULT_NOT_FOUND_STR = Fichier introuvable
RESULT_NOT_AVAILABLE_STR = URL non disponible
RESULT_ERROR_FAILURE_STR = Erreur de chargement
+RESULT_LOADING = Loading
CHECK_UPDATE = V\u00e9rification des fils
GET_RSS_TITLE= Trouver le nom du fil
@@ -36,7 +37,8 @@ opml_path_invalid = Invalid file path.
opml_import_fail = Load Failure
opml_import_badfile = This does not appear to be an OPML file.
opml_export_nocreate = File creation error
-
+opml_select_file = Select OPML File
+opml_opml_file = OPML File
# Date rendering values
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/sage-extension.git
More information about the Pkg-mozext-commits
mailing list