rails_kindeditor 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -18
- data/app/controllers/kindeditor/assets_controller.rb +2 -2
- data/lib/generators/rails_kindeditor/install/install_generator.rb +8 -0
- data/lib/generators/rails_kindeditor/install/templates/application.js +17 -0
- data/lib/generators/rails_kindeditor/install/templates/rails_kindeditor.rb +2 -2
- data/lib/generators/rails_kindeditor/migration/templates/models/active_record/kindeditor/asset.rb +1 -1
- data/lib/rails_kindeditor.rb +4 -4
- data/lib/rails_kindeditor/version.rb +1 -1
- metadata +3 -2
data/README.md
CHANGED
@@ -28,12 +28,6 @@ Deprecation: rails_kindeditor ~> v0.3.0 only support Rails3.1+!(include Rails3.1
|
|
28
28
|
rails generate rails_kindeditor:install
|
29
29
|
```
|
30
30
|
|
31
|
-
### Include kindeditor javascripts for assets pipeline in your application.js:
|
32
|
-
|
33
|
-
```ruby
|
34
|
-
//= require kindeditor
|
35
|
-
```
|
36
|
-
|
37
31
|
### Usage:
|
38
32
|
|
39
33
|
```ruby
|
@@ -55,7 +49,7 @@ You can use kindeditor's initial parameters as usual, please visit http://www.ki
|
|
55
49
|
|
56
50
|
additionally, rails_kindeditor provides one "simple_mode" parameter for render simple mode quickly.
|
57
51
|
|
58
|
-
<img src="https://github.com/Macrow/rails_kindeditor/raw/master/screenshots/
|
52
|
+
<img src="https://github.com/Macrow/rails_kindeditor/raw/master/screenshots/simple_mode.png" alt="simple mode">
|
59
53
|
|
60
54
|
```ruby
|
61
55
|
kindeditor_tag :content, 'default content value', :simple_mode => true
|
@@ -103,8 +97,8 @@ You can customize some option for uploading.
|
|
103
97
|
# before => after
|
104
98
|
# eg: 1600x1600 => 800x800
|
105
99
|
# 1600x800 => 800x400
|
106
|
-
# 400x400 =>
|
107
|
-
# config.
|
100
|
+
# 400x400 => 400x400 # No Change
|
101
|
+
# config.image_resize_to_limit = [800, 800]
|
108
102
|
```
|
109
103
|
|
110
104
|
## Save upload file information into database(optional)
|
@@ -165,12 +159,6 @@ rails_kindeditor可以帮助你的rails程序集成kindeditor,包括了图片和
|
|
165
159
|
rails generate rails_kindeditor:install
|
166
160
|
```
|
167
161
|
|
168
|
-
### 在application.js里面为assets pipeline加入以下代码:
|
169
|
-
|
170
|
-
```ruby
|
171
|
-
//= require kindeditor
|
172
|
-
```
|
173
|
-
|
174
162
|
### 使用方法:
|
175
163
|
|
176
164
|
```ruby
|
@@ -188,7 +176,7 @@ rails_kindeditor可以帮助你的rails程序集成kindeditor,包括了图片和
|
|
188
176
|
...
|
189
177
|
<% end -%>
|
190
178
|
```
|
191
|
-
|
179
|
+
你可以像往常那样使用kindeditor自身的初始化参数,请访问 http://www.kindsoft.net/docs/option.html 查看更多参数。
|
192
180
|
|
193
181
|
另外,rails_kindeditor还额外提供一个"simple_mode"参数,以便快捷使用简单模式的kindeditor。
|
194
182
|
|
@@ -235,8 +223,8 @@ rails_kindeditor可以帮助你的rails程序集成kindeditor,包括了图片和
|
|
235
223
|
# 处理以前 => 处理以后
|
236
224
|
# eg: 1600x1600 => 800x800
|
237
225
|
# 1600x800 => 800x400
|
238
|
-
# 400x400 =>
|
239
|
-
# config.
|
226
|
+
# 400x400 => 400x400 # 图片小于该限制尺寸则不作处理
|
227
|
+
# config.image_resize_to_limit = [800, 800]
|
240
228
|
```
|
241
229
|
|
242
230
|
## 将上传文件信息记录入数据库(可选)
|
@@ -4,9 +4,9 @@ class Kindeditor::AssetsController < ApplicationController
|
|
4
4
|
skip_before_filter :verify_authenticity_token
|
5
5
|
def create
|
6
6
|
@imgFile, @dir = params[:imgFile], params[:dir]
|
7
|
-
if !RailsKindeditor.
|
7
|
+
if !RailsKindeditor.image_resize_to_limit.nil? && @dir == 'image'
|
8
8
|
Kindeditor::AssetUploader.send(:include, CarrierWave::MiniMagick)
|
9
|
-
Kindeditor::AssetUploader.send(:process, :
|
9
|
+
Kindeditor::AssetUploader.send(:process, :resize_to_limit => RailsKindeditor.resize_to_limit)
|
10
10
|
end
|
11
11
|
unless @imgFile.nil?
|
12
12
|
if Kindeditor::AssetUploader.save_upload_info? # save upload info into database
|
@@ -11,5 +11,13 @@ module RailsKindeditor
|
|
11
11
|
template "rails_kindeditor.rb", "config/initializers/rails_kindeditor.rb"
|
12
12
|
end
|
13
13
|
end
|
14
|
+
|
15
|
+
def insert_or_copy_js_files
|
16
|
+
if File.exist?('app/assets/javascripts/application.js')
|
17
|
+
insert_into_file "app/assets/javascripts/application.js", "//= require kindeditor\n", :after => "jquery_ujs\n"
|
18
|
+
else
|
19
|
+
copy_file "application.js", "app/assets/javascripts/application.js"
|
20
|
+
end
|
21
|
+
end
|
14
22
|
end
|
15
23
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require kindeditor
|
16
|
+
//= require_tree .
|
17
|
+
|
@@ -13,7 +13,7 @@ RailsKindeditor.setup do |config|
|
|
13
13
|
# Porcess upload image size
|
14
14
|
# eg: 1600x1600 => 800x800
|
15
15
|
# 1600x800 => 800x400
|
16
|
-
# 400x400 =>
|
17
|
-
# config.
|
16
|
+
# 400x400 => 400x400 # No Change
|
17
|
+
# config.image_resize_to_limit = [800, 800]
|
18
18
|
|
19
19
|
end
|
data/lib/rails_kindeditor.rb
CHANGED
@@ -20,7 +20,7 @@ module RailsKindeditor
|
|
20
20
|
mattr_accessor :upload_file_ext
|
21
21
|
@@upload_file_ext = %w[doc docx xls xlsx ppt htm html txt zip rar gz bz2]
|
22
22
|
|
23
|
-
mattr_accessor :
|
23
|
+
mattr_accessor :image_resize_to_limit
|
24
24
|
|
25
25
|
def self.root_path
|
26
26
|
@root_path ||= Pathname.new(File.dirname(File.expand_path('../', __FILE__)))
|
@@ -39,9 +39,9 @@ module RailsKindeditor
|
|
39
39
|
dirs.join('/')
|
40
40
|
end
|
41
41
|
|
42
|
-
def self.
|
43
|
-
if !
|
44
|
-
[
|
42
|
+
def self.resize_to_limit
|
43
|
+
if !image_resize_to_limit.nil? && image_resize_to_limit.is_a?(Array)
|
44
|
+
[image_resize_to_limit[0], image_resize_to_limit[1]]
|
45
45
|
else
|
46
46
|
[800, 800]
|
47
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_kindeditor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: carrierwave
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- config/routes.rb
|
65
65
|
- lib/generators/rails_kindeditor/install/USAGE
|
66
66
|
- lib/generators/rails_kindeditor/install/install_generator.rb
|
67
|
+
- lib/generators/rails_kindeditor/install/templates/application.js
|
67
68
|
- lib/generators/rails_kindeditor/install/templates/rails_kindeditor.rb
|
68
69
|
- lib/generators/rails_kindeditor/migration/USAGE
|
69
70
|
- lib/generators/rails_kindeditor/migration/migration_generator.rb
|