Skip to content

Instantly share code, notes, and snippets.

@nightscape
Created November 18, 2008 10:51
Show Gist options
  • Save nightscape/26100 to your computer and use it in GitHub Desktop.
Save nightscape/26100 to your computer and use it in GitHub Desktop.
CmdUtils.makeSearchCommand({
name: "pickaxe",
url: "http://www.google.com/search?q=site:http://whytheluckystiff.net/ruby/pickaxe/%20{QUERY}&btnG=Search&btnI=3564",
icon: "http://whytheluckystiff.net/favicon.ico",
description: "Searches 'Programming Ruby The Pragmatic Programmer's Guide' for your words.",
preview: function(pblock, directObject) {
var searchTerm = directObject.text;
var pTemplate = "Searches 'Programming Ruby The Pragmatic Programmer's Guide' for ${query}";
var pData = {query: searchTerm};
pblock.innerHTML = CmdUtils.renderTemplate(pTemplate, pData);
var url = "http://ajax.googleapis.com/ajax/services/search/web";
var params = { v: "1.0", q: "site:http://whytheluckystiff.net/ruby/pickaxe/ "+searchTerm };
jQuery.get( url, params, function(data) {
var numToDisplay = 6;
var results = data.responseData.results.splice( 0, numToDisplay );
pblock.innerHTML = CmdUtils.renderTemplate( {file:"google-search.html"},
{results:results}
);
}, "json");
}
});
Attachments = {'google-search.html':'{for result in results}\n<div class="gresult">\n <div>\n <a href="${result.unescapedUrl}">${result.title}</a>\n </div>\n <xul:description class="gresult-content">${result.content}\n</xul:description>\n <div class="gresult-url">${result.visibleUrl}</div>\n</div>\n{forelse}\n<b>Your search - ${searchTerm} - did not match any documents. </b>\n{/for}'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment