[Vimperator] Addon search keywords
Kipling Inscore
k at bijna.net
Mon Jun 9 15:27:15 PDT 2008
On Thu, Jun 5, 2008 at 10:56 AM, Kipling Inscore <k at bijna.net> wrote:
> It seems to me that Firefox has at least two search engine keyword
> systems. One is accessible from the search bar, address bar and
> Vimperator's (tab)open commands; the other is accessible only from the
> address bar--this is the one that the del.icio.us and possibly other
So I see Vimperator checks the search aliases followed by bookmark shortcuts.
Turns out the del.icio.us addon overrides getShortcutOrURI so its
shortcuts don't show up in either of these services.
> addons use to add search engines (del.icio.us allows bookmarks to be
> tagged as shortcuts and used in the address bar as such). I don't know
> if this is a fault in Firefox (for providing pointless redundant
> mechanisms) or the del.icio.us addon (for using a deprecated mechanism
> or using the correct mechanism incorrectly) but it seems this can be
> solved in Vimperator. The mechanism is there in Firefox, after all, so
> if adding support doesn't make Vimperator's code unwieldy...
> For Vimperator 0.5.3 I created crude patch using getShortcutOrURI()
> (takes a keyword/search string or URI, returns a URI with
> keyword/search expansion) but I'm not sure this will be the correct
Seems getShortcutOrURI will be the only method unless the del.icio.us
addon can be (and is) modified to insert its shortcuts into the
bookmark service or search service (would this create local copies
that cannot be automatically removed?). I'll follow up on this with
the delicious at mozdev.org mailing list as if this modification is
possible seems the more "correct" way to go.
> method for Vimperator 1.x. I'll be working on a patch, particularly to
> support del.icio.us bookmark shortcuts through the official
> del.icio.us addon, so guidance on where I should be looking or whether
> I should be doing this would be appreciated.
>
Below is a patch against Vimperator CVS (2008-06-09T14:20Z-0700) which
modifies stringToURLArray in util.js to use getShortcutOrURI between
specific and default calls to getSearchURL; overall behavior should be
unchanged if no addons with an overloaded getShortcutOrURI are
installed and enabled. Perhaps getShortcutOrURI, if acceptable, should
be added to or replace most of liberator.bookmarks.getSearchURL?
Perhaps there's an extra feature of getSearchURL that I'm not seeing
(so I haven't removed calls to getSearchURL) but getShortcutOrURI
checks search aliases and bookmark shortcuts as long as it hasn't been
overridden by a function that doesn't fall back on the default
function (the del.icio.us addon overriding function does fall back on
the default).
diff -ru vimperator.orig/src/content/util.js vimperator/src/content/util.js
--- vimperator.orig/src/content/util.js 2008-06-09 14:21:15.136064000 -0700
+++ vimperator/src/content/util.js 2008-06-09 14:24:41.735064000 -0700
@@ -316,14 +316,23 @@
urls[url] = searchURL;
continue;
}
- else // the first word was not a search engine,
search for the whole string in the default engine
+ else // the first word was not a search engine, try shortcut
{
- searchURL =
liberator.bookmarks.getSearchURL(urls[url], null);
- if (searchURL)
+ var shortcutURL = getShortcutOrURI(urls[url]);
+ if (shortcutURL != urls[url])
{
- urls[url] = searchURL;
+ urls[url] = shortcutURL;
continue;
}
+ else // not a shortcut either, search for the
whole string in the default engine
+ {
+ searchURL =
liberator.bookmarks.getSearchURL(urls[url], null);
+ if (searchURL)
+ {
+ urls[url] = searchURL;
+ continue;
+ }
+ }
}
}
More information about the Vimperator
mailing list