-
-
Save zlu/43619 to your computer and use it in GitHub Desktop.
Ubiquity command for searching rails APIs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CmdUtils.CreateCommand( | |
{ | |
name: "rails", | |
takes: {"method": noun_arb_text}, | |
icon: "http://rubyonrails.org/images/rails.png", | |
homepage: "", | |
author: {name: "Zhao Lu", email: "[email protected]"}, | |
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