diff --git a/NEWS b/NEWS
index df3880b8..0e88ef42 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@
~/.vimperatorrc file instead for persistent options
* IMPORTANT! Major hints rewrite
read up the new help for the f, F and ; commands for details
+ * new :pa[geinfo] command (thanks Marco Candrian)
* added new :mkvimperatorrc command
* you can edit textfields with Ctrl-i now using an external editor (thanks to Joseph Xu)
* :open, :bmarks, etc. filter on space separated tokens now, so you can
diff --git a/content/buffers.js b/content/buffers.js
index 7f892139..03be899e 100644
--- a/content/buffers.js
+++ b/content/buffers.js
@@ -38,6 +38,7 @@ vimperator.Buffer = function() //{{{
var zoom_levels = [ 1, 10, 25, 50, 75, 90, 100,
120, 150, 200, 300, 500, 1000, 2000 ];
+
function setZoom(value, full_zoom)
{
if (value < 1 || value > 2000)
@@ -491,6 +492,136 @@ vimperator.Buffer = function() //{{{
{
bumpZoomLevel(-steps, full_zoom);
};
+
+ this.pageInfo = function(verbose)
+ {
+ // to get the file size later (from pageInfo.js) (setup cacheEntryDescriptor)
+ const nsICacheService = Components.interfaces.nsICacheService;
+ const ACCESS_READ = Components.interfaces.nsICache.ACCESS_READ;
+ const cacheService = Components.classes["@mozilla.org/network/cache-service;1"].getService(nsICacheService);
+ var httpCacheSession = cacheService.createSession("HTTP", 0, true);
+ httpCacheSession.doomEntriesIfExpired = false;
+ var ftpCacheSession = cacheService.createSession("FTP", 0, true);
+ ftpCacheSession.doomEntriesIfExpired = false;
+ var cacheKey = window.content.document.location.toString().replace(/#.*$/, "");
+ try
+ {
+ var cacheEntryDescriptor = httpCacheSession.openCacheEntry(cacheKey, ACCESS_READ, false);
+ }
+ catch (ex)
+ {
+ try
+ {
+ cacheEntryDescriptor = ftpCacheSession.openCacheEntry(cacheKey, ACCESS_READ, false);
+ }
+ catch (ex2) { }
+ }
+
+ if (!verbose)
+ {
+ // TODO: strip off any component after &
+ var file = window.content.document.location.pathname.split('/').pop();
+ if (!file)
+ file = "[No Name]";
+
+ var title = window.content.document.title;
+ if (title.length > 60)
+ title = title.substr(0,57) + "... ";
+ else if (!title.length)
+ title = "[No Title]";
+
+ if (cacheEntryDescriptor)
+ var pageSize = Math.round(cacheEntryDescriptor.dataSize / 1024 * 100) / 100 + "KB";
+
+ var pageInfoText = "" + file + ": " + title + " (" + pageSize + ", other cool things)";
+
+ vimperator.echo(pageInfoText, vimperator.commandline.FORCE_SINGLELINE);
+ return;
+ }
+
+ var pageGeneral = []; // keeps general infos
+ var pageMeta = []; // keeps meta infos
+
+ // get general infos
+ pageGeneral.push(["Title", window.content.document.title]);
+ pageGeneral.push(["URL", '' +
+ window.content.document.location.toString() + '']);
+ pageGeneral.push(["Referrer", ("referrer" in window.content.document && window.content.document.referrer)]);
+ pageGeneral.push(["Mime-Type", window.content.document.contentType]);
+ pageGeneral.push(["Encoding", window.content.document.characterSet]);
+
+
+ if (cacheEntryDescriptor) {
+ var pageSize = cacheEntryDescriptor.dataSize;
+ pageGeneral.push(["File Size", (Math.round(pageSize / 1024 * 100) / 100) + "KB (" + pageSize + " bytes)"]);
+ }
+
+ pageGeneral.push(["Compatibility", content.document.compatMode == "BackCompat" ?
+ "Quirks Mode" : "Full/Almost Standard Mode"]);
+ pageGeneral.push(["Last Modified", window.content.document.lastModified]);
+
+ // get meta tag infos info and sort and put into pageMeta[]
+ var metaNodes = window.content.document.getElementsByTagName("meta");
+ var length = metaNodes.length;
+ if (length)
+ {
+ var tmpSort = [];
+ var tmpDict = [];
+
+ for (var i = 0; i < length; i++)
+ {
+ var tmpTag = metaNodes[i].name || metaNodes[i].httpEquiv;// +
+ //'-eq'; // XXX: really important?
+ var tmpTagNr = tmpTag + "-" + i; // allows multiple (identical) meta names
+ tmpDict[tmpTagNr] = [tmpTag, metaNodes[i].content];
+ tmpSort.push(tmpTagNr); // array for sorting
+ }
+
+ // sort: ignore-case
+ tmpSort.sort(function (a,b){return a.toLowerCase() > b.toLowerCase() ? 1 : -1;});
+
+ for (var i=0; i < tmpSort.length; i++)
+ {
+ pageMeta.push([tmpDict[tmpSort[i]][0], tmpDict[tmpSort[i]][1]]);
+ }
+ }
+
+ var pageInfoText = "";
+ var option = vimperator.options["pageinfo"];
+
+ for (var z = 0; z < option.length; z++)
+ {
+ var newLine = z > 0 ? "
" : "";
+ switch (option[z])
+ {
+ case "g": pageInfoText += newLine + "
| General |
";
+ for (var i = 0; i < pageGeneral.length; i++)
+ {
+ if (pageGeneral[i][1])
+ pageInfoText += "| " + pageGeneral[i][0] + ": | " + pageGeneral[i][1] + " |
";
+ }
+ pageInfoText += "
";
+ break;
+
+ case "m": pageInfoText += newLine + "| Meta Tags |
";
+ if (pageMeta.length)
+ {
+ for (var i = 0; i < pageMeta.length; i++)
+ {
+ pageInfoText += "| " + pageMeta[i][0] + ": | " + pageMeta[i][1] + " |
";
+ }
+ }
+ else
+ {
+ pageInfoText += "| (no Meta-Tags on this page) |
";
+ }
+ pageInfoText += "
";
+ break;
+ }
+ }
+
+ vimperator.echo(pageInfoText, vimperator.commandline.FORCE_MULTILINE);
+ }
//}}}
} //}}}
diff --git a/content/commands.js b/content/commands.js
index 703f3aeb..1f025652 100644
--- a/content/commands.js
+++ b/content/commands.js
@@ -522,6 +522,14 @@ vimperator.Commands = function() //{{{
////////////////////// DEFAULT COMMANDS ////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
+ addDefaultCommand(new vimperator.Command(["pa[geinfo]"],
+ function () { vimperator.buffer.pageInfo(true); },
+ {
+ short_help: "Show general and/or meta-content site informations",
+ help: "Show general and/or meta-content site informations"
+ }
+ ));
+
addDefaultCommand(new vimperator.Command(["addo[ns]"],
function() { vimperator.open("chrome://mozapps/content/extensions/extensions.xul", vimperator.NEW_TAB); },
{
diff --git a/content/events.js b/content/events.js
index 5c881a9d..c8c1de4a 100644
--- a/content/events.js
+++ b/content/events.js
@@ -231,6 +231,12 @@ vimperator.Events = function() //{{{
// FIXME: this currently causes window map events which is _very_ annoying
// we want to stay in command mode after a page has loaded
//setTimeout(vimperator.focusContent, 10);
+ // setTimeout(function() {
+ // if (doc.commandDispatcher.focusedElement)
+ // doc.commandDispatcher.focusedElement.blur();
+ // alert(doc.commandDispatcher.focusedElement);
+ // }, 1000);
+
}
}
}
diff --git a/content/options.js b/content/options.js
index f72a13b4..a85657ef 100644
--- a/content/options.js
+++ b/content/options.js
@@ -435,6 +435,20 @@ vimperator.Options = function() //{{{
default_value: false
}
));
+ this.add(new vimperator.Option(["pageinfo", "pa"], "charlist",
+ {
+ short_help: "Desired info on :pa[geinfo]",
+ help: "Available items:
" +
+ "" +
+ "- g: general info
" +
+ "- m: meta tags
" +
+ "
" +
+ "The order matters",
+ default_value: "gm",
+ validator: function (value) { if (/[^gm]/.test(value) || value.length > 2 ||
+ value.length < 1) return false; else return true; }
+ }
+ ));
this.add(new vimperator.Option(["complete", "cpt"], "charlist",
{
short_help: "Items which are completed at the :[tab]open prompt",