Module: Refinery::Stylesheets::Dragonfly
- Defined in:
- lib/refinery/stylesheets/dragonfly.rb
Class Method Summary collapse
Class Method Details
.attach!(app) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/refinery/stylesheets/dragonfly.rb', line 32 def attach!(app) ### Extend active record ### app.config.middleware.insert_after 'Rack::Lock', 'Dragonfly::Middleware', :stylesheets 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')}" } end |
.setup! ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/refinery/stylesheets/dragonfly.rb', line 6 def setup! app_stylesheets = ::Dragonfly[:stylesheets] app_stylesheets.configure_with(:rails) do |c| c.datastore.root_path = Rails.root.join('public', 'system', 'stylesheets').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/stylesheets/:job/:basename.:format' c.secret = ::Refinery::Setting.find_or_set(:dragonfly_secret, Array.new(24) { rand(256) }.pack('C*').unpack('H*').first) end if ::Refinery.s3_backend app_stylesheets.configure_with(:heroku, ENV['S3_BUCKET']) # Dragonfly doesn't set the S3 region, so we have to do this manually app_stylesheets.datastore.configure do |d| d.region = ENV['S3_REGION'] if ENV['S3_REGION'] # otherwise defaults to 'us-east-1' end end #app_stylesheets.define_macro(::ActiveRecord::Base, :image_accessor) app_stylesheets.analyser.register(::Dragonfly::Analysis::FileCommandAnalyser) end |