-
-
Save nightscape/26100 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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