Sha256: 649f0d7cd893e176131b0899105df6fca05784c5e75d172eaaab5e92ef8f0ea1

Contents?: true

Size: 1.57 KB

Versions: 6

Compression:

Stored size: 1.57 KB

Contents

require 'rails_kindeditor/engine'
require 'rails_kindeditor/helper'
require 'rails_kindeditor/active_record'
require 'carrierwave'
require 'mini_magick'

module RailsKindeditor
  
  mattr_accessor :upload_dir
  @@upload_dir = 'uploads'
  
  mattr_accessor :upload_image_ext
  @@upload_image_ext = %w[gif jpg jpeg png bmp]
  
  mattr_accessor :upload_flash_ext
  @@upload_flash_ext = %w[swf flv]

  mattr_accessor :upload_media_ext
  @@upload_media_ext = %w[swf flv mp3 wav wma wmv mid avi mpg asf rm rmvb]
  
  mattr_accessor :upload_file_ext
  @@upload_file_ext = %w[doc docx xls xlsx ppt htm html txt zip rar gz bz2]
  
  mattr_accessor :image_resize_to_limit

  mattr_accessor :asset_url_prefix

  def self.base_path
    self.asset_url_prefix ? "#{self.asset_url_prefix}/kindeditor/" : '/assets/kindeditor/'
  end

  def self.root_path
    @root_path ||= Pathname.new(File.dirname(File.expand_path('../', __FILE__)))
  end

  def self.assets
    Dir[root_path.join('vendor/assets/javascripts/kindeditor/**', '*.{js,css}')].inject([]) do |assets, path|
      assets << Pathname.new(path).relative_path_from(root_path.join('vendor/assets/javascripts')).to_s
    end
  end
  
  def self.upload_store_dir
    dirs = upload_dir.gsub(/^\/+/,'').gsub(/\/+$/,'').split('/')
    dirs.each { |dir| dir.gsub!(/\W/, '') }
    dirs.delete('')
    dirs.join('/')
  end
  
  def self.resize_to_limit
    if !image_resize_to_limit.nil? && image_resize_to_limit.is_a?(Array)
      [image_resize_to_limit[0], image_resize_to_limit[1]]
    else
      [800, 800]
    end
  end
  
  def self.setup
    yield self
  end
  
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
rails_kindeditor-0.5.1 lib/rails_kindeditor.rb
rails_kindeditor-0.5.0 lib/rails_kindeditor.rb
rails_kindeditor-0.4.7 lib/rails_kindeditor.rb
rails_kindeditor-0.4.6 lib/rails_kindeditor.rb
rails_kindeditor-plus-0.4.5 lib/rails_kindeditor.rb
rails_kindeditor_upyun-0.4.5 lib/rails_kindeditor.rb