drg_default_html_editor 0.4.18 → 0.4.21

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: a91d9e11ca2d07063f52a3a2ae4a6dd8f0b2d958
4
- data.tar.gz: b482394f6af580f773440a03866dad4af5723a84
3
+ metadata.gz: cc37e55dfb38ded0ad6f5cb6e7e15175dc41b6b4
4
+ data.tar.gz: e42fd7f102c436c7fb00bd15675a1db8fda67ac5
5
5
  SHA512:
6
- metadata.gz: 8ee067a57d025929e2a831f15862c4f530efbbb0e5929e4c0c2d94311aa7903cac02b8a5439fed4788cb73abf8ca75554e46279620a5d45b2c5d3c50d7be7e71
7
- data.tar.gz: 1d3e6ca86e4fda085c81a46ea813785b6304c0acbca9303f00eaa27ae3d9eafe99b4e2b06873e679189c53413c1516c92aa7d05a3c38ba2d2ec2d8631e6c19d6
6
+ metadata.gz: d9b8f29604b009988f3bea017e242fa54125d7bf5f9693c008035f2a0f86d9debddef3fc8f1a9f2db82d0e47615e9c1b4bd761a5d3f745f9689faa32e689fc64
7
+ data.tar.gz: 64e30420d98102856ee7f54e61f1466b110b202ec4af9b8b6cc8251634720ce0af22b250a9489c24f39ac3a4da480eaab4576c54d7dd667f03bf4e3b3205f163
data/README.md CHANGED
@@ -1,12 +1,13 @@
1
1
  # DrgDefaultHtmlEditor
2
2
 
3
- Default HTML editor and file manager plugin for DRG CMS. DrgDefaultHtmlEditor consists
4
- of CK editor component and EL Finder file manager component.
3
+ Default HTML editor and file manager plugin for DRG CMS. Since DRG CMS doesn't come with HTML editor. DrgDefaultHtmlEditor gem adds html_field and file_select data entry fields to DRG CMS forms.
4
+
5
+ DrgDefaultHtmlEditor consists of CK editor component and EL Finder file manager component.
5
6
 
6
7
  Configuration
7
8
  ----------------
8
9
 
9
- Add this line to your gem file:
10
+ Add this line to your Gemfile:
10
11
  ```ruby
11
12
  gem 'drg_default_html_editor'
12
13
  ```
@@ -18,6 +19,11 @@ Usage in Forms:
18
19
  name: body
19
20
  type: html_field
20
21
  options: "height: 500, width: 550, toolbar: 'basic'"
22
+ # or
23
+ options:
24
+ height: 500
25
+ width: 550
26
+ toolbar: "'basic'"
21
27
 
22
28
  20:
23
29
  name: picture
@@ -8,8 +8,8 @@
8
8
  * You're free to add application-wide styles to this file and they'll appear at the top of the
9
9
  * compiled file, but it's generally better to create a new file per style scope.
10
10
  *
11
- *= require ../javascripts/drg_default_html_editor/elfinder/css/elfinder.min.css
12
- *= require ../javascripts/drg_default_html_editor/elfinder/css/theme.css
11
+ *= require drg_default_html_editor/elfinder/css/elfinder.min.css
12
+ *= require drg_default_html_editor/elfinder/css/theme.css
13
13
  */
14
14
 
15
15
 
@@ -0,0 +1,30 @@
1
+ #--
2
+ # Copyright (c) 2014+ Damjan Rems
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ #require 'patches/drgcms_form_field.rb'
25
+
26
+ patches_path = File.expand_path("../../../lib/patches", __FILE__)
27
+ # Add to DrgCms patches paths
28
+ DrgCms::add_patches_path(patches_path)
29
+ # Load initialy
30
+ Dir["#{patches_path}/**/*.rb"].each { |file| require file }
@@ -1,3 +1,3 @@
1
1
  module DrgDefaultHtmlEditor
2
- VERSION = "0.4.18"
2
+ VERSION = "0.4.21"
3
3
  end
@@ -4,3 +4,5 @@ require 'el_finder'
4
4
 
5
5
  module DrgDefaultHtmlEditor
6
6
  end
7
+
8
+ #DrgCms.add_patches_path(File.dirname(__FILE__) + '/patches')
@@ -36,11 +36,12 @@ def render
36
36
  return ro_standard if @readonly
37
37
  set_initial_value
38
38
  #
39
+ record = record_text_for(@yaml['name'])
39
40
  @js << <<EOJS
40
41
 
41
- $('#record_#{@yaml['name']}').dblclick(function(){
42
- $('#record_div_#{@yaml['name']}').show();
43
- var f = $('#record_div_#{@yaml['name']}').elfinder({
42
+ $('##{record}_#{@yaml['name']}').dblclick(function(){
43
+ $('##{record}_div_#{@yaml['name']}').show();
44
+ var f = $('##{record}_div_#{@yaml['name']}').elfinder({
44
45
  url : '/elfinder',
45
46
  transport : new elFinderSupportVer1(),
46
47
  height: 490,
@@ -49,15 +50,15 @@ $('#record_#{@yaml['name']}').dblclick(function(){
49
50
  lang: '#{I18n.locale}',
50
51
  getFileCallback : function(file) {
51
52
  file = file.replace('//','/');
52
- $('#record_#{@yaml['name']}').val(file);
53
- $('#record_div_#{@yaml['name']}').hide();
53
+ $('##{record}_#{@yaml['name']}').val(file);
54
+ $('##{record}_div_#{@yaml['name']}').hide();
54
55
  },
55
56
  });
56
57
  });
57
58
  EOJS
58
59
 
59
- @html << @parent.text_field('record', @yaml['name'], @yaml['html']) +
60
- "<div id='record_div_#{@yaml['name']}'></div>".html_safe
60
+ @html << @parent.text_field(record, @yaml['name'], @yaml['html']) +
61
+ "<div id='#{record}_div_#{@yaml['name']}'></div>".html_safe
61
62
  self
62
63
  end
63
64
 
@@ -65,7 +66,7 @@ end
65
66
  # Return html url code required for FileManager icon on CMS menu.
66
67
  ###########################################################################
67
68
  def self.file_manager_url(parent)
68
- url = "assets/drg_default_html_editor/elfinder/elfinder.html?CKEditorFuncNum=1&langCode=#{I18n.locale}"
69
+ url = "/assets/drg_default_html_editor/elfinder/elfinder.html?CKEditorFuncNum=1&langCode=#{I18n.locale}"
69
70
 
70
71
  parent.link_to( parent.image_tag('drg_cms/file_manager.png',
71
72
  class: 'dc-link-img',
@@ -104,8 +105,9 @@ def render
104
105
  @yaml['options'] << ", language: '#{I18n.locale}'" unless @yaml['options'].match('language:')
105
106
 
106
107
  options = @yaml['options'] ? ",{#{@yaml['options']}}" : ''
107
- @html << @parent.text_area('record', @yaml['name'], @yaml['html'])
108
- @js << "CKEDITOR.replace( 'record_#{@yaml['name']}'#{options} );"
108
+ record = record_text_for(@yaml['name'])
109
+ @html << @parent.text_area(record, @yaml['name'], @yaml['html'])
110
+ @js << "CKEDITOR.replace( '#{record}_#{@yaml['name']}'#{options} );"
109
111
  self
110
112
  end
111
113
  end
@@ -0,0 +1,113 @@
1
+ #--
2
+ # Copyright (c) 2012+ Damjan Rems
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+ DrgcmsFormFields rescue nil
24
+
25
+ module DrgcmsFormFields
26
+ ###########################################################################
27
+ # Class for creating ElFinder file manager enabled form field.
28
+ ###########################################################################
29
+ class Elfinder < DrgcmsField
30
+
31
+ ###########################################################################
32
+ # Return code required to render elfinder DRG CMS form field.
33
+ ###########################################################################
34
+ def render
35
+ return ro_standard if @readonly
36
+ set_initial_value
37
+ #
38
+ record = record_text_for(@yaml['name'])
39
+ @js << <<EOJS
40
+
41
+ $('##{record}_#{@yaml['name']}').dblclick(function(){
42
+ $('##{record}_div_#{@yaml['name']}').show();
43
+ var f = $('##{record}_div_#{@yaml['name']}').elfinder({
44
+ url : '/elfinder',
45
+ transport : new elFinderSupportVer1(),
46
+ height: 490,
47
+ docked: false,
48
+ dialog: { width: 400, modal: true },
49
+ lang: '#{I18n.locale}',
50
+ getFileCallback : function(file) {
51
+ file = file.replace('//','/');
52
+ $('##{record}_#{@yaml['name']}').val(file);
53
+ $('##{record}_div_#{@yaml['name']}').hide();
54
+ },
55
+ });
56
+ });
57
+ EOJS
58
+
59
+ @html << @parent.text_field(record, @yaml['name'], @yaml['html']) +
60
+ "<div id='#{record}_div_#{@yaml['name']}'></div>".html_safe
61
+ self
62
+ end
63
+
64
+ ###########################################################################
65
+ # Return html url code required for FileManager icon on CMS menu.
66
+ ###########################################################################
67
+ def self.file_manager_url(parent)
68
+ url = "/assets/drg_default_html_editor/elfinder/elfinder.html?CKEditorFuncNum=1&langCode=#{I18n.locale}"
69
+
70
+ parent.link_to( parent.fa_icon('archive lg',
71
+ title: parent.t('drgcms.file_manager')),
72
+ '#',
73
+ { onclick: "window.open('#{url}',
74
+ '#{parent.t('drgcms.file_manager')}',
75
+ 'width=700,height=500')"} )
76
+ end
77
+
78
+ end
79
+
80
+ ###########################################################################
81
+ # Class for creating ckeditor DRG CMS form field.
82
+ ###########################################################################
83
+ class Ckeditor < DrgcmsFormFields::DrgcmsField
84
+
85
+ ###########################################################################
86
+ # Return code required to render ckeditor DRG CMS form field.
87
+ ###########################################################################
88
+ def render
89
+ return ro_standard if @readonly
90
+ set_initial_value
91
+ # read configuration from site settings
92
+ ck_config = '/assets/ckeditor_config.js'
93
+ ck_css = '/assets/ckeditor_css.css'
94
+ ck = @parent.dc_get_site ? @parent.dc_get_site.params['ck_editor'] : nil # site might not be available yet
95
+ if ck
96
+ ck_config = ck['config_file'] if ck['config_file']
97
+ ck_css = ck['css_file'] if ck['css_file']
98
+ end
99
+ #
100
+ @yaml['options'] ||= ''
101
+ @yaml['options'] << ", customConfig: '#{ck_config}'"
102
+ @yaml['options'] << ", contentsCss: '#{ck_css}'" unless ck_css.blank?
103
+ @yaml['options'] << ", language: '#{I18n.locale}'" unless @yaml['options'].match('language:')
104
+
105
+ options = @yaml['options'] ? ",{#{@yaml['options']}}" : ''
106
+ record = record_text_for(@yaml['name'])
107
+ @html << @parent.text_area(record, @yaml['name'], @yaml['html'])
108
+ @js << "CKEDITOR.replace( '#{record}_#{@yaml['name']}'#{options} );"
109
+ self
110
+ end
111
+ end
112
+
113
+ end
@@ -20,6 +20,8 @@
20
20
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  #++
23
+ ElFinder rescue nil
24
+
23
25
  module ElFinder
24
26
  class Connector
25
27
 
@@ -0,0 +1,115 @@
1
+ #--
2
+ # Copyright (c) 2012+ Damjan Rems
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+ DrgcmsFormField rescue nil # force loading of drgcms_form_field.rb in development ;-)
24
+
25
+ module DrgcmsFormField
26
+
27
+ ###########################################################################
28
+ # Class for creating ElFinder file manager enabled form field.
29
+ ###########################################################################
30
+ class Elfinder < DrgcmsField
31
+
32
+ ###########################################################################
33
+ # Return code required to render elfinder DRG CMS form field.
34
+ ###########################################################################
35
+ def render
36
+ return ro_standard if @readonly
37
+ set_initial_value
38
+ #
39
+ record = record_text_for(@yaml['name'])
40
+ @js << <<EOJS
41
+
42
+ $('##{record}_#{@yaml['name']}').dblclick(function(){
43
+ $('##{record}_div_#{@yaml['name']}').show();
44
+ var f = $('##{record}_div_#{@yaml['name']}').elfinder({
45
+ url : '/elfinder',
46
+ transport : new elFinderSupportVer1(),
47
+ height: 490,
48
+ docked: false,
49
+ dialog: { width: 400, modal: true },
50
+ lang: '#{I18n.locale}',
51
+ getFileCallback : function(file) {
52
+ file = file.replace('//','/');
53
+ $('##{record}_#{@yaml['name']}').val(file);
54
+ $('##{record}_div_#{@yaml['name']}').hide();
55
+ },
56
+ });
57
+ });
58
+ EOJS
59
+
60
+ @html << @parent.text_field(record, @yaml['name'], @yaml['html']) +
61
+ "<div id='#{record}_div_#{@yaml['name']}'></div>".html_safe
62
+ self
63
+ end
64
+
65
+ ###########################################################################
66
+ # Return html url code required for FileManager icon on CMS menu.
67
+ ###########################################################################
68
+ def self.file_manager_url(parent)
69
+ url = "/assets/drg_default_html_editor/elfinder/elfinder.html?CKEditorFuncNum=1&langCode=#{I18n.locale}"
70
+
71
+ parent.link_to( parent.image_tag('drg_cms/file_manager.png',
72
+ class: 'dc-link-img',
73
+ title: parent.t('drgcms.file_manager')),
74
+ '#',
75
+ { onclick: "window.open('#{url}',
76
+ '#{parent.t('drgcms.file_manager')}',
77
+ 'width=700,height=500')"} )
78
+ end
79
+
80
+ end
81
+
82
+ ###########################################################################
83
+ # Class for creating ckeditor DRG CMS form field.
84
+ ###########################################################################
85
+ class Ckeditor < DrgcmsField
86
+
87
+ ###########################################################################
88
+ # Return code required to render ckeditor DRG CMS form field.
89
+ ###########################################################################
90
+ def render
91
+ return ro_standard if @readonly
92
+ set_initial_value
93
+ # read configuration from site settings
94
+ ck_config = '/assets/ckeditor_config.js'
95
+ ck_css = '/assets/ckeditor_css.css'
96
+ ck = @parent.dc_get_site ? @parent.dc_get_site.params['ck_editor'] : nil # site might not be available yet
97
+ if ck
98
+ ck_config = ck['config_file'] if ck['config_file']
99
+ ck_css = ck['css_file'] if ck['css_file']
100
+ end
101
+ #
102
+ @yaml['options'] ||= ''
103
+ @yaml['options'] << ", customConfig: '#{ck_config}'"
104
+ @yaml['options'] << ", contentsCss: '#{ck_css}'" unless ck_css.blank?
105
+ @yaml['options'] << ", language: '#{I18n.locale}'" unless @yaml['options'].match('language:')
106
+
107
+ options = @yaml['options'] ? ",{#{@yaml['options']}}" : ''
108
+ record = record_text_for(@yaml['name'])
109
+ @html << @parent.text_area(record, @yaml['name'], @yaml['html'])
110
+ @js << "CKEDITOR.replace( '#{record}_#{@yaml['name']}'#{options} );"
111
+ self
112
+ end
113
+ end
114
+
115
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drg_default_html_editor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.18
4
+ version: 0.4.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damjan Rems
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-22 00:00:00.000000000 Z
11
+ date: 2015-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -476,13 +476,15 @@ files:
476
476
  - app/assets/stylesheets/drg_default_html_editor_application.css
477
477
  - app/assets/stylesheets/drg_default_html_editor_cms.css
478
478
  - app/controllers/dc_elfinder_controller.rb
479
- - config/initializers/patch_drgcms_form_field.rb
480
- - config/initializers/patch_for_elfinder.rb
479
+ - config/initializers/load_patches.rb
481
480
  - config/routes.rb
482
481
  - lib/drg_default_html_editor.rb
483
482
  - lib/drg_default_html_editor.rb~
484
483
  - lib/drg_default_html_editor/engine.rb
485
484
  - lib/drg_default_html_editor/version.rb
485
+ - lib/patch_drgcms_form_field.rb
486
+ - lib/patches/drgcms_form_field.rb
487
+ - lib/patches/patch_for_elfinder.rb
486
488
  - lib/tasks/drg_default_html_editor_copy_assets.rake
487
489
  - lib/tasks/drg_default_html_editor_tasks.rake
488
490
  - test/drg_default_html_editor_test.rb
@@ -515,6 +517,7 @@ files:
515
517
  - test/dummy/public/favicon.ico
516
518
  - test/dummy/script/rails
517
519
  - test/integration/navigation_test.rb
520
+ - test/patch_drgcms_form_field.rb
518
521
  - test/test_helper.rb
519
522
  homepage: http://www.drgcms.org
520
523
  licenses:
@@ -536,13 +539,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
536
539
  version: '0'
537
540
  requirements: []
538
541
  rubyforge_project:
539
- rubygems_version: 2.2.2
542
+ rubygems_version: 2.2.3
540
543
  signing_key:
541
544
  specification_version: 4
542
545
  summary: 'DRG CMS: Default HTML editor and file manager plugin'
543
546
  test_files:
544
547
  - test/test_helper.rb
545
548
  - test/integration/navigation_test.rb
549
+ - test/patch_drgcms_form_field.rb
546
550
  - test/drg_default_html_editor_test.rb
547
551
  - test/dummy/README.rdoc
548
552
  - test/dummy/config/locales/en.yml