activeadmin-redactor 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20df383d123b4cb9f1c78c1370984c2fa442f1a8
4
- data.tar.gz: 7593077251d069dc64561f35c019bc992b6d6171
3
+ metadata.gz: 875ac513ca0716e7d14b73c076fd71a803bc3eae
4
+ data.tar.gz: c2ec0a7c7a1ebd28a2c4c732c39a507a4a530adc
5
5
  SHA512:
6
- metadata.gz: 40bc66441a4c0af3ab42c90ac3a8991f9287848bb2ea80e2f6bb53a6d8bfcc7672bb7e225254bb946cced6770b82b954340269d1af070d299dc3765eaaea71e5
7
- data.tar.gz: 128e9c73abd087dbbea248223cafcb2c75b4e3e9d2b9c8c5626f95c0f35867f36e577594e9d356f87a9f9928b698295afe18fcde7d109712d360316d25381657
6
+ metadata.gz: 14595fb2e9ff4338d596df0b5ad8800daf852459cc37d97fb55714f12dc0f75006831e3534451127e283129a097bc88167b459934d408bf35f7a841673f33791
7
+ data.tar.gz: 0252a50f7ad63882fc0799e25dab61aebb464abcb263e625289346cb054a227e75595a4b79456dc864d4783932ed7423361a069baf2bc0c5bc336e57123f065d
data/README.md CHANGED
@@ -30,27 +30,26 @@ end
30
30
  Default setting is 'activeadmin-redactor'
31
31
 
32
32
  ```ruby
33
- ActiveAdmin.register Page do
34
33
  redactorable stylesheets: ["fonts", "application"]
35
- end
34
+ ```
35
+ #### Javascripts
36
+ Default setting is 'jquery', 'jquery_ujs', 'activeadmin-redactor'
37
+ ```ruby
38
+ redactorable javascripts: ["textdirection.js"]
36
39
  ```
37
40
 
38
41
  #### Layout
39
42
  Default setting is 'redactor'
40
43
 
41
44
  ```ruby
42
- ActiveAdmin.register Page do
43
45
  redactorable layout: ["foobar"]
44
- end
45
46
  ```
46
47
 
47
48
  #### Tempate
48
49
  Default setting is 'redactor/editor'
49
50
 
50
51
  ```ruby
51
- ActiveAdmin.register Page do
52
52
  redactorable template: ["redactor/editor"]
53
- end
54
53
  ```
55
54
 
56
55
  ### Optional Redactor Customization
@@ -58,51 +57,46 @@ end
58
57
  Default setting is false
59
58
 
60
59
  ```ruby
61
- ActiveAdmin.register Page do
62
60
  redactorable redactor: {focus: true}
63
- end
64
61
  ```
65
62
  #### [iframe](http://imperavi.com/redactor/examples/iframe/)
66
63
  Default setting is false
67
64
 
68
65
  ```ruby
69
- ActiveAdmin.register Page do
70
66
  redactorable redactor: {iframe: true}
71
- end
72
67
  ```
73
68
  #### [fullpage](http://imperavi.com/redactor/examples/fullpage/)
74
69
  Default setting is false
75
70
 
76
71
  ```ruby
77
- ActiveAdmin.register Page do
78
72
  redactorable redactor: {fullpage: true}
79
- end
80
73
  ```
81
74
  #### [css](http://imperavi.com/redactor/examples/css/)
82
75
  Default setting is none
83
76
 
84
77
  ```ruby
85
- ActiveAdmin.register Page do
86
78
  redactorable redactor: {css: ['application', 'override']}
87
- end
88
79
  ```
89
80
 
90
81
  #### minHeight
91
82
  Default setting is false
92
83
 
93
84
  ```ruby
94
- ActiveAdmin.register Page do
95
85
  redactorable redactor: {minheight: 200}
96
- end
97
86
  ```
98
87
 
99
88
  #### imageUpload
100
89
  Default setting is false
101
90
 
102
91
  ```ruby
103
- ActiveAdmin.register Page do
104
- redactorable redactor: {imageupload: /foo/bar/path}
105
- end
92
+ redactorable redactor: {imageupload: '/foo/bar/path'}
93
+ ```
94
+
95
+ #### [plugins](http://imperavi.com/redactor/examples/plugin-create/)
96
+ Default setting is none
97
+
98
+ ```ruby
99
+ redactorable redactor: {plugins: ['admin/fontfamily.js']}
106
100
  ```
107
101
 
108
102
  ## Contributing
@@ -5,12 +5,7 @@
5
5
  <meta charset="utf-8">
6
6
  <%= csrf_meta_tags %>
7
7
  <%= stylesheet_link_tag *@viewport_opts.stylesheets %>
8
- </head>
9
-
10
- <body>
11
- <%= render "layouts/redactor_header" %>
12
- <%= yield %>
13
- <%= javascript_include_tag 'jquery', 'jquery_ujs', 'activeadmin-redactor' %>
8
+ <%= javascript_include_tag *@viewport_opts.javascripts %>
14
9
  <script type="text/javascript">
15
10
  $(function() {
16
11
  $('#redactor').redactor({
@@ -20,9 +15,15 @@
20
15
  css: <%=raw redactor_css(@redactor_opts.css) %>,
21
16
  minHeight: <%= @redactor_opts.minheight %>,
22
17
  imageUpload: '<%= @redactor_opts.imageupload %>',
18
+ plugins: <%=raw @redactor_opts.plugins %>,
23
19
  });
24
20
  });
25
21
  </script>
22
+ </head>
23
+
24
+ <body>
25
+ <%= render "layouts/redactor_header" %>
26
+ <%= yield %>
26
27
  <%= render "layouts/redactor_footer" %>
27
28
  </body>
28
29
  </html>
@@ -1,5 +1,5 @@
1
1
  module Activeadmin
2
2
  module Redactor
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
@@ -26,6 +26,10 @@ module Activeadmin
26
26
  def imageupload
27
27
  opts[:imageupload] || false
28
28
  end
29
+
30
+ def plugins
31
+ opts[:plugins] || []
32
+ end
29
33
  end
30
34
  end
31
35
  end
@@ -6,6 +6,7 @@ module Activeadmin
6
6
  DEFAULT_LAYOUT = 'redactor'
7
7
  DEFAULT_TEMPLATE = 'redactor/editor'
8
8
  DEFAULT_STYLESHEET = 'activeadmin-redactor'
9
+ DEFAULT_JAVASCRIPTS = %w(jquery jquery_ujs activeadmin-redactor)
9
10
 
10
11
  def layout
11
12
  opts[:layout] || DEFAULT_LAYOUT
@@ -18,6 +19,10 @@ module Activeadmin
18
19
  def stylesheets
19
20
  (opts[:stylesheets] || []).unshift(DEFAULT_STYLESHEET)
20
21
  end
22
+
23
+ def javascripts
24
+ (opts[:javascripts] || []).unshift(*DEFAULT_JAVASCRIPTS)
25
+ end
21
26
  end
22
27
  end
23
28
  end
@@ -3,7 +3,7 @@ require_relative '../../lib/activeadmin/redactor_opts.rb'
3
3
 
4
4
  describe Activeadmin::Redactor::RedactorOpts do
5
5
  subject { described_class.new(options) }
6
-
6
+
7
7
  describe '#iframe' do
8
8
  context 'no options passed' do
9
9
  let(:options) {Hash.new}
@@ -101,4 +101,21 @@ describe Activeadmin::Redactor::RedactorOpts do
101
101
  end
102
102
  end
103
103
  end
104
+
105
+ describe '#plugins' do
106
+ context 'no options passed' do
107
+ let(:options) {Hash.new}
108
+ it 'returns empty array' do
109
+ expect(subject.plugins).to eql([])
110
+ end
111
+ end
112
+
113
+ context 'options passed' do
114
+ let(:options) {{plugins: ['admin/fontfamily.js']}}
115
+ it 'returns unmodified array' do
116
+ expect(subject.plugins).to eql(['admin/fontfamily.js'])
117
+ end
118
+ end
119
+ end
120
+
104
121
  end
@@ -20,6 +20,24 @@ describe Activeadmin::Redactor::ViewportOpts do
20
20
  end
21
21
  end
22
22
 
23
+ describe '#javascripts' do
24
+ context 'no options passed' do
25
+ let(:options) {Hash.new}
26
+ it 'returns array with required js elements' do
27
+ expect(subject.javascripts).
28
+ to eql(['jquery', 'jquery_ujs', 'activeadmin-redactor'])
29
+ end
30
+ end
31
+
32
+ context 'options passed' do
33
+ let(:options) {{javascripts: ['foo.js', 'bar.js']}}
34
+ it 'returns javascripts with required js elements prepended' do
35
+ expect(subject.javascripts).
36
+ to eql(%w(jquery jquery_ujs activeadmin-redactor foo.js bar.js))
37
+ end
38
+ end
39
+ end
40
+
23
41
  describe '#layout' do
24
42
  context 'no options passed' do
25
43
  let(:options) {Hash.new}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin-redactor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Entwistle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-29 00:00:00.000000000 Z
11
+ date: 2014-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler