Permalink
Browse files

rails 3.2 only compatibility

  • Loading branch information...
1 parent 990c868 commit add80852f8c0b444d9c02cbe6cba4a1de81642b2 @mlitwiniuk committed May 17, 2012
Showing with 25 additions and 22 deletions.
  1. +3 −3 app/helpers/tinymce_fm/application_helper.rb
  2. +21 −18 lib/tinymce_fm/filemanager.rb
  3. +1 −1 tinymce_fm.gemspec
@@ -2,10 +2,10 @@ module TinymceFm
module ApplicationHelper
def tinymce_javascript_tag( controller = nil, theme = nil )
opts = {:manager => "#{controller.to_s if controller.present?}", :theme => theme}
- # scripts = javascript_include_tag('tinymce_fm/application.js') + javascript_include_tag(tinymce_fm_engine.tinymce_combine_js_path(opts))
- # "<script type='text/javascript' src='#{tinymce_fm_engine.tinymce_combine_js_path(opts)}'></script>"
+ # As using javascript_include_tag will malform js path
+ tinymce_js = "<script type='text/javascript' src='#{tinymce_fm_engine.tinymce_combine_js_path(opts)}'></script>"
scripts = [ javascript_include_tag('tinymce_fm/application.js'),
- javascript_include_tag(tinymce_fm_engine.tinymce_combine_js_path(opts)).sub('.js', ''),
+ tinymce_js,
stylesheet_link_tag('tinymce_fm/application.css')
].join("\n")
raw scripts
@@ -4,9 +4,12 @@ module Filemanager
def self.included(base)
base.extend ClassMethods
+ base.send :class_attribute, :tinymce_fm_settings
+ base.tinymce_fm_settings = {}
end
module ClassMethods
+
def tinymce_filemanager_list_images()
end
@@ -38,39 +41,39 @@ def tinymce_filemanager_list_links()
protected
def thumbs_subdir(*params)
- write_inheritable_array(:thumbs_subdir, params)
+ self.tinymce_fm_settings[:thumbs_subdir] = params
end
def thumbs_size(*params)
- write_inheritable_array(:thumbs_size, params)
+ self.tinymce_fm_settings[:thumbs_size] = params
end
def image_accept_mime_types(*params)
- write_inheritable_array(:image_accept_mime_types, *params)
+ self.tinymce_fm_settings[:image_accept_mime_types] = params
end
def image_save_into_public_subdir(*params)
- write_inheritable_array(:image_save_into_public_subdir, params)
+ self.tinymce_fm_settings[:image_save_into_public_subdir] = params
end
def image_file_size_limit(*params)
- write_inheritable_array(:image_file_size_limit, params)
+ self.tinymce_fm_settings[:image_file_size_limit] = params
end
def media_accept_mime_types(*params)
- write_inheritable_array(:media_accept_mime_types, *params)
+ self.tinymce_fm_settings[:media_accept_mime_types] = params
end
def media_save_into_public_subdir(*params)
- write_inheritable_array(:media_save_into_public_subdir, params)
+ self.tinymce_fm_settings[:media_save_into_public_subdir] = params
end
def media_file_size_limit(*params)
- write_inheritable_array(:media_file_size_limit, params)
+ self.tinymce_fm_settings[:media_file_size_limit] = params
end
def link_classes_accepted(*params)
- write_inheritable_array(:link_classes, params)
+ self.tinymce_fm_settings[:link_classes] = params
end
@@ -130,35 +133,35 @@ def accept_images_mime_types(params)
private
def images_folder
- self.class.read_inheritable_attribute(:image_save_into_public_subdir) || 'images'
+ self.tinymce_fm_settings[:image_save_into_public_subdir] || 'images'
end
def media_folder
- self.class.read_inheritable_attribute(:media_save_into_public_subdir) || 'media'
+ self.tinymce_fm_settings[:media_save_into_public_subdir] || 'media'
end
def thumbs_folder
- self.class.read_inheritable_attribute(:thumbs_subdir) || 'thumbs'
+ self.tinymce_fm_settings[:thumbs_subdir] || 'thumbs'
end
def accept_image_mime
- self.class.read_inheritable_attribute(:image_accept_mime_types) || ['image/jpeg', 'image/gif', 'image/png', 'image/jpg', 'image/bmp']
+ self.tinymce_fm_settings[:image_accept_mime_types] || ['image/jpeg', 'image/gif', 'image/png', 'image/jpg', 'image/bmp']
end
def accept_media_mime
- self.class.read_inheritable_attribute(:media_accept_mime_types) || ['video/mpeg', 'video/msvideo', 'video/quicktime', 'video/x-flv', 'application/x-shockwave-flash']
+ self.tinymce_fm_settings[:media_accept_mime_types] || ['video/mpeg', 'video/msvideo', 'video/quicktime', 'video/x-flv', 'application/x-shockwave-flash']
end
def image_size_limit
- (self.class.read_inheritable_attribute(:image_file_size_limit) && self.class.read_inheritable_attribute(:image_file_size_limit)[0]) || 5.megabytes
+ (self.tinymce_fm_settings[:image_file_size_limit] && self.tinymce_fm_settings[:image_file_size_limit][0]) || 5.megabytes
end
def media_size_limit
- (self.class.read_inheritable_attribute(:media_file_size_limit) && self.class.read_inheritable_attribute(:media_file_size_limit)[0]) || 30.megabytes
+ (self.tinymce_fm_settings[:media_file_size_limit] && self.tinymce_fm_settings[:media_file_size_limit][0]) || 30.megabytes
end
def link_classes
- (self.class.read_inheritable_attribute(:link_classes) || []).flatten
+ (self.tinymce_fm_settings[:link_classes] || []).flatten
end
@@form_file_upload_form_name = 'upload_form'
@@ -319,7 +322,7 @@ def upload_base(base_folder, list_action, mime_types, size_max, media_thumb = fa
flash[:error] = "Invalid mime type! (#{file.content_type()})"
end
else
- flash[:error] = "File to large! (Limit: #{size_max} file: #{File.size(file)})"
+ flash[:error] = "File to large! (Limit: #{size_max} file: #{File.size(file.tempfile).to_s})"
end
else
flash[:error] = "Field is not a file!"
View
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
s.files = Dir["{app,config,db,lib,vendor}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
s.test_files = Dir["test/**/*"]
- s.add_dependency "rails", "> 3.1"
+ s.add_dependency "rails", ">= 3.2"
# s.add_dependency "jquery-rails"
s.add_dependency 'mini_magick', "~> 3.4"

0 comments on commit add8085

Please sign in to comment.