Sha256: 7296d6396608821d9bad4ad926212e8a4173ba24d46e5e660558ca4282e8d664

Contents?: true

Size: 1.27 KB

Versions: 23

Compression:

Stored size: 1.27 KB

Contents

require "rubygems"
require "bundler/setup"
$:.unshift(File.expand_path('../../lib', __FILE__))
require 'dragonfly'

Dragonfly.logger = Logger.new(STDOUT)
Dragonfly.app.configure do
  plugin :imagemagick
  url_format '/images/:job'
  fetch_file_whitelist [String]
end

class App
  def call(env)
    image = Dragonfly.app.fetch_file('grid.jpg')
    request = Rack::Request.new(env)
    error = nil
    if request['code']
      begin
        img_src = eval("image.#{request['code']}").url
      rescue StandardError => e
        error = e
      end
    end
    [
      200,
      {'Content-Type' => 'text/html'},
      [%(
        <style>
          form, input {
            font-size: 32px;
          }
          p.error {
            color: red;
            font-size: 24px;
          }
        </style>
        <p class="error">#{error}</p>
        <table>
          <tr>
            <th>Original (#{image.width}x#{image.height})</th>
            <td><img src="#{image.url}" /></td>
          </tr>
          <tr>
            <th><form>image.<input size="40" autofocus placeholder="thumb('200x100')" name="code" value="#{request['code']}" /></form></th>
            <td><img src="#{img_src}" /></td>
          </tr>
        </table>
      )]
    ]
  end
end

use Dragonfly::Middleware
run App.new

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
dragonfly-1.4.0 dev/test.ru
dragonfly-1.3.0 dev/test.ru
dragonfly-1.2.1 dev/test.ru
dragonfly-1.2.0 dev/test.ru
dragonfly-1.1.5 dev/test.ru
dragonfly-1.1.4 dev/test.ru
dragonfly-1.1.3 dev/test.ru
dragonfly-1.1.2 dev/test.ru
dragonfly-1.1.1 dev/test.ru
dragonfly-1.1.0 dev/test.ru
dragonfly-1.0.12 dev/test.ru
dragonfly-1.0.11 dev/test.ru
dragonfly-1.0.10 dev/test.ru
dragonfly-1.0.9 dev/test.ru
dragonfly-1.0.8 dev/test.ru
dragonfly-1.0.7 dev/test.ru
dragonfly-1.0.6 dev/test.ru
dragonfly-1.0.5 dev/test.ru
dragonfly-1.0.4 dev/test.ru
dragonfly-1.0.3 dev/test.ru