activeadmin-redactor 0.0.2 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +44 -1
- data/activeadmin-redactor.gemspec +3 -0
- data/app/views/layouts/_redactor_footer.html.erb +0 -0
- data/app/views/layouts/_redactor_header.html.erb +0 -0
- data/app/views/layouts/redactor.html.erb +28 -0
- data/app/views/redactor/editor.html.erb +7 -31
- data/lib/activeadmin/options.rb +13 -0
- data/lib/activeadmin/redactor.rb +5 -4
- data/lib/activeadmin/redactor/version.rb +1 -1
- data/lib/activeadmin/redactor_opts.rb +14 -8
- data/lib/activeadmin/viewport_opts.rb +23 -0
- data/spec/activeadmin/redactor_opts_spec.rb +49 -1
- data/spec/activeadmin/viewport_opts_spec.rb +54 -0
- metadata +37 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20df383d123b4cb9f1c78c1370984c2fa442f1a8
|
4
|
+
data.tar.gz: 7593077251d069dc64561f35c019bc992b6d6171
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40bc66441a4c0af3ab42c90ac3a8991f9287848bb2ea80e2f6bb53a6d8bfcc7672bb7e225254bb946cced6770b82b954340269d1af070d299dc3765eaaea71e5
|
7
|
+
data.tar.gz: 128e9c73abd087dbbea248223cafcb2c75b4e3e9d2b9c8c5626f95c0f35867f36e577594e9d356f87a9f9928b698295afe18fcde7d109712d360316d25381657
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ end
|
|
27
27
|
|
28
28
|
### Optional View Port Customization
|
29
29
|
#### Stylesheets
|
30
|
-
Default setting is
|
30
|
+
Default setting is 'activeadmin-redactor'
|
31
31
|
|
32
32
|
```ruby
|
33
33
|
ActiveAdmin.register Page do
|
@@ -35,7 +35,33 @@ ActiveAdmin.register Page do
|
|
35
35
|
end
|
36
36
|
```
|
37
37
|
|
38
|
+
#### Layout
|
39
|
+
Default setting is 'redactor'
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
ActiveAdmin.register Page do
|
43
|
+
redactorable layout: ["foobar"]
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
#### Tempate
|
48
|
+
Default setting is 'redactor/editor'
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
ActiveAdmin.register Page do
|
52
|
+
redactorable template: ["redactor/editor"]
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
38
56
|
### Optional Redactor Customization
|
57
|
+
#### [focus](http://imperavi.com/redactor/examples/focus/)
|
58
|
+
Default setting is false
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
ActiveAdmin.register Page do
|
62
|
+
redactorable redactor: {focus: true}
|
63
|
+
end
|
64
|
+
```
|
39
65
|
#### [iframe](http://imperavi.com/redactor/examples/iframe/)
|
40
66
|
Default setting is false
|
41
67
|
|
@@ -44,6 +70,14 @@ ActiveAdmin.register Page do
|
|
44
70
|
redactorable redactor: {iframe: true}
|
45
71
|
end
|
46
72
|
```
|
73
|
+
#### [fullpage](http://imperavi.com/redactor/examples/fullpage/)
|
74
|
+
Default setting is false
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
ActiveAdmin.register Page do
|
78
|
+
redactorable redactor: {fullpage: true}
|
79
|
+
end
|
80
|
+
```
|
47
81
|
#### [css](http://imperavi.com/redactor/examples/css/)
|
48
82
|
Default setting is none
|
49
83
|
|
@@ -62,6 +96,15 @@ ActiveAdmin.register Page do
|
|
62
96
|
end
|
63
97
|
```
|
64
98
|
|
99
|
+
#### imageUpload
|
100
|
+
Default setting is false
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
ActiveAdmin.register Page do
|
104
|
+
redactorable redactor: {imageupload: /foo/bar/path}
|
105
|
+
end
|
106
|
+
```
|
107
|
+
|
65
108
|
## Contributing
|
66
109
|
|
67
110
|
1. Fork it ( https://github.com/[my-github-username]/activeadmin-redactor/fork )
|
@@ -17,6 +17,9 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
|
20
23
|
spec.add_dependency 'activeadmin', '~> 0.4'
|
21
24
|
spec.add_development_dependency 'rspec'
|
22
25
|
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Redactor</title>
|
5
|
+
<meta charset="utf-8">
|
6
|
+
<%= csrf_meta_tags %>
|
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' %>
|
14
|
+
<script type="text/javascript">
|
15
|
+
$(function() {
|
16
|
+
$('#redactor').redactor({
|
17
|
+
focus: <%= @redactor_opts.focus %>,
|
18
|
+
fullpage: <%= @redactor_opts.fullpage %>,
|
19
|
+
iframe: <%= @redactor_opts.iframe %>,
|
20
|
+
css: <%=raw redactor_css(@redactor_opts.css) %>,
|
21
|
+
minHeight: <%= @redactor_opts.minheight %>,
|
22
|
+
imageUpload: '<%= @redactor_opts.imageupload %>',
|
23
|
+
});
|
24
|
+
});
|
25
|
+
</script>
|
26
|
+
<%= render "layouts/redactor_footer" %>
|
27
|
+
</body>
|
28
|
+
</html>
|
@@ -1,31 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
</head>
|
9
|
-
|
10
|
-
<body>
|
11
|
-
<div id="viewport">
|
12
|
-
<%= form_for(resource, url: resource_path(resource)) do |f| %>
|
13
|
-
<%= f.submit %>
|
14
|
-
<%= f.text_area :redactorable, id: 'redactor' %>
|
15
|
-
<%= f.submit %>
|
16
|
-
<% end %>
|
17
|
-
</div>
|
18
|
-
|
19
|
-
<%= javascript_include_tag 'activeadmin-redactor' %>
|
20
|
-
<script type="text/javascript">
|
21
|
-
$(function()
|
22
|
-
{
|
23
|
-
$('#redactor').redactor({
|
24
|
-
iframe: <%= @redactor_opts.iframe %>,
|
25
|
-
css: <%=raw redactor_css(@redactor_opts.css) %>,
|
26
|
-
minHeight: window.innerHeight - 100,
|
27
|
-
});
|
28
|
-
});
|
29
|
-
</script>
|
30
|
-
</body>
|
31
|
-
</html>
|
1
|
+
<div id="viewport">
|
2
|
+
<%= form_for(resource, url: resource_path(resource)) do |f| %>
|
3
|
+
<%= f.submit %>
|
4
|
+
<%= f.text_area :redactorable, id: 'redactor' %>
|
5
|
+
<%= f.submit %>
|
6
|
+
<% end %>
|
7
|
+
</div>
|
data/lib/activeadmin/redactor.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
require 'activeadmin/redactor/version'
|
2
2
|
require 'activeadmin/redactor_opts'
|
3
|
+
require 'activeadmin/viewport_opts'
|
3
4
|
require 'activeadmin'
|
4
5
|
require 'rails/engine'
|
5
6
|
|
6
7
|
module Activeadmin
|
7
8
|
module Redactor
|
8
9
|
module ControllerActions
|
9
|
-
def redactorable(
|
10
|
+
def redactorable(options={})
|
10
11
|
member_action :redactor do
|
11
|
-
@
|
12
|
-
@
|
13
|
-
render
|
12
|
+
@viewport_opts = ViewportOpts.new(options)
|
13
|
+
@redactor_opts = RedactorOpts.new(options[:redactor])
|
14
|
+
render @viewport_opts.template, layout: @viewport_opts.layout
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
@@ -1,12 +1,18 @@
|
|
1
|
+
require_relative 'options'
|
2
|
+
|
1
3
|
module Activeadmin
|
2
4
|
module Redactor
|
3
|
-
class RedactorOpts
|
4
|
-
def
|
5
|
-
|
5
|
+
class RedactorOpts < Options
|
6
|
+
def iframe
|
7
|
+
opts[:iframe] === true
|
6
8
|
end
|
7
9
|
|
8
|
-
def
|
9
|
-
opts[:
|
10
|
+
def fullpage
|
11
|
+
opts[:fullpage] === true
|
12
|
+
end
|
13
|
+
|
14
|
+
def focus
|
15
|
+
opts[:focus] === true
|
10
16
|
end
|
11
17
|
|
12
18
|
def css
|
@@ -17,9 +23,9 @@ module Activeadmin
|
|
17
23
|
opts[:minheight] || false
|
18
24
|
end
|
19
25
|
|
20
|
-
|
21
|
-
|
22
|
-
|
26
|
+
def imageupload
|
27
|
+
opts[:imageupload] || false
|
28
|
+
end
|
23
29
|
end
|
24
30
|
end
|
25
31
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative 'options'
|
2
|
+
|
3
|
+
module Activeadmin
|
4
|
+
module Redactor
|
5
|
+
class ViewportOpts < Options
|
6
|
+
DEFAULT_LAYOUT = 'redactor'
|
7
|
+
DEFAULT_TEMPLATE = 'redactor/editor'
|
8
|
+
DEFAULT_STYLESHEET = 'activeadmin-redactor'
|
9
|
+
|
10
|
+
def layout
|
11
|
+
opts[:layout] || DEFAULT_LAYOUT
|
12
|
+
end
|
13
|
+
|
14
|
+
def template
|
15
|
+
opts[:template] || DEFAULT_TEMPLATE
|
16
|
+
end
|
17
|
+
|
18
|
+
def stylesheets
|
19
|
+
(opts[:stylesheets] || []).unshift(DEFAULT_STYLESHEET)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
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}
|
@@ -20,6 +20,38 @@ describe Activeadmin::Redactor::RedactorOpts do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
describe '#fullpage' do
|
24
|
+
context 'no options passed' do
|
25
|
+
let(:options) {Hash.new}
|
26
|
+
it 'returns false' do
|
27
|
+
expect(subject.fullpage).to eql(false)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'options passed' do
|
32
|
+
let(:options) {{fullpage: true}}
|
33
|
+
it 'returns true' do
|
34
|
+
expect(subject.fullpage).to eql(true)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#focus' do
|
40
|
+
context 'no options passed' do
|
41
|
+
let(:options) {Hash.new}
|
42
|
+
it 'returns false' do
|
43
|
+
expect(subject.focus).to eql(false)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'options passed' do
|
48
|
+
let(:options) {{focus: true}}
|
49
|
+
it 'returns true' do
|
50
|
+
expect(subject.focus).to eql(true)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
23
55
|
describe '#css' do
|
24
56
|
context 'no options passed' do
|
25
57
|
let(:options) {Hash.new}
|
@@ -53,4 +85,20 @@ describe Activeadmin::Redactor::RedactorOpts do
|
|
53
85
|
end
|
54
86
|
end
|
55
87
|
end
|
88
|
+
|
89
|
+
describe '#imageupload' do
|
90
|
+
context 'no options passed' do
|
91
|
+
let(:options) {Hash.new}
|
92
|
+
it 'returns false' do
|
93
|
+
expect(subject.imageupload).to eql(false)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'options passed' do
|
98
|
+
let(:options) {{imageupload: '/foo/bar/path'}}
|
99
|
+
it 'returns unmodified string' do
|
100
|
+
expect(subject.imageupload).to eql('/foo/bar/path')
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
56
104
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../../lib/activeadmin/viewport_opts.rb'
|
3
|
+
|
4
|
+
describe Activeadmin::Redactor::ViewportOpts do
|
5
|
+
subject { described_class.new(options) }
|
6
|
+
|
7
|
+
describe '#stylesheets' do
|
8
|
+
context 'no options passed' do
|
9
|
+
let(:options) {Hash.new}
|
10
|
+
it 'returns array with single element \'activeadmin-redactor\'' do
|
11
|
+
expect(subject.stylesheets).to eql(['activeadmin-redactor'])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'options passed' do
|
16
|
+
let(:options) {{stylesheets: ['foo.css', 'bar.css']}}
|
17
|
+
it 'returns stylesheets with activeadmin-redactor prepended' do
|
18
|
+
expect(subject.stylesheets).to eql(['activeadmin-redactor', 'foo.css', 'bar.css'])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#layout' do
|
24
|
+
context 'no options passed' do
|
25
|
+
let(:options) {Hash.new}
|
26
|
+
it 'returns default layout' do
|
27
|
+
expect(subject.layout).to eql('redactor')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'options passed' do
|
32
|
+
let(:options) {{layout: 'foobar'}}
|
33
|
+
it 'returns unmodified layout' do
|
34
|
+
expect(subject.layout).to eql('foobar')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#template' do
|
40
|
+
context 'no options passed' do
|
41
|
+
let(:options) {Hash.new}
|
42
|
+
it 'returns default template redactor/editor' do
|
43
|
+
expect(subject.template).to eql('redactor/editor')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'options passed' do
|
48
|
+
let(:options) {{template: 'foo/bar'}}
|
49
|
+
it 'returns unmodified template' do
|
50
|
+
expect(subject.template).to eql('foo/bar')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin-redactor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.2
|
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-
|
11
|
+
date: 2014-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: activeadmin
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,11 +80,17 @@ files:
|
|
52
80
|
- Rakefile
|
53
81
|
- activeadmin-redactor.gemspec
|
54
82
|
- app/helpers/redactor_helper.rb
|
83
|
+
- app/views/layouts/_redactor_footer.html.erb
|
84
|
+
- app/views/layouts/_redactor_header.html.erb
|
85
|
+
- app/views/layouts/redactor.html.erb
|
55
86
|
- app/views/redactor/editor.html.erb
|
87
|
+
- lib/activeadmin/options.rb
|
56
88
|
- lib/activeadmin/redactor.rb
|
57
89
|
- lib/activeadmin/redactor/version.rb
|
58
90
|
- lib/activeadmin/redactor_opts.rb
|
91
|
+
- lib/activeadmin/viewport_opts.rb
|
59
92
|
- spec/activeadmin/redactor_opts_spec.rb
|
93
|
+
- spec/activeadmin/viewport_opts_spec.rb
|
60
94
|
- spec/spec_helper.rb
|
61
95
|
- vendor/assets/javascripts/activeadmin-redactor.js
|
62
96
|
- vendor/assets/stylesheets/activeadmin-redactor.css
|
@@ -86,4 +120,5 @@ specification_version: 4
|
|
86
120
|
summary: Redactor WYSIWYG Editor Integration for ActiveAdmin resources.
|
87
121
|
test_files:
|
88
122
|
- spec/activeadmin/redactor_opts_spec.rb
|
123
|
+
- spec/activeadmin/viewport_opts_spec.rb
|
89
124
|
- spec/spec_helper.rb
|