Sha256: 734165ae665f19cd815e77132a048a9491ad9119b3008b8225fc0959908149fa

Contents?: true

Size: 1.55 KB

Versions: 8

Compression:

Stored size: 1.55 KB

Contents

module Locomotive
  module Steam
    module Initializers

      class Dragonfly

        def run
          require 'dragonfly'

          # need to be called outside of the configure method
          imagemagick_commands = find_imagemagick_commands

          ::Dragonfly.app(:steam).configure do
            if imagemagick_commands
              plugin :imagemagick, imagemagick_commands
            end

            verify_urls true

            secret Locomotive::Steam.configuration.image_resizer_secret

            url_format '/images/dynamic/:job/:basename.:ext'

            fetch_file_whitelist /public/

            fetch_url_whitelist /.+/
          end

          if ::Dragonfly.logger.nil?
            ::Dragonfly.logger = Locomotive::Common::Logger.instance
          end
        end

        def find_imagemagick_commands
          convert   = `which convert`.strip.presence || '/usr/local/bin/convert'
          identify  = `which identify`.strip.presence || '/usr/local/bin/identify'

          if File.exists?(convert)
            { convert_command: convert, identify_command: identify }
          else
            missing_image_magick
            nil
          end
        end

        def missing_image_magick
          Locomotive::Common::Logger.warn <<-EOF
[Dragonfly] !disabled!
[Dragonfly] If you want to take full benefits of all the features in Locomotive Steam, we recommend you to install ImageMagick. Check out the documentation here: http://doc.locomotivecms.com.
EOF
        end

      end
    end
  end
end

Locomotive::Steam::Initializers::Dragonfly.new.run

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
locomotivecms_steam-1.0.0.rc1 lib/locomotive/steam/initializers/dragonfly.rb
locomotivecms_steam-1.0.0.pre.beta.3 lib/locomotive/steam/initializers/dragonfly.rb
locomotivecms_steam-1.0.0.pre.beta.2 lib/locomotive/steam/initializers/dragonfly.rb
locomotivecms_steam-1.0.0.pre.beta.1 lib/locomotive/steam/initializers/dragonfly.rb
locomotivecms_steam-1.0.0.pre.alpha.3 lib/locomotive/steam/initializers/dragonfly.rb
locomotivecms_steam-1.0.0.pre.alpha.2 lib/locomotive/steam/initializers/dragonfly.rb
locomotivecms_steam-1.0.0.pre.alpha.1 lib/locomotive/steam/initializers/dragonfly.rb
locomotivecms_steam-1.0.0.pre.alpha lib/locomotive/steam/initializers/dragonfly.rb