Skip to content

Instantly share code, notes, and snippets.

@tom

tom/x

Created November 18, 2008 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tom/26231 to your computer and use it in GitHub Desktop.
Save tom/26231 to your computer and use it in GitHub Desktop.
// Based on apidock.org Ubiquity Search: http://gist.github.com/8132
CmdUtils.CreateCommand(
{
name: "code",
takes: {"function": noun_arb_text},
icon: "http://github.com/fluidicon.png",
homepage: "http://tiago.zusee.com",
author: {name: "Tiago Bastos", email: "comechao@gmail.com"},
license: "MPL,GPL",
description: "Search on Github Code Search",
help: "Search on Github Code Search",
execute: function(directObject)
{
var url = "http://github.com/codesearch?q={QUERY}"
var urlString = url.replace("{QUERY}", directObject.text);
Utils.openUrlInBrowser(urlString);
},
preview: function(pblock, directObject)
{
searchText = jQuery.trim(directObject.text);
if(searchText.length <= 0)
{
pblock.innerHTML = "Search on github codesearch";
return;
}
var previewTemplate = "Search on Github: ${query}";
var previewData = {query: searchText};
pblock.innerHTML = CmdUtils.renderTemplate(previewTemplate, previewData);
}
});
/* This is a template command */
CmdUtils.CreateCommand({
name: "example",
icon: "http://example.com/example.png",
homepage: "http://example.com/",
author: { name: "Your Name", email: "you@example.com"},
license: "GPL",
description: "A short description of your command",
help: "how to use your command",
takes: {"input": noun_arb_text},
preview: function( pblock, input ) {
var template = "Hello ${name}";
pblock.innerHTML = CmdUtils.renderTemplate(template, {"name": "World!"});
},
execute: function(input) {
CmdUtils.setSelection("You selected: "+input.html);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment