rails_kindeditor_qiniu 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +5 -0
- data/README.md +234 -0
- data/Rakefile +2 -0
- data/app/assets/javascripts/kindeditor.js +1 -0
- data/app/controllers/kindeditor/assets_controller.rb +37 -0
- data/config/routes.rb +5 -0
- data/lib/generators/rails_kindeditor/install/USAGE +10 -0
- data/lib/generators/rails_kindeditor/install/install_generator.rb +23 -0
- data/lib/generators/rails_kindeditor/install/templates/application.js +17 -0
- data/lib/generators/rails_kindeditor/install/templates/rails_kindeditor.rb +19 -0
- data/lib/generators/rails_kindeditor/migration/USAGE +14 -0
- data/lib/generators/rails_kindeditor/migration/migration_generator.rb +33 -0
- data/lib/generators/rails_kindeditor/migration/templates/migration/migration.rb +16 -0
- data/lib/generators/rails_kindeditor/migration/templates/models/active_record/kindeditor/asset.rb +13 -0
- data/lib/generators/rails_kindeditor/migration/templates/models/active_record/kindeditor/file.rb +3 -0
- data/lib/generators/rails_kindeditor/migration/templates/models/active_record/kindeditor/flash.rb +3 -0
- data/lib/generators/rails_kindeditor/migration/templates/models/active_record/kindeditor/image.rb +3 -0
- data/lib/generators/rails_kindeditor/migration/templates/models/active_record/kindeditor/media.rb +3 -0
- data/lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/asset.rb +22 -0
- data/lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/file.rb +3 -0
- data/lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/flash.rb +3 -0
- data/lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/image.rb +3 -0
- data/lib/generators/rails_kindeditor/migration/templates/models/mongoid/kindeditor/media.rb +3 -0
- data/lib/rails_kindeditor/engine.rb +25 -0
- data/lib/rails_kindeditor/formtastic.rb +12 -0
- data/lib/rails_kindeditor/helper.rb +50 -0
- data/lib/rails_kindeditor/simple_form.rb +11 -0
- data/lib/rails_kindeditor/version.rb +4 -0
- data/lib/rails_kindeditor.rb +52 -0
- data/rails_kindeditor.gemspec +19 -0
- data/screenshots/rails_kindeditor.png +0 -0
- data/screenshots/simple_mode.png +0 -0
- data/vendor/assets/javascripts/kindeditor/kindeditor.js +5871 -0
- data/vendor/assets/javascripts/kindeditor/lang/ar.js +232 -0
- data/vendor/assets/javascripts/kindeditor/lang/en.js +231 -0
- data/vendor/assets/javascripts/kindeditor/lang/zh_CN.js +235 -0
- data/vendor/assets/javascripts/kindeditor/lang/zh_TW.js +234 -0
- data/vendor/assets/javascripts/kindeditor/plugins/anchor/anchor.js +46 -0
- data/vendor/assets/javascripts/kindeditor/plugins/autoheight/autoheight.js +27 -0
- data/vendor/assets/javascripts/kindeditor/plugins/baidumap/baidumap.js +93 -0
- data/vendor/assets/javascripts/kindeditor/plugins/baidumap/index.html +83 -0
- data/vendor/assets/javascripts/kindeditor/plugins/baidumap/map.html +43 -0
- data/vendor/assets/javascripts/kindeditor/plugins/clearhtml/clearhtml.js +29 -0
- data/vendor/assets/javascripts/kindeditor/plugins/code/code.js +57 -0
- data/vendor/assets/javascripts/kindeditor/plugins/code/prettify.css +13 -0
- data/vendor/assets/javascripts/kindeditor/plugins/code/prettify.js +28 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/emoticons.js +129 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/0.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/1.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/10.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/100.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/101.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/102.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/103.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/104.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/105.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/106.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/107.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/108.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/109.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/11.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/110.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/111.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/112.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/113.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/114.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/115.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/116.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/117.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/118.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/119.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/12.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/120.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/121.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/122.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/123.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/124.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/125.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/126.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/127.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/128.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/129.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/13.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/130.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/131.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/132.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/133.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/134.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/14.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/15.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/16.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/17.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/18.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/19.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/2.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/20.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/21.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/22.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/23.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/24.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/25.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/26.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/27.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/28.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/29.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/3.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/30.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/31.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/32.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/33.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/34.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/35.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/36.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/37.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/38.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/39.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/4.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/40.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/41.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/42.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/43.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/44.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/45.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/46.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/47.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/48.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/49.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/5.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/50.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/51.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/52.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/53.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/54.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/55.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/56.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/57.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/58.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/59.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/6.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/60.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/61.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/62.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/63.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/64.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/65.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/66.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/67.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/68.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/69.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/7.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/70.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/71.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/72.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/73.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/74.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/75.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/76.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/77.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/78.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/79.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/8.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/80.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/81.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/82.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/83.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/84.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/85.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/86.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/87.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/88.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/89.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/9.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/90.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/91.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/92.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/93.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/94.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/95.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/96.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/97.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/98.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/99.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/emoticons/images/static.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/filemanager/filemanager.js +189 -0
- data/vendor/assets/javascripts/kindeditor/plugins/filemanager/images/file-16.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/filemanager/images/file-64.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/filemanager/images/folder-16.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/filemanager/images/folder-64.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/filemanager/images/go-up.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/flash/flash.js +159 -0
- data/vendor/assets/javascripts/kindeditor/plugins/image/image.js +315 -0
- data/vendor/assets/javascripts/kindeditor/plugins/image/images/align_left.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/image/images/align_right.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/image/images/align_top.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/image/images/refresh.png +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/insertfile/insertfile.js +138 -0
- data/vendor/assets/javascripts/kindeditor/plugins/lineheight/lineheight.js +38 -0
- data/vendor/assets/javascripts/kindeditor/plugins/link/link.js +66 -0
- data/vendor/assets/javascripts/kindeditor/plugins/map/map.html +57 -0
- data/vendor/assets/javascripts/kindeditor/plugins/map/map.js +137 -0
- data/vendor/assets/javascripts/kindeditor/plugins/media/media.js +168 -0
- data/vendor/assets/javascripts/kindeditor/plugins/multiimage/images/image.png +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/multiimage/images/select-files-en.png +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/multiimage/images/select-files-zh_CN.png +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/multiimage/images/swfupload.swf +0 -0
- data/vendor/assets/javascripts/kindeditor/plugins/multiimage/multiimage.js +1385 -0
- data/vendor/assets/javascripts/kindeditor/plugins/pagebreak/pagebreak.js +29 -0
- data/vendor/assets/javascripts/kindeditor/plugins/plainpaste/plainpaste.js +41 -0
- data/vendor/assets/javascripts/kindeditor/plugins/preview/preview.js +31 -0
- data/vendor/assets/javascripts/kindeditor/plugins/quickformat/quickformat.js +81 -0
- data/vendor/assets/javascripts/kindeditor/plugins/table/table.js +705 -0
- data/vendor/assets/javascripts/kindeditor/plugins/template/html/1.html +14 -0
- data/vendor/assets/javascripts/kindeditor/plugins/template/html/2.html +42 -0
- data/vendor/assets/javascripts/kindeditor/plugins/template/html/3.html +36 -0
- data/vendor/assets/javascripts/kindeditor/plugins/template/template.js +58 -0
- data/vendor/assets/javascripts/kindeditor/plugins/wordpaste/wordpaste.js +51 -0
- data/vendor/assets/javascripts/kindeditor/themes/common/anchor.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/themes/common/blank.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/themes/common/flash.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/themes/common/loading.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/themes/common/media.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/themes/common/rm.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/themes/default/background.png +0 -0
- data/vendor/assets/javascripts/kindeditor/themes/default/default.css +1148 -0
- data/vendor/assets/javascripts/kindeditor/themes/default/default.png +0 -0
- data/vendor/assets/javascripts/kindeditor/themes/qq/editor.gif +0 -0
- data/vendor/assets/javascripts/kindeditor/themes/qq/qq.css +143 -0
- data/vendor/assets/javascripts/kindeditor/themes/simple/simple.css +100 -0
- metadata +274 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,234 @@
|
|
1
|
+
对rails_kindeditor的简单粗暴的修改,将后台存储改file为qiniu。
|
2
|
+
|
3
|
+
### Run install generator:
|
4
|
+
|
5
|
+
```bash
|
6
|
+
rails generate rails_kindeditor:install
|
7
|
+
```
|
8
|
+
|
9
|
+
### Usage:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
1. <%= kindeditor_tag :content, 'default content value' %>
|
13
|
+
# or <%= kindeditor_tag :content, 'default content value', :width => 800, :height => 300 %>
|
14
|
+
# or <%= kindeditor_tag :content, 'default content value', :allowFileManager => false %>
|
15
|
+
```
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
2. <%= form_for @article do |f| -%>
|
19
|
+
...
|
20
|
+
<%= f.kindeditor :content %>
|
21
|
+
# or <%= f.kindeditor :content, :width => 800, :height => 300 %>
|
22
|
+
# or <%= f.kindeditor :content, :allowFileManager => false %>
|
23
|
+
...
|
24
|
+
<% end -%>
|
25
|
+
```
|
26
|
+
You can use kindeditor's initial parameters as usual, please visit http://www.kindsoft.net/docs/option.html for details.
|
27
|
+
|
28
|
+
additionally, rails_kindeditor provides one "simple_mode" parameter for render simple mode quickly.
|
29
|
+
|
30
|
+
<img src="https://github.com/Macrow/rails_kindeditor/raw/master/screenshots/simple_mode.png" alt="simple mode">
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
kindeditor_tag :content, 'default content value', :simple_mode => true
|
34
|
+
f.kindeditor_tag :content, :simple_mode => true
|
35
|
+
f.input :content, :as => :kindeditor, :input_html => { :simple_mode => true } # simple_form & formtastic
|
36
|
+
```
|
37
|
+
|
38
|
+
That's all.
|
39
|
+
|
40
|
+
## SimpleForm and Formtastic integration
|
41
|
+
|
42
|
+
### simple_form:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
<%= form.input :content, :as => :kindeditor %>
|
46
|
+
# or
|
47
|
+
<%= form.input :content, :as => :kindeditor, :label => false, :input_html => { :width => 800, :height => 300 } %>
|
48
|
+
```
|
49
|
+
|
50
|
+
### formtastic:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
<%= form.input :content, :as => :kindeditor %>
|
54
|
+
# or
|
55
|
+
<%= form.input :content, :as => :kindeditor, :input_html => { :height => 300 } %>
|
56
|
+
```
|
57
|
+
|
58
|
+
## Upload options configuration
|
59
|
+
|
60
|
+
When you run "rails generate rails_kindeditor:install", installer will copy configuration files in config/initializers folder.
|
61
|
+
You can customize some option for uploading.
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
# Specify the subfolders in public directory.
|
65
|
+
# You can customize it , eg: config.upload_dir = 'this/is/my/folder'
|
66
|
+
config.upload_dir = 'uploads'
|
67
|
+
|
68
|
+
# Allowed file types for upload.
|
69
|
+
config.upload_image_ext = %w[gif jpg jpeg png bmp]
|
70
|
+
config.upload_flash_ext = %w[swf flv]
|
71
|
+
config.upload_media_ext = %w[swf flv mp3 wav wma wmv mid avi mpg asf rm rmvb]
|
72
|
+
config.upload_file_ext = %w[doc docx xls xlsx ppt htm html txt zip rar gz bz2]
|
73
|
+
|
74
|
+
# Porcess upload image size, need mini_magick
|
75
|
+
# before => after
|
76
|
+
# eg: 1600x1600 => 800x800
|
77
|
+
# 1600x800 => 800x400
|
78
|
+
# 400x400 => 400x400 # No Change
|
79
|
+
# config.image_resize_to_limit = [800, 800]
|
80
|
+
```
|
81
|
+
|
82
|
+
## Save upload file information into database(optional)
|
83
|
+
|
84
|
+
rails_kindeditor can save upload file information into database.
|
85
|
+
|
86
|
+
### Just run migration generate, there are two ORM options for you: 1.active_record 2.mongoid, default is active_record.
|
87
|
+
|
88
|
+
```bash
|
89
|
+
rails generate rails_kindeditor:migration
|
90
|
+
or
|
91
|
+
rails generate rails_kindeditor:migration -o mongoid
|
92
|
+
```
|
93
|
+
|
94
|
+
### The generator will copy model and migration to your application. When you are done, remember run rake db:migrate:
|
95
|
+
|
96
|
+
```bash
|
97
|
+
rake db:migrate
|
98
|
+
```
|
99
|
+
|
100
|
+
### If you're using mongoid, please add 'gem "carrierwave-mongoid"' in your Gemfile
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
gem 'carrierwave-mongoid'
|
104
|
+
```
|
105
|
+
|
106
|
+
## License
|
107
|
+
|
108
|
+
MIT License.
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
# Kindeditor for Ruby on Rails 中文文档
|
113
|
+
|
114
|
+
Kindeditor是国产的所见即所得javascript富文本编辑器, 访问 http://www.kindsoft.net 获取更多信息.
|
115
|
+
rails_kindeditor可以帮助你的rails程序集成kindeditor,包括了图片和附件上传功能,文件按照类型、日期进行存储。
|
116
|
+
|
117
|
+
注意: rails_kindeditor ~> v0.3.0 仅支持Rails3.1+!当然,包括Rails3.1和Rails3.2.
|
118
|
+
如果你使用rails3.0.x,请使用rails_kindeditor v0.2.8
|
119
|
+
|
120
|
+
## 安装及使用
|
121
|
+
|
122
|
+
### 将下面代码加入Gemfile:
|
123
|
+
|
124
|
+
```ruby
|
125
|
+
gem 'rails_kindeditor', '~> 0.3.11'
|
126
|
+
```
|
127
|
+
|
128
|
+
### 运行"bundle"命令:
|
129
|
+
|
130
|
+
```bash
|
131
|
+
bundle
|
132
|
+
```
|
133
|
+
|
134
|
+
### 安装Kindeditor,运行下面的代码:
|
135
|
+
|
136
|
+
```bash
|
137
|
+
rails generate rails_kindeditor:install
|
138
|
+
```
|
139
|
+
|
140
|
+
### 使用方法:
|
141
|
+
|
142
|
+
```ruby
|
143
|
+
1. <%= kindeditor_tag :content, 'default content value' %>
|
144
|
+
# or <%= kindeditor_tag :content, 'default content value', :width => 800, :height => 300 %>
|
145
|
+
# or <%= kindeditor_tag :content, 'default content value', :allowFileManager => false %>
|
146
|
+
```
|
147
|
+
|
148
|
+
```ruby
|
149
|
+
2. <%= form_for @article do |f| -%>
|
150
|
+
...
|
151
|
+
<%= f.kindeditor :content %>
|
152
|
+
# or <%= f.kindeditor :content, :width => 800, :height => 300 %>
|
153
|
+
# or <%= f.kindeditor :content, :allowFileManager => false %>
|
154
|
+
...
|
155
|
+
<% end -%>
|
156
|
+
```
|
157
|
+
你可以像往常那样使用kindeditor自身的初始化参数,请访问 http://www.kindsoft.net/docs/option.html 查看更多参数。
|
158
|
+
|
159
|
+
另外,rails_kindeditor还额外提供一个"simple_mode"参数,以便快捷使用简单模式的kindeditor。
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
kindeditor_tag :content, 'default content value', :simple_mode => true
|
163
|
+
f.kindeditor_tag :content, :simple_mode => true
|
164
|
+
f.input :content, :as => :kindeditor, :input_html => { :simple_mode => true } # simple_form & formtastic
|
165
|
+
```
|
166
|
+
|
167
|
+
完毕!
|
168
|
+
|
169
|
+
## SimpleForm与Formtastic集成:
|
170
|
+
|
171
|
+
### simple_form:
|
172
|
+
|
173
|
+
```ruby
|
174
|
+
<%= form.input :content, :as => :kindeditor, :label => false, :input_html => { :width => 800, :height => 300 } %>
|
175
|
+
```
|
176
|
+
|
177
|
+
### formtastic:
|
178
|
+
|
179
|
+
```ruby
|
180
|
+
<%= form.input :content, :as => :kindeditor %>
|
181
|
+
<%= form.input :content, :as => :kindeditor, :input_html => { :height => 300 } %>
|
182
|
+
```
|
183
|
+
|
184
|
+
## 上传图片及文件配置
|
185
|
+
|
186
|
+
当你运行"rails generate rails_kindeditor:install"的时候,安装器会将配置文件拷贝到config/initializers文件夹。
|
187
|
+
你可以配置以下上传选项:
|
188
|
+
|
189
|
+
```ruby
|
190
|
+
# 指定上传目录,目录可以指定多级,都存储在public目录下.
|
191
|
+
# You can customize it , eg: config.upload_dir = 'this/is/my/folder'
|
192
|
+
config.upload_dir = 'uploads'
|
193
|
+
|
194
|
+
# 指定允许上传的文件类型.
|
195
|
+
config.upload_image_ext = %w[gif jpg jpeg png bmp]
|
196
|
+
config.upload_flash_ext = %w[swf flv]
|
197
|
+
config.upload_media_ext = %w[swf flv mp3 wav wma wmv mid avi mpg asf rm rmvb]
|
198
|
+
config.upload_file_ext = %w[doc docx xls xlsx ppt htm html txt zip rar gz bz2]
|
199
|
+
|
200
|
+
# 处理上传文件,需要mini_magick
|
201
|
+
# 处理以前 => 处理以后
|
202
|
+
# eg: 1600x1600 => 800x800
|
203
|
+
# 1600x800 => 800x400
|
204
|
+
# 400x400 => 400x400 # 图片小于该限制尺寸则不作处理
|
205
|
+
# config.image_resize_to_limit = [800, 800]
|
206
|
+
```
|
207
|
+
|
208
|
+
## 将上传文件信息记录入数据库(可选)
|
209
|
+
|
210
|
+
rails_kindeditor 可以将上传文件信息记录入数据库,以便扩展应用.
|
211
|
+
|
212
|
+
### 运行下面的代码,有两项选项:1.active_record 2.mongoid,默认是active_record。
|
213
|
+
|
214
|
+
```bash
|
215
|
+
rails generate rails_kindeditor:migration
|
216
|
+
or
|
217
|
+
rails generate rails_kindeditor:migration -o mongoid
|
218
|
+
```
|
219
|
+
|
220
|
+
### 运行下面的代码:
|
221
|
+
|
222
|
+
```bash
|
223
|
+
rake db:migrate
|
224
|
+
```
|
225
|
+
|
226
|
+
### 如果你使用的是mongoid, 请在你的Gemfile里加入'gem "carrierwave-mongoid"'
|
227
|
+
|
228
|
+
```ruby
|
229
|
+
gem 'carrierwave-mongoid'
|
230
|
+
```
|
231
|
+
|
232
|
+
## License
|
233
|
+
|
234
|
+
MIT License.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
//= require kindeditor/kindeditor.js
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
class Kindeditor::AssetsController < ApplicationController
|
3
|
+
skip_before_filter :verify_authenticity_token
|
4
|
+
|
5
|
+
def create
|
6
|
+
@img_file = params[:imgFile]
|
7
|
+
upload_token = generate_upload_token
|
8
|
+
key = generate_key
|
9
|
+
response = Qiniu::RS.upload_file \
|
10
|
+
uptoken: upload_token,
|
11
|
+
file: @img_file.tempfile.path,
|
12
|
+
bucket: "testimages",
|
13
|
+
key: key,
|
14
|
+
note: "rails kindeditor"
|
15
|
+
|
16
|
+
Kindeditor::Asset.create \
|
17
|
+
asset: key,
|
18
|
+
file_name: @img_file.original_filename,
|
19
|
+
file_type: @img_file.content_type,
|
20
|
+
file_size: @img_file.size
|
21
|
+
p response # should be checked for error handle
|
22
|
+
render :text => ({:error => 0, :url => "http://testimages.qiniudn.com/#{key}"}.to_json)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def generate_upload_token
|
27
|
+
Qiniu::RS.generate_upload_token \
|
28
|
+
scope: "testimages",
|
29
|
+
customer: "as181920"
|
30
|
+
end
|
31
|
+
|
32
|
+
def generate_key
|
33
|
+
SecureRandom.uuid
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
data/config/routes.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module RailsKindeditor
|
2
|
+
class InstallGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
desc "Install kindeditor for your application."
|
5
|
+
|
6
|
+
def copy_kindeditor_files
|
7
|
+
if ::Rails.version < "3.1.0"
|
8
|
+
warn "Warning: rails_kindeditor ~> v0.3.0 only support Rails3.1+!"
|
9
|
+
warn "If you're using rails3.0.x, please check rails_kindeditor v0.2.8"
|
10
|
+
else
|
11
|
+
template "rails_kindeditor.rb", "config/initializers/rails_kindeditor.rb"
|
12
|
+
end
|
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
|
22
|
+
end
|
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
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
RailsKindeditor.setup do |config|
|
2
|
+
|
3
|
+
# Specify the subfolders in public directory.
|
4
|
+
# You can customize it , eg: config.upload_dir = 'this/is/my/folder'
|
5
|
+
config.upload_dir = 'uploads'
|
6
|
+
|
7
|
+
# Allowed file types for upload.
|
8
|
+
config.upload_image_ext = %w[gif jpg jpeg png bmp]
|
9
|
+
config.upload_flash_ext = %w[swf flv]
|
10
|
+
config.upload_media_ext = %w[swf flv mp3 wav wma wmv mid avi mpg asf rm rmvb]
|
11
|
+
config.upload_file_ext = %w[doc docx xls xlsx ppt htm html txt zip rar gz bz2]
|
12
|
+
|
13
|
+
# Porcess upload image size
|
14
|
+
# eg: 1600x1600 => 800x800
|
15
|
+
# 1600x800 => 800x400
|
16
|
+
# 400x400 => 400x400 # No Change
|
17
|
+
# config.image_resize_to_limit = [800, 800]
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Description:
|
2
|
+
Copy model, migration and uploader to your application.
|
3
|
+
|
4
|
+
Example:
|
5
|
+
rails generate rails_kindeditor:migration
|
6
|
+
|
7
|
+
This will create:
|
8
|
+
app/models/kindeditor/asset.rb
|
9
|
+
app/models/kindeditor/file.rb
|
10
|
+
app/models/kindeditor/flash.rb
|
11
|
+
app/models/kindeditor/image.rb
|
12
|
+
app/models/kindeditor/media.rb
|
13
|
+
db/migrate/xxxxxxxxx_create_kindeditor_assets.rb
|
14
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module RailsKindeditor
|
2
|
+
class MigrationGenerator < Rails::Generators::Base
|
3
|
+
include Rails::Generators::Migration
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
desc "Copy model and migration to your application."
|
6
|
+
class_option :orm, :type => :string, :aliases => "-o", :default => "active_record", :desc => "ORM options: active_record or mongoid"
|
7
|
+
|
8
|
+
def copy_files
|
9
|
+
orm = options[:orm].to_s
|
10
|
+
orm = "active_record" unless %w{active_record mongoid}.include?(orm)
|
11
|
+
%w(asset file flash image media).each do |file|
|
12
|
+
copy_model(orm, file)
|
13
|
+
end
|
14
|
+
if orm == "active_record"
|
15
|
+
migration_template "migration/migration.rb", "db/migrate/create_kindeditor_assets.rb"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.next_migration_number(dirname)
|
20
|
+
if ActiveRecord::Base.timestamped_migrations
|
21
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
22
|
+
else
|
23
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def copy_model(orm, name)
|
29
|
+
template "models/#{orm}/kindeditor/#{name}.rb", "app/models/kindeditor/#{name}.rb"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateKindeditorAssets < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :kindeditor_assets do |t|
|
4
|
+
t.string :asset
|
5
|
+
t.string :file_name
|
6
|
+
t.integer :file_size
|
7
|
+
t.string :file_type
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.down
|
13
|
+
drop_table :kindeditor_assets
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
data/lib/generators/rails_kindeditor/migration/templates/models/active_record/kindeditor/asset.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
class Kindeditor::Asset < ActiveRecord::Base
|
2
|
+
self.table_name = 'kindeditor_assets'
|
3
|
+
attr_accessible :asset, :file_name, :file_type, :file_size
|
4
|
+
#mount_uploader :asset, AssetUploader
|
5
|
+
#validates_presence_of :asset
|
6
|
+
#before_save :update_asset_attributes
|
7
|
+
#
|
8
|
+
#private
|
9
|
+
#def update_asset_attributes
|
10
|
+
# self.file_size = asset.file.size
|
11
|
+
# self.file_type = asset.file.content_type
|
12
|
+
#end
|
13
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'carrierwave/mongoid'
|
2
|
+
|
3
|
+
class Kindeditor::Asset
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Timestamps
|
6
|
+
mount_uploader :asset, AssetUploader
|
7
|
+
field :file_size, :type => Integer
|
8
|
+
field :file_type, :type => String
|
9
|
+
validates_presence_of :asset
|
10
|
+
before_save :update_asset_attributes
|
11
|
+
attr_accessible :asset
|
12
|
+
|
13
|
+
def self.collection_name
|
14
|
+
:kindeditor_assets
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
def update_asset_attributes
|
19
|
+
self.file_size = asset.file.size
|
20
|
+
self.file_type = asset.file.content_type
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "rails_kindeditor"
|
2
|
+
require "rails"
|
3
|
+
require "action_controller"
|
4
|
+
|
5
|
+
module RailsKindeditor
|
6
|
+
class Engine < Rails::Engine
|
7
|
+
|
8
|
+
initializer "rails_kindeditor.assets_precompile" do |app|
|
9
|
+
app.config.assets.precompile += RailsKindeditor.assets
|
10
|
+
end
|
11
|
+
|
12
|
+
initializer "rails_kindeditor.simple_form_and_formtastic" do
|
13
|
+
require "rails_kindeditor/simple_form" if Object.const_defined?("SimpleForm")
|
14
|
+
require "rails_kindeditor/formtastic" if Object.const_defined?("Formtastic")
|
15
|
+
end
|
16
|
+
|
17
|
+
initializer "rails_kindeditor.helper_and_builder" do
|
18
|
+
ActiveSupport.on_load :action_view do
|
19
|
+
ActionView::Base.send(:include, RailsKindeditor::Helper)
|
20
|
+
ActionView::Helpers::FormBuilder.send(:include, RailsKindeditor::Builder)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module RailsKindeditor
|
2
|
+
module Helper
|
3
|
+
def kindeditor_tag(name, content = nil, options = {})
|
4
|
+
id = sanitize_to_id(name)
|
5
|
+
input_html = { :id => id }.merge(options.delete(:input_html) || {})
|
6
|
+
output = ActiveSupport::SafeBuffer.new
|
7
|
+
output << text_area_tag(name, content, input_html)
|
8
|
+
output << javascript_tag(js_replace(id, options))
|
9
|
+
end
|
10
|
+
|
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)
|
16
|
+
output_buffer = ActiveSupport::SafeBuffer.new
|
17
|
+
output_buffer << instance_tag.to_text_area_tag(input_html)
|
18
|
+
js = js_replace(hash['id'], options)
|
19
|
+
output_buffer << javascript_tag(js)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
def js_replace(dom_id, options = {})
|
24
|
+
"KindEditor.ready(function(K){
|
25
|
+
K.create('##{dom_id}', #{get_options(options).to_json});
|
26
|
+
});"
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_options(options)
|
30
|
+
options.delete(:uploadJson)
|
31
|
+
options.delete(:fileManagerJson)
|
32
|
+
options.reverse_merge!(:width => '100%')
|
33
|
+
options.reverse_merge!(:height => 300)
|
34
|
+
options.reverse_merge!(:allowFileManager => true)
|
35
|
+
options.merge!(:uploadJson => '/kindeditor/upload')
|
36
|
+
options.merge!(:fileManagerJson => '/kindeditor/filemanager')
|
37
|
+
if options[:simple_mode] == true
|
38
|
+
options.delete(:simple_mode)
|
39
|
+
options.merge!(:items => %w{fontname fontsize | forecolor hilitecolor bold italic underline removeformat | justifyleft justifycenter justifyright insertorderedlist insertunorderedlist | emoticons image link})
|
40
|
+
end
|
41
|
+
options
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
module Builder
|
46
|
+
def kindeditor(method, options = {})
|
47
|
+
@template.send("kindeditor", @object_name, method, objectify_options(options))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module RailsKindeditor
|
2
|
+
module SimpleForm
|
3
|
+
class KindeditorInput < ::SimpleForm::Inputs::Base
|
4
|
+
def input
|
5
|
+
@builder.kindeditor(attribute_name, input_html_options)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
::SimpleForm::FormBuilder.map_type :kindeditor, :to => RailsKindeditor::SimpleForm::KindeditorInput
|