diff --git a/content/bookmarks.js b/content/bookmarks.js index 5a0481a8..8e564211 100644 --- a/content/bookmarks.js +++ b/content/bookmarks.js @@ -68,7 +68,7 @@ function Bookmarks() //{{{ let uri = ioService.newURI(node.uri, null, null); let keyword = bookmarksService.getKeywordForBookmark(node.itemId); let tags = taggingService.getTagsForURI(uri, {}) || []; - let icon = faviconService.getFaviconImageForPage(uri).spec; + let icon = faviconService.getFaviconImageForPage(uri).spec; // for performance reasons, use this rather than getFavicon return bookmarks.push(new Bookmark(node.uri, node.title, icon, keyword, tags, node.itemId)); } @@ -183,6 +183,18 @@ function Bookmarks() //{{{ bookmarksService.addObserver(observer, false); } + function getFavicon(uri) + { + try + { + return faviconService.getFaviconImageForPage(ioService.newURI(uri, null, null)).spec; + } + catch (e) + { + return ""; + } + } + let bookmarkObserver = function (key, event, arg) { if (event == "add") @@ -319,8 +331,8 @@ function Bookmarks() //{{{ { if (bypassCache) // Is this really necessary anymore? cache.load(); - return completion.cached("bookmarks", filter, function () cache.bookmarks, - "filterURLArray", tags); + + return completion.cached("bookmarks", filter, function () cache.bookmarks, "filterURLArray", tags); }, // if starOnly = true it is saved in the unfiledBookmarksFolder, otherwise in the bookmarksMenuFolder @@ -425,6 +437,8 @@ function Bookmarks() //{{{ return count.value; }, + getFavicon: function (url) { return getFavicon(url); }, + // TODO: add filtering // also ensures that each search engine has a Vimperator-friendly alias getSearchEngines: function () @@ -515,10 +529,11 @@ function Bookmarks() //{{{ { url: item.url, title: item.title, + icon: getFavicon(item.url), extra: [['keyword', item.keyword, "hl-Keyword"], ['tags', item.tags.join(', '), "hl-Tag"] ].filter(function (i) i[1]) - } for each (item in items))); + } for each ([i, item] in Iterator(items)) if (i < 1000))); commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE); } }; @@ -533,14 +548,6 @@ function History() //{{{ const historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"] .getService(Components.interfaces.nsINavHistoryService); - const ioService = Components.classes["@mozilla.org/network/io-service;1"] - .getService(Components.interfaces.nsIIOService); - const faviconService = Components.classes["@mozilla.org/browser/favicon-service;1"] - .getService(Components.interfaces.nsIFaviconService); - function getIcon(uri) - { - return faviconService.getFaviconImageForPage(ioService.newURI(uri, null, null)).spec; - } var placesHistory; var cachedHistory = []; // add pages here after loading the initial Places history @@ -564,7 +571,7 @@ function History() //{{{ var node = rootNode.getChild(i); // liberator.dump("History child " + node.itemId + ": " + node.title + " - " + node.type); if (node.type == node.RESULT_TYPE_URI) // just make sure it's a bookmark - placesHistory.push([node.uri, node.title || "[No title]", getIcon(node.uri)]); + placesHistory.push([node.uri, node.title || "[No title]"]); } // close a container after using it! @@ -747,10 +754,11 @@ function History() //{{{ } else cachedHistory = cachedHistory.filter(filter); + if (placesHistory.some(function (h) h[0] == url)) placesHistory = placesHistory.filter(filter); - cachedHistory.unshift([url, title || "[No title]", getIcon(url)]); + cachedHistory.unshift([url, title || "[No title]"]); return true; }, @@ -812,18 +820,16 @@ function History() //{{{ } if (openItems) - { return liberator.open([i[0] for each (i in items)], liberator.NEW_TAB); - } - else - { - let list = template.bookmarks("title", ( - { - title: item[1], - url: item[0] - } for each (item in items))); - commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE); - } + + // TODO: is there a faster way to limit to max. 1000 items? + let list = template.bookmarks("title", ( + { + url: item[0], + title: item[1], + icon: bookmarks.getFavicon(item[0]), + } for each ([i, item] in Iterator(items)) if (i < 1000))); + commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE); } }; //}}} diff --git a/content/completion.js b/content/completion.js index 52be594b..ceea59a5 100644 --- a/content/completion.js +++ b/content/completion.js @@ -529,6 +529,8 @@ function Completion() //{{{ }; let javascript = new Javascript(); + // FIXME: unused, remove? If not, document, what it does. + // Those one liners might be convinient to write, but not to read --mst function filterFavicon(array, want) { return want ? array : [a[2] ? a.slice(0, 2) : a for ([i, a] in Iterator(array))]; @@ -782,11 +784,20 @@ function Completion() //{{{ buffer: function buffer(filter) { - let items = []; // FIXME: liberator.has("tabs") + let items = []; + let xml =
| {header} | URL | +{header} | URL | |
|---|---|---|---|---|
| {util.clip(item.title, 50)} | -
+
|
-