Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
/* Based on gist: 26061 by bastos. */
CmdUtils.CreateCommand({
names: ["code"],
icon: "http://www.github.com/favicon.ico",
author: {name: "Pedro Valencia", email: "pvalencia+github@gmail.com"},
license: "GPL",
homepage: "http://gist.github.com/gists/168442",
description: "Search on Github Code Search",
help: "Search on Github Code Search",
arguments: [{role: 'object', nountype: noun_arb_text, label: 'function'}],
preview: function preview(pblock, args) {
searchText = jQuery.trim(args.object.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);
},
execute: function execute(args) {
var url = "http://github.com/search?type=Code&q={QUERY}";
var urlString = url.replace("{QUERY}", args.object.text);
Utils.openUrlInBrowser(urlString);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment