ckeditor 3.7.1 → 3.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +12 -10
- data/app/assets/javascripts/ckeditor/config.js +98 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/gal_add.jpg +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/gal_add.png +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/gal_del.png +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/gal_more.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/preloader.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/avi.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/ckfnothumb.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/doc.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/docx.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/exe.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/gz.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/htm.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/jpg.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/mp3.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/mpg.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/pdf.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/psd.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/rar.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/swf.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/tar.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/txt.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/unknown.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/wmv.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/xls.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/xlsx.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/images/thumbs/zip.gif +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/javascripts/application.js +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/javascripts/fileuploader.js +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/javascripts/jquery.min.js +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/javascripts/jquery.tmpl.min.js +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/javascripts/rails.js +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/filebrowser/stylesheets/uploader.css +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/plugins/attachment/dialogs/attachment.js +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/plugins/attachment/images/attachment.png +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/plugins/attachment/lang/en.js +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/plugins/attachment/lang/ru.js +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/plugins/attachment/lang/uk.js +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/plugins/attachment/plugin.js +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/plugins/embed/dialogs/embed.js +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/plugins/embed/images/embed.png +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/plugins/embed/lang/el.js +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/plugins/embed/lang/en.js +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/plugins/embed/lang/ru.js +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/plugins/embed/lang/uk.js +0 -0
- data/{vendor → app}/assets/javascripts/ckeditor/plugins/embed/plugin.js +0 -0
- data/config/locales/it.ckeditor.yml +8 -0
- data/config/locales/nl.ckeditor.yml +8 -0
- data/lib/ckeditor/helpers/view_helper.rb +1 -1
- data/lib/ckeditor/utils.rb +15 -3
- data/lib/ckeditor/version.rb +2 -2
- data/lib/ckeditor.rb +6 -7
- data/lib/generators/ckeditor/templates/active_record/carrierwave/ckeditor/attachment_file.rb +4 -4
- data/lib/generators/ckeditor/templates/active_record/carrierwave/ckeditor/picture.rb +4 -4
- data/lib/generators/ckeditor/templates/active_record/carrierwave/migration.rb +6 -6
- data/lib/generators/ckeditor/templates/active_record/paperclip/migration.rb +6 -6
- data/lib/generators/ckeditor/templates/base/carrierwave/uploaders/ckeditor_attachment_file_uploader.rb +1 -1
- data/lib/generators/ckeditor/templates/base/carrierwave/uploaders/ckeditor_picture_uploader.rb +1 -1
- data/lib/generators/ckeditor/templates/base/dragonfly/initializer.rb +3 -3
- data/lib/generators/ckeditor/templates/mongoid/carrierwave/ckeditor/attachment_file.rb +4 -4
- data/lib/generators/ckeditor/templates/mongoid/carrierwave/ckeditor/picture.rb +4 -4
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +6716 -11138
- data/test/dummy/script/rails +0 -0
- data/vendor/assets/javascripts/ckeditor/CHANGES.html +45 -0
- data/vendor/assets/javascripts/ckeditor/ckeditor.js +123 -122
- data/vendor/assets/javascripts/ckeditor/ckeditor_basic.js +1 -1
- data/vendor/assets/javascripts/ckeditor/ckeditor_basic_source.js +1 -1
- data/vendor/assets/javascripts/ckeditor/ckeditor_source.js +1 -1
- data/vendor/assets/javascripts/ckeditor/config.js +4 -90
- data/vendor/assets/javascripts/ckeditor/lang/_translationstatus.txt +61 -60
- data/vendor/assets/javascripts/ckeditor/lang/af.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ar.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/bg.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/bn.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/bs.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ca.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/cs.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/cy.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/da.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/de.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/el.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/en-au.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/en-ca.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/en-gb.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/en.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/eo.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/es.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/et.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/eu.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/fa.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/fi.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/fo.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/fr-ca.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/fr.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/gl.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/gu.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/he.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/hi.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/hr.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/hu.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/id.js +6 -0
- data/vendor/assets/javascripts/ckeditor/lang/is.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/it.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ja.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ka.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/km.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ko.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/lt.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/lv.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/mk.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/mn.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ms.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/nb.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/nl.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/no.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/pl.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/pt-br.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/pt.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ro.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ru.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/sk.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/sl.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/sr-latn.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/sr.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/sv.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/th.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/tr.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ug.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/uk.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/vi.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/zh-cn.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/zh.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/lang/_translationstatus.txt +4 -2
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/lang/da.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/lang/el.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/lang/pt-br.js +6 -0
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/lang/ro.js +6 -0
- data/vendor/assets/javascripts/ckeditor/plugins/devtools/lang/_translationstatus.txt +1 -0
- data/vendor/assets/javascripts/ckeditor/plugins/devtools/lang/pt-br.js +6 -0
- data/vendor/assets/javascripts/ckeditor/plugins/devtools/plugin.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/find/dialogs/find.js +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/flash/dialogs/flash.js +3 -3
- data/vendor/assets/javascripts/ckeditor/plugins/link/dialogs/anchor.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/placeholder/lang/_translationstatus.txt +2 -1
- data/vendor/assets/javascripts/ckeditor/plugins/placeholder/lang/da.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/placeholder/lang/pt-br.js +6 -0
- data/vendor/assets/javascripts/ckeditor/plugins/placeholder/lang/vi.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/placeholder/plugin.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/preview/preview.html +10 -0
- data/vendor/assets/javascripts/ckeditor/plugins/specialchar/lang/_translationstatus.txt +3 -0
- data/vendor/assets/javascripts/ckeditor/plugins/specialchar/lang/el.js +6 -0
- data/vendor/assets/javascripts/ckeditor/plugins/specialchar/lang/he.js +6 -0
- data/vendor/assets/javascripts/ckeditor/plugins/specialchar/lang/pt-br.js +6 -0
- data/vendor/assets/javascripts/ckeditor/plugins/tabletools/dialogs/tableCell.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/uicolor/lang/_translationstatus.txt +1 -0
- data/vendor/assets/javascripts/ckeditor/plugins/uicolor/lang/pt-br.js +6 -0
- data/vendor/assets/javascripts/ckeditor/plugins/uicolor/plugin.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/uicolor/yui/assets/yui.css +1 -1
- data/vendor/assets/javascripts/ckeditor/skins/kama/dialog.css +5 -5
- data/vendor/assets/javascripts/ckeditor/skins/office2003/dialog.css +5 -4
- data/vendor/assets/javascripts/ckeditor/skins/v2/dialog.css +4 -4
- metadata +445 -422
data/README.rdoc
CHANGED
@@ -68,6 +68,10 @@ Mount engine in your routes (config/routes.rb):
|
|
68
68
|
|
69
69
|
mount Ckeditor::Engine => "/ckeditor"
|
70
70
|
|
71
|
+
Procompile ckeditor js and css files (config/environments/production.rb):
|
72
|
+
|
73
|
+
config.assets.precompile += Ckeditor.assets
|
74
|
+
|
71
75
|
Include ckeditor javascripts rails 3.2:
|
72
76
|
|
73
77
|
//= require ckeditor/init
|
@@ -88,18 +92,16 @@ Form helpers:
|
|
88
92
|
cktext_area_tag("content", "Ckeditor", :input_html => {:cols => 10, :rows => 20}, :toolbar => 'Easy')
|
89
93
|
|
90
94
|
* input_html - Options for text_area tag, others for ckeditor javascript configuration.
|
91
|
-
* language - appends automatically, by default
|
95
|
+
* language - appends automatically, by default it's I18n.locale
|
92
96
|
* available ckeditor options - http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html
|
93
97
|
|
94
|
-
|
98
|
+
In order to configure the ckeditor default options, create files:
|
95
99
|
|
96
|
-
|
97
|
-
|
98
|
-
This stylesheet use editor for displaying edit area:
|
100
|
+
app/assets/javascripts/ckeditor/config.js
|
99
101
|
|
100
|
-
|
101
|
-
|
102
|
-
FormBuilder helper
|
102
|
+
app/assets/javascripts/ckeditor/contents.css
|
103
|
+
|
104
|
+
Here's a FormBuilder helper example:
|
103
105
|
|
104
106
|
<%= form_for @page do |form| -%>
|
105
107
|
...
|
@@ -112,7 +114,7 @@ FormBuilder helper for more usefully:
|
|
112
114
|
|
113
115
|
=== AJAX
|
114
116
|
|
115
|
-
|
117
|
+
jQuery sample:
|
116
118
|
|
117
119
|
<script type='text/javascript' charset='UTF-8'>
|
118
120
|
$(document).ready(function(){
|
@@ -146,7 +148,7 @@ For example, you need split assets collection for each user.
|
|
146
148
|
end
|
147
149
|
end
|
148
150
|
|
149
|
-
If
|
151
|
+
If you want to filter only pictures or attachment_files - redefine methods "ckeditor_pictures_scope" or "ckeditor_attachment_files_scope" respectively.
|
150
152
|
By default, both these methods call "ckeditor_filebrowser_scope" method:
|
151
153
|
|
152
154
|
class ApplicationController < ActionController::Base
|
@@ -0,0 +1,98 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
|
3
|
+
For licensing, see LICENSE.html or http://ckeditor.com/license
|
4
|
+
*/
|
5
|
+
|
6
|
+
jQuery.noConflict();
|
7
|
+
|
8
|
+
CKEDITOR.editorConfig = function( config )
|
9
|
+
{
|
10
|
+
// Define changes to default configuration here. For example:
|
11
|
+
// config.language = 'fr';
|
12
|
+
// config.uiColor = '#AADC6E';
|
13
|
+
|
14
|
+
/* Filebrowser routes */
|
15
|
+
// The location of an external file browser, that should be launched when "Browse Server" button is pressed.
|
16
|
+
config.filebrowserBrowseUrl = "/ckeditor/attachment_files";
|
17
|
+
|
18
|
+
// The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Flash dialog.
|
19
|
+
config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files";
|
20
|
+
|
21
|
+
// The location of a script that handles file uploads in the Flash dialog.
|
22
|
+
config.filebrowserFlashUploadUrl = "/ckeditor/attachment_files";
|
23
|
+
|
24
|
+
// The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Link tab of Image dialog.
|
25
|
+
config.filebrowserImageBrowseLinkUrl = "/ckeditor/pictures";
|
26
|
+
|
27
|
+
// The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Image dialog.
|
28
|
+
config.filebrowserImageBrowseUrl = "/ckeditor/pictures";
|
29
|
+
|
30
|
+
// The location of a script that handles file uploads in the Image dialog.
|
31
|
+
config.filebrowserImageUploadUrl = "/ckeditor/pictures";
|
32
|
+
|
33
|
+
// The location of a script that handles file uploads.
|
34
|
+
config.filebrowserUploadUrl = "/ckeditor/attachment_files";
|
35
|
+
|
36
|
+
// Rails CSRF token
|
37
|
+
config.filebrowserParams = function(){
|
38
|
+
var csrf_token = jQuery('meta[name=csrf-token]').attr('content'),
|
39
|
+
csrf_param = jQuery('meta[name=csrf-param]').attr('content'),
|
40
|
+
params = new Object();
|
41
|
+
|
42
|
+
if (csrf_param !== undefined && csrf_token !== undefined) {
|
43
|
+
params[csrf_param] = csrf_token;
|
44
|
+
}
|
45
|
+
|
46
|
+
return params;
|
47
|
+
};
|
48
|
+
|
49
|
+
config.addQueryString = function( url, params ){
|
50
|
+
var queryString = [];
|
51
|
+
|
52
|
+
if ( !params ) {
|
53
|
+
return url;
|
54
|
+
} else {
|
55
|
+
for ( var i in params )
|
56
|
+
queryString.push( i + "=" + encodeURIComponent( params[ i ] ) );
|
57
|
+
}
|
58
|
+
|
59
|
+
return url + ( ( url.indexOf( "?" ) != -1 ) ? "&" : "?" ) + queryString.join( "&" );
|
60
|
+
};
|
61
|
+
|
62
|
+
// Integrate Rails CSRF token into file upload dialogs (link, image, attachment and flash)
|
63
|
+
CKEDITOR.on( 'dialogDefinition', function( ev ){
|
64
|
+
// Take the dialog name and its definition from the event data.
|
65
|
+
var dialogName = ev.data.name;
|
66
|
+
var dialogDefinition = ev.data.definition;
|
67
|
+
var content, upload;
|
68
|
+
|
69
|
+
if (jQuery.inArray(dialogName, ['link', 'image', 'attachment', 'flash']) > -1) {
|
70
|
+
content = (dialogDefinition.getContents('Upload') || dialogDefinition.getContents('upload'));
|
71
|
+
upload = (content == null ? null : content.get('upload'));
|
72
|
+
|
73
|
+
if (upload && upload.filebrowser['params'] == null) {
|
74
|
+
upload.filebrowser['params'] = config.filebrowserParams();
|
75
|
+
upload.action = config.addQueryString(upload.action, upload.filebrowser['params']);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
});
|
79
|
+
|
80
|
+
/* Extra plugins */
|
81
|
+
// works only with en, ru, uk locales
|
82
|
+
config.extraPlugins = "embed,attachment";
|
83
|
+
|
84
|
+
/* Toolbars */
|
85
|
+
config.toolbar = 'Easy';
|
86
|
+
|
87
|
+
config.toolbar_Easy =
|
88
|
+
[
|
89
|
+
['Source','-','Preview'],
|
90
|
+
['Cut','Copy','Paste','PasteText','PasteFromWord',],
|
91
|
+
['Undo','Redo','-','SelectAll','RemoveFormat'],
|
92
|
+
['Styles','Format'], ['Subscript', 'Superscript', 'TextColor'], ['Maximize','-','About'], '/',
|
93
|
+
['Bold','Italic','Underline','Strike'], ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
|
94
|
+
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
|
95
|
+
['Link','Unlink','Anchor'], ['Image', 'Attachment', 'Flash', 'Embed'],
|
96
|
+
['Table','HorizontalRule','Smiley','SpecialChar','PageBreak']
|
97
|
+
];
|
98
|
+
};
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -4,7 +4,7 @@ module Ckeditor
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
def cktext_area_tag(name, content = nil, options = {})
|
7
|
-
element_id = sanitize_to_id(name)
|
7
|
+
element_id = sanitize_to_id(options[:id] || name)
|
8
8
|
options = { :language => I18n.locale.to_s }.merge(options)
|
9
9
|
input_html = { :id => element_id }.merge( options.delete(:input_html) || {} )
|
10
10
|
js_content_for_section = options.delete(:js_content_for)
|
data/lib/ckeditor/utils.rb
CHANGED
@@ -19,6 +19,8 @@ module Ckeditor
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def parameterize_filename(filename)
|
22
|
+
return filename unless Ckeditor.parameterize_filenames
|
23
|
+
|
22
24
|
extension = File.extname(filename)
|
23
25
|
basename = filename.gsub(/#{extension}$/, "")
|
24
26
|
|
@@ -31,7 +33,7 @@ module Ckeditor
|
|
31
33
|
js = ["if (CKEDITOR.instances['#{dom_id}']) {CKEDITOR.remove(CKEDITOR.instances['#{dom_id}']);}"]
|
32
34
|
js << "CKEDITOR.replace('#{dom_id}', #{js_options});"
|
33
35
|
|
34
|
-
"
|
36
|
+
"window.onload = function(){ #{js.join} };".html_safe
|
35
37
|
end
|
36
38
|
|
37
39
|
def js_fileuploader(uploader_type, options = {})
|
@@ -51,13 +53,13 @@ module Ckeditor
|
|
51
53
|
|
52
54
|
js_options = ActiveSupport::JSON.encode(options)
|
53
55
|
|
54
|
-
"
|
56
|
+
"window.onload = function(){ new qq.FileUploaderInput(#{js_options}); };".html_safe
|
55
57
|
end
|
56
58
|
|
57
59
|
def filethumb(filename)
|
58
60
|
extname = filename.blank? ? "unknown" : File.extname(filename).gsub(/^\./, '')
|
59
61
|
image = "#{extname}.gif"
|
60
|
-
source = Ckeditor.root_path.join("
|
62
|
+
source = Ckeditor.root_path.join("app/assets/javascripts/ckeditor/filebrowser/images/thumbs")
|
61
63
|
|
62
64
|
unless File.exists?(File.join(source, image))
|
63
65
|
image = "unknown.gif"
|
@@ -65,6 +67,16 @@ module Ckeditor
|
|
65
67
|
|
66
68
|
File.join(Ckeditor.relative_path, "filebrowser/images/thumbs", image)
|
67
69
|
end
|
70
|
+
|
71
|
+
def select_assets(path, relative_path)
|
72
|
+
folder = File.join(path, '**')
|
73
|
+
relative_folder = Ckeditor.root_path.join(relative_path)
|
74
|
+
|
75
|
+
Dir[Ckeditor.root_path.join(folder, '*.{js,css}')].inject([]) do |list, file|
|
76
|
+
list << Pathname.new(file).relative_path_from(relative_folder).to_s
|
77
|
+
list
|
78
|
+
end
|
79
|
+
end
|
68
80
|
end
|
69
81
|
end
|
70
82
|
end
|
data/lib/ckeditor/version.rb
CHANGED
data/lib/ckeditor.rb
CHANGED
@@ -41,6 +41,10 @@ module Ckeditor
|
|
41
41
|
# Ckeditor assets for precompilation
|
42
42
|
mattr_accessor :assets
|
43
43
|
@@assets = nil
|
44
|
+
|
45
|
+
# Turn on/off filename parameterize
|
46
|
+
mattr_accessor :parameterize_filenames
|
47
|
+
@@parameterize_filenames = true
|
44
48
|
|
45
49
|
# Default way to setup Ckeditor. Run rails generate ckeditor to create
|
46
50
|
# a fresh initializer with all configuration values.
|
@@ -54,13 +58,8 @@ module Ckeditor
|
|
54
58
|
|
55
59
|
def self.assets
|
56
60
|
@@assets ||= begin
|
57
|
-
|
58
|
-
|
59
|
-
list << Pathname.new(path).relative_path_from(root_path.join('vendor/assets/javascripts'))
|
60
|
-
end
|
61
|
-
|
62
|
-
list
|
63
|
-
end
|
61
|
+
Utils.select_assets("vendor/assets/javascripts/ckeditor", "vendor/assets/javascripts") +
|
62
|
+
Utils.select_assets("app/assets/javascripts/ckeditor/plugins", "app/assets/javascripts")
|
64
63
|
end
|
65
64
|
end
|
66
65
|
|
data/lib/generators/ckeditor/templates/active_record/carrierwave/ckeditor/attachment_file.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
class Ckeditor::AttachmentFile < Ckeditor::Asset
|
2
2
|
mount_uploader :data, CkeditorAttachmentFileUploader, :mount_on => :data_file_name
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
|
4
|
+
def url_thumb
|
5
|
+
@url_thumb ||= Ckeditor::Utils.filethumb(filename)
|
6
|
+
end
|
7
7
|
end
|
@@ -6,18 +6,18 @@ class CreateCkeditorAssets < ActiveRecord::Migration
|
|
6
6
|
t.integer :data_file_size
|
7
7
|
|
8
8
|
t.integer :assetable_id
|
9
|
-
|
9
|
+
t.string :assetable_type, :limit => 30
|
10
10
|
t.string :type, :limit => 30
|
11
|
-
|
11
|
+
|
12
12
|
# Uncomment it to save images dimensions, if your need it
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
t.integer :width
|
14
|
+
t.integer :height
|
15
|
+
|
16
16
|
t.timestamps
|
17
17
|
end
|
18
18
|
|
19
19
|
add_index "ckeditor_assets", ["assetable_type", "type", "assetable_id"], :name => "idx_ckeditor_assetable_type"
|
20
|
-
|
20
|
+
add_index "ckeditor_assets", ["assetable_type", "assetable_id"], :name => "idx_ckeditor_assetable"
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.down
|
@@ -6,18 +6,18 @@ class CreateCkeditorAssets < ActiveRecord::Migration
|
|
6
6
|
t.integer :data_file_size
|
7
7
|
|
8
8
|
t.integer :assetable_id
|
9
|
-
|
9
|
+
t.string :assetable_type, :limit => 30
|
10
10
|
t.string :type, :limit => 30
|
11
|
-
|
11
|
+
|
12
12
|
# Uncomment it to save images dimensions, if your need it
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
t.integer :width
|
14
|
+
t.integer :height
|
15
|
+
|
16
16
|
t.timestamps
|
17
17
|
end
|
18
18
|
|
19
19
|
add_index "ckeditor_assets", ["assetable_type", "type", "assetable_id"], :name => "idx_ckeditor_assetable_type"
|
20
|
-
|
20
|
+
add_index "ckeditor_assets", ["assetable_type", "assetable_id"], :name => "idx_ckeditor_assetable"
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.down
|
@@ -13,7 +13,7 @@ class CkeditorAttachmentFileUploader < CarrierWave::Uploader::Base
|
|
13
13
|
# Override the directory where uploaded files will be stored.
|
14
14
|
# This is a sensible default for uploaders that are meant to be mounted:
|
15
15
|
def store_dir
|
16
|
-
"
|
16
|
+
"/uploads/ckeditor/attachments/#{model.id}"
|
17
17
|
end
|
18
18
|
|
19
19
|
# Provide a default URL as a default if there hasn't been a file uploaded:
|
data/lib/generators/ckeditor/templates/base/carrierwave/uploaders/ckeditor_picture_uploader.rb
CHANGED
@@ -13,7 +13,7 @@ class CkeditorPictureUploader < CarrierWave::Uploader::Base
|
|
13
13
|
# Override the directory where uploaded files will be stored.
|
14
14
|
# This is a sensible default for uploaders that are meant to be mounted:
|
15
15
|
def store_dir
|
16
|
-
"
|
16
|
+
"/uploads/ckeditor/pictures/#{model.id}"
|
17
17
|
end
|
18
18
|
|
19
19
|
# Provide a default URL as a default if there hasn't been a file uploaded:
|
@@ -11,15 +11,15 @@ app.define_macro(ActiveRecord::Base, :ckeditor_file_accessor) if defined?(Active
|
|
11
11
|
app.define_macro_on_include(Mongoid::Document, :ckeditor_file_accessor) if defined?(Mongoid::Document)
|
12
12
|
|
13
13
|
app.configure do |c|
|
14
|
-
# Store files in public/
|
14
|
+
# Store files in public/uploads/ckeditor. This is not
|
15
15
|
# mandatory and the files don't even have to be stored under
|
16
16
|
# public. If not storing under public then set server_root to nil.
|
17
|
-
c.datastore.root_path = Rails.root.join("public", "
|
17
|
+
c.datastore.root_path = Rails.root.join("public", "uploads", "ckeditor", Rails.env).to_s
|
18
18
|
c.datastore.server_root = Rails.root.join("public").to_s
|
19
19
|
|
20
20
|
# Accept asset requests on /ckeditor_assets. Again, this is not
|
21
21
|
# mandatory. Just be sure to include :job somewhere.
|
22
|
-
c.url_format = "/
|
22
|
+
c.url_format = "/uploads/ckeditor/:job/:basename.:format"
|
23
23
|
end
|
24
24
|
|
25
25
|
# Insert our Dragonfly "app" into the stack.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Ckeditor::AttachmentFile < Ckeditor::Asset
|
2
2
|
mount_uploader :data, CkeditorAttachmentFileUploader, :mount_on => :data_file_name
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
|
4
|
+
def url_thumb
|
5
|
+
@url_thumb ||= Ckeditor::Utils.filethumb(filename)
|
6
|
+
end
|
7
7
|
end
|
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|