Skip to content

Instantly share code, notes, and snippets.

@spejman
Created December 29, 2009 12:56
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 spejman/265296 to your computer and use it in GitHub Desktop.
Save spejman/265296 to your computer and use it in GitHub Desktop.
// Based on Zhao Lu Ubiquity < 0.5 command
CmdUtils.CreateCommand({
names: ['rails', 'search rails documentation'],
arguments: [{role: 'object', nountype: noun_arb_text, label: 'method'}],
icon: "http://rubyonrails.org/images/rails.png",
homepage: "",
author: {name: "Sergio Espeja", email: "sergio.espeja@gmail.com"},
license: "MPL,GPL",
description: "Search rails documentation",
help: "Type a rails class or method",
execute: function(args)
{
var url = "http://apidock.com/rails/{TERM}"
var urlString = url.replace("{TERM}", args.object.text);
Utils.openUrlInBrowser(urlString);
},
preview: function(pblock, args)
{
searchText = jQuery.trim(args.object.text);
if(searchText.length <= 0)
{
pblock.innerHTML = "Search rails documentation";
return;
}
var previewTemplate = "Search rails documentation of ${query}";
var previewData = {query: searchText};
pblock.innerHTML = CmdUtils.renderTemplate(previewTemplate, previewData);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment