Skip to content

Commit

Permalink
Tweaks to the App Store link command (smarter context detection)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttscoff committed Aug 21, 2009
1 parent ee8f821 commit 9706563
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 7 additions & 4 deletions Commands/App Store Link.tmCommand
Expand Up @@ -9,14 +9,15 @@
SUPPORT = ENV['TM_SUPPORT_PATH']
DIALOG = ENV['DIALOG']
require SUPPORT + '/lib/escape'
require SUPPORT + '/lib/ui'
require SUPPORT + '/lib/osx/plist'
require SUPPORT + '/lib/exit_codes'
require 'erb'
require 'net/http'
phrase = STDIN.read
escapedUrl = "http://beta.appspace.com/apps/find/#{e_url(phrase.strip)}/"
keyword = phrase.empty? ? TextMate::UI.request_string(:title => "Enter keywords",:prompt => "Find App Store link for:") : phrase
escapedUrl = "http://beta.appspace.com/apps/find/#{e_url(keyword.strip)}/"
res = Net::HTTP.get_response(URI.parse(escapedUrl)).body
apps = []
Expand Down Expand Up @@ -48,9 +49,9 @@ id = scrape.match(/viewSoftware%3Fid%3D(\d+)/)[1]
price = scrape.match(/buy_button">\$(\d+\.\d\d)/)[1].to_s
url = "http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=#{id}&mt=8"
input = "#{sel}"
input = phrase.empty? ? sel : phrase
if !(ENV['TM_SCOPE'].scan(/markdown/).empty?) && ENV['TM_CURRENT_LINE'] =~ /^(\s+)?$/
if !(ENV['TM_SCOPE'].scan(/markdown/).empty?) && ENV['TM_CURRENT_LINE'] =~ /^(#{phrase})?(\s+)?$/
print ERB.new(ENV['TM_REF_LINK_FORMAT']).result
else
print ERB.new(ENV['TM_BLINK_FORMAT']).result
Expand All @@ -59,6 +60,8 @@ end
</string>
<key>fallbackInput</key>
<string>word</string>
<key>input</key>
<string>selection</string>
<key>keyEquivalent</key>
Expand Down
1 change: 0 additions & 1 deletion info.plist
Expand Up @@ -14,7 +14,6 @@
<string>6C1B5472-C629-439C-BC50-560EB3766C19</string>
<string>F7332367-4230-444D-AE21-5BAD1E5F6A2E</string>
<string>1E8D16F5-4FD0-47D6-9C8B-62EDFE2733CF</string>
<string>165B02E9-40F9-4444-B9EA-1C9561D7980A</string>
</array>
<key>mainMenu</key>
<dict>
Expand Down

0 comments on commit 9706563

Please sign in to comment.