From 28f615138cff8a9866cde45d48729c1c7cfadcf8 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Mon, 24 Oct 2005 02:07:51 +0200 Subject: [PATCH] Add some smart lambda derived prefixes: gmane, bugzilla --- contrib/see/hooks.js | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/contrib/see/hooks.js b/contrib/see/hooks.js index 9cfa28646..9111a89a0 100644 --- a/contrib/see/hooks.js +++ b/contrib/see/hooks.js @@ -78,9 +78,41 @@ function expand_dumbprefix(context, current_url) goto_url_hooks.push(expand_dumbprefix) +function gmane (url) +{ + var match = url.match(/([^\s]+)\s+(.*)$/) + var group = match[1] + var words = match[2] + + if (!words) return null + + return "http://search.gmane.org/search.php?query=" + words + "&group=" + group +} + +// You can write "gg:foo" or "gg foo" to goto URL dialog and it'll ask google +// for it automagically. + +// Note that this is _mostly_ obsoleted by the URI rewrite plugin. (It can't do the +// metas, though.) + +function bugzilla (base_url) +{ + return function (arguments) { + if (!arguments || arguments == '') + return base_url + + if (arguments.match(/^[\d]+$/)) + return base_url + 'show_bug.cgi?id=' + arguments + + return base_url + 'buglist.cgi?short_desc_type=allwordssubstr' + + '&short_desc=' + escape(arguments) + } +} + var smartprefixes = { arc: "http://web.archive.org/web/*/%s", + bug: bugzilla('http://bugzilla.elinks.or.cz/'), cambridge: "http://dictionary.cambridge.org/results.asp?searchword=%s", cliki: "http://www.cliki.net/admin/search?words: %s", d: "http://www.dict.org/bin/Dict?Query: %s&Form=Dict1&Strategy=*&Database=*&submit=Submit+query", @@ -92,6 +124,7 @@ var smartprefixes = { // Whose idea was it to use 'gg' for websearches? -- Miciah //gg = "http://groups.google.com/groups?q=%s", gi: "http://images.google.com/images?q=%s", + gmane: gmane, gn: "http://news.google.com/news?q=%s", go: "http://www.google.com/search?q=%s&btnG=Google+Search", gwho: "http://www.googlism.com/?ism=%s&name=1", @@ -155,8 +188,7 @@ function expand_smartprefix(context, current_url) context.url = smartprefixes[nick].replace(/%s/, escape(val)) return true - } else if (typeof smartprefixes[nick] == 'object' - && smartprefixes[nick].constructor == Function) { + } else if (typeof smartprefixes[nick] == 'function') { context.url = smartprefixes[nick](val) return true