Created
January 23, 2012 13:29
-
-
Save luikore/1663128 to your computer and use it in GitHub Desktop.
Textmate command to search api (input = selected or current word)
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
#! /usr/bin/env ruby | |
word = gets.strip.gsub "'", '' | |
mods = | |
case ENV['TM_FILENAME'][/\w+$/] | |
when 'js', 'coffee' | |
%w[module_gecko.js module_jquery.js] | |
when 'rb' | |
%w[module_rubyrails.js rubystdlib.js] | |
when 'erb', 'slim', 'haml' | |
%w[module_rubyrails.js module_jquery.js] | |
else | |
puts 'can not determine file type' | |
exit | |
end | |
scripts = mods.map do |mod| | |
%Q|<script type="text/javascript" src="http://www.gotapi.com/widgets/compiled/c1_#{mod}.jsz"></script>| | |
end.join | |
mod = mods.first | |
puts <<htmlu | |
<div> | |
<input id='gaSearch' size='20' value="#{word}" /> | |
<div id='gaInfo'></div><div id='gaWait'></div> | |
</div> | |
<script> | |
gaMod='#{mod}' | |
gaTitle='Search Result' | |
updateWhenLoaded=true | |
gaL=true | |
document.getElementById('gaSearch').focus() | |
</script> | |
#{scripts} | |
<style> | |
.gaMenu{border:1px solid #505050;background:#FAFAFA;padding:0px 5px 0px 5px;} | |
.gaHeaderRow{color:#359155;border-top:1px solid #C0C0C0;width:250px;} | |
.gaRegularRow,.gaFooterRow{cursor:pointer;} | |
.gaSelectedRow{background:#c1e0e6;cursor:pointer;} | |
</style> | |
htmlu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment