Last active
December 18, 2015 03:58
-
-
Save dandehavilland/5721857 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Resources App | |
app_resources = Dragonfly[:resources] | |
app_resources.configure_with(:rails) do |c| | |
c.datastore.root_path = Rails.root.join('public', 'system', 'resources').to_s | |
# This url_format makes it so that dragonfly urls work in traditional | |
# situations where the filename and extension are required, e.g. lightbox. | |
# What this does is takes the url that is about to be produced e.g. | |
# /system/resources/BAhbB1sHOgZmIiMyMDEwLzA5LzAxL1NTQ19DbGllbnRfQ29uZi5qcGdbCDoGcDoKdGh1bWIiDjk0MngzNjAjYw | |
# and adds the filename onto the end (say the file was 'refinery_is_awesome.pdf') | |
# /system/resources/BAhbB1sHOgZmIiMyMDEwLzA5LzAxL1NTQ19DbGllbnRfQ29uZi5qcGdbCDoGcDoKdGh1bWIiDjk0MngzNjAjYw/refinery_is_awesome.pdf | |
c.url_format = '/system/resources/:job/:basename.:format' | |
c.secret = RefinerySetting.find_or_set(:dragonfly_secret, | |
Array.new(24) { rand(256) }.pack('C*').unpack('H*').first) | |
end | |
# Images App | |
app_images = Dragonfly[:images] | |
app_images.configure_with(:imagemagick) | |
app_images.configure_with(:rails) do |c| | |
c.datastore.root_path = Rails.root.join('public', 'system', 'images').to_s | |
# This url_format it so that dragonfly urls work in traditional | |
# situations where the filename and extension are required, e.g. lightbox. | |
# What this does is takes the url that is about to be produced e.g. | |
# /system/images/BAhbB1sHOgZmIiMyMDEwLzA5LzAxL1NTQ19DbGllbnRfQ29uZi5qcGdbCDoGcDoKdGh1bWIiDjk0MngzNjAjYw | |
# and adds the filename onto the end (say the image was 'refinery_is_awesome.jpg') | |
# /system/images/BAhbB1sHOgZmIiMyMDEwLzA5LzAxL1NTQ19DbGllbnRfQ29uZi5qcGdbCDoGcDoKdGh1bWIiDjk0MngzNjAjYw/refinery_is_awesome.jpg | |
c.url_format = '/system/images/:job/:basename.:format' | |
c.secret = RefinerySetting.find_or_set(:dragonfly_secret, | |
Array.new(24) { rand(256) }.pack('C*').unpack('H*').first) | |
end | |
# Images middleware | |
app.config.middleware.insert_after 'Rack::Lock', 'Dragonfly::Middleware', :images | |
app.config.middleware.insert_before 'Dragonfly::Middleware', 'Rack::Cache', { | |
:verbose => Rails.env.development?, | |
:metastore => "file:#{Rails.root.join('tmp', 'dragonfly', 'cache', 'meta')}", | |
:entitystore => "file:#{Rails.root.join('tmp', 'dragonfly', 'cache', 'body')}" | |
} | |
# Resources middleware | |
app.config.middleware.insert_after 'Rack::Lock', 'Dragonfly::Middleware', :resources | |
app.config.middleware.insert_before 'Dragonfly::Middleware', 'Rack::Cache', { | |
:verbose => Rails.env.development?, | |
:metastore => "file:#{Rails.root.join('tmp', 'dragonfly', 'cache', 'meta')}", | |
:entitystore => "file:#{Rails.root.join('tmp', 'dragonfly', 'cache', 'body')}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment