Sha256: b311008fa5a18bd1a64a2a04df26b3bd25a16a294c62e2eaa27eaf0a5d77b801

Contents?: true

Size: 1.89 KB

Versions: 36

Compression:

Stored size: 1.89 KB

Contents

require 'paperclip'

if TrustyCms.config.table_exists?
  if TrustyCms.config['assets.create_image_thumbnails?']
    # Check that we can run convert
    begin
      output = Paperclip.run('convert', '-version')
      Rails.logger.info %{[Clipped] Using image thumbnailer: #{output.split("\n").first.sub(/^Version: /i, '')}}
    rescue Cocaine::CommandNotFoundError
      TrustyCms.config['assets.create_image_thumbnails?'] = false
      TrustyCms.config['assets.create_pdf_thumbnails?'] = false
      Rails.logger.warn "ImageMagick 'convert' executable not found: image and pdf thumbnailing disabled."
    rescue Cocaine::ExitStatusError => e
      Rails.logger.warn "ImageMagick is present but calling 'convert -version' returns an error: #{e}"
    end
  end

  if TrustyCms.config['assets.create_pdf_thumbnails?']
    # Check that we can run ghostscript
    begin
     output = Paperclip.run('gs', '-v')
     Rails.logger.info %{[Clipped] Using PDF thumbnailer: #{output.split("\n").first}}
    rescue Cocaine::CommandNotFoundError
      TrustyCms.config['assets.create_pdf_thumbnails?'] = false
      Rails.logger.warn "Ghostscript 'gs' executable not found: pdf thumbnailing disabled."
    rescue Cocaine::ExitStatusError => e
      Rails.logger.warn "Ghostscript is present but calling 'gs -v' returns an error: #{e}"
    end
  end

  if TrustyCms.config['assets.create_video_thumbnails?']
    # Check that we can run ffmpeg
    begin
      output = Paperclip.run('ffmpeg', '-version 2> /dev/null')
      Rails.logger.info %{[Clipped] Using video frame grabber: #{output.split("\n").first}}
    rescue Cocaine::CommandNotFoundError
      TrustyCms.config['assets.create_video_thumbnails?'] = false
      Rails.logger.warn "FFmpeg executable not found: video thumbnailing disabled."
    rescue Cocaine::ExitStatusError => e
      Rails.logger.warn "FFmpeg is present but calling 'ffmpeg -L' returns an error: #{e}"
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
trusty-clipped-extension-3.1.4 config/initializers/processors.rb
trusty-clipped-extension-3.1.3 config/initializers/processors.rb
trusty-clipped-extension-3.1.2 config/initializers/processors.rb
trusty-clipped-extension-3.1.1 config/initializers/processors.rb
trusty-clipped-extension-3.1.0 config/initializers/processors.rb
trusty-clipped-extension-3.0.0 config/initializers/processors.rb
trusty-clipped-extension-2.0.15 config/initializers/processors.rb
trusty-clipped-extension-2.0.14 config/initializers/processors.rb
trusty-clipped-extension-2.0.13 config/initializers/processors.rb
trusty-clipped-extension-2.0.12 config/initializers/processors.rb
trusty-clipped-extension-2.0.11 config/initializers/processors.rb
trusty-clipped-extension-2.0.10 config/initializers/processors.rb
trusty-clipped-extension-2.0.9 config/initializers/processors.rb
trusty-clipped-extension-2.0.8 config/initializers/processors.rb
trusty-clipped-extension-2.0.7 config/initializers/processors.rb
trusty-clipped-extension-2.0.6 config/initializers/processors.rb
trusty-clipped-extension-2.0.5 config/initializers/processors.rb
trusty-clipped-extension-2.0.4 config/initializers/processors.rb
trusty-clipped-extension-2.0.3.pre.beta config/initializers/processors.rb
trusty-clipped-extension-2.0.2.pre.beta config/initializers/processors.rb