Skip to content

Commit

Permalink
fix for http_proxy
Browse files Browse the repository at this point in the history
catch some exceptions
  • Loading branch information
whomwah committed Aug 31, 2011
1 parent 22d20f8 commit 12e15e7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ gem 'rack'
gem 'rack-cache', :require => "rack/cache"
gem 'rqrcode'
gem 'rmagick'
# uncomment if you need http_proxy until bitly is updated
#gem 'bitly', :git => 'http://github.com/whomwah/bitly.git'
gem 'bitly'
5 changes: 5 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@ task :test do
Rake::TestTask.new
end

desc "Clear cache"
task :clear_cache do
system "rm -rf /tmp/rack"
end

task :default => 'test'

4 changes: 4 additions & 0 deletions webapp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def shorten(url)
Bitly.use_api_version_3
bitly = Bitly.new(BITLY[:username], BITLY[:api_key])
bitly.shorten(url).short_url
rescue SocketError
nil
end

def is_bbc?(url)
Expand Down Expand Up @@ -99,6 +101,8 @@ def to_qrcode_base64(blob)
redirect to('/') unless is_bbc?(url)

short = shorten(url)
halt 404, "Error! I can't connect to bit.ly" unless short

code = short.split('/').last
size = params[:size] ? params[:size].to_i : 0
@qrcode = {
Expand Down

0 comments on commit 12e15e7

Please sign in to comment.