Skip to content

Instantly share code, notes, and snippets.

@zlu zlu/x
Created Jan 6, 2009

Embed
What would you like to do?
Ubiquity command for searching rails APIs
CmdUtils.CreateCommand(
{
name: "rails",
takes: {"method": noun_arb_text},
icon: "http://rubyonrails.org/images/rails.png",
homepage: "",
author: {name: "Zhao Lu", email: "zhao.lu.us@gmail.com"},
license: "MPL,GPL",
description: "Search rails documentation",
help: "Type a rails class or method",
execute: function(directObject)
{
var url = "http://apidock.com/rails/{TERM}"
var urlString = url.replace("{TERM}", directObject.text);
Utils.openUrlInBrowser(urlString);
},
preview: function(pblock, directObject)
{
searchText = jQuery.trim(directObject.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
You can’t perform that action at this time.