Skip to content

Instantly share code, notes, and snippets.

@tjweir
Created December 31, 2008 16:46
Show Gist options
  • Save tjweir/42049 to your computer and use it in GitHub Desktop.
Save tjweir/42049 to your computer and use it in GitHub Desktop.
Use Ubiquity to search Lift's API.
CmdUtils.CreateCommand({
name: "lift",
homepage: "http://praytothemachine.com/evil/code/ubiquity/lift.js",
description: "Search Lift's API",
help: "Simply type lift and the classname and it will do a google search for API documentation on that class",
icon: "http://www.scala-lang.org/sites/default/files/favicon.gif",
takes: {"class name": noun_arb_text},
preview: function(pblock, directObject) {
var searchTerm = directObject.text;
var pTemplate = "Searches Lift Docs for <b>${query}</b>";
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://scala-tools.org/scaladocs/liftweb/1.0/ "+searchTerm };
jQuery.get( url, params, function(data) {
var numToDisplay = 3;
var results = data.responseData.results.splice( 0, numToDisplay );
pblock.innerHTML = CmdUtils.renderTemplate( {file:"google-search.html"},
{results:results}
);
}, "json");
},
execute: function( theClass){
var URL = "http://www.google.com/search?hl=en&q=site:http://scala-tools.org/scaladocs/liftweb/1.0/%20"+theClass.text+"&btnG=Search&btnI=3564";
Utils.openUrlInBrowser(URL);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment