loyal_rails_kindeditor 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 +6 -0
- data/README.md +317 -0
- data/Rakefile +2 -0
- data/app/assets/javascripts/kindeditor.js +1 -0
- data/app/controllers/kindeditor/assets_controller.rb +123 -0
- data/app/uploaders/kindeditor/asset_uploader.rb +89 -0
- data/app/uploaders/kindeditor/file_uploader.rb +10 -0
- data/app/uploaders/kindeditor/flash_uploader.rb +10 -0
- data/app/uploaders/kindeditor/image_uploader.rb +10 -0
- data/app/uploaders/kindeditor/media_uploader.rb +10 -0
- data/config/routes.rb +6 -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 +36 -0
- data/lib/generators/rails_kindeditor/migration/templates/migration/migration.rb +15 -0
- data/lib/generators/rails_kindeditor/migration/templates/models/active_record/kindeditor/asset.rb +12 -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 +21 -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 +34 -0
- data/lib/rails_kindeditor/formtastic.rb +12 -0
- data/lib/rails_kindeditor/helper.rb +70 -0
- data/lib/rails_kindeditor/simple_form.rb +11 -0
- data/lib/rails_kindeditor/version.rb +4 -0
- data/lib/rails_kindeditor.rb +54 -0
- data/lib/tasks/assets.rake +9 -0
- data/rails_kindeditor.gemspec +23 -0
- data/screenshots/rails_kindeditor.png +0 -0
- data/screenshots/simple_mode.png +0 -0
- data/vendor/assets/javascripts/kindeditor/kindeditor.js +5827 -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/ko.js +237 -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 +190 -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 +160 -0
- data/vendor/assets/javascripts/kindeditor/plugins/image/image.js +316 -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 +139 -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 +169 -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 +314 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,317 @@
|
|
1
|
+
# Kindeditor for Ruby on Rails
|
2
|
+
|
3
|
+
Kindeditor is a WYSIWYG javascript editor, visit http://www.kindsoft.net for details.
|
4
|
+
rails_kindeditor will helps your rails app integrate with kindeditor, includes images and files uploading.
|
5
|
+
|
6
|
+
<img src="https://github.com/Macrow/rails_kindeditor/raw/master/screenshots/rails_kindeditor.png" alt="rails_indeditor">
|
7
|
+
|
8
|
+
## Installation and usage
|
9
|
+
|
10
|
+
### Add this to your Gemfile
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'rails_kindeditor', '~> 0.3.19'
|
14
|
+
```
|
15
|
+
|
16
|
+
### Run "bundle" command.
|
17
|
+
|
18
|
+
```bash
|
19
|
+
bundle
|
20
|
+
```
|
21
|
+
|
22
|
+
### Run install generator:
|
23
|
+
|
24
|
+
```bash
|
25
|
+
rails generate rails_kindeditor:install
|
26
|
+
```
|
27
|
+
|
28
|
+
### Rails4 in production mode
|
29
|
+
|
30
|
+
In Rails 4.0, precompiling assets no longer automatically copies non-JS/CSS assets from vendor/assets and lib/assets. see https://github.com/rails/rails/pull/7968
|
31
|
+
In Rails 4.0's production mode, please run 'rake kindeditor:assets', this method just copy kindeditor into public folder.
|
32
|
+
|
33
|
+
```bash
|
34
|
+
rake kindeditor:assets
|
35
|
+
```
|
36
|
+
|
37
|
+
### Usage:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
1. <%= kindeditor_tag :content, 'default content value' %>
|
41
|
+
# or <%= kindeditor_tag :content, 'default content value', :width => 800, :height => 300 %>
|
42
|
+
# or <%= kindeditor_tag :content, 'default content value', :allowFileManager => false %>
|
43
|
+
```
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
2. <%= form_for @article do |f| %>
|
47
|
+
...
|
48
|
+
<%= f.kindeditor :content %>
|
49
|
+
# or <%= f.kindeditor :content, :width => 800, :height => 300 %>
|
50
|
+
# or <%= f.kindeditor :content, :allowFileManager => false %>
|
51
|
+
...
|
52
|
+
<% end %>
|
53
|
+
```
|
54
|
+
You can use kindeditor's initial parameters as usual, please visit http://www.kindsoft.net/docs/option.html for details.
|
55
|
+
|
56
|
+
additionally, rails_kindeditor provides one "simple_mode" parameter for render simple mode quickly.
|
57
|
+
|
58
|
+
<img src="https://github.com/Macrow/rails_kindeditor/raw/master/screenshots/simple_mode.png" alt="simple mode">
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
kindeditor_tag :content, 'default content value', :simple_mode => true
|
62
|
+
f.kindeditor_tag :content, :simple_mode => true
|
63
|
+
f.input :content, :as => :kindeditor, :input_html => { :simple_mode => true } # simple_form & formtastic
|
64
|
+
```
|
65
|
+
|
66
|
+
That's all.
|
67
|
+
|
68
|
+
### Include javascript files at bottom ? Not in the head tag ? How can I load kindeditor correctly ?
|
69
|
+
|
70
|
+
For some reasons, you includes javascript files at bottom in your template, rails_kindeditor provides a options for lazyload:
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
<%= f.kindeditor :content, :window_onload => true %>
|
74
|
+
```
|
75
|
+
|
76
|
+
Warning: Kindeditor will load after all the objects loaded.
|
77
|
+
|
78
|
+
## SimpleForm and Formtastic integration
|
79
|
+
|
80
|
+
### simple_form:
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
<%= form.input :content, :as => :kindeditor %>
|
84
|
+
# or
|
85
|
+
<%= form.input :content, :as => :kindeditor, :label => false, :input_html => { :width => 800, :height => 300 } %>
|
86
|
+
```
|
87
|
+
|
88
|
+
### formtastic:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
<%= form.input :content, :as => :kindeditor %>
|
92
|
+
# or
|
93
|
+
<%= form.input :content, :as => :kindeditor, :input_html => { :height => 300 } %>
|
94
|
+
```
|
95
|
+
|
96
|
+
## How to get kindeditor's content
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
<%= form_for @article do |f| %>
|
100
|
+
<%= f.kindeditor :content, :editor_id => 'my_editor' %>
|
101
|
+
<% end %>
|
102
|
+
```
|
103
|
+
|
104
|
+
You can get content like this:
|
105
|
+
|
106
|
+
```javascript
|
107
|
+
// Javascript code
|
108
|
+
my_editor.html();
|
109
|
+
```
|
110
|
+
|
111
|
+
## Upload options configuration
|
112
|
+
|
113
|
+
When you run "rails generate rails_kindeditor:install", installer will copy configuration files in config/initializers folder.
|
114
|
+
You can customize some option for uploading.
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
# Specify the subfolders in public directory.
|
118
|
+
# You can customize it , eg: config.upload_dir = 'this/is/my/folder'
|
119
|
+
config.upload_dir = 'uploads'
|
120
|
+
|
121
|
+
# Allowed file types for upload.
|
122
|
+
config.upload_image_ext = %w[gif jpg jpeg png bmp]
|
123
|
+
config.upload_flash_ext = %w[swf flv]
|
124
|
+
config.upload_media_ext = %w[swf flv mp3 wav wma wmv mid avi mpg asf rm rmvb]
|
125
|
+
config.upload_file_ext = %w[doc docx xls xlsx ppt htm html txt zip rar gz bz2]
|
126
|
+
|
127
|
+
# Porcess upload image size, need mini_magick
|
128
|
+
# before => after
|
129
|
+
# eg: 1600x1600 => 800x800
|
130
|
+
# 1600x800 => 800x400
|
131
|
+
# 400x400 => 400x400 # No Change
|
132
|
+
# config.image_resize_to_limit = [800, 800]
|
133
|
+
```
|
134
|
+
|
135
|
+
## Save upload file information into database(optional)
|
136
|
+
|
137
|
+
rails_kindeditor can save upload file information into database.
|
138
|
+
|
139
|
+
### Just run migration generate, there are two ORM options for you: 1.active_record 2.mongoid, default is active_record.
|
140
|
+
|
141
|
+
```bash
|
142
|
+
rails generate rails_kindeditor:migration
|
143
|
+
or
|
144
|
+
rails generate rails_kindeditor:migration -o mongoid
|
145
|
+
```
|
146
|
+
|
147
|
+
### The generator will copy model and migration to your application. When you are done, remember run rake db:migrate:
|
148
|
+
|
149
|
+
```bash
|
150
|
+
rake db:migrate
|
151
|
+
```
|
152
|
+
|
153
|
+
### If you're using mongoid, please add 'gem "carrierwave-mongoid"' in your Gemfile
|
154
|
+
|
155
|
+
```ruby
|
156
|
+
gem 'carrierwave-mongoid'
|
157
|
+
```
|
158
|
+
|
159
|
+
## License
|
160
|
+
|
161
|
+
MIT License.
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
# Kindeditor for Ruby on Rails 中文文档
|
166
|
+
|
167
|
+
Kindeditor是国产的所见即所得javascript富文本编辑器, 访问 http://www.kindsoft.net 获取更多信息.
|
168
|
+
rails_kindeditor可以帮助你的rails程序集成kindeditor,包括了图片和附件上传功能,文件按照类型、日期进行存储。
|
169
|
+
|
170
|
+
## 安装及使用
|
171
|
+
|
172
|
+
### 将下面代码加入Gemfile:
|
173
|
+
|
174
|
+
```ruby
|
175
|
+
gem 'rails_kindeditor', '~> 0.3.19'
|
176
|
+
```
|
177
|
+
|
178
|
+
### 运行"bundle"命令:
|
179
|
+
|
180
|
+
```bash
|
181
|
+
bundle
|
182
|
+
```
|
183
|
+
|
184
|
+
### 安装Kindeditor,运行下面的代码:
|
185
|
+
|
186
|
+
```bash
|
187
|
+
rails generate rails_kindeditor:install
|
188
|
+
```
|
189
|
+
|
190
|
+
### Rails4 in production mode
|
191
|
+
|
192
|
+
从Rails 4.0开始, precompiling assets不再自动从vendor/assets和lib/assets拷贝非JS/CSS文件. 参见 https://github.com/rails/rails/pull/7968
|
193
|
+
如果要使用Rails 4.0的生产模式,请运行'rake kindeditor:assets', 此方法可将kindeditor自动拷贝到你的public/assets目录.
|
194
|
+
|
195
|
+
```bash
|
196
|
+
rake kindeditor:assets
|
197
|
+
```
|
198
|
+
|
199
|
+
### 使用方法:
|
200
|
+
|
201
|
+
```ruby
|
202
|
+
1. <%= kindeditor_tag :content, 'default content value' %>
|
203
|
+
# or <%= kindeditor_tag :content, 'default content value', :width => 800, :height => 300 %>
|
204
|
+
# or <%= kindeditor_tag :content, 'default content value', :allowFileManager => false %>
|
205
|
+
```
|
206
|
+
|
207
|
+
```ruby
|
208
|
+
2. <%= form_for @article do |f| -%>
|
209
|
+
...
|
210
|
+
<%= f.kindeditor :content %>
|
211
|
+
# or <%= f.kindeditor :content, :width => 800, :height => 300 %>
|
212
|
+
# or <%= f.kindeditor :content, :allowFileManager => false %>
|
213
|
+
...
|
214
|
+
<% end -%>
|
215
|
+
```
|
216
|
+
你可以像往常那样使用kindeditor自身的初始化参数,请访问 http://www.kindsoft.net/docs/option.html 查看更多参数。
|
217
|
+
|
218
|
+
另外,rails_kindeditor还额外提供一个"simple_mode"参数,以便快捷使用简单模式的kindeditor。
|
219
|
+
|
220
|
+
```ruby
|
221
|
+
kindeditor_tag :content, 'default content value', :simple_mode => true
|
222
|
+
f.kindeditor_tag :content, :simple_mode => true
|
223
|
+
f.input :content, :as => :kindeditor, :input_html => { :simple_mode => true } # simple_form & formtastic
|
224
|
+
```
|
225
|
+
|
226
|
+
完毕!
|
227
|
+
|
228
|
+
### 把javascript放在模板最下方,不放在head里面,如何正确加载kindeditor?
|
229
|
+
|
230
|
+
有时候,为了加快页面载入速度,也许你会把javascript引用放在template的底部,rails_kindeditor提供了一个参数可以确保正常加载:
|
231
|
+
|
232
|
+
```ruby
|
233
|
+
<%= f.kindeditor :content, :window_onload => true %>
|
234
|
+
```
|
235
|
+
|
236
|
+
警告:Kindeditor会在页面所有的内容加载完毕后才进行加载,所以需谨慎使用
|
237
|
+
|
238
|
+
## SimpleForm与Formtastic集成:
|
239
|
+
|
240
|
+
### simple_form:
|
241
|
+
|
242
|
+
```ruby
|
243
|
+
<%= form.input :content, :as => :kindeditor, :label => false, :input_html => { :width => 800, :height => 300 } %>
|
244
|
+
```
|
245
|
+
|
246
|
+
### formtastic:
|
247
|
+
|
248
|
+
```ruby
|
249
|
+
<%= form.input :content, :as => :kindeditor %>
|
250
|
+
<%= form.input :content, :as => :kindeditor, :input_html => { :height => 300 } %>
|
251
|
+
```
|
252
|
+
## 如何获取kindeditor的内容
|
253
|
+
|
254
|
+
```ruby
|
255
|
+
<%= form_for @article do |f| %>
|
256
|
+
<%= f.kindeditor :content, :editor_id => 'my_editor' %>
|
257
|
+
<% end %>
|
258
|
+
```
|
259
|
+
|
260
|
+
可通过下面的Javascript代码获取内容:
|
261
|
+
|
262
|
+
```javascript
|
263
|
+
// Javascript code
|
264
|
+
my_editor.html();
|
265
|
+
```
|
266
|
+
|
267
|
+
## 上传图片及文件配置
|
268
|
+
|
269
|
+
当你运行"rails generate rails_kindeditor:install"的时候,安装器会将配置文件拷贝到config/initializers文件夹。
|
270
|
+
你可以配置以下上传选项:
|
271
|
+
|
272
|
+
```ruby
|
273
|
+
# 指定上传目录,目录可以指定多级,都存储在public目录下.
|
274
|
+
# You can customize it , eg: config.upload_dir = 'this/is/my/folder'
|
275
|
+
config.upload_dir = 'uploads'
|
276
|
+
|
277
|
+
# 指定允许上传的文件类型.
|
278
|
+
config.upload_image_ext = %w[gif jpg jpeg png bmp]
|
279
|
+
config.upload_flash_ext = %w[swf flv]
|
280
|
+
config.upload_media_ext = %w[swf flv mp3 wav wma wmv mid avi mpg asf rm rmvb]
|
281
|
+
config.upload_file_ext = %w[doc docx xls xlsx ppt htm html txt zip rar gz bz2]
|
282
|
+
|
283
|
+
# 处理上传文件,需要mini_magick
|
284
|
+
# 处理以前 => 处理以后
|
285
|
+
# eg: 1600x1600 => 800x800
|
286
|
+
# 1600x800 => 800x400
|
287
|
+
# 400x400 => 400x400 # 图片小于该限制尺寸则不作处理
|
288
|
+
# config.image_resize_to_limit = [800, 800]
|
289
|
+
```
|
290
|
+
|
291
|
+
## 将上传文件信息记录入数据库(可选)
|
292
|
+
|
293
|
+
rails_kindeditor 可以将上传文件信息记录入数据库,以便扩展应用.
|
294
|
+
|
295
|
+
### 运行下面的代码,有两项选项:1.active_record 2.mongoid,默认是active_record。
|
296
|
+
|
297
|
+
```bash
|
298
|
+
rails generate rails_kindeditor:migration
|
299
|
+
or
|
300
|
+
rails generate rails_kindeditor:migration -o mongoid
|
301
|
+
```
|
302
|
+
|
303
|
+
### 运行下面的代码:
|
304
|
+
|
305
|
+
```bash
|
306
|
+
rake db:migrate
|
307
|
+
```
|
308
|
+
|
309
|
+
### 如果你使用的是mongoid, 请在你的Gemfile里加入'gem "carrierwave-mongoid"'
|
310
|
+
|
311
|
+
```ruby
|
312
|
+
gem 'carrierwave-mongoid'
|
313
|
+
```
|
314
|
+
|
315
|
+
## License
|
316
|
+
|
317
|
+
MIT License.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
//= require kindeditor/kindeditor.js
|
@@ -0,0 +1,123 @@
|
|
1
|
+
#coding: utf-8
|
2
|
+
require "find"
|
3
|
+
class Kindeditor::AssetsController < ApplicationController
|
4
|
+
skip_before_filter :verify_authenticity_token
|
5
|
+
def create
|
6
|
+
@imgFile, @dir = params[:imgFile], params[:dir]
|
7
|
+
unless @imgFile.nil?
|
8
|
+
if Kindeditor::AssetUploader.save_upload_info? # save upload info into database
|
9
|
+
begin
|
10
|
+
@asset = "Kindeditor::#{@dir.camelize}".constantize.new(:asset => @imgFile)
|
11
|
+
if @asset.save
|
12
|
+
render :text => ({:error => 0, :url => @asset.asset.url}.to_json)
|
13
|
+
else
|
14
|
+
show_error(@asset.errors.full_messages)
|
15
|
+
end
|
16
|
+
rescue Exception => e
|
17
|
+
show_error(e.to_s)
|
18
|
+
end
|
19
|
+
else # do not touch database
|
20
|
+
begin
|
21
|
+
uploader = "Kindeditor::#{@dir.camelize}Uploader".constantize.new
|
22
|
+
uploader.store!(@imgFile)
|
23
|
+
render :text => ({:error => 0, :url => uploader.url}.to_json)
|
24
|
+
rescue CarrierWave::UploadError => e
|
25
|
+
show_error(e.message)
|
26
|
+
rescue Exception => e
|
27
|
+
show_error(e.to_s)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
else
|
31
|
+
show_error("No File Selected!")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def list
|
36
|
+
@root_path = "#{Rails.public_path}/#{RailsKindeditor.upload_store_dir}/"
|
37
|
+
@root_url = "/#{RailsKindeditor.upload_store_dir}/"
|
38
|
+
@img_ext = Kindeditor::AssetUploader::EXT_NAMES[:image]
|
39
|
+
@dir = params[:dir].strip || ""
|
40
|
+
unless Kindeditor::AssetUploader::EXT_NAMES.keys.map(&:to_s).push("").include?(@dir)
|
41
|
+
render :text => "Invalid Directory name."
|
42
|
+
return
|
43
|
+
end
|
44
|
+
|
45
|
+
Dir.chdir(Rails.public_path)
|
46
|
+
RailsKindeditor.upload_store_dir.split('/').each do |dir|
|
47
|
+
Dir.mkdir(dir) unless Dir.exist?(dir)
|
48
|
+
Dir.chdir(dir)
|
49
|
+
end
|
50
|
+
|
51
|
+
Dir.mkdir(@dir) unless Dir.exist?(@dir)
|
52
|
+
|
53
|
+
@root_path += @dir + "/"
|
54
|
+
@root_url += @dir + "/"
|
55
|
+
|
56
|
+
@path = params[:path].strip || ""
|
57
|
+
if @path.empty?
|
58
|
+
@current_path = @root_path
|
59
|
+
@current_url = @root_url
|
60
|
+
@current_dir_path = ""
|
61
|
+
@moveup_dir_path = ""
|
62
|
+
else
|
63
|
+
@current_path = @root_path + @path + "/"
|
64
|
+
@current_url = @root_url + @path + "/"
|
65
|
+
@current_dir_path = @path
|
66
|
+
@moveup_dir_path = @current_dir_path.gsub(/(.*?)[^\/]+\/$/, "")
|
67
|
+
end
|
68
|
+
@order = %w(name size type).include?(params[:order].downcase) ? params[:order].downcase : "name"
|
69
|
+
if !@current_path.match(/\.\./).nil?
|
70
|
+
render :text => "Access is not allowed."
|
71
|
+
return
|
72
|
+
end
|
73
|
+
if @current_path.match(/\/$/).nil?
|
74
|
+
render :text => "Parameter is not valid."
|
75
|
+
return
|
76
|
+
end
|
77
|
+
if !File.exist?(@current_path) || !File.directory?(@current_path)
|
78
|
+
render :text => "Directory does not exist."
|
79
|
+
return
|
80
|
+
end
|
81
|
+
@file_list = []
|
82
|
+
Dir.foreach(@current_path) do |filename|
|
83
|
+
hash = {}
|
84
|
+
if filename != "." and filename != ".." and filename != ".DS_Store"
|
85
|
+
file = @current_path + filename
|
86
|
+
if File.directory?(file)
|
87
|
+
hash[:is_dir] = true
|
88
|
+
hash[:has_file] = (Dir.foreach(file).count > 2)
|
89
|
+
hash[:filesize] = 0
|
90
|
+
hash[:is_photo] = false
|
91
|
+
hash[:filetype] = ""
|
92
|
+
else
|
93
|
+
hash[:is_dir] = false
|
94
|
+
hash[:has_file] = false
|
95
|
+
hash[:filesize] = File.size(file)
|
96
|
+
hash[:dir_path] = ""
|
97
|
+
file_ext = file.gsub(/.*\./,"")
|
98
|
+
hash[:is_photo] = @img_ext.include?(file_ext)
|
99
|
+
hash[:filetype] = file_ext
|
100
|
+
end
|
101
|
+
hash[:filename] = filename
|
102
|
+
hash[:datetime] = File.mtime(file).to_s(:db)
|
103
|
+
@file_list << hash
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
@file_list.sort! {|a, b| a["file#{@order}".to_sym] <=> b["file#{@order}".to_sym]}
|
108
|
+
|
109
|
+
@result = {}
|
110
|
+
@result[:moveup_dir_path] = @moveup_dir_path
|
111
|
+
@result[:current_dir_path] = @current_dir_path
|
112
|
+
@result[:current_url] = @current_url
|
113
|
+
@result[:total_count] = @file_list.count
|
114
|
+
@result[:file_list] = @file_list
|
115
|
+
render :text => @result.to_json
|
116
|
+
end
|
117
|
+
|
118
|
+
private
|
119
|
+
def show_error(msg)
|
120
|
+
render :text => ({:error => 1, :message => msg}.to_json)
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class Kindeditor::AssetUploader < CarrierWave::Uploader::Base
|
4
|
+
|
5
|
+
EXT_NAMES = {:image => RailsKindeditor.upload_image_ext,
|
6
|
+
:flash => RailsKindeditor.upload_flash_ext,
|
7
|
+
:media => RailsKindeditor.upload_media_ext,
|
8
|
+
:file => RailsKindeditor.upload_file_ext}
|
9
|
+
|
10
|
+
# Include RMagick or ImageScience support:
|
11
|
+
# include CarrierWave::RMagick
|
12
|
+
# include CarrierWave::ImageScience
|
13
|
+
# include CarrierWave::MiniMagick
|
14
|
+
|
15
|
+
# Choose what kind of storage to use for this uploader:
|
16
|
+
storage :file
|
17
|
+
# storage :fog
|
18
|
+
|
19
|
+
# Override the directory where uploaded files will be stored.
|
20
|
+
# This is a sensible default for uploaders that are meant to be mounted:
|
21
|
+
def store_dir
|
22
|
+
if Kindeditor::AssetUploader.save_upload_info?
|
23
|
+
"#{RailsKindeditor.upload_store_dir}/#{model.class.to_s.underscore.gsub(/(kindeditor\/)|(_uploader)/, '')}/#{model.created_at.strftime("%Y%m")}"
|
24
|
+
else
|
25
|
+
"#{RailsKindeditor.upload_store_dir}/#{self.class.to_s.underscore.gsub(/(kindeditor\/)|(_uploader)/, '')}/#{Time.now.strftime("%Y%m")}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def cache_dir
|
30
|
+
"#{Rails.root}/tmp/uploads"
|
31
|
+
end
|
32
|
+
|
33
|
+
# Provide a default URL as a default if there hasn't been a file uploaded:
|
34
|
+
# def default_url
|
35
|
+
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
36
|
+
# end
|
37
|
+
|
38
|
+
# Process files as they are uploaded:
|
39
|
+
# process :scale => [200, 300]
|
40
|
+
#
|
41
|
+
# def scale(width, height)
|
42
|
+
# # do something
|
43
|
+
# end
|
44
|
+
|
45
|
+
# Create different versions of your uploaded files:
|
46
|
+
# version :thumb do
|
47
|
+
# process :scale => [50, 50]
|
48
|
+
# end
|
49
|
+
|
50
|
+
# Add a white list of extensions which are allowed to be uploaded.
|
51
|
+
# For images you might use something like this:
|
52
|
+
|
53
|
+
# Override the filename of the uploaded files:
|
54
|
+
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
55
|
+
before :store, :remember_cache_id
|
56
|
+
after :store, :delete_tmp_dir
|
57
|
+
|
58
|
+
# store! nil's the cache_id after it finishes so we need to remember it for deletition
|
59
|
+
def remember_cache_id(new_file)
|
60
|
+
@cache_id_was = cache_id
|
61
|
+
end
|
62
|
+
|
63
|
+
def delete_tmp_dir(new_file)
|
64
|
+
# make sure we don't delete other things accidentally by checking the name pattern
|
65
|
+
if @cache_id_was.present? && @cache_id_was =~ /\A[\d]{8}\-[\d]{4}\-[\d]+\-[\d]{4}\z/
|
66
|
+
FileUtils.rm_rf(File.join(cache_dir, @cache_id_was))
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def filename
|
71
|
+
if original_filename
|
72
|
+
@name ||= Digest::MD5.hexdigest(File.dirname(current_path)).slice(0, 12)
|
73
|
+
"#{@name}.#{file.extension}"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.save_upload_info?
|
78
|
+
begin
|
79
|
+
%w(asset file flash image media).each do |s|
|
80
|
+
"Kindeditor::#{s.camelize}".constantize
|
81
|
+
end
|
82
|
+
return true
|
83
|
+
rescue
|
84
|
+
return false
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
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
|
+
|