Sha256: 0f8e5075969dff52e32ba8774d3f6ef32603fcf42c547074ead9bd68eb472ca7
Contents?: true
Size: 666 Bytes
Versions: 10
Compression:
Stored size: 666 Bytes
Contents
ROOT = File.expand_path(File.dirname(__FILE__)) require 'sinatra' require ROOT + '/../lib/dimension' get '/' do images = Dir.glob(File.join(ROOT, 'assets') + '/*') links = images.map do |i| name = File.basename(i) "<a href='/images/#{name}'>#{name}</a>" end '<ul><li>' + links.join('</li><li>') + '</li></ul>' end get '/images/:file' do file = File.join(ROOT, 'assets', params[:file]) if params[:geometry].nil? puts "Returning original file: #{file}" return send_file file end begin thumb = Dimension.open(file) rescue => e return e.message end thumb.generate(params[:geometry]) do thumb.to_response end end
Version data entries
10 entries across 10 versions & 1 rubygems