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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3680418bc5ccda9846453cb46a95a060c80956d2
4
- data.tar.gz: 3d243ae1d624fe66a5b0922d88c5fee93e454185
3
+ metadata.gz: 6a1e8f122ffafd83075927c405f1f4a4a70cb158
4
+ data.tar.gz: 207f4b085893e971a883c72eea73fd892f0ab9e2
5
5
  SHA512:
6
- metadata.gz: 4cb474c81d141261799eb09c1942892af0858749c1e4b7881ea7665ad517550afb81b5b52ca4275f8aa6de2a898bcf42fa019e95c9e347dd178339f469eaac10
7
- data.tar.gz: c858f334904e3458921738bd0ae115054567ba27913064607d323b0e770641c677d9ec543e9057dfddaaae38ccb6cbe6a4fd1964958f5a4a0e79bac787a59269
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
- gem 'ckeditor_rails'
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
- //= require ckeditor-jquery
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
- <%= f.text_area :content, :class => 'ckeditor' %>
33
-
36
+ ``` ruby
37
+ <%= f.text_area :content, :class => 'ckeditor' %>
38
+ ```
34
39
 
35
40
  ### Initialize CKEditor in Javascript file
36
41
 
37
- $('.ckeditor').ckeditor({
38
- // optional config
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
- CKEDITOR.editorConfig = (config) ->
54
- config.language = "zh"
55
- config.uiColor = "#AADC6E"
56
- true
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
- base_path = ''
64
- if ENV['PROJECT'] =~ /editor/i
65
- base_path << "/#{Rails.root.basename.to_s}/"
66
- end
67
- base_path << Rails.application.config.assets.prefix
68
- base_path << '/ckeditor/'
69
- %>
70
- var CKEDITOR_BASEPATH = '<%= base_path %>';
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
- body {
77
- font-size: 14px;
78
- color: gray;
79
- background-color: yellow;
80
- }
81
- ol,ul,dl {
82
- *margin-right:0px;
83
- padding:4 20px;
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
 
@@ -2,13 +2,67 @@ require 'ckeditor-rails/version'
2
2
 
3
3
  module Ckeditor
4
4
  module Rails
5
- case ::Rails.version.to_s
6
- when /^4/
7
- require 'ckeditor-rails/engine'
8
- when /^3\.[12]/
9
- require 'ckeditor-rails/engine3'
10
- when /^3\.[0]/
11
- require 'ckeditor-rails/railtie'
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 += %W(
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 += %W(
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 += %W(
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/assets/ckeditor/**/*"]
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)
@@ -1,6 +1,6 @@
1
1
  module Ckeditor
2
2
  module Rails
3
- VERSION = '4.4.7'
3
+ VERSION = '4.4.8'
4
4
  EDITOR_VERSION = '4.4.7'
5
5
  end
6
6
  end
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.7
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-05-08 00:00:00.000000000 Z
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