Sha256: 4a2f1d474e52cb8ab4536d98ba634f8ed4efdca0ce09b0eaebbc88774b561a91

Contents?: true

Size: 1.28 KB

Versions: 22

Compression:

Stored size: 1.28 KB

Contents

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

      module ClassMethods
        def attachment_file_types
          @attachment_file_types ||= Ckeditor.attachment_file_types.map(&:to_sym).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}".to_sym)
            end
          end
        end

        def image_file_types
          @image_file_types ||= Ckeditor.image_file_types.map(&:to_sym)
        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

22 entries across 22 versions & 2 rubygems

Version Path
glebtv-ckeditor-4.4.7.4 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.4.7.3 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.4.7.2 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.4.7.1 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.4.7 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.4.6 lib/ckeditor/backend/dragonfly.rb
ckeditor-4.1.1 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.4.3.4 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.4.3.3 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.4.3.2 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.4.3.1 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.4.3.0 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.3.2.6 lib/ckeditor/backend/dragonfly.rb
ckeditor-4.1.0 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.3.2.5 lib/ckeditor/backend/dragonfly.rb
ckeditor-4.0.11 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.3.2.4 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.3.2.3 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.3.2.2 lib/ckeditor/backend/dragonfly.rb
glebtv-ckeditor-4.3.2.1 lib/ckeditor/backend/dragonfly.rb