Module: Rack::Thumb::Proxy::ViewHelpers

Defined in:
lib/rack-thumb-proxy/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#hash_signature_for(image_url, options = nil) ⇒ Object



20
21
22
23
24
25
# File 'lib/rack-thumb-proxy/view_helpers.rb', line 20

def hash_signature_for(image_url, options = nil)
  return nil unless rack_thumb_proxy_hash_signatures_enabled?
  key_length = rack_thumb_proxy_configuration.key_length
  secret     = rack_thumb_proxy_configuration.secret
  ('%s\t%s\t%s' % [secret, options, escape_image_url(image_url)])[0..key_length-1]
end

#proxied_image_url(image_url, options = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rack-thumb-proxy/view_helpers.rb', line 6

def proxied_image_url(image_url, options = nil)

  if rack_thumb_proxy_hash_signatures_enabled?
    signature = hash_signature_for(image_url, options)
  end

  options           = rack_thumb_proxy_options_to_s(options)
  escaped_image_url = escape_image_url(image_url)
  mount_point       = rack_thumb_proxy_configuration.mount_point

  mount_point + [signature, options, escaped_image_url].compact.join("/")

end