Module: RailsKindeditor

Defined in:
lib/rails_kindeditor.rb,
lib/rails_kindeditor/engine.rb,
lib/rails_kindeditor/helper.rb,
lib/rails_kindeditor/version.rb,
lib/rails_kindeditor/simple_form.rb,
lib/generators/rails_kindeditor/install/install_generator.rb,
lib/generators/rails_kindeditor/migration/migration_generator.rb

Defined Under Namespace

Modules: Builder, Helper, SimpleForm Classes: Engine, InstallGenerator, MigrationGenerator

Constant Summary collapse

VERSION =
"0.5.1"
@@upload_dir =
'uploads'
@@upload_image_ext =
%w[gif jpg jpeg png bmp]
@@upload_flash_ext =
%w[swf flv]
@@upload_media_ext =
%w[swf flv mp3 wav wma wmv mid avi mpg asf rm rmvb]
@@upload_file_ext =
%w[doc docx xls xlsx ppt htm html txt zip rar gz bz2]
@@use_original_filename =
true

Class Method Summary collapse

Class Method Details

.assetsObject



33
34
35
36
37
# File 'lib/rails_kindeditor.rb', line 33

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

.resize_to_limitObject



46
47
48
49
50
51
52
# File 'lib/rails_kindeditor.rb', line 46

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

.root_pathObject



29
30
31
# File 'lib/rails_kindeditor.rb', line 29

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

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



54
55
56
# File 'lib/rails_kindeditor.rb', line 54

def self.setup
  yield self
end

.upload_store_dirObject



39
40
41
42
43
44
# File 'lib/rails_kindeditor.rb', line 39

def self.upload_store_dir
  dirs = upload_dir.gsub(/^\/+/,'').gsub(/\/+$/,'').split('/')
  dirs.each { |dir| dir.gsub!(/\W/, '') }
  dirs.delete('')
  dirs.join('/')
end