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.
Files changed (179) hide show
  1. data/Gemfile +23 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +96 -97
  4. data/Rakefile +16 -33
  5. data/app/controllers/ckeditor/attachment_files_controller.rb +4 -4
  6. data/app/controllers/ckeditor/base_controller.rb +15 -42
  7. data/app/controllers/ckeditor/pictures_controller.rb +3 -3
  8. data/app/views/ckeditor/attachment_files/index.html.erb +13 -51
  9. data/app/views/ckeditor/pictures/index.html.erb +14 -52
  10. data/app/views/ckeditor/shared/_asset.html.erb +19 -0
  11. data/app/views/ckeditor/shared/_asset_tmpl.html.erb +21 -0
  12. data/app/views/layouts/ckeditor.html.erb +16 -23
  13. data/config/locales/en.ckeditor.yml +3 -7
  14. data/config/locales/ru.ckeditor.yml +4 -8
  15. data/config/locales/uk.ckeditor.yml +4 -8
  16. data/config/routes.rb +3 -3
  17. data/lib/ckeditor.rb +30 -79
  18. data/lib/ckeditor/engine.rb +14 -13
  19. data/lib/ckeditor/helpers/controllers.rb +30 -0
  20. data/lib/ckeditor/helpers/form_builder.rb +11 -0
  21. data/lib/ckeditor/helpers/form_helper.rb +25 -0
  22. data/lib/ckeditor/helpers/view_helper.rb +19 -0
  23. data/lib/ckeditor/http.rb +81 -0
  24. data/lib/ckeditor/orm/active_record.rb +91 -0
  25. data/lib/ckeditor/utils.rb +51 -70
  26. data/lib/ckeditor/version.rb +2 -7
  27. data/lib/generators/ckeditor/install_generator.rb +62 -0
  28. data/lib/generators/ckeditor/models_generator.rb +51 -0
  29. data/lib/generators/ckeditor/templates/ckeditor.rb +18 -0
  30. data/lib/generators/ckeditor/templates/ckeditor/config.js +52 -0
  31. data/lib/generators/ckeditor/templates/ckeditor/filebrowser/images/gal_add.jpg +0 -0
  32. data/lib/generators/ckeditor/templates/ckeditor/filebrowser/images/gal_add.png +0 -0
  33. data/lib/generators/ckeditor/templates/ckeditor/filebrowser/images/gal_del.png +0 -0
  34. data/lib/generators/ckeditor/templates/ckeditor/filebrowser/images/gal_more.gif +0 -0
  35. data/lib/generators/ckeditor/templates/ckeditor/filebrowser/images/preloader.gif +0 -0
  36. data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/ckfnothumb.gif +0 -0
  37. data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/mp3.gif +0 -0
  38. data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/pdf.gif +0 -0
  39. data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/rar.gif +0 -0
  40. data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/swf.gif +0 -0
  41. data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/xls.gif +0 -0
  42. data/lib/generators/ckeditor/templates/ckeditor/filebrowser/javascripts/application.js +222 -0
  43. data/lib/generators/ckeditor/templates/ckeditor/filebrowser/stylesheets/uploader.css +112 -0
  44. data/lib/generators/ckeditor/{base/templates → templates}/ckeditor/plugins/attachment/dialogs/attachment.js +0 -0
  45. data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/attachment/images/attachment.png +0 -0
  46. data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/attachment/lang/en.js +0 -0
  47. data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/attachment/lang/ru.js +0 -0
  48. data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/attachment/lang/uk.js +0 -0
  49. data/lib/generators/ckeditor/{base/templates → templates}/ckeditor/plugins/attachment/plugin.js +0 -0
  50. data/lib/generators/ckeditor/{base/templates → templates}/ckeditor/plugins/embed/dialogs/embed.js +0 -0
  51. data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/embed/images/embed.png +0 -0
  52. data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/embed/lang/en.js +0 -0
  53. data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/embed/lang/ru.js +0 -0
  54. data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/embed/lang/uk.js +0 -0
  55. data/lib/generators/ckeditor/{base/templates → templates}/ckeditor/plugins/embed/plugin.js +0 -0
  56. data/lib/generators/ckeditor/templates/models/active_record/asset.rb +7 -0
  57. data/lib/generators/ckeditor/templates/models/active_record/attachment_file.rb +15 -0
  58. data/lib/generators/ckeditor/{migration/templates/models/paperclip → templates/models/active_record}/migration.rb +3 -8
  59. data/lib/generators/ckeditor/templates/models/active_record/picture.rb +13 -0
  60. data/test/ckeditor_test.rb +13 -0
  61. data/test/controllers/attachment_files_controller_test.rb +52 -0
  62. data/test/controllers/pictures_controller_test.rb +52 -0
  63. data/test/dummy/Rakefile +7 -0
  64. data/test/dummy/app/controllers/application_controller.rb +4 -0
  65. data/test/dummy/app/controllers/posts_controller.rb +83 -0
  66. data/test/dummy/app/helpers/application_helper.rb +2 -0
  67. data/test/dummy/app/helpers/posts_helper.rb +2 -0
  68. data/test/dummy/app/models/ckeditor/asset.rb +7 -0
  69. data/test/dummy/app/models/ckeditor/attachment_file.rb +15 -0
  70. data/test/dummy/app/models/ckeditor/picture.rb +13 -0
  71. data/test/dummy/app/models/post.rb +3 -0
  72. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  73. data/test/dummy/app/views/posts/_form.html.erb +30 -0
  74. data/test/dummy/app/views/posts/edit.html.erb +6 -0
  75. data/test/dummy/app/views/posts/index.html.erb +27 -0
  76. data/test/dummy/app/views/posts/new.html.erb +5 -0
  77. data/test/dummy/app/views/posts/show.html.erb +5 -0
  78. data/test/dummy/config.ru +4 -0
  79. data/test/dummy/config/application.rb +46 -0
  80. data/test/dummy/config/boot.rb +10 -0
  81. data/test/dummy/config/database.yml +34 -0
  82. data/test/dummy/config/environment.rb +5 -0
  83. data/test/dummy/config/environments/development.rb +26 -0
  84. data/test/dummy/config/environments/production.rb +49 -0
  85. data/test/dummy/config/environments/test.rb +35 -0
  86. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  87. data/test/dummy/config/initializers/ckeditor.rb +18 -0
  88. data/test/dummy/config/initializers/inflections.rb +10 -0
  89. data/test/dummy/config/initializers/mime_types.rb +5 -0
  90. data/test/dummy/config/initializers/secret_token.rb +7 -0
  91. data/test/dummy/config/initializers/session_store.rb +8 -0
  92. data/test/dummy/config/locales/en.yml +5 -0
  93. data/test/dummy/config/routes.rb +4 -0
  94. data/test/dummy/db/migrate/20110623120047_create_posts.rb +14 -0
  95. data/test/dummy/db/migrate/20110705195648_create_ckeditor_assets.rb +26 -0
  96. data/test/dummy/db/schema.rb +36 -0
  97. data/test/dummy/log/development.log +818 -0
  98. data/test/dummy/log/production.log +0 -0
  99. data/test/dummy/log/server.log +0 -0
  100. data/test/dummy/log/test.log +5398 -0
  101. data/test/dummy/public/404.html +26 -0
  102. data/test/dummy/public/422.html +26 -0
  103. data/test/dummy/public/500.html +26 -0
  104. data/test/dummy/public/favicon.ico +0 -0
  105. data/test/dummy/public/javascripts/application.js +2 -0
  106. data/test/dummy/public/javascripts/controls.js +965 -0
  107. data/test/dummy/public/javascripts/dragdrop.js +974 -0
  108. data/test/dummy/public/javascripts/effects.js +1123 -0
  109. data/test/dummy/public/javascripts/prototype.js +6001 -0
  110. data/test/dummy/public/javascripts/rails.js +191 -0
  111. data/test/dummy/public/stylesheets/scaffold.css +56 -0
  112. data/test/dummy/script/rails +6 -0
  113. data/test/dummy/test/fixtures/files/rails.png +0 -0
  114. data/test/dummy/test/fixtures/files/rails.tar.gz +0 -0
  115. data/test/generators/install_generator_test.rb +18 -0
  116. data/test/generators/models_generator_test.rb +21 -0
  117. data/test/integration/navigation_test.rb +7 -0
  118. data/test/integration/posts_test.rb +41 -0
  119. data/test/routes_test.rb +47 -0
  120. data/test/support/integration_case.rb +5 -0
  121. data/test/test_helper.rb +28 -0
  122. data/test/tmp/app/models/ckeditor/asset.rb +7 -0
  123. data/test/tmp/app/models/ckeditor/attachment_file.rb +15 -0
  124. data/test/tmp/app/models/ckeditor/picture.rb +13 -0
  125. data/test/tmp/db/migrate/20110711170413_create_ckeditor_assets.rb +26 -0
  126. metadata +220 -99
  127. data/CHANGELOG +0 -15
  128. data/app/helpers/ckeditor/base_helper.rb +0 -21
  129. data/app/views/ckeditor/_asset.html.erb +0 -20
  130. data/app/views/ckeditor/_swfupload.html.erb +0 -73
  131. data/lib/ckeditor/form_builder.rb +0 -22
  132. data/lib/ckeditor/middleware.rb +0 -18
  133. data/lib/ckeditor/view_helper.rb +0 -92
  134. data/lib/generators/ckeditor/base/USAGE +0 -9
  135. data/lib/generators/ckeditor/base/base_generator.rb +0 -41
  136. data/lib/generators/ckeditor/base/templates/ckeditor.rb +0 -54
  137. data/lib/generators/ckeditor/base/templates/ckeditor/_source/plugins/attachment/dialogs/attachment.js +0 -384
  138. data/lib/generators/ckeditor/base/templates/ckeditor/_source/plugins/attachment/plugin.js +0 -44
  139. data/lib/generators/ckeditor/base/templates/ckeditor/_source/plugins/embed/dialogs/embed.js +0 -65
  140. data/lib/generators/ckeditor/base/templates/ckeditor/_source/plugins/embed/plugin.js +0 -43
  141. data/lib/generators/ckeditor/base/templates/ckeditor/config.js +0 -43
  142. data/lib/generators/ckeditor/base/templates/ckeditor/css/ckfinder.css +0 -316
  143. data/lib/generators/ckeditor/base/templates/ckeditor/css/fck_dialog.css +0 -119
  144. data/lib/generators/ckeditor/base/templates/ckeditor/css/fck_editor.css +0 -448
  145. data/lib/generators/ckeditor/base/templates/ckeditor/css/swfupload.css +0 -94
  146. data/lib/generators/ckeditor/base/templates/ckeditor/images/add.gif +0 -0
  147. data/lib/generators/ckeditor/base/templates/ckeditor/images/cancelbutton.gif +0 -0
  148. data/lib/generators/ckeditor/base/templates/ckeditor/images/doc.gif +0 -0
  149. data/lib/generators/ckeditor/base/templates/ckeditor/images/refresh.gif +0 -0
  150. data/lib/generators/ckeditor/base/templates/ckeditor/images/select_files.png +0 -0
  151. data/lib/generators/ckeditor/base/templates/ckeditor/images/spacer.gif +0 -0
  152. data/lib/generators/ckeditor/base/templates/ckeditor/images/toolbar.start.gif +0 -0
  153. data/lib/generators/ckeditor/base/templates/ckeditor/plugins/attachment/images/attachment.png +0 -0
  154. data/lib/generators/ckeditor/base/templates/ckeditor/plugins/attachment/lang/en.js +0 -10
  155. data/lib/generators/ckeditor/base/templates/ckeditor/plugins/attachment/lang/ru.js +0 -10
  156. data/lib/generators/ckeditor/base/templates/ckeditor/plugins/attachment/lang/uk.js +0 -10
  157. data/lib/generators/ckeditor/base/templates/ckeditor/plugins/embed/images/embed.png +0 -0
  158. data/lib/generators/ckeditor/base/templates/ckeditor/plugins/embed/lang/en.js +0 -9
  159. data/lib/generators/ckeditor/base/templates/ckeditor/plugins/embed/lang/ru.js +0 -9
  160. data/lib/generators/ckeditor/base/templates/ckeditor/plugins/embed/lang/uk.js +0 -9
  161. data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/fileprogress.js +0 -266
  162. data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/handlers.js +0 -181
  163. data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/jquery-1.5.1.min.js +0 -16
  164. data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/querystring.js +0 -40
  165. data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/rails.js +0 -158
  166. data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/swfupload.js +0 -1
  167. data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/swfupload.queue.js +0 -1
  168. data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/swfupload.swf +0 -0
  169. data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/swfupload.swfobject.js +0 -111
  170. data/lib/generators/ckeditor/migration/USAGE +0 -12
  171. data/lib/generators/ckeditor/migration/migration_generator.rb +0 -46
  172. data/lib/generators/ckeditor/migration/templates/models/attachment_fu/asset.rb +0 -32
  173. data/lib/generators/ckeditor/migration/templates/models/attachment_fu/attachment_file.rb +0 -24
  174. data/lib/generators/ckeditor/migration/templates/models/attachment_fu/migration.rb +0 -30
  175. data/lib/generators/ckeditor/migration/templates/models/attachment_fu/picture.rb +0 -25
  176. data/lib/generators/ckeditor/migration/templates/models/paperclip/asset.rb +0 -97
  177. data/lib/generators/ckeditor/migration/templates/models/paperclip/attachment_file.rb +0 -40
  178. data/lib/generators/ckeditor/migration/templates/models/paperclip/picture.rb +0 -23
  179. data/lib/tasks/ckeditor_tasks.rake +0 -3
@@ -1,20 +0,0 @@
1
- <div class="FCKThumb">
2
- <%= link_to('&nbsp'.html_safe, polymorphic_path(asset, :format => :json),
3
- :method => :delete, :remote => true, :class => 'FCKFileDelete') %>
4
-
5
- <div class='FCKAsset'>
6
- <table border="0" cellpadding="0" cellspacing="0" height="100" width="100">
7
- <tbody>
8
- <tr>
9
- <td align="center" valign="middle">
10
- <%= image_tag(asset.url_thumb, :alt => asset.url_content, :title => asset.filename, :onerror=>"this.src='/javascripts/ckeditor/images/ckfnothumb.gif'", :class=>'image') %>
11
- </td>
12
- </tr>
13
- </tbody>
14
- </table>
15
-
16
- <div class="FCKFileName"><%= asset.filename %></div>
17
- <div class="FCKFileDate"><%= asset.format_created_at %></div>
18
- <div class="FCKFileSize"><%= number_to_human_size(asset.size, :precision => 2) %></div>
19
- </div>
20
- </div>
@@ -1,73 +0,0 @@
1
- <script type="text/javascript">
2
- var swfu = null;
3
-
4
- window.onload = function()
5
- {
6
- var f = new FileThumb('qu');
7
- var t = new ToolBar('nv');
8
-
9
- var b1 = new Button('<%= I18n.t("upload.hint", :scope => [:ckeditor, :buttons]) %>', '<%= I18n.t("upload.title", :scope => [:ckeditor, :buttons]) %>', 'add.gif');
10
- var b2 = new Button('<%= I18n.t("refresh.hint", :scope => [:ckeditor, :buttons]) %>', '<%= I18n.t("refresh.title", :scope => [:ckeditor, :buttons]) %>', 'refresh.gif');
11
-
12
- b1.callback = uploadButton;
13
- b2.callback = function(){ window.location.reload(); }
14
-
15
- t.buttons.push(b1);
16
- t.buttons.push(b2);
17
-
18
- t.init();
19
- init_swfupload();
20
-
21
- $('a.FCKFileDelete').bind('ajax:complete', function(){
22
- $(this).parents('div.FCKThumb').remove();
23
- });
24
- }
25
-
26
- function init_swfupload() {
27
- var params = editor.config['swf_params'];
28
-
29
- swfu = new SWFUpload({
30
- // Backend settings
31
- upload_url: upload_path,
32
- post_params: params,
33
- file_post_name: "<%= @swf_file_post_name %>",
34
-
35
- // Flash file settings
36
- file_size_limit : "<%= @file_size_limit %>",
37
- file_types : "<%= @file_types %>",
38
- file_types_description : "<%= @file_types_description %>",
39
- file_upload_limit : "<%= @file_upload_limit %>",
40
- file_queue_limit : 0,
41
-
42
- // The event handler functions are defined in handlers.js
43
- //swfupload_loaded_handler : swfUploadLoaded,
44
- file_queued_handler : fileQueued,
45
- file_queue_error_handler : fileQueueError,
46
- file_dialog_complete_handler : fileDialogComplete,
47
- upload_start_handler : uploadStart,
48
- upload_progress_handler : uploadProgress,
49
- upload_error_handler : uploadError,
50
- upload_success_handler : uploadSuccess,
51
- upload_complete_handler : uploadComplete,
52
- queue_complete_handler : queueComplete, // Queue plugin event
53
-
54
- // Button Settings
55
- button_image_url : "/javascripts/ckeditor/images/select_files.png",
56
- button_placeholder_id : "spanButtonPlaceholder",
57
- button_width: 117,
58
- button_height: 29,
59
- button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
60
- button_cursor: SWFUpload.CURSOR.HAND,
61
-
62
- // Flash Settings
63
- flash_url : "/javascripts/ckeditor/swfupload/swfupload.swf",
64
-
65
- custom_settings : {
66
- progressTarget : "divFileProgressContainer"
67
- },
68
-
69
- // Debug settings
70
- debug: false
71
- });
72
- };
73
- </script>
@@ -1,22 +0,0 @@
1
- module Ckeditor
2
- module FormBuilder
3
- def self.included(base)
4
- base.send(:include, Ckeditor::ViewHelper)
5
- base.send(:include, Ckeditor::FormBuilder::ClassMethods)
6
- end
7
-
8
- module ClassMethods
9
- # Example:
10
- # <% form_for :post, :url => posts_path do |form| %>
11
- # ...
12
- # <%= form.cktext_area :notes, :toolbar=>'Full', :width=>'400px', :heigth=>'200px' %>
13
- # <% end %>
14
- #
15
- # With swfupload options:
16
- # <%= form.cktext_area :content, :swf_params=>{:assetable_type=>'User', :assetable_id=>current_user.id} %>
17
- def cktext_area(method, options = {})
18
- ckeditor_textarea(@object_name, method, objectify_options(options))
19
- end
20
- end
21
- end
22
- end
@@ -1,18 +0,0 @@
1
- require 'rack/utils'
2
-
3
- module Ckeditor
4
- class Middleware
5
- def initialize(app, session_key = '_session_id')
6
- @app = app
7
- @session_key = session_key
8
- end
9
-
10
- def call(env)
11
- if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave)\s+Flash/
12
- params = ::Rack::Utils.parse_query(env['QUERY_STRING'])
13
- env['HTTP_COOKIE'] = [ @session_key, ::Rack::Utils.unescape(params[@session_key]) ].join('=').freeze unless params[@session_key].nil?
14
- end
15
- @app.call(env)
16
- end
17
- end
18
- end
@@ -1,92 +0,0 @@
1
- module Ckeditor
2
- module ViewHelper
3
- include ActionView::Helpers::JavaScriptHelper
4
- include ActionView::Helpers::TagHelper
5
-
6
- # Ckeditor helper:
7
- # <%= ckeditor_textarea("object", "field", :width => '100%', :height => '200px') %>
8
- #
9
- # Two forms on one page:
10
- # <%= form_tag "one" %>
11
- # <%= ckeditor_textarea("object", "field", :index => "1") %>
12
- # <% end %>
13
- # ...
14
- # <%= form_tag "two" %>
15
- # <%= ckeditor_textarea("object", "field", :index => "2") %>
16
- # <% end %>
17
- #
18
- def ckeditor_textarea(object_name, field, options = {})
19
- options = options.dup.symbolize_keys
20
-
21
- object = options.delete(:object) if options.key?(:object)
22
- object ||= @template.instance_variable_get("@#{object_name}")
23
-
24
- value = options.delete(:value) if options.key?(:value)
25
- value ||= object.send(field)
26
-
27
- element_id = options.delete(:id) || ckeditor_element_id(object_name, field, options.delete(:index))
28
- width = options.delete(:width) || '100%'
29
- height = options.delete(:height) || '100%'
30
-
31
- textarea_options = { :id => element_id }
32
-
33
- textarea_options[:cols] = (options.delete(:cols) || 70).to_i
34
- textarea_options[:rows] = (options.delete(:rows) || 20).to_i
35
- textarea_options[:class] = (options.delete(:class) || 'editor').to_s
36
- textarea_options[:style] = "width:#{width};height:#{height}"
37
-
38
- ckeditor_options = {:width => width, :height => height }
39
- ckeditor_options[:language] = (options.delete(:language) || I18n.locale).to_s
40
- ckeditor_options[:toolbar] = options.delete(:toolbar) if options[:toolbar]
41
- ckeditor_options[:skin] = options.delete(:skin) if options[:skin]
42
-
43
- ckeditor_options[:swf_params] = options.delete(:swf_params) if options[:swf_params]
44
-
45
- ckeditor_options[:filebrowserBrowseUrl] = Ckeditor.file_manager_uri
46
- ckeditor_options[:filebrowserUploadUrl] = Ckeditor.file_manager_upload_uri
47
-
48
- ckeditor_options[:filebrowserImageBrowseUrl] = Ckeditor.file_manager_image_uri
49
- ckeditor_options[:filebrowserImageUploadUrl] = Ckeditor.file_manager_image_upload_uri
50
-
51
- output_buffer = ActiveSupport::SafeBuffer.new
52
-
53
- output_buffer << ActionView::Base::InstanceTag.new(object_name, field, self, object).to_text_area_tag(textarea_options.merge(options))
54
-
55
- output_buffer << javascript_tag("if (CKEDITOR.instances['#{element_id}']) {
56
- CKEDITOR.remove(CKEDITOR.instances['#{element_id}']);}
57
- CKEDITOR.replace('#{element_id}', { #{ckeditor_applay_options(ckeditor_options)} });")
58
-
59
- output_buffer
60
- end
61
-
62
- def ckeditor_ajax_script(backend = 'jquery')
63
- javascript_tag("$(document).ready(function(){
64
- $('form[data-remote]').bind('ajax:before', function(){
65
- for (instance in CKEDITOR.instances){
66
- CKEDITOR.instances[instance].updateElement();
67
- }
68
- });
69
- });")
70
- end
71
-
72
- protected
73
-
74
- def ckeditor_element_id(object_name, field, index = nil)
75
- [object_name, index, field, 'editor'].compact.join('_')
76
- end
77
-
78
- def ckeditor_applay_options(options={})
79
- str = []
80
- options.each do |k, v|
81
- value = case v.class.to_s.downcase
82
- when 'string' then "'#{v}'"
83
- when 'hash' then "{ #{ckeditor_applay_options(v)} }"
84
- else v
85
- end
86
- str << "#{k}: #{value}"
87
- end
88
-
89
- str.join(',')
90
- end
91
- end
92
- end
@@ -1,9 +0,0 @@
1
- CKEditor
2
- ========
3
-
4
- # Download and extract ckeditor's core files into 'public/javascripts'
5
- # and generate configuration file in 'config/initializers/ckeditor.rb'
6
-
7
- rails generate ckeditor:base
8
-
9
- rails generate ckeditor:base version=3.5.2
@@ -1,41 +0,0 @@
1
- require 'rails/generators'
2
-
3
- module Ckeditor
4
- class BaseGenerator < Rails::Generators::Base
5
- class_option :version, :type => :string, :default => '3.6',
6
- :desc => "Version of ckeditor which be install"
7
-
8
- def self.source_root
9
- @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
10
- end
11
-
12
- # copy configuration
13
- def copy_initializer
14
- template "ckeditor.rb", "config/initializers/ckeditor.rb"
15
- end
16
-
17
- # copy ckeditor files
18
- def install_ckeditor
19
- puts "Start download #{filename}"
20
- file = Ckeditor::Utils.download(download_url)
21
-
22
- if File.exist?(file.path)
23
- Ckeditor::Utils.extract(file.path, Rails.root.join('public', 'javascripts'))
24
- directory "ckeditor", "public/javascripts/ckeditor"
25
- file.unlink
26
- else
27
- raise Rails::Generators::Error.new("Cannot download file #{download_url}")
28
- end
29
- end
30
-
31
- protected
32
-
33
- def download_url
34
- "http://download.cksource.com/CKEditor/CKEditor/CKEditor%20#{options[:version]}/ckeditor_#{options[:version]}.tar.gz"
35
- end
36
-
37
- def filename
38
- "ckeditor_#{options[:version]}.tar.gz"
39
- end
40
- end
41
- end
@@ -1,54 +0,0 @@
1
- # Use this hook to configure ckeditor
2
- if Object.const_defined?("Ckeditor")
3
- Ckeditor.setup do |config|
4
- # The file_post_name allows you to set the value name used to post the file.
5
- # This is not related to the file name. The default value is 'data'.
6
- # For maximum compatibility it is recommended that the default value is used.
7
- #config.swf_file_post_name = "data"
8
-
9
- # A text description that is displayed to the user in the File Browser dialog.
10
- #config.swf_file_types_description = "Files"
11
-
12
- # The file_types setting accepts a semi-colon separated list of file extensions
13
- # that are allowed to be selected by the user. Use '*.*' to allow all file types.
14
- #config.swf_file_types = "*.doc;*.wpd;*.pdf;*.swf;*.xls"
15
-
16
- # The file_size_limit setting defines the maximum allowed size of a file to be uploaded.
17
- # This setting accepts a value and unit. Valid units are B, KB, MB and GB.
18
- # If the unit is omitted default is KB. A value of 0 (zero) is interpreted as unlimited.
19
- # Note: This setting only applies to the user's browser. It does not affect any settings or limits on the web server.
20
- #config.swf_file_size_limit = "10 MB"
21
-
22
- # Defines the number of files allowed to be uploaded by SWFUpload.
23
- # This setting also sets the upper bound of the file_queue_limit setting.
24
- # Once the user has uploaded or queued the maximum number of files she will
25
- # no longer be able to queue additional files. The value of 0 (zero) is interpreted as unlimited.
26
- # Only successful uploads (uploads the trigger the uploadSuccess event) are counted toward the upload limit.
27
- # The setStats function can be used to modify the number of successful uploads.
28
- # Note: This value is not tracked across pages and is reset when a page is refreshed.
29
- # File quotas should be managed by the web server.
30
- #config.swf_file_upload_limit = 5
31
-
32
- # The same as for downloads files, only to upload images
33
- #config.swf_image_file_types_description = "Images"
34
- #config.swf_image_file_types = "*.jpg;*.jpeg;*.png;*.gif"
35
- #config.swf_image_file_size_limit = "5 MB"
36
- #config.swf_image_file_upload_limit = 10
37
-
38
- # Path for view all uploaded files
39
- #config.file_manager_uri = "/ckeditor/attachments"
40
-
41
- # Path for upload files process
42
- #config.file_manager_upload_uri = "/ckeditor/attachments"
43
-
44
- # Path for view all uploaded images
45
- #config.file_manager_image_uri = "/ckeditor/pictures"
46
-
47
- # Path for upload images process
48
- #config.file_manager_image_upload_uri = "/ckeditor/pictures"
49
-
50
- # Model's names witch processing in ckeditor_controller
51
- #config.file_manager_image_model = "Ckeditor::Picture"
52
- #config.file_manager_file_model = "Ckeditor::AttachmentFile"
53
- end
54
- end
@@ -1,384 +0,0 @@
1
- /*
2
- Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
3
- For licensing, see LICENSE.html or http://ckeditor.com/license
4
- */
5
-
6
- (function()
7
- {
8
- CKEDITOR.dialog.add( 'attachment', function( editor )
9
- {
10
- var selectableTargets = /^(_(?:self|top|parent|blank))$/;
11
-
12
- var parseLink = function( editor, element )
13
- {
14
- var href = element ? ( element.getAttribute( '_cke_saved_href' ) || element.getAttribute( 'href' ) ) : '',
15
- emailMatch,
16
- anchorMatch,
17
- urlMatch,
18
- retval = {};
19
-
20
- retval.type = 'url';
21
- retval.url = href;
22
-
23
- // Load target and popup settings.
24
- if ( element )
25
- {
26
- var target = element.getAttribute( 'target' );
27
- retval.target = {};
28
-
29
- // IE BUG: target attribute is an empty string instead of null in IE if it's not set.
30
- if ( target )
31
- {
32
- var targetMatch = target.match( selectableTargets );
33
- if ( targetMatch )
34
- retval.target.type = retval.target.name = target;
35
- else
36
- {
37
- retval.target.type = 'frame';
38
- retval.target.name = target;
39
- }
40
- }
41
-
42
- var me = this;
43
-
44
- retval.title = element.getAttribute('title');
45
- }
46
-
47
- // Find out whether we have any anchors in the editor.
48
- // Get all IMG elements in CK document.
49
- var elements = editor.document.getElementsByTag( 'img' ),
50
- realAnchors = new CKEDITOR.dom.nodeList( editor.document.$.anchors ),
51
- anchors = retval.anchors = [];
52
-
53
- for( var i = 0; i < elements.count() ; i++ )
54
- {
55
- var item = elements.getItem( i );
56
- if ( item.getAttribute( '_cke_realelement' ) && item.getAttribute( '_cke_real_element_type' ) == 'anchor' )
57
- {
58
- anchors.push( editor.restoreRealElement( item ) );
59
- }
60
- }
61
-
62
- for ( i = 0 ; i < realAnchors.count() ; i++ )
63
- anchors.push( realAnchors.getItem( i ) );
64
-
65
- for ( i = 0 ; i < anchors.length ; i++ )
66
- {
67
- item = anchors[ i ];
68
- anchors[ i ] = { name : item.getAttribute( 'name' ), id : item.getAttribute( 'id' ) };
69
- }
70
-
71
- // Record down the selected element in the dialog.
72
- this._.selectedElement = element;
73
-
74
- return retval;
75
- };
76
- // Handles the event when the "Target" selection box is changed.
77
- var targetChanged = function()
78
- {
79
- var dialog = this.getDialog(),
80
- targetName = dialog.getContentElement( 'general', 'linkTargetName' ),
81
- value = this.getValue();
82
-
83
- if ( !targetName )
84
- return;
85
-
86
- targetName.setLabel( editor.lang.link.targetFrameName );
87
- this.getDialog().setValueOf( 'general', 'linkTargetName', value.charAt( 0 ) == '_' ? value : '' );
88
- };
89
-
90
- function parseUrl(url)
91
- {
92
- var filename = url.split('/').pop();
93
- var extname = filename.split('.').pop();
94
-
95
- return { filename : filename, className : "attach_" + extname };
96
- }
97
-
98
- return {
99
- title : editor.lang.attachment.title,
100
- minWidth : 420,
101
- minHeight : 200,
102
-
103
- onShow : function()
104
- {
105
- this.fakeObj = false;
106
-
107
- var editor = this.getParentEditor(),
108
- selection = editor.getSelection(),
109
- ranges = selection.getRanges(),
110
- element = null,
111
- me = this;
112
- // Fill in all the relevant fields if there's already one link selected.
113
- if ( ranges.length == 1 )
114
- {
115
-
116
- var rangeRoot = ranges[0].getCommonAncestor( true );
117
- element = rangeRoot.getAscendant( 'a', true );
118
- if ( element && element.getAttribute( 'href' ) )
119
- {
120
- selection.selectElement( element );
121
- }
122
- else if ( ( element = rangeRoot.getAscendant( 'img', true ) ) &&
123
- element.getAttribute( '_cke_real_element_type' ) &&
124
- element.getAttribute( '_cke_real_element_type' ) == 'anchor' )
125
- {
126
- this.fakeObj = element;
127
- element = editor.restoreRealElement( this.fakeObj );
128
- selection.selectElement( this.fakeObj );
129
- }
130
- else
131
- element = null;
132
- }
133
-
134
- this.setupContent( parseLink.apply( this, [ editor, element ] ) );
135
- },
136
-
137
- onOk : function()
138
- {
139
- var attributes = { href : 'javascript:void(0)/*' + CKEDITOR.tools.getNextNumber() + '*/' },
140
- removeAttributes = [],
141
- data = { href : attributes.href },
142
- me = this,
143
- editor = this.getParentEditor();
144
-
145
- this.commitContent( data );
146
-
147
-
148
- var url = data.url || '';
149
- attributes._cke_saved_href = ( url.indexOf( '/' ) === 0 ) ? url : "http://" + url;
150
-
151
- var file = parseUrl(url);
152
-
153
- var title = data.title || '';
154
- attributes.title = (data.title.length == 0) ? file.filename : data.title;
155
- attributes.class = file.className;
156
-
157
- // Popups and target.
158
- if ( data.target )
159
- {
160
- if ( data.target.type != 'notSet' && data.target.name )
161
- attributes.target = data.target.name;
162
- else
163
- removeAttributes.push( 'target' );
164
-
165
- removeAttributes.push( '_cke_pa_onclick', 'onclick' );
166
- }
167
-
168
- // Insert Link
169
- if ( !this._.selectedElement )
170
- {
171
- // Create element if current selection is collapsed.
172
- var selection = editor.getSelection(),
173
- ranges = selection.getRanges();
174
- if ( ranges.length == 1 && ranges[0].collapsed )
175
- {
176
- var text = new CKEDITOR.dom.text( attributes.title, editor.document );
177
- ranges[0].insertNode( text );
178
- ranges[0].selectNodeContents( text );
179
- selection.selectRanges( ranges );
180
- }
181
-
182
- // Apply style.
183
- var style = new CKEDITOR.style( { element : 'a', attributes : attributes } );
184
- style.type = CKEDITOR.STYLE_INLINE; // need to override... dunno why.
185
- style.apply( editor.document );
186
- }
187
- else
188
- {
189
- // We're only editing an existing link, so just overwrite the attributes.
190
- var element = this._.selectedElement;
191
-
192
- // IE BUG: Setting the name attribute to an existing link doesn't work.
193
- // Must re-create the link from weired syntax to workaround.
194
- if ( CKEDITOR.env.ie && attributes.name != element.getAttribute( 'name' ) )
195
- {
196
- var newElement = new CKEDITOR.dom.element( '<a name="' + CKEDITOR.tools.htmlEncode( attributes.name ) + '">',
197
- editor.document );
198
-
199
- selection = editor.getSelection();
200
-
201
- element.moveChildren( newElement );
202
- element.copyAttributes( newElement, { name : 1 } );
203
- newElement.replace( element );
204
- element = newElement;
205
-
206
- selection.selectElement( element );
207
- }
208
-
209
- element.setAttributes( attributes );
210
- element.removeAttributes( removeAttributes );
211
-
212
- if (element.getAttribute('title') )
213
- element.setHtml(element.getAttribute('title'));
214
-
215
- // Make the element display as an anchor if a name has been set.
216
- if ( element.getAttribute( 'name' ) )
217
- element.addClass( 'cke_anchor' );
218
- else
219
- element.removeClass( 'cke_anchor' );
220
-
221
- if ( this.fakeObj )
222
- editor.createFakeElement( element, 'cke_anchor', 'anchor' ).replace( this.fakeObj );
223
-
224
- delete this._.selectedElement;
225
- }
226
- },
227
-
228
- contents :
229
- [
230
- {
231
- label : editor.lang.common.generalTab,
232
- id : 'general',
233
- accessKey : 'I',
234
- elements :
235
- [
236
- {
237
- type : 'vbox',
238
- padding : 0,
239
- children :
240
- [
241
- {
242
- type : 'html',
243
- html : '<span>' + CKEDITOR.tools.htmlEncode( editor.lang.attachment.url ) + '</span>'
244
- },
245
- {
246
- type : 'hbox',
247
- widths : [ '280px', '110px' ],
248
- align : 'right',
249
- children :
250
- [
251
- {
252
- id : 'src',
253
- type : 'text',
254
- label : '',
255
- validate : CKEDITOR.dialog.validate.notEmpty( editor.lang.flash.validateSrc ),
256
- setup : function( data )
257
- {
258
- if ( data.url )
259
- this.setValue( data.url );
260
-
261
- this.select();
262
- },
263
- commit : function( data )
264
- {
265
- data.url = this.getValue();
266
- }
267
- },
268
- {
269
- type : 'button',
270
- id : 'browse',
271
- filebrowser : 'general:src',
272
- hidden : true,
273
- align : 'center',
274
- label : editor.lang.common.browseServer
275
- }
276
- ]
277
- }
278
- ]
279
- },
280
-
281
- {
282
- type : 'vbox',
283
- padding : 0,
284
- children :
285
- [
286
- {
287
- id : 'name',
288
- type : 'text',
289
- label : editor.lang.attachment.name,
290
- setup : function( data )
291
- {
292
- if ( data.title )
293
- this.setValue( data.title );
294
- },
295
- commit : function( data )
296
- {
297
- data.title = this.getValue();
298
- }
299
- }
300
- ]
301
- },
302
-
303
- {
304
- type : 'hbox',
305
- widths : [ '50%', '50%' ],
306
- children :
307
- [
308
- {
309
- type : 'select',
310
- id : 'linkTargetType',
311
- label : editor.lang.link.target,
312
- 'default' : 'notSet',
313
- style : 'width : 100%;',
314
- 'items' :
315
- [
316
- [ editor.lang.link.targetNotSet, 'notSet' ],
317
- [ editor.lang.link.targetFrame, 'frame' ],
318
- [ editor.lang.link.targetNew, '_blank' ],
319
- [ editor.lang.link.targetTop, '_top' ],
320
- [ editor.lang.link.targetSelf, '_self' ],
321
- [ editor.lang.link.targetParent, '_parent' ]
322
- ],
323
- onChange : targetChanged,
324
- setup : function( data )
325
- {
326
- if ( data.target )
327
- this.setValue( data.target.type );
328
- },
329
- commit : function( data )
330
- {
331
- if ( !data.target )
332
- data.target = {};
333
-
334
- data.target.type = this.getValue();
335
- }
336
- },
337
- {
338
- type : 'text',
339
- id : 'linkTargetName',
340
- label : editor.lang.link.targetFrameName,
341
- 'default' : '',
342
- setup : function( data )
343
- {
344
- if ( data.target )
345
- this.setValue( data.target.name );
346
- },
347
- commit : function( data )
348
- {
349
- if ( !data.target )
350
- data.target = {};
351
-
352
- data.target.name = this.getValue();
353
- }
354
- }
355
- ]
356
- }
357
- ]
358
- },
359
- {
360
- id : 'Upload',
361
- hidden : true,
362
- filebrowser : 'uploadButton',
363
- label : editor.lang.common.upload,
364
- elements :
365
- [
366
- {
367
- type : 'file',
368
- id : 'upload',
369
- label : editor.lang.common.upload,
370
- size : 38
371
- },
372
- {
373
- type : 'fileButton',
374
- id : 'uploadButton',
375
- label : editor.lang.common.uploadSubmit,
376
- filebrowser : 'general:src',
377
- 'for' : [ 'Upload', 'upload' ]
378
- }
379
- ]
380
- },
381
- ]
382
- };
383
- });
384
- })();