Sha256: 04f0acaf89e6c213698d6958b7086ae0ef5b1194e1ab1d8d51d249aae871f90c

Contents?: true

Size: 1.38 KB

Versions: 13

Compression:

Stored size: 1.38 KB

Contents

module Ckeditor
  module Backend
    module Dragonfly
      def self.included(base)
        base.send(:extend, ::Dragonfly::Model)
        base.send(:extend, ::Dragonfly::Model::Validations)
        base.send(:extend, ClassMethods)
        base.send(:include, InstanceMethods)
      end

      module ClassMethods
        def attachment_file_types
          @attachment_file_types ||= Ckeditor.attachment_file_types.map(&:to_s).tap do |formats|
            # This is not ideal but Dragonfly doesn't return double
            # extensions. Having said that, the other backends
            # currently don't use attachment_file_types at all.
            [ 'bz2', 'gz', 'lzma', 'xz' ].each do |f|
              formats << f if formats.include?("tar.#{f}")
            end
          end
        end

        def image_file_types
          @image_file_types ||= Ckeditor.image_file_types.map(&:to_s)
        end
      end

      module InstanceMethods
        delegate :url, :path, :size, :image?, :width, :height, :to => :data

        alias_attribute :data_file_name, :data_name
        alias_attribute :data_content_type, :"data.mime_type"
        alias_attribute :data_file_size, :data_size

        private

        def url_thumb_options
          if data.basename.present?
            { :basename => "thumb_#{data.basename}" }
          else
            {}
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
danabr75-ckeditor-4.1.6 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.6.0 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.5.10.3 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.5.10.2 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.5.10.1 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.5.7.1 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.5.7 lib/ckeditor/backend/dragonfly.rb
ckeditor_custom_controller-4.1.6 lib/ckeditor/backend/dragonfly.rb
ckeditor-4.1.6 lib/ckeditor/backend/dragonfly.rb
ckeditor-4.1.5 lib/ckeditor/backend/dragonfly.rb
ckeditor-4.1.4 lib/ckeditor/backend/dragonfly.rb
ckeditor-4.1.3 lib/ckeditor/backend/dragonfly.rb
ckeditor-4.1.2 lib/ckeditor/backend/dragonfly.rb