Ahoi hoi..

I'm very satisfied with conkeror. Good work.

But I missed some features to use the global browser history.

Therefore I decided to patch the code and maybe you also have fun
with that.

greeting
 jesus..
diff -Naur conkeror/content/commands.js conkeror-hist/content/commands.js
--- conkeror/content/commands.js        2006-06-01 03:11:56.000000000 +0200
+++ conkeror-hist/content/commands.js   2006-07-24 20:35:50.000000000 +0200
@@ -44,8 +44,10 @@
     add_command("link-menu", link_menu, [["p"]]);
     add_command("beginning-of-line", beginning_of_line, []);
     add_command("bookmark-bmenu-list", bookmark_bmenu_list, [["p"]]);
+    add_command("history-hmenu-list", history_hmenu_list, [["p"]]);
     add_command("bookmark-current-url", bookmark_current_url, []);
     add_command("bookmark-jump", goto_bookmark, [["p"]]);
+    add_command("history-jump", goto_history, [["p"]]);
     add_command("buffer-next", browser_next, []);
     add_command("buffer-previous", browser_prev, []);
     add_command("cmd_beginLine", cmd_beginLine, []);
@@ -539,6 +541,13 @@
                       get_bm_strings(), false, function(url) { 
open_url_in(prefix,url); });
 }
 
+function goto_history(args)
+{
+    var prefix = args[0];
+    miniBufferComplete(open_url_in_prompt(prefix,"Go to history"), null, 
"history", 
+                      get_hs_strings(), false, function(url) { 
open_url_in(prefix,url); });
+}
+
 function bookmark_current_url()
 {
     readFromMiniBuffer("Add bookmark:", 
getBrowser().mCurrentBrowser.contentTitle, "add-bookmark",
@@ -677,6 +686,12 @@
     open_url_in (prefix, "chrome://conkeror/content/bookmarks.html");
 }
 
+function history_hmenu_list(args)
+{
+    var prefix = args[0];
+    open_url_in (prefix, "chrome://conkeror/content/history.html");
+}
+
 
 /// built in commands
 function doCommandNTimes(n,cmd)
diff -Naur conkeror/content/conkeror.xul conkeror-hist/content/conkeror.xul
--- conkeror/content/conkeror.xul       2006-04-02 11:42:08.000000000 +0200
+++ conkeror-hist/content/conkeror.xul  2006-07-24 20:36:26.000000000 +0200
@@ -19,6 +19,7 @@
 
   <script type="application/x-javascript" src="utils.js"/>
   <script type="application/x-javascript" src="bm.js"/>
+  <script type="application/x-javascript" src="history.js"/>
   <script type="application/x-javascript" src="numberedlinks.js"/>
   <script type="application/x-javascript" src="commands.js"/>
   <script type="application/x-javascript" src="url.js"/>
diff -Naur conkeror/content/history.html conkeror-hist/content/history.html
--- conkeror/content/history.html       1970-01-01 01:00:00.000000000 +0100
+++ conkeror-hist/content/history.html  2006-07-24 20:31:28.000000000 +0200
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd";>
+<html>
+    <head>
+       <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+       <title>History</title>
+       <script  type="text/javascript" 
src="chrome://conkeror/content/history.js"></script>
+    </head>
+    <body onload="genHistory();"></body>
+</html>
+
diff -Naur conkeror/content/history.js conkeror-hist/content/history.js
--- conkeror/content/history.js 1970-01-01 01:00:00.000000000 +0100
+++ conkeror-hist/content/history.js    2006-07-24 21:10:10.000000000 +0200
@@ -0,0 +1,110 @@
+// -*- mode: java -*-
+/***** BEGIN LICENSE BLOCK *****
+Version: MPL 1.1/GPL 2.0/LGPL 2.1
+
+The contents of this file are subject to the Mozilla Public License Version
+1.1 (the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+http://www.mozilla.org/MPL/
+
+Software distributed under the License is distributed on an "AS IS" basis,
+WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+for the specific language governing rights and limitations under the
+License.
+
+The Initial Developer of the Original Code is Shawn Betts.
+Portions created by the Initial Developer are Copyright (C) 2004,2005
+by the Initial Developer. All Rights Reserved.
+
+Alternatively, the contents of this file may be used under the terms of
+either the GNU General Public License Version 2 or later (the "GPL"), or
+the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+in which case the provisions of the GPL or the LGPL are applicable instead
+of those above. If you wish to allow use of your version of this file only
+under the terms of either the GPL or the LGPL, and not to allow others to
+use your version of this file under the terms of the MPL, indicate your
+decision by deleting the provisions above and replace them with the notice
+and other provisions required by the GPL or the LGPL. If you do not delete
+the provisions above, a recipient may use your version of this file under
+the terms of any one of the MPL, the GPL or the LGPL.
+***** END LICENSE BLOCK *****/
+
+// our history array
+var history_cache = [];
+
+// RDF variables for History
+var NC_NS = "http://home.netscape.com/NC-rdf#";;
+
+var HkRDFContractID = "@mozilla.org/rdf/rdf-service;1";
+var HkRDFSVCIID = Components.interfaces.nsIRDFService;
+var HkRDFRSCIID = Components.interfaces.nsIRDFResource;
+var HkRDFLITIID = Components.interfaces.nsIRDFLiteral;
+var HRDF = Components.classes[HkRDFContractID].getService( HkRDFSVCIID );
+var HRDF_NS     = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";;
+
+var HMDS = HRDF.GetDataSourceBlocking("rdf:history");
+var HistoryRoot = HRDF.GetResource("NC:HistoryRoot");
+
+function getHistoryProperty(aInput, aArcURI, aDS)
+{
+    var node;
+    var arc  = HRDF.GetResource(aArcURI);
+    if (typeof(aInput) == "string") 
+       aInput = HRDF.GetResource(aInput);
+    if (!aDS)
+       node = HMDS.GetTarget(aInput, arc, true);
+    else
+       node = aDS.GetTarget(aInput, arc, true);
+    try {
+       return node.QueryInterface(HkRDFRSCIID).Value;
+    }
+    catch (e) {
+       return node? node.QueryInterface(HkRDFLITIID).Value : "";
+    }    
+}
+
+function get_hs_strings()
+{
+    try {
+       // only update our history array if it is empty (==simple cache)
+       if (history_cache.length == 0) {
+           var first_child = HRDF.GetResource(NC_NS+"child");
+           var children = HMDS.GetTargets(HistoryRoot, first_child, true);
+       
+           while (children.hasMoreElements()){
+               var child = children.getNext() ;
+               if (child instanceof Components.interfaces.nsIRDFResource){
+                   var title = getHistoryProperty(child, NC_NS+"Name");
+                   var url = getHistoryProperty(child, NC_NS+"URL");
+                   history_cache.push([title, url]);
+               }
+           }
+       }
+
+    } catch (e) {alert(e);}
+
+    return history_cache;
+}
+
+function genHistory()
+{
+    try {
+       var hss = get_hs_strings();
+       document.write("<h1>History</h1>")
+
+           if (hss.length) {
+               // last inserted history-entry should be at the top
+               hss.reverse();
+               document.write("<table>");
+               for (var i=0; i<hss.length; i++) {
+                   document.write("<TR>");
+                   document.write("<TD><a href=\"" + hss[i][1] + "\">" + 
hss[i][0] + "</TD>");
+                   document.write("</TR>");
+               }
+               document.write("</table>");
+           } else {
+               document.write("<p>No history.</p>");
+           }
+
+    } catch(e) {alert(e);}
+}
_______________________________________________
Conkeror mailing list
[email protected]
http://mozdev.org/mailman/listinfo/conkeror

Reply via email to