ckeditor 4.1.0 → 4.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +41 -5
  5. data/app/assets/javascripts/ckeditor/config.js +25 -0
  6. data/app/assets/javascripts/ckeditor/filebrowser/javascripts/application.js.erb +1 -1
  7. data/app/assets/javascripts/ckeditor/filebrowser/stylesheets/uploader.css.erb +1 -1
  8. data/{vendor → app}/assets/javascripts/ckeditor/styles.js +1 -2
  9. data/{vendor/assets/javascripts → app/assets/stylesheets}/ckeditor/contents.css +1 -1
  10. data/app/controllers/ckeditor/application_controller.rb +1 -1
  11. data/lib/ckeditor.rb +1 -1
  12. data/lib/ckeditor/backend/carrierwave.rb +1 -8
  13. data/lib/ckeditor/backend/paperclip.rb +7 -11
  14. data/lib/ckeditor/http.rb +1 -3
  15. data/lib/ckeditor/utils.rb +6 -4
  16. data/lib/ckeditor/utils/content_type_detector.rb +41 -0
  17. data/lib/ckeditor/utils/javascript_code.rb +10 -0
  18. data/lib/ckeditor/version.rb +2 -2
  19. data/lib/generators/ckeditor/templates/pundit_policy/attachment_file_policy.rb +3 -3
  20. data/lib/generators/ckeditor/templates/pundit_policy/picture_policy.rb +3 -3
  21. data/lib/tasks/ckeditor.rake +2 -2
  22. data/test/models/attachment_file_test.rb +1 -1
  23. data/test/models/utils_test.rb +6 -6
  24. data/vendor/assets/javascripts/ckeditor/CHANGES.md +117 -1
  25. data/vendor/assets/javascripts/ckeditor/ckeditor.js +642 -625
  26. data/vendor/assets/javascripts/ckeditor/lang/af.js +1 -1
  27. data/vendor/assets/javascripts/ckeditor/lang/ar.js +1 -1
  28. data/vendor/assets/javascripts/ckeditor/lang/bg.js +1 -1
  29. data/vendor/assets/javascripts/ckeditor/lang/bn.js +1 -1
  30. data/vendor/assets/javascripts/ckeditor/lang/bs.js +1 -1
  31. data/vendor/assets/javascripts/ckeditor/lang/ca.js +1 -1
  32. data/vendor/assets/javascripts/ckeditor/lang/cs.js +1 -1
  33. data/vendor/assets/javascripts/ckeditor/lang/cy.js +1 -1
  34. data/vendor/assets/javascripts/ckeditor/lang/da.js +1 -1
  35. data/vendor/assets/javascripts/ckeditor/lang/de.js +1 -1
  36. data/vendor/assets/javascripts/ckeditor/lang/el.js +1 -1
  37. data/vendor/assets/javascripts/ckeditor/lang/en-au.js +1 -1
  38. data/vendor/assets/javascripts/ckeditor/lang/en-ca.js +1 -1
  39. data/vendor/assets/javascripts/ckeditor/lang/en-gb.js +1 -1
  40. data/vendor/assets/javascripts/ckeditor/lang/en.js +1 -1
  41. data/vendor/assets/javascripts/ckeditor/lang/eo.js +1 -1
  42. data/vendor/assets/javascripts/ckeditor/lang/es.js +1 -1
  43. data/vendor/assets/javascripts/ckeditor/lang/et.js +1 -1
  44. data/vendor/assets/javascripts/ckeditor/lang/eu.js +1 -1
  45. data/vendor/assets/javascripts/ckeditor/lang/fa.js +1 -1
  46. data/vendor/assets/javascripts/ckeditor/lang/fi.js +1 -1
  47. data/vendor/assets/javascripts/ckeditor/lang/fo.js +1 -1
  48. data/vendor/assets/javascripts/ckeditor/lang/fr-ca.js +1 -1
  49. data/vendor/assets/javascripts/ckeditor/lang/fr.js +1 -1
  50. data/vendor/assets/javascripts/ckeditor/lang/gl.js +1 -1
  51. data/vendor/assets/javascripts/ckeditor/lang/gu.js +1 -1
  52. data/vendor/assets/javascripts/ckeditor/lang/he.js +1 -1
  53. data/vendor/assets/javascripts/ckeditor/lang/hi.js +1 -1
  54. data/vendor/assets/javascripts/ckeditor/lang/hr.js +1 -1
  55. data/vendor/assets/javascripts/ckeditor/lang/hu.js +1 -1
  56. data/vendor/assets/javascripts/ckeditor/lang/id.js +1 -1
  57. data/vendor/assets/javascripts/ckeditor/lang/is.js +1 -1
  58. data/vendor/assets/javascripts/ckeditor/lang/it.js +1 -1
  59. data/vendor/assets/javascripts/ckeditor/lang/ja.js +1 -1
  60. data/vendor/assets/javascripts/ckeditor/lang/ka.js +1 -1
  61. data/vendor/assets/javascripts/ckeditor/lang/km.js +1 -1
  62. data/vendor/assets/javascripts/ckeditor/lang/ko.js +1 -1
  63. data/vendor/assets/javascripts/ckeditor/lang/ku.js +1 -1
  64. data/vendor/assets/javascripts/ckeditor/lang/lt.js +1 -1
  65. data/vendor/assets/javascripts/ckeditor/lang/lv.js +1 -1
  66. data/vendor/assets/javascripts/ckeditor/lang/mk.js +1 -1
  67. data/vendor/assets/javascripts/ckeditor/lang/mn.js +1 -1
  68. data/vendor/assets/javascripts/ckeditor/lang/ms.js +1 -1
  69. data/vendor/assets/javascripts/ckeditor/lang/nb.js +1 -1
  70. data/vendor/assets/javascripts/ckeditor/lang/nl.js +1 -1
  71. data/vendor/assets/javascripts/ckeditor/lang/no.js +1 -1
  72. data/vendor/assets/javascripts/ckeditor/lang/pl.js +1 -1
  73. data/vendor/assets/javascripts/ckeditor/lang/pt-br.js +1 -1
  74. data/vendor/assets/javascripts/ckeditor/lang/pt.js +1 -1
  75. data/vendor/assets/javascripts/ckeditor/lang/ro.js +1 -1
  76. data/vendor/assets/javascripts/ckeditor/lang/ru.js +1 -1
  77. data/vendor/assets/javascripts/ckeditor/lang/si.js +1 -1
  78. data/vendor/assets/javascripts/ckeditor/lang/sk.js +1 -1
  79. data/vendor/assets/javascripts/ckeditor/lang/sl.js +1 -1
  80. data/vendor/assets/javascripts/ckeditor/lang/sq.js +1 -1
  81. data/vendor/assets/javascripts/ckeditor/lang/sr-latn.js +1 -1
  82. data/vendor/assets/javascripts/ckeditor/lang/sr.js +1 -1
  83. data/vendor/assets/javascripts/ckeditor/lang/sv.js +1 -1
  84. data/vendor/assets/javascripts/ckeditor/lang/th.js +1 -1
  85. data/vendor/assets/javascripts/ckeditor/lang/tr.js +1 -1
  86. data/vendor/assets/javascripts/ckeditor/lang/tt.js +1 -1
  87. data/vendor/assets/javascripts/ckeditor/lang/ug.js +1 -1
  88. data/vendor/assets/javascripts/ckeditor/lang/uk.js +1 -1
  89. data/vendor/assets/javascripts/ckeditor/lang/vi.js +1 -1
  90. data/vendor/assets/javascripts/ckeditor/lang/zh-cn.js +1 -1
  91. data/vendor/assets/javascripts/ckeditor/lang/zh.js +1 -1
  92. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/af.js +11 -0
  93. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/da.js +5 -5
  94. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/de.js +4 -3
  95. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/es.js +3 -3
  96. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/he.js +3 -3
  97. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/ku.js +2 -2
  98. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/pl.js +2 -2
  99. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/sk.js +3 -3
  100. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/tr.js +3 -3
  101. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/zh.js +2 -3
  102. data/vendor/assets/javascripts/ckeditor/plugins/about/dialogs/about.js +1 -1
  103. data/vendor/assets/javascripts/ckeditor/plugins/iframe/images/placeholder.png +0 -0
  104. data/vendor/assets/javascripts/ckeditor/plugins/image/dialogs/image.js +22 -22
  105. data/vendor/assets/javascripts/ckeditor/plugins/link/images/anchor.png +0 -0
  106. data/vendor/assets/javascripts/ckeditor/plugins/link/images/hidpi/anchor.png +0 -0
  107. data/vendor/assets/javascripts/ckeditor/plugins/magicline/images/hidpi/icon-rtl.png +0 -0
  108. data/vendor/assets/javascripts/ckeditor/plugins/magicline/images/hidpi/icon.png +0 -0
  109. data/vendor/assets/javascripts/ckeditor/plugins/magicline/images/icon-rtl.png +0 -0
  110. data/vendor/assets/javascripts/ckeditor/plugins/magicline/images/icon.png +0 -0
  111. data/vendor/assets/javascripts/ckeditor/plugins/pastefromword/filter/default.js +7 -7
  112. data/vendor/assets/javascripts/ckeditor/plugins/preview/preview.html +8 -5
  113. data/vendor/assets/javascripts/ckeditor/plugins/scayt/dialogs/options.js +16 -16
  114. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_address.png +0 -0
  115. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_blockquote.png +0 -0
  116. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_div.png +0 -0
  117. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_h1.png +0 -0
  118. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_h2.png +0 -0
  119. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_h3.png +0 -0
  120. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_h4.png +0 -0
  121. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_h5.png +0 -0
  122. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_h6.png +0 -0
  123. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_p.png +0 -0
  124. data/vendor/assets/javascripts/ckeditor/plugins/showblocks/images/block_pre.png +0 -0
  125. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/angel_smile.gif +0 -0
  126. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/angel_smile.png +0 -0
  127. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/angry_smile.gif +0 -0
  128. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/angry_smile.png +0 -0
  129. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/broken_heart.gif +0 -0
  130. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/broken_heart.png +0 -0
  131. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/confused_smile.gif +0 -0
  132. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/confused_smile.png +0 -0
  133. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/cry_smile.png +0 -0
  134. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/devil_smile.png +0 -0
  135. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/embaressed_smile.gif +0 -0
  136. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/embarrassed_smile.gif +0 -0
  137. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/embarrassed_smile.png +0 -0
  138. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/envelope.gif +0 -0
  139. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/envelope.png +0 -0
  140. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/heart.gif +0 -0
  141. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/heart.png +0 -0
  142. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/kiss.gif +0 -0
  143. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/kiss.png +0 -0
  144. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/lightbulb.gif +0 -0
  145. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/lightbulb.png +0 -0
  146. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/omg_smile.gif +0 -0
  147. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/omg_smile.png +0 -0
  148. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/regular_smile.gif +0 -0
  149. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/regular_smile.png +0 -0
  150. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/sad_smile.gif +0 -0
  151. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/sad_smile.png +0 -0
  152. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/shades_smile.gif +0 -0
  153. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/shades_smile.png +0 -0
  154. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/teeth_smile.gif +0 -0
  155. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/teeth_smile.png +0 -0
  156. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/thumbs_down.gif +0 -0
  157. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/thumbs_down.png +0 -0
  158. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/thumbs_up.gif +0 -0
  159. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/thumbs_up.png +0 -0
  160. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/tongue_smile.gif +0 -0
  161. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/tongue_smile.png +0 -0
  162. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/tounge_smile.gif +0 -0
  163. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/whatchutalkingabout_smile.gif +0 -0
  164. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/whatchutalkingabout_smile.png +0 -0
  165. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/wink_smile.gif +0 -0
  166. data/vendor/assets/javascripts/ckeditor/plugins/smiley/images/wink_smile.png +0 -0
  167. data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/af.js +13 -0
  168. data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/da.js +13 -0
  169. data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/el.js +8 -8
  170. data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/lt.js +13 -0
  171. data/vendor/assets/javascripts/ckeditor/plugins/tabletools/dialogs/tableCell.js +6 -6
  172. data/vendor/assets/javascripts/ckeditor/plugins/wsc/dialogs/wsc.js +68 -68
  173. data/vendor/assets/javascripts/ckeditor/skins/moono/editor_ie7.css +1 -1
  174. data/vendor/assets/javascripts/ckeditor/skins/moono/editor_iequirks.css +1 -1
  175. data/vendor/assets/javascripts/ckeditor/skins/moono/images/arrow.png +0 -0
  176. data/vendor/assets/javascripts/ckeditor/skins/moono/images/close.png +0 -0
  177. data/vendor/assets/javascripts/ckeditor/skins/moono/images/hidpi/close.png +0 -0
  178. data/vendor/assets/javascripts/ckeditor/skins/moono/images/hidpi/lock-open.png +0 -0
  179. data/vendor/assets/javascripts/ckeditor/skins/moono/images/hidpi/lock.png +0 -0
  180. data/vendor/assets/javascripts/ckeditor/skins/moono/images/hidpi/refresh.png +0 -0
  181. data/vendor/assets/javascripts/ckeditor/skins/moono/images/lock-open.png +0 -0
  182. data/vendor/assets/javascripts/ckeditor/skins/moono/images/lock.png +0 -0
  183. data/vendor/assets/javascripts/ckeditor/skins/moono/images/refresh.png +0 -0
  184. metadata +21 -13
  185. data/vendor/assets/javascripts/ckeditor/config.js +0 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 718c57a411fa584f92a7b532b9044f0814cb8c4b
4
- data.tar.gz: 8be0eb212ece8e16ee5cc7bbd72786e792b7e068
3
+ metadata.gz: b293a89d93a9fec21bf515407aa6653525390cea
4
+ data.tar.gz: 54bdec36f7488d7d342f786f27ea05b211c649a6
5
5
  SHA512:
6
- metadata.gz: f9502d82221ba196b1ac27b2490095c79f83ab4ae3eb417d8b6fee07af2c55f45be2ca0961cac30c50bf63829ef1cfed63008a86b0931724f39a7bc4d63aebdd
7
- data.tar.gz: d397998fd9e23e06e95e31456ce4c73cf4cf4a9d5dc885c935dea9865f6cd870f97ef5a6bb80aaff601089aa00fd67c3bd9ce7a37a3138ede1bef72539fcf545
6
+ metadata.gz: cfa69f8249288901d774ceef2dba001c9366c87050fc1fc5bb18cb81e1e6034b9484018bf22c84ed228c636fdfcd559c01b58c982398629cc82c12e05531e918
7
+ data.tar.gz: 3bd0a775d343d5a5c5699791040ec89e5342b88a8278e1957436e58eafcb0d23b766b9ffc08951010792d3a4d65be7ab600e6adc9aef6039327a40a7ddaf060a
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem "rails", "3.2.3"
5
+ gem "rails", "3.2.21"
6
6
 
7
7
  platforms :mri_18 do
8
8
  group :test do
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2011 AIMBULANCE
1
+ Copyright 2011-2014 Fodojo. http://www.fodojo.com/
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
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.2 (full)
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 generage models for file storage.
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
- Autoload ckeditor models folder (application.rb):
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 rails 3.2 (application.js):
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 {
@@ -118,5 +118,5 @@ img {
118
118
  }
119
119
 
120
120
  .pagination, .pagination a {
121
- display: none;
121
+ text-decoration: none;
122
122
  }
@@ -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
+ ] );
@@ -131,4 +131,4 @@ a > img {
131
131
  margin: 1px;
132
132
  border: none;
133
133
  outline: 1px solid #0782C1;
134
- }
134
+ }
@@ -1,4 +1,4 @@
1
- class Ckeditor::ApplicationController < ActionController::Base
1
+ class Ckeditor::ApplicationController < ApplicationController
2
2
  respond_to :html, :json
3
3
  layout 'ckeditor/application'
4
4
 
data/lib/ckeditor.rb CHANGED
@@ -48,7 +48,7 @@ module Ckeditor
48
48
 
49
49
  # Ckeditor files destination path
50
50
  mattr_accessor :relative_path
51
- @@relative_path = '/assets/ckeditor'
51
+ @@relative_path = 'ckeditor'
52
52
 
53
53
  # Ckeditor assets path
54
54
  mattr_accessor :asset_path
@@ -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
- if file.content_type == 'application/octet-stream' || file.content_type.blank?
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 ||= begin
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
- if data_content_type == "application/octet-stream" && !data_file_name.blank?
49
- content_types = MIME::Types.type_for(data_file_name)
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
- types = MIME::Types.type_for(original_filename)
65
- types.empty? ? @request.content_type : types.first.to_s
63
+ @request.content_type
66
64
  end
67
65
 
68
66
  def body
@@ -3,10 +3,8 @@ require 'active_support/json/encoding'
3
3
 
4
4
  module Ckeditor
5
5
  module Utils
6
- class JavascriptCode < String
7
- def as_json(options = nil) self end #:nodoc:
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
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ module Ckeditor
4
+ module Utils
5
+ class JavascriptCode < String
6
+ def as_json(options = nil) self end #:nodoc:
7
+ def encode_json(encoder) self end #:nodoc:
8
+ end
9
+ end
10
+ end
@@ -1,6 +1,6 @@
1
1
  module Ckeditor
2
2
  module Version
3
- GEM = "4.1.0".freeze
4
- EDITOR = "4.4.2".freeze
3
+ GEM = "4.1.1".freeze
4
+ EDITOR = "4.4.6".freeze
5
5
  end
6
6
  end
@@ -7,14 +7,14 @@ class Ckeditor::AttachmentFilePolicy
7
7
  end
8
8
 
9
9
  def index?
10
- true and ! @user.nil?
10
+ user.present?
11
11
  end
12
12
 
13
13
  def create?
14
- true and ! @user.nil?
14
+ user.present?
15
15
  end
16
16
 
17
17
  def destroy?
18
- @attachment.assetable_id == @user.id
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
- true and ! @user.nil?
10
+ user.present?
11
11
  end
12
12
 
13
13
  def create?
14
- true and ! @user.nil?
14
+ user.present?
15
15
  end
16
16
 
17
17
  def destroy?
18
- @picture.assetable_id == @user.id
18
+ picture.assetable_id == user.id
19
19
  end
20
20
  end
@@ -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 "/assets/ckeditor/filebrowser/images/thumbs/gz.gif", @attachment.url_thumb
20
+ assert_equal "ckeditor/filebrowser/images/thumbs/gz.gif", @attachment.url_thumb
21
21
  end
22
22
  end
@@ -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 "/assets/ckeditor/filebrowser/images/thumbs/#{ext}.gif", Ckeditor::Utils.filethumb("somefile.#{ext}")
6
+ assert_equal "ckeditor/filebrowser/images/thumbs/#{ext}.gif", Ckeditor::Utils.filethumb("somefile.#{ext}")
7
7
  end
8
8
 
9
- assert_equal "/assets/ckeditor/filebrowser/images/thumbs/unknown.gif", Ckeditor::Utils.filethumb("somefile.ddd")
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 "/assets/ckeditor/filebrowser/images/thumbs/unknown.gif", Ckeditor::Utils.filethumb("somefile.ddd")
14
- assert_equal "/assets/ckeditor/filebrowser/images/thumbs/unknown.gif", Ckeditor::Utils.filethumb("somefile")
15
- assert_equal "/assets/ckeditor/filebrowser/images/thumbs/unknown.gif", Ckeditor::Utils.filethumb("")
16
- assert_equal "/assets/ckeditor/filebrowser/images/thumbs/unknown.gif", Ckeditor::Utils.filethumb(nil)
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