rails_kindeditor 0.3.15 → 0.3.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b6cfb7130f199515719e293a4c199691661712a
4
- data.tar.gz: 15881a605cca4945a17d87f11739bf6d8f513980
3
+ metadata.gz: 1ec1c8cf8e810c9bc12a13f6bd1efb3f10818a0c
4
+ data.tar.gz: aabd2dde91fca3a5469ad062831ee78ae3a431c2
5
5
  SHA512:
6
- metadata.gz: 1a71b336bcb4280a0b2edab79132834fdfb7a7889150a1dd533d922e71fdb62fc2aed35251f96fb6c6338d2183ced82a96971722f5259797c4683144c9929ffd
7
- data.tar.gz: c3dd5813fe30b5d2fdff83bd50dfd9c60567776ab49f872dba6c7ee66bcf4b4660788520ee388f0d6bf21b2e7660117c10692861720dc54793069d8ed2a75892
6
+ metadata.gz: b09e83fccbba0a9ebd3e1a3c97d6ae0e6ec9822719da688dcef792738b766492887de8ea909dcf31aae9f1221bcb0380ace3aae3d39e473e80973aaab913ce0c
7
+ data.tar.gz: 4029988064429d22be68bc02928d2e7dbbf520772eebb3c786d22d9ad46e5c261fcfa65924481249632470203f25025af365ed6ef4c2b7aad20fbcd8a41888b2
data/README.md CHANGED
@@ -3,9 +3,6 @@
3
3
  Kindeditor is a WYSIWYG javascript editor, visit http://www.kindsoft.net for details.
4
4
  rails_kindeditor will helps your rails app integrate with kindeditor, includes images and files uploading.
5
5
 
6
- Deprecation: rails_kindeditor ~> v0.3.0 only support Rails3.1+!(include Rails3.1 and Rails3.2)
7
- If you're using rails3.0.x, please check rails_kindeditor v0.2.8
8
-
9
6
  <img src="https://github.com/Macrow/rails_kindeditor/raw/master/screenshots/rails_kindeditor.png" alt="rails_indeditor">
10
7
 
11
8
  ## Installation and usage
@@ -13,7 +10,7 @@ Deprecation: rails_kindeditor ~> v0.3.0 only support Rails3.1+!(include Rails3.1
13
10
  ### Add this to your Gemfile
14
11
 
15
12
  ```ruby
16
- gem 'rails_kindeditor', '~> 0.3.15'
13
+ gem 'rails_kindeditor', '~> 0.3.16'
17
14
  ```
18
15
 
19
16
  ### Run "bundle" command.
@@ -161,15 +158,12 @@ MIT License.
161
158
  Kindeditor是国产的所见即所得javascript富文本编辑器, 访问 http://www.kindsoft.net 获取更多信息.
162
159
  rails_kindeditor可以帮助你的rails程序集成kindeditor,包括了图片和附件上传功能,文件按照类型、日期进行存储。
163
160
 
164
- 注意: rails_kindeditor ~> v0.3.0 仅支持Rails3.1+!当然,包括Rails3.1和Rails3.2.
165
- 如果你使用rails3.0.x,请使用rails_kindeditor v0.2.8
166
-
167
161
  ## 安装及使用
168
162
 
169
163
  ### 将下面代码加入Gemfile:
170
164
 
171
165
  ```ruby
172
- gem 'rails_kindeditor', '~> 0.3.15'
166
+ gem 'rails_kindeditor', '~> 0.3.16'
173
167
  ```
174
168
 
175
169
  ### 运行"bundle"命令:
@@ -9,13 +9,11 @@ module RailsKindeditor
9
9
  end
10
10
 
11
11
  def kindeditor(name, method, options = {})
12
- input_html = (options.delete(:input_html) || {})
13
- hash = input_html.stringify_keys
14
- instance_tag = ActionView::Base::InstanceTag.new(name, method, self, options.delete(:object))
15
- instance_tag.send(:add_default_name_and_id, hash)
12
+ # TODO: Refactory options: 1. kindeditor_option 2. html_option
13
+ input_html = (options.delete(:input_html) || {}).stringify_keys
16
14
  output_buffer = ActiveSupport::SafeBuffer.new
17
- output_buffer << instance_tag.to_text_area_tag(input_html)
18
- output_buffer << javascript_tag(js_replace(hash['id'], options))
15
+ output_buffer << build_text_area_tag(name, method, self, options, input_html)
16
+ output_buffer << javascript_tag(js_replace(input_html['id'], options))
19
17
  end
20
18
 
21
19
  private
@@ -41,11 +39,27 @@ module RailsKindeditor
41
39
  options.merge!(:uploadJson => '/kindeditor/upload')
42
40
  options.merge!(:fileManagerJson => '/kindeditor/filemanager')
43
41
  if options[:simple_mode] == true
44
- options.delete(:simple_mode)
45
42
  options.merge!(:items => %w{fontname fontsize | forecolor hilitecolor bold italic underline removeformat | justifyleft justifycenter justifyright insertorderedlist insertunorderedlist | emoticons image link})
46
43
  end
44
+ options.delete(:simple_mode)
47
45
  options
48
- end
46
+ end
47
+
48
+ def build_text_area_tag(name, method, template, options, input_html)
49
+ if Rails.version >= '4.0.0'
50
+ text_area_tag = ActionView::Helpers::Tags::TextArea.new(name, method, template, options)
51
+ text_area_tag.send(:add_default_name_and_id, input_html)
52
+ text_area_tag.render
53
+ elsif Rails.version >= '3.1.0'
54
+ text_area_tag = ActionView::Base::InstanceTag.new(name, method, template, options.delete(:object))
55
+ text_area_tag.send(:add_default_name_and_id, input_html)
56
+ text_area_tag.to_text_area_tag(input_html)
57
+ elsif Rails.version >= '3.0.0'
58
+ raise 'Please use rails_kindeditor v0.2.8 for Rails v3.0.x'
59
+ else
60
+ raise 'Please upgrade your Rails !'
61
+ end
62
+ end
49
63
  end
50
64
 
51
65
  module Builder
@@ -1,4 +1,4 @@
1
1
  module RailsKindeditor
2
- VERSION = "0.3.15"
2
+ VERSION = "0.3.16"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_kindeditor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.15
4
+ version: 0.3.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Macrow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-22 00:00:00.000000000 Z
11
+ date: 2013-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: carrierwave