ckeditor 3.5.4 → 3.6.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +23 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +96 -97
- data/Rakefile +16 -33
- data/app/controllers/ckeditor/attachment_files_controller.rb +4 -4
- data/app/controllers/ckeditor/base_controller.rb +15 -42
- data/app/controllers/ckeditor/pictures_controller.rb +3 -3
- data/app/views/ckeditor/attachment_files/index.html.erb +13 -51
- data/app/views/ckeditor/pictures/index.html.erb +14 -52
- data/app/views/ckeditor/shared/_asset.html.erb +19 -0
- data/app/views/ckeditor/shared/_asset_tmpl.html.erb +21 -0
- data/app/views/layouts/ckeditor.html.erb +16 -23
- data/config/locales/en.ckeditor.yml +3 -7
- data/config/locales/ru.ckeditor.yml +4 -8
- data/config/locales/uk.ckeditor.yml +4 -8
- data/config/routes.rb +3 -3
- data/lib/ckeditor.rb +30 -79
- data/lib/ckeditor/engine.rb +14 -13
- data/lib/ckeditor/helpers/controllers.rb +30 -0
- data/lib/ckeditor/helpers/form_builder.rb +11 -0
- data/lib/ckeditor/helpers/form_helper.rb +25 -0
- data/lib/ckeditor/helpers/view_helper.rb +19 -0
- data/lib/ckeditor/http.rb +81 -0
- data/lib/ckeditor/orm/active_record.rb +91 -0
- data/lib/ckeditor/utils.rb +51 -70
- data/lib/ckeditor/version.rb +2 -7
- data/lib/generators/ckeditor/install_generator.rb +62 -0
- data/lib/generators/ckeditor/models_generator.rb +51 -0
- data/lib/generators/ckeditor/templates/ckeditor.rb +18 -0
- data/lib/generators/ckeditor/templates/ckeditor/config.js +52 -0
- data/lib/generators/ckeditor/templates/ckeditor/filebrowser/images/gal_add.jpg +0 -0
- data/lib/generators/ckeditor/templates/ckeditor/filebrowser/images/gal_add.png +0 -0
- data/lib/generators/ckeditor/templates/ckeditor/filebrowser/images/gal_del.png +0 -0
- data/lib/generators/ckeditor/templates/ckeditor/filebrowser/images/gal_more.gif +0 -0
- data/lib/generators/ckeditor/templates/ckeditor/filebrowser/images/preloader.gif +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/ckfnothumb.gif +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/mp3.gif +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/pdf.gif +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/rar.gif +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/swf.gif +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/xls.gif +0 -0
- data/lib/generators/ckeditor/templates/ckeditor/filebrowser/javascripts/application.js +222 -0
- data/lib/generators/ckeditor/templates/ckeditor/filebrowser/stylesheets/uploader.css +112 -0
- data/lib/generators/ckeditor/{base/templates → templates}/ckeditor/plugins/attachment/dialogs/attachment.js +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/attachment/images/attachment.png +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/attachment/lang/en.js +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/attachment/lang/ru.js +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/attachment/lang/uk.js +0 -0
- data/lib/generators/ckeditor/{base/templates → templates}/ckeditor/plugins/attachment/plugin.js +0 -0
- data/lib/generators/ckeditor/{base/templates → templates}/ckeditor/plugins/embed/dialogs/embed.js +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/embed/images/embed.png +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/embed/lang/en.js +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/embed/lang/ru.js +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/embed/lang/uk.js +0 -0
- data/lib/generators/ckeditor/{base/templates → templates}/ckeditor/plugins/embed/plugin.js +0 -0
- data/lib/generators/ckeditor/templates/models/active_record/asset.rb +7 -0
- data/lib/generators/ckeditor/templates/models/active_record/attachment_file.rb +15 -0
- data/lib/generators/ckeditor/{migration/templates/models/paperclip → templates/models/active_record}/migration.rb +3 -8
- data/lib/generators/ckeditor/templates/models/active_record/picture.rb +13 -0
- data/test/ckeditor_test.rb +13 -0
- data/test/controllers/attachment_files_controller_test.rb +52 -0
- data/test/controllers/pictures_controller_test.rb +52 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/controllers/application_controller.rb +4 -0
- data/test/dummy/app/controllers/posts_controller.rb +83 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/posts_helper.rb +2 -0
- data/test/dummy/app/models/ckeditor/asset.rb +7 -0
- data/test/dummy/app/models/ckeditor/attachment_file.rb +15 -0
- data/test/dummy/app/models/ckeditor/picture.rb +13 -0
- data/test/dummy/app/models/post.rb +3 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/posts/_form.html.erb +30 -0
- data/test/dummy/app/views/posts/edit.html.erb +6 -0
- data/test/dummy/app/views/posts/index.html.erb +27 -0
- data/test/dummy/app/views/posts/new.html.erb +5 -0
- data/test/dummy/app/views/posts/show.html.erb +5 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +46 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +34 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +26 -0
- data/test/dummy/config/environments/production.rb +49 -0
- data/test/dummy/config/environments/test.rb +35 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/ckeditor.rb +18 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/db/migrate/20110623120047_create_posts.rb +14 -0
- data/test/dummy/db/migrate/20110705195648_create_ckeditor_assets.rb +26 -0
- data/test/dummy/db/schema.rb +36 -0
- data/test/dummy/log/development.log +818 -0
- data/test/dummy/log/production.log +0 -0
- data/test/dummy/log/server.log +0 -0
- data/test/dummy/log/test.log +5398 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/javascripts/application.js +2 -0
- data/test/dummy/public/javascripts/controls.js +965 -0
- data/test/dummy/public/javascripts/dragdrop.js +974 -0
- data/test/dummy/public/javascripts/effects.js +1123 -0
- data/test/dummy/public/javascripts/prototype.js +6001 -0
- data/test/dummy/public/javascripts/rails.js +191 -0
- data/test/dummy/public/stylesheets/scaffold.css +56 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test/fixtures/files/rails.png +0 -0
- data/test/dummy/test/fixtures/files/rails.tar.gz +0 -0
- data/test/generators/install_generator_test.rb +18 -0
- data/test/generators/models_generator_test.rb +21 -0
- data/test/integration/navigation_test.rb +7 -0
- data/test/integration/posts_test.rb +41 -0
- data/test/routes_test.rb +47 -0
- data/test/support/integration_case.rb +5 -0
- data/test/test_helper.rb +28 -0
- data/test/tmp/app/models/ckeditor/asset.rb +7 -0
- data/test/tmp/app/models/ckeditor/attachment_file.rb +15 -0
- data/test/tmp/app/models/ckeditor/picture.rb +13 -0
- data/test/tmp/db/migrate/20110711170413_create_ckeditor_assets.rb +26 -0
- metadata +220 -99
- data/CHANGELOG +0 -15
- data/app/helpers/ckeditor/base_helper.rb +0 -21
- data/app/views/ckeditor/_asset.html.erb +0 -20
- data/app/views/ckeditor/_swfupload.html.erb +0 -73
- data/lib/ckeditor/form_builder.rb +0 -22
- data/lib/ckeditor/middleware.rb +0 -18
- data/lib/ckeditor/view_helper.rb +0 -92
- data/lib/generators/ckeditor/base/USAGE +0 -9
- data/lib/generators/ckeditor/base/base_generator.rb +0 -41
- data/lib/generators/ckeditor/base/templates/ckeditor.rb +0 -54
- data/lib/generators/ckeditor/base/templates/ckeditor/_source/plugins/attachment/dialogs/attachment.js +0 -384
- data/lib/generators/ckeditor/base/templates/ckeditor/_source/plugins/attachment/plugin.js +0 -44
- data/lib/generators/ckeditor/base/templates/ckeditor/_source/plugins/embed/dialogs/embed.js +0 -65
- data/lib/generators/ckeditor/base/templates/ckeditor/_source/plugins/embed/plugin.js +0 -43
- data/lib/generators/ckeditor/base/templates/ckeditor/config.js +0 -43
- data/lib/generators/ckeditor/base/templates/ckeditor/css/ckfinder.css +0 -316
- data/lib/generators/ckeditor/base/templates/ckeditor/css/fck_dialog.css +0 -119
- data/lib/generators/ckeditor/base/templates/ckeditor/css/fck_editor.css +0 -448
- data/lib/generators/ckeditor/base/templates/ckeditor/css/swfupload.css +0 -94
- data/lib/generators/ckeditor/base/templates/ckeditor/images/add.gif +0 -0
- data/lib/generators/ckeditor/base/templates/ckeditor/images/cancelbutton.gif +0 -0
- data/lib/generators/ckeditor/base/templates/ckeditor/images/doc.gif +0 -0
- data/lib/generators/ckeditor/base/templates/ckeditor/images/refresh.gif +0 -0
- data/lib/generators/ckeditor/base/templates/ckeditor/images/select_files.png +0 -0
- data/lib/generators/ckeditor/base/templates/ckeditor/images/spacer.gif +0 -0
- data/lib/generators/ckeditor/base/templates/ckeditor/images/toolbar.start.gif +0 -0
- data/lib/generators/ckeditor/base/templates/ckeditor/plugins/attachment/images/attachment.png +0 -0
- data/lib/generators/ckeditor/base/templates/ckeditor/plugins/attachment/lang/en.js +0 -10
- data/lib/generators/ckeditor/base/templates/ckeditor/plugins/attachment/lang/ru.js +0 -10
- data/lib/generators/ckeditor/base/templates/ckeditor/plugins/attachment/lang/uk.js +0 -10
- data/lib/generators/ckeditor/base/templates/ckeditor/plugins/embed/images/embed.png +0 -0
- data/lib/generators/ckeditor/base/templates/ckeditor/plugins/embed/lang/en.js +0 -9
- data/lib/generators/ckeditor/base/templates/ckeditor/plugins/embed/lang/ru.js +0 -9
- data/lib/generators/ckeditor/base/templates/ckeditor/plugins/embed/lang/uk.js +0 -9
- data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/fileprogress.js +0 -266
- data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/handlers.js +0 -181
- data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/jquery-1.5.1.min.js +0 -16
- data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/querystring.js +0 -40
- data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/rails.js +0 -158
- data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/swfupload.js +0 -1
- data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/swfupload.queue.js +0 -1
- data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/swfupload.swf +0 -0
- data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/swfupload.swfobject.js +0 -111
- data/lib/generators/ckeditor/migration/USAGE +0 -12
- data/lib/generators/ckeditor/migration/migration_generator.rb +0 -46
- data/lib/generators/ckeditor/migration/templates/models/attachment_fu/asset.rb +0 -32
- data/lib/generators/ckeditor/migration/templates/models/attachment_fu/attachment_file.rb +0 -24
- data/lib/generators/ckeditor/migration/templates/models/attachment_fu/migration.rb +0 -30
- data/lib/generators/ckeditor/migration/templates/models/attachment_fu/picture.rb +0 -25
- data/lib/generators/ckeditor/migration/templates/models/paperclip/asset.rb +0 -97
- data/lib/generators/ckeditor/migration/templates/models/paperclip/attachment_file.rb +0 -40
- data/lib/generators/ckeditor/migration/templates/models/paperclip/picture.rb +0 -23
- data/lib/tasks/ckeditor_tasks.rake +0 -3
data/Gemfile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
source "http://rubygems.org"
|
|
2
|
+
|
|
3
|
+
gemspec
|
|
4
|
+
|
|
5
|
+
gem "rails", "3.0.9"
|
|
6
|
+
|
|
7
|
+
platforms :ruby do
|
|
8
|
+
gem "mysql2", '0.2.11'
|
|
9
|
+
|
|
10
|
+
group :development, :test do
|
|
11
|
+
gem "capybara", ">= 0.4.0"
|
|
12
|
+
gem "redgreen", "~> 1.2.2"
|
|
13
|
+
gem "paperclip", "~> 2.3.12"
|
|
14
|
+
|
|
15
|
+
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
|
|
16
|
+
# gem 'ruby-debug'
|
|
17
|
+
# gem 'ruby-debug19'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
group :development do
|
|
21
|
+
gem "mongrel"
|
|
22
|
+
end
|
|
23
|
+
end
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2011 AIMBULANCE
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
|
@@ -1,89 +1,59 @@
|
|
|
1
|
-
=
|
|
1
|
+
= Ckeditor
|
|
2
2
|
|
|
3
3
|
CKEditor is a text editor to be used inside web pages. It's a WYSIWYG editor, which means that the text being edited on it looks as similar as possible to
|
|
4
4
|
the results users have when publishing it. It brings to the web common editing features found on desktop editing applications like Microsoft Word and OpenOffice.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
This is the ideal editor for developers, created to provide easy and powerful solutions to their users.
|
|
6
|
+
== Features
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
* Rails 3 integration
|
|
9
|
+
* Files browser
|
|
10
|
+
* HTML5 files uploader
|
|
11
|
+
* Hooks for formtastic and simple_form forms generators
|
|
12
|
+
* Extra plugins: attachment and embed.
|
|
13
|
+
* Assets pagination (under construction)
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
== Install (not currently available, under construction)
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Demo appication (Rails 2.3.8):
|
|
16
|
-
http://github.com/galetahub/rails-ckeditor-demo-app
|
|
17
|
-
|
|
18
|
-
Demo appication (Rails 3.x):
|
|
19
|
-
http://github.com/galetahub/ckeditor-demo-app
|
|
20
|
-
|
|
21
|
-
== Install
|
|
22
|
-
|
|
23
|
-
=== Rails 3
|
|
24
|
-
|
|
25
|
-
In your appication "Gemfile":
|
|
26
|
-
|
|
27
|
-
gem 'ckeditor'
|
|
17
|
+
gem "ckeditor", "~> 3.6.0"
|
|
28
18
|
|
|
29
|
-
|
|
30
|
-
gem 'ckeditor', :git => 'git://github.com/galetahub/rails-ckeditor.git', :branch => 'rails3'
|
|
19
|
+
rails generate ckeditor:install
|
|
31
20
|
|
|
32
|
-
|
|
33
|
-
Check "config/initializers/ckeditor.rb" for more configuration options:
|
|
21
|
+
You can pass version of ckeditor to download (http://ckeditor.com/download/releases):
|
|
34
22
|
|
|
35
|
-
rails generate ckeditor:
|
|
23
|
+
rails generate ckeditor:install --version=3.5.4
|
|
36
24
|
|
|
37
|
-
|
|
25
|
+
Now generate models for store uploading files:
|
|
38
26
|
|
|
39
|
-
rails generate ckeditor:
|
|
27
|
+
rails generate ckeditor:models --orm=active_record
|
|
40
28
|
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
Available orms:
|
|
30
|
+
* active_record
|
|
31
|
+
* mongo_mapper (under construction)
|
|
32
|
+
* mongoid (under construction)
|
|
43
33
|
|
|
44
|
-
|
|
34
|
+
Autoload ckeditor models folder (application.rb):
|
|
45
35
|
|
|
46
|
-
|
|
36
|
+
config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
|
|
47
37
|
|
|
48
|
-
|
|
38
|
+
=== Dependencies
|
|
49
39
|
|
|
50
|
-
|
|
40
|
+
For active_record orm is used paperclip gem (it's by default).
|
|
51
41
|
|
|
52
|
-
|
|
42
|
+
gem "paperclip"
|
|
43
|
+
|
|
44
|
+
For gem "carrierwave" shortly I will give an example.
|
|
53
45
|
|
|
54
46
|
== Usage
|
|
55
47
|
|
|
56
|
-
Basically include this in the page you wish to use the editor in:
|
|
57
|
-
|
|
58
48
|
<%= javascript_include_tag :ckeditor %>
|
|
49
|
+
|
|
50
|
+
cktext_area_tag("test_area", "Ckeditor is the best")
|
|
59
51
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
<%= ckeditor_textarea("object", "field", :width => '100%', :height => '200px') %>
|
|
63
|
-
|
|
64
|
-
FormBuilder helper for more usefully:
|
|
65
|
-
|
|
66
|
-
<%= form_for @page do |form| -%>
|
|
67
|
-
...
|
|
68
|
-
<%= form.cktext_area :notes, :toolbar=>'Full', :width=>'400px', :height=>'200px' %>
|
|
69
|
-
...
|
|
70
|
-
<%= form.cktext_area :content, :swf_params=>{:assetable_type=>'User', :assetable_id=>current_user.id} %>
|
|
71
|
-
...
|
|
72
|
-
<% end -%>
|
|
52
|
+
cktext_area_tag("content", "Ckeditor", :input_html => {:cols => 10, :rows => 20}, :toolbar => 'Easy')
|
|
73
53
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
:rows # Textarea rows (default: 20)
|
|
78
|
-
:width # Editor width (default: 100%)
|
|
79
|
-
:height # Editor height (default: 100%)
|
|
80
|
-
:class # Textarea css class name
|
|
81
|
-
:toolbar # Toolbar name
|
|
82
|
-
:skin # Editor skin
|
|
83
|
-
:language # Editor language (default: I18n.locale)
|
|
84
|
-
:swf_params # SWFUpload additional params (Hash)
|
|
85
|
-
:id # textarea DOM element id
|
|
86
|
-
:index # element id index
|
|
54
|
+
* input_html - Options for text_area tag, others for ckeditor javascript configuration.
|
|
55
|
+
* language - appends automatically, by default is I18n.locale
|
|
56
|
+
* available ckeditor options - http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html
|
|
87
57
|
|
|
88
58
|
For configure ckeditor default options check:
|
|
89
59
|
|
|
@@ -92,22 +62,21 @@ For configure ckeditor default options check:
|
|
|
92
62
|
This stylesheet use editor for displaying edit area:
|
|
93
63
|
|
|
94
64
|
public/javascripts/ckeditor/contents.css
|
|
95
|
-
|
|
96
|
-
=== AJAX
|
|
97
65
|
|
|
98
|
-
|
|
66
|
+
FormBuilder helper for more usefully:
|
|
99
67
|
|
|
100
|
-
<%= form_for @page
|
|
101
|
-
<%= form.cktext_area("note", "content") %>
|
|
68
|
+
<%= form_for @page do |form| -%>
|
|
102
69
|
...
|
|
103
|
-
<%= form.cktext_area
|
|
70
|
+
<%= form.cktext_area :notes, :toolbar => 'Full', :width => 800, :height => 400 %>
|
|
104
71
|
...
|
|
105
|
-
<%=
|
|
72
|
+
<%= form.cktext_area :content, :input_html => { :value => "Default value" } %>
|
|
106
73
|
...
|
|
107
|
-
<%=
|
|
108
|
-
<% end
|
|
74
|
+
<%= cktext_area :page, :info %>
|
|
75
|
+
<% end -%>
|
|
76
|
+
|
|
77
|
+
=== AJAX
|
|
109
78
|
|
|
110
|
-
|
|
79
|
+
Jquery sample:
|
|
111
80
|
|
|
112
81
|
<script type='text/javascript' charset='UTF-8'>
|
|
113
82
|
$(document).ready(function(){
|
|
@@ -119,46 +88,76 @@ Helper "ckeditor_ajax_script" generate next script (jquery):
|
|
|
119
88
|
});
|
|
120
89
|
</script>
|
|
121
90
|
|
|
122
|
-
|
|
91
|
+
=== Formtastic integration
|
|
123
92
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
http://github.com/thoughtbot/paperclip
|
|
93
|
+
<%= form.input :content, :as => :ckeditor %>
|
|
94
|
+
<%= form.input :content, :as => :ckeditor, :input_html => { :height => 400 } %>
|
|
128
95
|
|
|
129
|
-
|
|
96
|
+
=== SimpleForm integration
|
|
130
97
|
|
|
131
|
-
|
|
98
|
+
<%= form.ckeditor :content, :label => false, :input_html => { :toolbar => 'Full' } %>
|
|
132
99
|
|
|
133
|
-
|
|
134
|
-
<%= form.input :content, :as => :ckeditor, :input_html => { :height => 400, :swf_params => { ... } } %>
|
|
100
|
+
=== Default scope
|
|
135
101
|
|
|
136
|
-
|
|
102
|
+
For example, you need split assets collection for each user.
|
|
137
103
|
|
|
138
|
-
|
|
104
|
+
class ApplicationController < ActionController::Base
|
|
105
|
+
|
|
106
|
+
protected
|
|
107
|
+
|
|
108
|
+
def ckeditor_filebrowser_scope(options = {})
|
|
109
|
+
super { :assetable_id => current_user.id, :assetable_type => 'User' }.merge(options)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
If your wont filter only pictures or attachment_files - redefine methods "ckeditor_pictures_scope" or "ckeditor_attachment_files_scope" respectively.
|
|
114
|
+
By default, both these methods call "ckeditor_filebrowser_scope" method:
|
|
139
115
|
|
|
140
|
-
|
|
116
|
+
class ApplicationController < ActionController::Base
|
|
117
|
+
|
|
118
|
+
protected
|
|
141
119
|
|
|
142
|
-
|
|
143
|
-
|
|
120
|
+
def ckeditor_pictures_scope(options = {})
|
|
121
|
+
ckeditor_filebrowser_scope(options)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def ckeditor_attachment_files_scope(options = {})
|
|
125
|
+
ckeditor_filebrowser_scope(options)
|
|
126
|
+
end
|
|
127
|
+
end
|
|
144
128
|
|
|
145
|
-
|
|
129
|
+
=== Callbacks
|
|
146
130
|
|
|
147
|
-
|
|
131
|
+
class ApplicationController < ActionController::Base
|
|
132
|
+
|
|
133
|
+
protected
|
|
134
|
+
|
|
135
|
+
# Cancan example
|
|
136
|
+
def ckeditor_authenticate
|
|
137
|
+
authorize! action_name, @asset
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Set current_user as assetable
|
|
141
|
+
def ckeditor_before_create_asset(asset)
|
|
142
|
+
asset.assetable = current_user
|
|
143
|
+
return true
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
== I18n
|
|
148
149
|
|
|
149
150
|
en:
|
|
150
151
|
ckeditor:
|
|
151
152
|
page_title: "CKEditor Files Manager"
|
|
152
|
-
|
|
153
|
+
confirm_delete: "Delete file?"
|
|
153
154
|
buttons:
|
|
154
155
|
cancel: "Cancel"
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
title: "Upload"
|
|
160
|
-
hint: "Upload New File"
|
|
156
|
+
upload: "Upload"
|
|
157
|
+
delete: "Delete"
|
|
158
|
+
|
|
159
|
+
== Tests
|
|
161
160
|
|
|
162
|
-
|
|
161
|
+
rake test
|
|
163
162
|
|
|
164
|
-
|
|
163
|
+
This project rocks and uses MIT-LICENSE.
|
data/Rakefile
CHANGED
|
@@ -1,46 +1,29 @@
|
|
|
1
|
-
# encoding:
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
require 'rubygems'
|
|
3
|
+
begin
|
|
4
|
+
require 'bundler/setup'
|
|
5
|
+
rescue LoadError
|
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
7
|
+
end
|
|
8
|
+
|
|
2
9
|
require 'rake'
|
|
3
|
-
require '
|
|
4
|
-
require 'rake/rdoctask'
|
|
5
|
-
require File.join(File.dirname(__FILE__), 'lib', 'ckeditor', 'version')
|
|
10
|
+
require 'rdoc/task'
|
|
6
11
|
|
|
7
|
-
|
|
8
|
-
task :default => :test
|
|
12
|
+
require 'rake/testtask'
|
|
9
13
|
|
|
10
|
-
desc 'Test the rails-ckeditor plugin.'
|
|
11
14
|
Rake::TestTask.new(:test) do |t|
|
|
12
15
|
t.libs << 'lib'
|
|
13
16
|
t.libs << 'test'
|
|
14
17
|
t.pattern = 'test/**/*_test.rb'
|
|
15
|
-
t.verbose =
|
|
18
|
+
t.verbose = false
|
|
16
19
|
end
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
task :default => :test
|
|
22
|
+
|
|
23
|
+
RDoc::Task.new do |rdoc|
|
|
20
24
|
rdoc.rdoc_dir = 'rdoc'
|
|
21
|
-
rdoc.title = '
|
|
25
|
+
rdoc.title = 'Ckeditor'
|
|
22
26
|
rdoc.options << '--line-numbers' << '--inline-source'
|
|
23
|
-
rdoc.rdoc_files.include('README.
|
|
27
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
24
28
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
25
29
|
end
|
|
26
|
-
|
|
27
|
-
begin
|
|
28
|
-
require 'jeweler'
|
|
29
|
-
Jeweler::Tasks.new do |gemspec|
|
|
30
|
-
gemspec.name = "ckeditor"
|
|
31
|
-
gemspec.version = Ckeditor::Version.dup
|
|
32
|
-
gemspec.summary = "Rails plugin for integration ckeditor 3.x"
|
|
33
|
-
gemspec.description = "CKEditor is a WYSIWYG editor to be used inside web pages"
|
|
34
|
-
gemspec.email = "galeta.igor@gmail.com"
|
|
35
|
-
gemspec.homepage = "http://github.com/galetahub/rails-ckeditor"
|
|
36
|
-
gemspec.authors = ["Igor Galeta"]
|
|
37
|
-
gemspec.files = FileList["[A-Z]*", "{app,config,lib}/**/*"]
|
|
38
|
-
gemspec.rubyforge_project = "ckeditor"
|
|
39
|
-
|
|
40
|
-
gemspec.add_dependency('mime-types', '>= 1.16')
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
Jeweler::GemcutterTasks.new
|
|
44
|
-
rescue LoadError
|
|
45
|
-
puts "Jeweler not available. Install it with: gem install jeweler"
|
|
46
|
-
end
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
class Ckeditor::AttachmentFilesController < Ckeditor::BaseController
|
|
2
2
|
|
|
3
3
|
def index
|
|
4
|
-
@attachments = Ckeditor.
|
|
4
|
+
@attachments = Ckeditor.attachment_file_model.find_all(ckeditor_attachment_files_scope)
|
|
5
5
|
respond_with(@attachments)
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
def create
|
|
9
|
-
@attachment = Ckeditor.
|
|
9
|
+
@attachment = Ckeditor::AttachmentFile.new
|
|
10
10
|
respond_with_asset(@attachment)
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def destroy
|
|
14
14
|
@attachment.destroy
|
|
15
|
-
respond_with(@attachment, :location =>
|
|
15
|
+
respond_with(@attachment, :location => ckeditor_attachment_files_path)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
protected
|
|
19
19
|
|
|
20
20
|
def find_asset
|
|
21
|
-
@attachment = Ckeditor.
|
|
21
|
+
@attachment = Ckeditor.attachment_file_model.get!(params[:id])
|
|
22
22
|
end
|
|
23
23
|
end
|
|
@@ -1,55 +1,28 @@
|
|
|
1
1
|
class Ckeditor::BaseController < ApplicationController
|
|
2
|
-
skip_before_filter :verify_authenticity_token, :only => [:create]
|
|
3
|
-
|
|
4
|
-
before_filter :swf_options, :only => [:index, :create]
|
|
5
|
-
before_filter :find_asset, :only => [:destroy]
|
|
6
|
-
|
|
7
2
|
respond_to :html, :json
|
|
8
|
-
|
|
9
3
|
layout "ckeditor"
|
|
4
|
+
|
|
5
|
+
before_filter :set_locale
|
|
6
|
+
before_filter :find_asset, :only => [:destroy]
|
|
7
|
+
before_filter :ckeditor_authenticate
|
|
10
8
|
|
|
11
9
|
protected
|
|
12
10
|
|
|
13
|
-
def
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
@file_size_limit = Ckeditor.swf_image_file_size_limit
|
|
18
|
-
@file_types = Ckeditor.swf_image_file_types
|
|
19
|
-
@file_types_description = Ckeditor.swf_image_file_types_description
|
|
20
|
-
@file_upload_limit = Ckeditor.swf_image_file_upload_limit
|
|
21
|
-
else
|
|
22
|
-
@file_size_limit = Ckeditor.swf_file_size_limit
|
|
23
|
-
@file_types = Ckeditor.swf_file_types
|
|
24
|
-
@file_types_description = Ckeditor.swf_file_types_description
|
|
25
|
-
@file_upload_limit = Ckeditor.swf_file_upload_limit
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
@swf_file_post_name ||= 'data'
|
|
29
|
-
@file_size_limit ||= "5 MB"
|
|
30
|
-
@file_types ||= "*.jpg;*.jpeg;*.png;*.gif"
|
|
31
|
-
@file_types_description ||= "Images"
|
|
32
|
-
@file_upload_limit ||= 10
|
|
11
|
+
def set_locale
|
|
12
|
+
if !params[:langCode].blank? && I18n.available_locales.include?(params[:langCode].to_sym)
|
|
13
|
+
I18n.locale = params[:langCode]
|
|
14
|
+
end
|
|
33
15
|
end
|
|
34
16
|
|
|
35
|
-
def respond_with_asset(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
end
|
|
17
|
+
def respond_with_asset(asset)
|
|
18
|
+
file = params[:CKEditor].blank? ? params[:qqfile] : params[:upload]
|
|
19
|
+
asset.data = Ckeditor::Http.normalize_param(file, request)
|
|
39
20
|
|
|
40
|
-
|
|
21
|
+
callback = ckeditor_before_create_asset(asset)
|
|
41
22
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
record.attributes = options
|
|
48
|
-
record.user ||= current_user if respond_to?(:current_user)
|
|
49
|
-
|
|
50
|
-
if record.valid? && record.save
|
|
51
|
-
body = params[:CKEditor].blank? ? record.to_json(:only=>[:id, :type], :methods=>[:url, :content_type, :size, :filename, :format_created_at], :root => "asset") : %Q"<script type='text/javascript'>
|
|
52
|
-
window.parent.CKEDITOR.tools.callFunction(#{params[:CKEditorFuncNum]}, '#{Ckeditor::Utils.escape_single_quotes(record.url_content)}');
|
|
23
|
+
if callback && asset.save
|
|
24
|
+
body = params[:CKEditor].blank? ? asset.to_json(:only=>[:id, :type]) : %Q"<script type='text/javascript'>
|
|
25
|
+
window.parent.CKEDITOR.tools.callFunction(#{params[:CKEditorFuncNum]}, '#{Ckeditor::Utils.escape_single_quotes(asset.url_content)}');
|
|
53
26
|
</script>"
|
|
54
27
|
|
|
55
28
|
render :text => body
|