ckeditor_rails 4.4.7 → 4.4.8
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.
- checksums.yaml +4 -4
- data/README.md +59 -29
- data/lib/ckeditor-rails.rb +61 -7
- data/lib/ckeditor-rails/asset.rb +89 -0
- data/lib/ckeditor-rails/engine.rb +1 -8
- data/lib/ckeditor-rails/engine3.rb +1 -8
- data/lib/ckeditor-rails/railtie.rb +1 -8
- data/lib/ckeditor-rails/tasks.rake +1 -1
- data/lib/ckeditor-rails/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a1e8f122ffafd83075927c405f1f4a4a70cb158
|
4
|
+
data.tar.gz: 207f4b085893e971a883c72eea73fd892f0ab9e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1f0c99974da656d72bc44c593746871a8ff011493019ca911f2ee948faff3034d2296f3fc9cb8e3b0d362381ce20d77dff18f338abe86c36a0145587e7ab34e
|
7
|
+
data.tar.gz: 924942548d26a0777bc6627f6e3320a4c608379785ae0f60d5d766728e2d60627cd2e825785de7e602f5cfa97d59cb33af52125faefcc0ab9b98255200eb68ff
|
data/README.md
CHANGED
@@ -15,7 +15,9 @@ And it would work with following environments:
|
|
15
15
|
|
16
16
|
Include `ckeditor_rails` in Gemefile
|
17
17
|
|
18
|
-
|
18
|
+
```ruby
|
19
|
+
gem 'ckeditor_rails'
|
20
|
+
```
|
19
21
|
|
20
22
|
Then run `bundle install`
|
21
23
|
|
@@ -23,20 +25,25 @@ Then run `bundle install`
|
|
23
25
|
|
24
26
|
Add to your `app/assets/javascripts/application.js` after `//= require jquery_ujs` to work with jQuery
|
25
27
|
|
26
|
-
|
28
|
+
``` javascript
|
29
|
+
//= require ckeditor-jquery
|
30
|
+
```
|
27
31
|
|
28
32
|
### Modify form field for CKEditor
|
29
33
|
|
30
34
|
Add `ckeditor` class to text area tag
|
31
35
|
|
32
|
-
|
33
|
-
|
36
|
+
``` ruby
|
37
|
+
<%= f.text_area :content, :class => 'ckeditor' %>
|
38
|
+
```
|
34
39
|
|
35
40
|
### Initialize CKEditor in Javascript file
|
36
41
|
|
37
|
-
|
38
|
-
|
39
|
-
|
42
|
+
``` javascript
|
43
|
+
$('.ckeditor').ckeditor({
|
44
|
+
// optional config
|
45
|
+
});
|
46
|
+
```
|
40
47
|
|
41
48
|
### Deployment
|
42
49
|
|
@@ -50,38 +57,61 @@ Eric Anderson, thanks.
|
|
50
57
|
|
51
58
|
Add your `app/assets/javascripts/ckeditor/config.js.coffee` like
|
52
59
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
60
|
+
```
|
61
|
+
CKEDITOR.editorConfig = (config) ->
|
62
|
+
config.language = "zh"
|
63
|
+
config.uiColor = "#AADC6E"
|
64
|
+
true
|
65
|
+
```
|
57
66
|
|
58
67
|
### Include customized CKEDITOR_BASEPATH setting
|
59
68
|
|
60
69
|
Add your `app/assets/javascripts/ckeditor/basepath.js.erb` like
|
61
70
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
+
``` ruby
|
72
|
+
<%
|
73
|
+
base_path = ''
|
74
|
+
if ENV['PROJECT'] =~ /editor/i
|
75
|
+
base_path << "/#{Rails.root.basename.to_s}/"
|
76
|
+
end
|
77
|
+
base_path << Rails.application.config.assets.prefix
|
78
|
+
base_path << '/ckeditor/'
|
79
|
+
%>
|
80
|
+
var CKEDITOR_BASEPATH = '<%= base_path %>';
|
81
|
+
```
|
71
82
|
|
72
83
|
### Include customized stylesheet for contents of CKEditor
|
73
84
|
|
74
85
|
Add your `app/assets/stylesheets/ckeditor/contents.css.scss` like
|
75
86
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
87
|
+
``` scss
|
88
|
+
body {
|
89
|
+
font-size: 14px;
|
90
|
+
color: gray;
|
91
|
+
background-color: yellow;
|
92
|
+
}
|
93
|
+
ol,ul,dl {
|
94
|
+
*margin-right:0px;
|
95
|
+
padding:4 20px;
|
96
|
+
}
|
97
|
+
```
|
98
|
+
|
99
|
+
### Configure plugins, languages, and skins of CKEditor assets
|
100
|
+
|
101
|
+
Add `ckeditor_rails.rb` to `config/initializers/`
|
102
|
+
|
103
|
+
``` ruby
|
104
|
+
Ckeditor::Rails.configure do |config|
|
105
|
+
# default is nil for all languages, or set as %w[en zh]
|
106
|
+
config.assets_languages = nil
|
107
|
+
|
108
|
+
# default is nil for all plugins, or set as %w[image link liststyle table tabletools]
|
109
|
+
config.assets_plugins = nil
|
110
|
+
|
111
|
+
# default is nil for all skins, or set as %w[moon]
|
112
|
+
config.assets_skins = nil
|
113
|
+
end
|
114
|
+
```
|
85
115
|
|
86
116
|
## Gem maintenance
|
87
117
|
|
data/lib/ckeditor-rails.rb
CHANGED
@@ -2,13 +2,67 @@ require 'ckeditor-rails/version'
|
|
2
2
|
|
3
3
|
module Ckeditor
|
4
4
|
module Rails
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
|
6
|
+
mattr_accessor :assets_languages
|
7
|
+
@@assets_languages = nil
|
8
|
+
|
9
|
+
mattr_accessor :assets_plugins
|
10
|
+
@@assets_plugins = nil
|
11
|
+
|
12
|
+
mattr_accessor :assets_skins
|
13
|
+
@@assets_skins = nil
|
14
|
+
|
15
|
+
class << self
|
16
|
+
def configure
|
17
|
+
yield self
|
18
|
+
end
|
19
|
+
|
20
|
+
def root_path
|
21
|
+
@root_path ||= Pathname.new(File.expand_path('..', __FILE__))
|
22
|
+
end
|
23
|
+
|
24
|
+
def default_plugins
|
25
|
+
%W[
|
26
|
+
a11yhelp
|
27
|
+
about
|
28
|
+
clipboard
|
29
|
+
colordialog
|
30
|
+
dialog
|
31
|
+
div
|
32
|
+
find
|
33
|
+
flash
|
34
|
+
forms
|
35
|
+
iframe
|
36
|
+
image
|
37
|
+
link
|
38
|
+
liststyle
|
39
|
+
pastefromword
|
40
|
+
preview
|
41
|
+
scayt
|
42
|
+
smiley
|
43
|
+
specialchar
|
44
|
+
table
|
45
|
+
tabletools
|
46
|
+
templates
|
47
|
+
wsc
|
48
|
+
]
|
49
|
+
end
|
50
|
+
|
51
|
+
def default_skins
|
52
|
+
%w[moono]
|
53
|
+
end
|
12
54
|
end
|
55
|
+
|
13
56
|
end
|
14
57
|
end
|
58
|
+
|
59
|
+
require 'ckeditor-rails/asset'
|
60
|
+
|
61
|
+
case ::Rails.version.to_s
|
62
|
+
when /^4/
|
63
|
+
require 'ckeditor-rails/engine'
|
64
|
+
when /^3\.[12]/
|
65
|
+
require 'ckeditor-rails/engine3'
|
66
|
+
when /^3\.[0]/
|
67
|
+
require 'ckeditor-rails/railtie'
|
68
|
+
end if defined? ::Rails
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module Ckeditor
|
2
|
+
module Rails
|
3
|
+
class Asset
|
4
|
+
|
5
|
+
attr_reader :name, :root
|
6
|
+
|
7
|
+
def initialize name = 'ckeditor', path = '../vendor/assets'
|
8
|
+
@name = name
|
9
|
+
@root = Ckeditor::Rails.root_path.join path
|
10
|
+
end
|
11
|
+
|
12
|
+
def image_files
|
13
|
+
path = root.join('images', name)
|
14
|
+
files = Dir.glob(path.join('plugins', '**', '*.{png,gif,jpg}')).reject { |file|
|
15
|
+
invalid_plugin_file?(file)
|
16
|
+
}
|
17
|
+
files += Dir.glob(path.join('skins', '**', '*.{png,gif,jpg}')).reject { |file|
|
18
|
+
invalid_skin_file?(file)
|
19
|
+
}
|
20
|
+
files
|
21
|
+
end
|
22
|
+
|
23
|
+
def javascript_files
|
24
|
+
path = root.join('javascripts', name)
|
25
|
+
files = Dir.glob(path.join('*.js'))
|
26
|
+
files += Dir.glob(path.join('lang', '*.js')).reject { |file|
|
27
|
+
invalid_lang_file?(file)
|
28
|
+
}
|
29
|
+
files += Dir.glob(path.join('plugins', '**', '*.{js,html}')).reject { |file|
|
30
|
+
invalid_plugin_file?(file) or invalid_lang_file?(file)
|
31
|
+
}
|
32
|
+
files
|
33
|
+
end
|
34
|
+
|
35
|
+
def stylesheet_files
|
36
|
+
path = root.join('stylesheets', name)
|
37
|
+
files = Dir.glob(path.join('*.css'))
|
38
|
+
files += Dir.glob(path.join('plugins', '**', '*.css')).reject { |file|
|
39
|
+
invalid_plugin_file?(file)
|
40
|
+
}
|
41
|
+
files += Dir.glob(path.join('skins', '**', '*.css')).reject { |file|
|
42
|
+
invalid_skin_file?(file)
|
43
|
+
}
|
44
|
+
files
|
45
|
+
end
|
46
|
+
|
47
|
+
def files
|
48
|
+
files = []
|
49
|
+
files += image_files
|
50
|
+
files += javascript_files
|
51
|
+
files += stylesheet_files
|
52
|
+
files
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def languages
|
58
|
+
Ckeditor::Rails.assets_languages
|
59
|
+
end
|
60
|
+
|
61
|
+
def plugins
|
62
|
+
Ckeditor::Rails.assets_plugins
|
63
|
+
end
|
64
|
+
|
65
|
+
def skins
|
66
|
+
Ckeditor::Rails.assets_skins
|
67
|
+
end
|
68
|
+
|
69
|
+
def invalid_lang_file? file
|
70
|
+
return false if languages.nil?
|
71
|
+
return false unless file.include? '/lang/'
|
72
|
+
not languages.include? File.basename(file, '.*')
|
73
|
+
end
|
74
|
+
|
75
|
+
def invalid_plugin_file? file
|
76
|
+
return false if plugins.nil?
|
77
|
+
retrun false unless file.include? '/plugins/'
|
78
|
+
plugins.none? { |plugin| file.include? "/#{plugin}/" }
|
79
|
+
end
|
80
|
+
|
81
|
+
def invalid_skin_file? file
|
82
|
+
return false if skins.nil?
|
83
|
+
return false unless file.include? '/skins/'
|
84
|
+
skins.none? { |skin| file.include? "/#{skin}/" }
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -2,14 +2,7 @@ module Ckeditor
|
|
2
2
|
module Rails
|
3
3
|
class Engine < ::Rails::Engine
|
4
4
|
initializer 'ckeditor.assets.precompile', group: :all do |app|
|
5
|
-
app.config.assets.precompile +=
|
6
|
-
ckeditor/*.js
|
7
|
-
ckeditor/*.css
|
8
|
-
ckeditor/*.png
|
9
|
-
ckeditor/*.gif
|
10
|
-
ckeditor/*.html
|
11
|
-
ckeditor/*.md
|
12
|
-
)
|
5
|
+
app.config.assets.precompile += Ckeditor::Rails::Asset.new.files
|
13
6
|
end
|
14
7
|
|
15
8
|
rake_tasks do
|
@@ -2,14 +2,7 @@ module Ckeditor
|
|
2
2
|
module Rails
|
3
3
|
class Engine < ::Rails::Engine
|
4
4
|
initializer 'ckeditor.assets.precompile', group: :all do |app|
|
5
|
-
app.config.assets.precompile +=
|
6
|
-
ckeditor/*.js
|
7
|
-
ckeditor/*.css
|
8
|
-
ckeditor/*.png
|
9
|
-
ckeditor/*.gif
|
10
|
-
ckeditor/*.html
|
11
|
-
ckeditor/*.md
|
12
|
-
)
|
5
|
+
app.config.assets.precompile += Ckeditor::Rails::Asset.new.files
|
13
6
|
end
|
14
7
|
end
|
15
8
|
end
|
@@ -2,14 +2,7 @@ module Ckeditor
|
|
2
2
|
module Rails
|
3
3
|
class Railtie < ::Rails::Railtie
|
4
4
|
initializer 'ckeditor.assets.precompile', group: :all do |app|
|
5
|
-
app.config.assets.precompile +=
|
6
|
-
ckeditor/*.js
|
7
|
-
ckeditor/*.css
|
8
|
-
ckeditor/*.png
|
9
|
-
ckeditor/*.gif
|
10
|
-
ckeditor/*.html
|
11
|
-
ckeditor/*.md
|
12
|
-
)
|
5
|
+
app.config.assets.precompile += Ckeditor::Rails::Asset.new.files
|
13
6
|
end
|
14
7
|
end
|
15
8
|
end
|
@@ -3,7 +3,7 @@ require 'fileutils'
|
|
3
3
|
desc "Create nondigest versions of all ckeditor digest assets"
|
4
4
|
task "assets:precompile" do
|
5
5
|
fingerprint = /\-([0-9a-f]{32}|[0-9a-f]{64})\./
|
6
|
-
for file in Dir["public
|
6
|
+
for file in Dir["#{File.join('public', Rails.configuration.assets.prefix)}/ckeditor/**/*"]
|
7
7
|
next unless file =~ fingerprint
|
8
8
|
nondigest = file.sub fingerprint, '.'
|
9
9
|
if !File.exist?(nondigest) or File.mtime(file) > File.mtime(nondigest)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ckeditor_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.4.
|
4
|
+
version: 4.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tse-Ching Ho
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- lib/assets/javascripts/ckeditor/basepath.js.erb
|
86
86
|
- lib/assets/javascripts/ckeditor/jquery.js
|
87
87
|
- lib/ckeditor-rails.rb
|
88
|
+
- lib/ckeditor-rails/asset.rb
|
88
89
|
- lib/ckeditor-rails/engine.rb
|
89
90
|
- lib/ckeditor-rails/engine3.rb
|
90
91
|
- lib/ckeditor-rails/railtie.rb
|