[Pkg-mozext-commits] [sage-extension] 35/49: [15101, 15260] content sanitization, FF2 compatibility, first run improvements

David Prévot taffit at moszumanska.debian.org
Fri May 1 03:10:55 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to tag sage_1_3_10
in repository sage-extension.

commit cce8b0ebb9f263f915ce76894d5488225fd785c6
Author: Peter Andrews <petea at jhu.edu>
Date:   Mon Oct 2 09:35:28 2006 +0000

    [15101, 15260] content sanitization, FF2 compatibility, first run improvements
---
 src/sage/content/createhtml.js    | 18 ++++++++--
 src/sage/content/feedlib.js       |  2 +-
 src/sage/content/sage-Overlay.js  | 69 +++++++++++++++++++++++++++++++++++++++
 src/sage/content/sage-Overlay.xul |  3 ++
 src/sage/content/sage.js          | 36 --------------------
 src/sage/content/sage.xul         | 10 +++---
 src/sage/skin/classic/sage.css    |  4 +--
 7 files changed, 96 insertions(+), 46 deletions(-)

diff --git a/src/sage/content/createhtml.js b/src/sage/content/createhtml.js
index 1ffcb39..7abc4e5 100755
--- a/src/sage/content/createhtml.js
+++ b/src/sage/content/createhtml.js
@@ -92,7 +92,14 @@ var CreateHTML = {
 			var pubDate = "";
 
 			if(items[i].hasContent()) {
-				description = allowEContent ? items[i].getContent() : htmlToText(items[i].getContent());
+				if (allowEContent) {
+					description = items[i].getContent();
+				} else {
+					description = htmlToText(items[i].getContent());
+				}
+				this.filterHtmlHandler.clear();
+				this.simpleHtmlParser.parse(description);
+				description = this.filterHtmlHandler.toString();
 				description = "<div class=\"item-desc\">" + description + "</div>";
 			}
 
@@ -117,5 +124,10 @@ var CreateHTML = {
 	getSpecialDir: function(aProp) {
 		var dirService = Components.classes['@mozilla.org/file/directory_service;1'].getService(Components.interfaces.nsIProperties);
 		return dirService.get(aProp, Components.interfaces.nsILocalFile);
-	}
-}
\ No newline at end of file
+	},
+	
+	simpleHtmlParser:	new SimpleHtmlParser,
+	filterHtmlHandler:	new FilterHtmlHandler
+}
+
+CreateHTML.simpleHtmlParser.contentHandler = CreateHTML.filterHtmlHandler;
\ No newline at end of file
diff --git a/src/sage/content/feedlib.js b/src/sage/content/feedlib.js
index 0a858d1..e905422 100644
--- a/src/sage/content/feedlib.js
+++ b/src/sage/content/feedlib.js
@@ -308,7 +308,7 @@ Feed.prototype.hasDescription = function() {
 
 Feed.prototype.getDescription = function() {
 	if(this.hasDescription()) {
-		return this.description;
+		return this.description.replace(/<.*?>/g,'');
 	} else {
 		return "";
 	}
diff --git a/src/sage/content/sage-Overlay.js b/src/sage/content/sage-Overlay.js
new file mode 100644
index 0000000..97a6c09
--- /dev/null
+++ b/src/sage/content/sage-Overlay.js
@@ -0,0 +1,69 @@
+function addSageButton() {
+	var toolbox = document.getElementById("navigator-toolbox");
+	var toolboxDocument = toolbox.ownerDocument;
+    
+	var hasSageButton = false;
+	for (var i = 0; i < toolbox.childNodes.length; ++i) {
+		var toolbar = toolbox.childNodes[i];
+		if (toolbar.localName == "toolbar" && toolbar.getAttribute("customizable") == "true") {
+			if (toolbar.currentSet.indexOf("sage-button") > -1) {
+				hasSageButton = true;
+			}
+    	}
+    }
+
+	if(!hasSageButton) {
+		for (var i = 0; i < toolbox.childNodes.length; ++i) {
+			toolbar = toolbox.childNodes[i];
+			if (toolbar.localName == "toolbar" &&  toolbar.getAttribute("customizable") == "true" && toolbar.id == "nav-bar") {
+				var newSet = "";
+				var child = toolbar.firstChild;
+				while (child) {
+					if(!hasSageButton && child.id == "urlbar-container") {
+						newSet += "sage-button,";
+						hasSageButton = true;
+					}
+					newSet += child.id + ",";
+					child = child.nextSibling;
+				}
+				newSet = newSet.substring(0, newSet.length - 1);
+				toolbar.currentSet = newSet;
+				toolbar.setAttribute("currentset", newSet);
+				toolboxDocument.persist(toolbar.id, "currentset");
+				try {
+					BrowserToolboxCustomizeDone(true);
+				} catch (e) {}
+				break;
+			}
+		}
+	}
+}
+
+function sageInit() {
+	var prefService = Components.classes["@mozilla.org/preferences;1"].getService(Components.interfaces.nsIPrefService);
+	var prefBranch = prefService.getBranch("sage.");
+	if (!prefBranch.prefHasUserValue("last_version")) {  // new user
+		var new_folder = BMSVC.createFolderInContainer("Sage Feeds", RDF.GetResource("NC:BookmarksRoot"), null);
+		prefBranch.setCharPref("folder_id", new_folder.Value);
+		if (BMSVC.createBookmarkInContainer.length == 7) { // firefox 0.8 and lower
+			BMSVC.createBookmarkInContainer("BBC News | News Front Page | World Edition", "http://news.bbc.co.uk/rss/newsonline_world_edition/front_page/rss091.xml", null, "updated", null, new_folder, null);
+			BMSVC.createBookmarkInContainer("Yahoo! News - Sports", "http://rss.news.yahoo.com/rss/sports", null, "updated", null, new_folder, null);
+			BMSVC.createBookmarkInContainer("Sage Project News", "http://sage.mozdev.org/rss.xml", null, "updated", null, new_folder, null);
+		} else {
+			BMSVC.createBookmarkInContainer("BBC News | News Front Page | World Edition", "http://news.bbc.co.uk/rss/newsonline_world_edition/front_page/rss091.xml", null, "updated", null, null, new_folder, null);
+			BMSVC.createBookmarkInContainer("Yahoo! News - Sports", "http://rss.news.yahoo.com/rss/sports", null, "updated", null, null, new_folder, null);
+			BMSVC.createBookmarkInContainer("Sage Project News", "http://sage.mozdev.org/rss.xml", null, "updated", null, null, new_folder, null);
+		}
+		addSageButton();
+		prefBranch.setCharPref("last_version", "1.3.7");
+	} else { // check for upgrade
+		var lastVersion = prefBranch.getCharPref("last_version");
+		alert(lastVersion);
+		if (lastVersion != "1.3.7") { // upgrade
+			addSageButton();
+			prefBranch.setCharPref("last_version", "1.3.7");
+		}
+	}
+}
+
+window.addEventListener("load", function() { setTimeout(sageInit, 500); }, false);
\ No newline at end of file
diff --git a/src/sage/content/sage-Overlay.xul b/src/sage/content/sage-Overlay.xul
index 342ef66..33f4531 100755
--- a/src/sage/content/sage-Overlay.xul
+++ b/src/sage/content/sage-Overlay.xul
@@ -4,6 +4,8 @@
 <!DOCTYPE overlay SYSTEM "chrome://sage/locale/sage.dtd">
 <overlay id="sageOverlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
+	<script type="application/x-javascript" src="chrome://sage/content/sage-Overlay.js" />
+
 	<menupopup id="viewSidebarMenu">
 		<menuitem key="key_openSageSidebar" observes="viewSageSidebar"/>
 	</menupopup>
@@ -32,4 +34,5 @@
 	<toolbarpalette id="BrowserToolbarPalette">
 		<toolbarbutton id="sage-button" tooltiptext="&sage.tooltip;" observes="viewSageSidebar" class="toolbarbutton-1"/>
 	</toolbarpalette>
+	
 </overlay>
diff --git a/src/sage/content/sage.js b/src/sage/content/sage.js
index b7ac28b..76be958 100755
--- a/src/sage/content/sage.js
+++ b/src/sage/content/sage.js
@@ -48,42 +48,6 @@ function init() {
 		strRes.getString("RESULT_ERROR_FAILURE_STR")
 	);
 	
-	// get the version string from the last release used
-	var lastVersion = CommonFunc.getPrefValue(CommonFunc.LAST_VERSION, "str", null);
-	if(lastVersion) {
-		lastVersion = CommonFunc.versionStrDecode(lastVersion);
-	} else {
-		lastVersion = Array(0,0,0);
-	}
-	var currentVersion = CommonFunc.VERSION;
-
-	// if feed folder has not been set, assume new user and install default feed folder and demo feeds
-	if(!CommonFunc.getPrefValue(CommonFunc.FEED_FOLDER_ID, "str", null)) { // check for new user
-		logMessage("new user, creating feed folder and setting default preferences...");
-		var new_folder = BMSVC.createFolderInContainer("Sage Feeds", RDF.GetResource("NC:BookmarksRoot"), null);
-		CommonFunc.setPrefValue(CommonFunc.FEED_FOLDER_ID, "str", new_folder.Value);
-		if(BMSVC.createBookmarkInContainer.length == 7) { // firefox 0.8 and lower
-			BMSVC.createBookmarkInContainer("BBC News | News Front Page | World Edition", "http://news.bbc.co.uk/rss/newsonline_world_edition/front_page/rss091.xml", null, "updated", null, new_folder, null);
-			BMSVC.createBookmarkInContainer("Yahoo! News - Sports", "http://rss.news.yahoo.com/rss/sports", null, "updated", null, new_folder, null);
-			BMSVC.createBookmarkInContainer("Sage Project News", "http://sage.mozdev.org/rss.xml", null, "updated", null, new_folder, null);
-		} else {
-			BMSVC.createBookmarkInContainer("BBC News | News Front Page | World Edition", "http://news.bbc.co.uk/rss/newsonline_world_edition/front_page/rss091.xml", null, "updated", null, null, new_folder, null);
-			BMSVC.createBookmarkInContainer("Yahoo! News - Sports", "http://rss.news.yahoo.com/rss/sports", null, "updated", null, null, new_folder, null);
-			BMSVC.createBookmarkInContainer("Sage Project News", "http://sage.mozdev.org/rss.xml", null, "updated", null, null, new_folder, null);
-		}
-		setCheckbox("chkShowSearchBar", "false");
-		setCheckbox("chkShowTooltip", "true");
-		setCheckbox("chkShowFeedItemList", "true");
-		setCheckbox("chkShowFeedItemListToolbar", "true");
-	} else if(CommonFunc.versionCompare(currentVersion, lastVersion)) {  // check for upgrade
-		logMessage("upgrade (last version: " + CommonFunc.versionString(lastVersion, 0) + ", current version: " + CommonFunc.versionString(currentVersion, 0) + "), setting new default preferences...");
-		if(CommonFunc.versionCompare(Array(1,3,0), lastVersion)) {
-			setCheckbox("chkShowFeedItemListToolbar", "true");
-		}
-	}
-
-	CommonFunc.setPrefValue(CommonFunc.LAST_VERSION, "str", CommonFunc.versionString(currentVersion, 0));
-
 	// get feed folder location
 	sageFolderID = CommonFunc.getPrefValue(CommonFunc.FEED_FOLDER_ID, "str", "NC:BookmarksRoot");
 	// check for changes to the feed folder
diff --git a/src/sage/content/sage.xul b/src/sage/content/sage.xul
index 38ade55..8a298cc 100755
--- a/src/sage/content/sage.xul
+++ b/src/sage/content/sage.xul
@@ -24,6 +24,8 @@
 <script type="application/x-javascript" src="chrome://sage/content/sha1.js"/>
 <script type="application/x-javascript" src="chrome://sage/content/sage.js"/>
 <script type="application/x-javascript" src="chrome://sage/content/updatechecker.js"/>
+<script type="application/x-javascript" src="chrome://sage/content/simplehtmlparser.js"/>
+<script type="application/x-javascript" src="chrome://sage/content/filterhtmlhandler.js"/>
 <script type="application/x-javascript" src="chrome://sage/content/createhtml.js"/>
 <script type="application/x-javascript" src="chrome://sage/content/getrsstitle.js"/>
 <script type="application/x-javascript" src="chrome://sage/content/search/feedsearch.js"/>
@@ -82,10 +84,10 @@
 		<spacer flex="1"/>
 		<toolbarbutton id="toolsMenuButton" type="menu" label="&menu.tools;" class="sage_button toolbarbutton-1">
 			<menupopup>
-				<menuitem id="chkShowSearchBar" type="checkbox" persist="checked" label="&menu.showSearchBar;" oncommand="toggleShowSearchBar()"/>
-				<menuitem id="chkShowTooltip" type="checkbox" persist="checked" label="&menu.showDescTooltip;"/>
-				<menuitem id="chkShowFeedItemList" type="checkbox" persist="checked" label="&menu.showFeedItemList;" oncommand="toggleShowFeedItemList()"/>
-				<menuitem id="chkShowFeedItemListToolbar" type="checkbox" persist="checked" label="&menu.showFeedItemListToolbar;" oncommand="toggleShowFeedItemListToolbar()"/>
+				<menuitem id="chkShowSearchBar" type="checkbox" checked="false" persist="checked" label="&menu.showSearchBar;" oncommand="toggleShowSearchBar()"/>
+				<menuitem id="chkShowTooltip" type="checkbox" checked="true" persist="checked" label="&menu.showDescTooltip;"/>
+				<menuitem id="chkShowFeedItemList" type="checkbox" checked="true" persist="checked" label="&menu.showFeedItemList;" oncommand="toggleShowFeedItemList()"/>
+				<menuitem id="chkShowFeedItemListToolbar" type="checkbox" checked="true" persist="checked" label="&menu.showFeedItemListToolbar;" oncommand="toggleShowFeedItemListToolbar()"/>
 				<menuseparator/>
 				<menuitem label="&menu.manageRSSList;" oncommand="manageRSSList()"/>
 				<menuitem label="&menu.opmlImportExport;" oncommand="openOPMLWizard()"/>
diff --git a/src/sage/skin/classic/sage.css b/src/sage/skin/classic/sage.css
index d72d673..b898678 100755
--- a/src/sage/skin/classic/sage.css
+++ b/src/sage/skin/classic/sage.css
@@ -4,8 +4,8 @@ toolbarbutton.sage_button {
 	list-style-image:	url("chrome://sage/skin/toolbar.png") !important;
 }
 
-toolbarbutton.sage_button2 > .toolbarbutton-text {
-	display: none !important;
+toolbarbutton.sage_button .toolbarbutton-text {
+	display: none;
 }
 
 /* Override to hide icon and show text */

-- 
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