Skip to content

Instantly share code, notes, and snippets.

@koduki
Created July 18, 2009 22:44
Show Gist options
  • Save koduki/149718 to your computer and use it in GitHub Desktop.
Save koduki/149718 to your computer and use it in GitHub Desktop.
rubysearch.js
CmdUtils.CreateCommand({
name: "ruby api search",
icon: "http://doc.loveruby.net/refm/api/theme/default/rurema.png",
description: "るりまからRubyのAPIを検索",
help: "How to use your command.",
author: {name: "koduki", email: "[email protected]"},
homepage: "http://gist.github.com/149718",
arguments: {type: noun_arb_text, object: noun_arb_text},
preview: function preview(pblock, args) {
var xs = args.object.html.toString().split(" ");
var name = xs[0];
var type = (xs.length > 1) ? xs[1] : "";
var msg = (type == 'g') ? 'Google経由で' : '';
pblock.innerHTML = "Rubyリファレンスマニュアルから" + msg + "<b>" + name + "</b>を検索する";
},
execute: function execute(args) {
var xs = args.object.html.toString().split(" ");
var name = xs[0];
var type = (xs.length > 1) ? xs[1] : "";
var url = (type == 'g') ? 'http://www.google.co.jp/search?q=site%3Ahttp%3A%2F%2Fdoc.loveruby.net%2Frefm+' + name
:'http://doc.loveruby.net/refm/api/view/search?q=' + name;
Utils.openUrlInBrowser(url);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment