ckeditor 4.1.0 → 4.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/MIT-LICENSE +1 -1
- data/README.md +41 -5
- data/app/assets/javascripts/ckeditor/config.js +25 -0
- data/app/assets/javascripts/ckeditor/filebrowser/javascripts/application.js.erb +1 -1
- data/app/assets/javascripts/ckeditor/filebrowser/stylesheets/uploader.css.erb +1 -1
- data/{vendor → app}/assets/javascripts/ckeditor/styles.js +1 -2
- data/{vendor/assets/javascripts → app/assets/stylesheets}/ckeditor/contents.css +1 -1
- data/app/controllers/ckeditor/application_controller.rb +1 -1
- data/lib/ckeditor.rb +1 -1
- data/lib/ckeditor/backend/carrierwave.rb +1 -8
- data/lib/ckeditor/backend/paperclip.rb +7 -11
- data/lib/ckeditor/http.rb +1 -3
- data/lib/ckeditor/utils.rb +6 -4
- data/lib/ckeditor/utils/content_type_detector.rb +41 -0
- data/lib/ckeditor/utils/javascript_code.rb +10 -0
- data/lib/ckeditor/version.rb +2 -2
- data/lib/generators/ckeditor/templates/pundit_policy/attachment_file_policy.rb +3 -3
- data/lib/generators/ckeditor/templates/pundit_policy/picture_policy.rb +3 -3
- data/lib/tasks/ckeditor.rake +2 -2
- data/test/models/attachment_file_test.rb +1 -1
- data/test/models/utils_test.rb +6 -6
- data/vendor/assets/javascripts/ckeditor/CHANGES.md +117 -1
- data/vendor/assets/javascripts/ckeditor/ckeditor.js +642 -625
- data/vendor/assets/javascripts/ckeditor/lang/af.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ar.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/bg.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/bn.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/bs.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ca.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/cs.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/cy.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/da.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/de.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/el.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/en-au.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/en-ca.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/en-gb.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/en.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/eo.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/es.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/et.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/eu.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/fa.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/fi.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/fo.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/fr-ca.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/fr.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/gl.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/gu.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/he.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/hi.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/hr.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/hu.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/id.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/is.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/it.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ja.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ka.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/km.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ko.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ku.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/lt.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/lv.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/mk.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/mn.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ms.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/nb.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/nl.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/no.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/pl.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/pt-br.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/pt.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ro.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ru.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/si.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/sk.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/sl.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/sq.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/sr-latn.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/sr.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/sv.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/th.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/tr.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/tt.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ug.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/uk.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/vi.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/zh-cn.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/zh.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/af.js +11 -0
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/da.js +5 -5
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/de.js +4 -3
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/es.js +3 -3
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/he.js +3 -3
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/ku.js +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/pl.js +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/sk.js +3 -3
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/tr.js +3 -3
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/zh.js +2 -3
- data/vendor/assets/javascripts/ckeditor/plugins/about/dialogs/about.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/iframe/images/placeholder.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/image/dialogs/image.js +22 -22
- data/vendor/assets/javascripts/ckeditor/plugins/link/images/anchor.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/link/images/hidpi/anchor.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/magicline/images/hidpi/icon-rtl.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/magicline/images/hidpi/icon.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/magicline/images/icon-rtl.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/magicline/images/icon.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/pastefromword/filter/default.js +7 -7
- data/vendor/assets/javascripts/ckeditor/plugins/preview/preview.html +8 -5
- data/vendor/assets/javascripts/ckeditor/plugins/scayt/dialogs/options.js +16 -16
- data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_address.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_blockquote.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_div.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_h1.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_h2.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_h3.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_h4.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_h5.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_h6.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_p.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_pre.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/angel_smile.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/angel_smile.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/angry_smile.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/angry_smile.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/broken_heart.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/broken_heart.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/confused_smile.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/confused_smile.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/cry_smile.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/devil_smile.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/embaressed_smile.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/embarrassed_smile.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/embarrassed_smile.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/envelope.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/envelope.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/heart.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/heart.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/kiss.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/kiss.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/lightbulb.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/lightbulb.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/omg_smile.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/omg_smile.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/regular_smile.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/regular_smile.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/sad_smile.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/sad_smile.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/shades_smile.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/shades_smile.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/teeth_smile.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/teeth_smile.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/thumbs_down.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/thumbs_down.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/thumbs_up.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/thumbs_up.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/tongue_smile.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/tongue_smile.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/tounge_smile.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/whatchutalkingabout_smile.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/whatchutalkingabout_smile.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/wink_smile.gif +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/wink_smile.png +0 -0
- data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/af.js +13 -0
- data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/da.js +13 -0
- data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/el.js +8 -8
- data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/lt.js +13 -0
- data/vendor/assets/javascripts/ckeditor/plugins/tabletools/dialogs/tableCell.js +6 -6
- data/vendor/assets/javascripts/ckeditor/plugins/wsc/dialogs/wsc.js +68 -68
- data/vendor/assets/javascripts/ckeditor/skins/moono/editor_ie7.css +1 -1
- data/vendor/assets/javascripts/ckeditor/skins/moono/editor_iequirks.css +1 -1
- data/vendor/assets/javascripts/ckeditor/skins/moono/images/arrow.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/images/close.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/images/hidpi/close.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/images/hidpi/lock-open.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/images/hidpi/lock.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/images/hidpi/refresh.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/images/lock-open.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/images/lock.png +0 -0
- data/vendor/assets/javascripts/ckeditor/skins/moono/images/refresh.png +0 -0
- metadata +21 -13
- data/vendor/assets/javascripts/ckeditor/config.js +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b293a89d93a9fec21bf515407aa6653525390cea
|
4
|
+
data.tar.gz: 54bdec36f7488d7d342f786f27ea05b211c649a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfa69f8249288901d774ceef2dba001c9366c87050fc1fc5bb18cb81e1e6034b9484018bf22c84ed228c636fdfcd559c01b58c982398629cc82c12e05531e918
|
7
|
+
data.tar.gz: 3bd0a775d343d5a5c5699791040ec89e5342b88a8278e1957436e58eafcb0d23b766b9ffc08951010792d3a4d65be7ab600e6adc9aef6039327a40a7ddaf060a
|
data/Gemfile
CHANGED
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -5,7 +5,7 @@ CKEditor is a ready-for-use HTML text editor designed to simplify web content cr
|
|
5
5
|
|
6
6
|
## Features
|
7
7
|
|
8
|
-
* Ckeditor version 4.4.
|
8
|
+
* Ckeditor version 4.4.6 (full)
|
9
9
|
* Rails 4 integration
|
10
10
|
* Files browser
|
11
11
|
* HTML5 files uploader
|
@@ -19,6 +19,13 @@ For basic usage just include ckeditor gem:
|
|
19
19
|
```
|
20
20
|
gem 'ckeditor'
|
21
21
|
```
|
22
|
+
|
23
|
+
or if you want to use the latest version from github:
|
24
|
+
|
25
|
+
```
|
26
|
+
gem 'ckeditor', github: 'galetahub/ckeditor'
|
27
|
+
```
|
28
|
+
|
22
29
|
#### Using with ruby 1.8.7
|
23
30
|
|
24
31
|
For usage with ruby 1.8.7 you need to specify gem version:
|
@@ -27,7 +34,7 @@ For usage with ruby 1.8.7 you need to specify gem version:
|
|
27
34
|
gem 'ckeditor', '4.0.4'
|
28
35
|
```
|
29
36
|
|
30
|
-
For files uploading support you need
|
37
|
+
For files uploading support you need generate models for file storage.
|
31
38
|
Currently supported next backends:
|
32
39
|
|
33
40
|
* ActiveRecord (paperclip, carrierwave, dragonfly)
|
@@ -74,7 +81,7 @@ rails generate ckeditor:install --orm=mongoid --backend=carrierwave
|
|
74
81
|
#### Load generated models
|
75
82
|
|
76
83
|
All ckeditor models will be generated into app/models/ckeditor folder.
|
77
|
-
|
84
|
+
Models are autoloaded in Rails 4. For earlier Rails versions you need to add them to autoload path (in application.rb):
|
78
85
|
|
79
86
|
```ruby
|
80
87
|
config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
|
@@ -88,7 +95,7 @@ mount Ckeditor::Engine => '/ckeditor'
|
|
88
95
|
|
89
96
|
## Usage
|
90
97
|
|
91
|
-
Include ckeditor javascripts
|
98
|
+
Include ckeditor javascripts in your `app/assets/javascripts/application.js`:
|
92
99
|
|
93
100
|
```
|
94
101
|
//= require ckeditor/init
|
@@ -120,8 +127,35 @@ app/assets/javascripts/ckeditor/config.js
|
|
120
127
|
app/assets/javascripts/ckeditor/contents.css
|
121
128
|
```
|
122
129
|
|
130
|
+
#### Custom toolbars example
|
131
|
+
|
132
|
+
Adding custom toolbar:
|
133
|
+
|
134
|
+
```javascript
|
135
|
+
# in app/assets/javascripts/ckeditor/config.js
|
136
|
+
|
137
|
+
CKEDITOR.editorConfig = function (config) {
|
138
|
+
// ... other configuration ...
|
139
|
+
|
140
|
+
config.toolbar_mini = [
|
141
|
+
["Bold", "Italic", "Underline", "Strike", "-", "Subscript", "Superscript"],
|
142
|
+
];
|
143
|
+
config.toolbar = "simple";
|
144
|
+
|
145
|
+
// ... rest of the original config.js ...
|
146
|
+
}
|
147
|
+
```
|
148
|
+
|
149
|
+
When overriding default `config.js` you have to set all configuration yourself since bundled `config.js` will not be loaded. To see the default configuration run `bundle open ckeditor` and copy `app/assets/javascripts/ckeditor/config.js` to your project and customize it to your needs.
|
150
|
+
|
123
151
|
### Deployment
|
124
152
|
|
153
|
+
For Rails 4, add the following to `config/initializers/assets.rb`:
|
154
|
+
|
155
|
+
```ruby
|
156
|
+
Rails.application.config.assets.precompile += %w( ckeditor/* )
|
157
|
+
```
|
158
|
+
|
125
159
|
Since version 4.1.0, non-digested assets of ckeditor will simply be copied after digested assets were compiled.
|
126
160
|
For older versions, use gem [non-stupid-digest-assets](https://rubygems.org/gems/non-stupid-digest-assets), to copy non digest assets.
|
127
161
|
|
@@ -136,8 +170,10 @@ Ckeditor.setup do |config|
|
|
136
170
|
end
|
137
171
|
```
|
138
172
|
|
173
|
+
Note that you have to list your plugins including all their dependencies.
|
174
|
+
|
139
175
|
### Include customized CKEDITOR_BASEPATH setting
|
140
|
-
|
176
|
+
|
141
177
|
Add your app/assets/javascripts/ckeditor/basepath.js.erb like
|
142
178
|
|
143
179
|
```erb
|
@@ -31,6 +31,8 @@ CKEDITOR.editorConfig = function( config )
|
|
31
31
|
// The location of a script that handles file uploads.
|
32
32
|
config.filebrowserUploadUrl = "/ckeditor/attachment_files";
|
33
33
|
|
34
|
+
config.allowedContent = true;
|
35
|
+
|
34
36
|
// Rails CSRF token
|
35
37
|
config.filebrowserParams = function(){
|
36
38
|
var csrf_token, csrf_param, meta,
|
@@ -89,4 +91,27 @@ CKEDITOR.editorConfig = function( config )
|
|
89
91
|
}
|
90
92
|
}
|
91
93
|
});
|
94
|
+
|
95
|
+
// Toolbar groups configuration.
|
96
|
+
config.toolbar = [
|
97
|
+
{ name: 'document', groups: [ 'mode', 'document', 'doctools' ], items: [ 'Source'] },
|
98
|
+
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
|
99
|
+
// { name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ], items: [ 'Find', 'Replace', '-', 'SelectAll', '-', 'Scayt' ] },
|
100
|
+
// { name: 'forms', items: [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] },
|
101
|
+
{ name: 'links', items: [ 'Link', 'Unlink', 'Anchor' ] },
|
102
|
+
{ name: 'insert', items: [ 'Image', 'Flash', 'Table', 'HorizontalRule', 'SpecialChar' ] },
|
103
|
+
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock' ] },
|
104
|
+
'/',
|
105
|
+
{ name: 'styles', items: [ 'Styles', 'Format', 'Font', 'FontSize' ] },
|
106
|
+
{ name: 'colors', items: [ 'TextColor', 'BGColor' ] },
|
107
|
+
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] }
|
108
|
+
];
|
109
|
+
|
110
|
+
config.toolbar_mini = [
|
111
|
+
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock' ] },
|
112
|
+
{ name: 'styles', items: [ 'Font', 'FontSize' ] },
|
113
|
+
{ name: 'colors', items: [ 'TextColor', 'BGColor' ] },
|
114
|
+
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] },
|
115
|
+
{ name: 'insert', items: [ 'Image', 'Table', 'HorizontalRule', 'SpecialChar' ] }
|
116
|
+
];
|
92
117
|
};
|
@@ -177,7 +177,7 @@ qq.extend(qq.FileUploaderInput.prototype, {
|
|
177
177
|
qq.addClass(item, this._classes.success);
|
178
178
|
|
179
179
|
asset.size = this._formatSize(asset.size);
|
180
|
-
asset.controller = (asset.type.toLowerCase() == "ckeditor::picture" ? "pictures" : "attachment_files");
|
180
|
+
asset.controller = (asset.type !== undefined && asset.type.toLowerCase() == "ckeditor::picture" ? "pictures" : "attachment_files");
|
181
181
|
|
182
182
|
$(item).replaceWith($(this._options.template_id).tmpl(asset));
|
183
183
|
} else {
|
@@ -107,5 +107,4 @@ CKEDITOR.stylesSet.add( 'default', [
|
|
107
107
|
|
108
108
|
{ name: 'Borderless Table', element: 'table', styles: { 'border-style': 'hidden', 'background-color': '#E6E6FA' } },
|
109
109
|
{ name: 'Square Bulleted List', element: 'ul', styles: { 'list-style-type': 'square' } }
|
110
|
-
] );
|
111
|
-
|
110
|
+
] );
|
data/lib/ckeditor.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'mime/types'
|
2
1
|
require 'mini_magick'
|
3
2
|
|
4
3
|
module Ckeditor
|
@@ -38,13 +37,7 @@ module Ckeditor
|
|
38
37
|
end
|
39
38
|
|
40
39
|
def extract_content_type
|
41
|
-
|
42
|
-
content_type = MIME::Types.type_for(original_filename).first
|
43
|
-
else
|
44
|
-
content_type = file.content_type
|
45
|
-
end
|
46
|
-
|
47
|
-
model.data_content_type = content_type.to_s
|
40
|
+
model.data_content_type = Utils::ContentTypeDetector.new(file.path).detect
|
48
41
|
end
|
49
42
|
|
50
43
|
def set_size
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'mime/types'
|
2
|
-
|
3
1
|
module Ckeditor
|
4
2
|
module Backend
|
5
3
|
module Paperclip
|
@@ -21,14 +19,15 @@ module Ckeditor
|
|
21
19
|
|
22
20
|
module InstanceMethods
|
23
21
|
def geometry
|
24
|
-
@geometry ||=
|
25
|
-
file = data.respond_to?(:queued_for_write) ? data.queued_for_write[:original] : data.to_file
|
26
|
-
::Paperclip::Geometry.from_file(file)
|
27
|
-
end
|
22
|
+
@geometry ||= ::Paperclip::Geometry.from_file(file)
|
28
23
|
end
|
29
24
|
|
30
25
|
protected
|
31
26
|
|
27
|
+
def file
|
28
|
+
@file ||= data.respond_to?(:queued_for_write) ? data.queued_for_write[:original] : data.to_file
|
29
|
+
end
|
30
|
+
|
32
31
|
def parameterize_filename
|
33
32
|
unless data_file_name.blank?
|
34
33
|
filename = Ckeditor::Utils.parameterize_filename(data_file_name)
|
@@ -43,12 +42,9 @@ module Ckeditor
|
|
43
42
|
end
|
44
43
|
end
|
45
44
|
|
46
|
-
# Extract content_type from filename using mime/types gem
|
47
45
|
def extract_content_type
|
48
|
-
|
49
|
-
|
50
|
-
self.data_content_type = content_types.first.to_s unless content_types.empty?
|
51
|
-
end
|
46
|
+
path = file.nil? ? nil : file.path
|
47
|
+
self.data_content_type = Utils::ContentTypeDetector.new(path).detect
|
52
48
|
end
|
53
49
|
end
|
54
50
|
end
|
data/lib/ckeditor/http.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'digest/sha1'
|
3
|
-
require 'mime/types'
|
4
3
|
|
5
4
|
module Ckeditor
|
6
5
|
module Http
|
@@ -61,8 +60,7 @@ module Ckeditor
|
|
61
60
|
end
|
62
61
|
|
63
62
|
def content_type
|
64
|
-
|
65
|
-
types.empty? ? @request.content_type : types.first.to_s
|
63
|
+
@request.content_type
|
66
64
|
end
|
67
65
|
|
68
66
|
def body
|
data/lib/ckeditor/utils.rb
CHANGED
@@ -3,10 +3,8 @@ require 'active_support/json/encoding'
|
|
3
3
|
|
4
4
|
module Ckeditor
|
5
5
|
module Utils
|
6
|
-
|
7
|
-
|
8
|
-
def encode_json(encoder) self end #:nodoc:
|
9
|
-
end
|
6
|
+
autoload :JavascriptCode, 'ckeditor/utils/javascript_code'
|
7
|
+
autoload :ContentTypeDetector, 'ckeditor/utils/content_type_detector'
|
10
8
|
|
11
9
|
class << self
|
12
10
|
def escape_single_quotes(str)
|
@@ -105,6 +103,10 @@ module Ckeditor
|
|
105
103
|
items
|
106
104
|
end
|
107
105
|
end
|
106
|
+
|
107
|
+
def extract_content_type(file)
|
108
|
+
|
109
|
+
end
|
108
110
|
end
|
109
111
|
end
|
110
112
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'cocaine'
|
3
|
+
|
4
|
+
module Ckeditor
|
5
|
+
module Utils
|
6
|
+
class ContentTypeDetector
|
7
|
+
EMPTY_CONTENT_TYPE = 'inode/x-empty'
|
8
|
+
DEFAULT_CONTENT_TYPE = 'application/octet-stream'
|
9
|
+
|
10
|
+
def initialize(file_path)
|
11
|
+
@file_path = file_path
|
12
|
+
end
|
13
|
+
|
14
|
+
# content type detection strategy:
|
15
|
+
#
|
16
|
+
# 1. empty file: returns 'inode/x-empty'
|
17
|
+
# 2. nonempty file: if the file is not empty then returns the content type using file command
|
18
|
+
# 3. invalid file: file command raises error and returns 'application/octet-stream'
|
19
|
+
|
20
|
+
def detect
|
21
|
+
empty_file? ? EMPTY_CONTENT_TYPE : content_type_from_file_command
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def empty_file?
|
27
|
+
return true if @file_path.blank?
|
28
|
+
File.exists?(@file_path) && File.size(@file_path) == 0
|
29
|
+
end
|
30
|
+
|
31
|
+
def content_type_from_file_command
|
32
|
+
type = begin
|
33
|
+
Cocaine::CommandLine.new('file', '-b --mime-type :file').run(file: @file_path)
|
34
|
+
rescue Cocaine::CommandLineError => e
|
35
|
+
# TODO: log command failure
|
36
|
+
DEFAULT_CONTENT_TYPE
|
37
|
+
end.strip
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/ckeditor/version.rb
CHANGED
@@ -7,14 +7,14 @@ class Ckeditor::AttachmentFilePolicy
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def index?
|
10
|
-
|
10
|
+
user.present?
|
11
11
|
end
|
12
12
|
|
13
13
|
def create?
|
14
|
-
|
14
|
+
user.present?
|
15
15
|
end
|
16
16
|
|
17
17
|
def destroy?
|
18
|
-
|
18
|
+
attachment.assetable_id == user.id
|
19
19
|
end
|
20
20
|
end
|
@@ -7,14 +7,14 @@ class Ckeditor::PicturePolicy
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def index?
|
10
|
-
|
10
|
+
user.present?
|
11
11
|
end
|
12
12
|
|
13
13
|
def create?
|
14
|
-
|
14
|
+
user.present?
|
15
15
|
end
|
16
16
|
|
17
17
|
def destroy?
|
18
|
-
|
18
|
+
picture.assetable_id == user.id
|
19
19
|
end
|
20
20
|
end
|
data/lib/tasks/ckeditor.rake
CHANGED
@@ -7,7 +7,7 @@ task "assets:precompile" do
|
|
7
7
|
next unless file =~ fingerprint
|
8
8
|
nondigest = file.sub fingerprint, '.'
|
9
9
|
if !File.exist?(nondigest) or File.mtime(file) > File.mtime(nondigest)
|
10
|
-
FileUtils.cp file, nondigest, verbose: true
|
10
|
+
FileUtils.cp file, nondigest, verbose: true, preserve: true
|
11
11
|
end
|
12
12
|
end
|
13
|
-
end
|
13
|
+
end
|
@@ -17,6 +17,6 @@ class AttachmentFileTest < ActiveSupport::TestCase
|
|
17
17
|
|
18
18
|
assert_equal "application/x-gzip", @attachment.data_content_type
|
19
19
|
assert_equal 6823, @attachment.data_file_size
|
20
|
-
assert_equal "
|
20
|
+
assert_equal "ckeditor/filebrowser/images/thumbs/gz.gif", @attachment.url_thumb
|
21
21
|
end
|
22
22
|
end
|
data/test/models/utils_test.rb
CHANGED
@@ -3,16 +3,16 @@ require 'test_helper'
|
|
3
3
|
class UtilsTest < ActiveSupport::TestCase
|
4
4
|
test 'exists filethumb' do
|
5
5
|
%w(avi doc docx exe gz htm jpg mp3 mpg pdf psd rar swf tar txt wmv xlsx zip).each do |ext|
|
6
|
-
assert_equal "
|
6
|
+
assert_equal "ckeditor/filebrowser/images/thumbs/#{ext}.gif", Ckeditor::Utils.filethumb("somefile.#{ext}")
|
7
7
|
end
|
8
8
|
|
9
|
-
assert_equal "
|
9
|
+
assert_equal "ckeditor/filebrowser/images/thumbs/unknown.gif", Ckeditor::Utils.filethumb("somefile.ddd")
|
10
10
|
end
|
11
11
|
|
12
12
|
test 'wrong filethumb' do
|
13
|
-
assert_equal "
|
14
|
-
assert_equal "
|
15
|
-
assert_equal "
|
16
|
-
assert_equal "
|
13
|
+
assert_equal "ckeditor/filebrowser/images/thumbs/unknown.gif", Ckeditor::Utils.filethumb("somefile.ddd")
|
14
|
+
assert_equal "ckeditor/filebrowser/images/thumbs/unknown.gif", Ckeditor::Utils.filethumb("somefile")
|
15
|
+
assert_equal "ckeditor/filebrowser/images/thumbs/unknown.gif", Ckeditor::Utils.filethumb("")
|
16
|
+
assert_equal "ckeditor/filebrowser/images/thumbs/unknown.gif", Ckeditor::Utils.filethumb(nil)
|
17
17
|
end
|
18
18
|
end
|