activeadmin-redactor 0.0.1 → 0.0.2

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: d8618918ff5e9c5566cc758c3bc17dd1f6b86b0a
4
- data.tar.gz: 656f047b560a7473682ef026a6528b4c37fdf58c
3
+ metadata.gz: aa6771ecaeb76d1f6049cd1eb5797063e82f8ad6
4
+ data.tar.gz: 5bb17692296a4e2d5da434249a6873167ed04eae
5
5
  SHA512:
6
- metadata.gz: f843367199e6337ca4377d5dda2b32ee1bf3f36e8cb8b7325dc797c38320b77b172b203c2d43f0102cf4dd269b9769fd5244fe0002b18d6def26dcbb5ba01e1c
7
- data.tar.gz: 9fa0e359745e99ba12e9d8aa9b5e5fafd5fb0b22c6971f503afc1e0681db84e16c50fc5699dca2b37e917c45e5a870d20d56cff972d3c8b45700bafac4129d17
6
+ metadata.gz: d97a1ca1dcdc10c701aceeba9cd1226a4694c97221872c705d47d59d0e4e2420c44b152fbd2f343582af2d54c4a9add7c19c22817473941080148869f24bd31c
7
+ data.tar.gz: 35e55733d1e99763e72d38d3d2b07c495a24474468fbd2253d824e7910defefc0caad8af59042c52b55d9d374ce132d9f9081b97f2d4c17bc3761d22f2177a74
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Activeadmin::Redactor
2
2
 
3
- TODO: Write a gem description
3
+ Limited subsection of [redactor](http://imperavi.com/redactor/) options.
4
+ Currently no plans to make this feature complete (supporting all the options from the API).
5
+ Feel free to add options and submit a pull request if missing one you require.
4
6
 
5
7
  ## Usage
6
8
 
@@ -23,6 +25,43 @@ ActiveAdmin.register Page do
23
25
  end
24
26
  ```
25
27
 
28
+ ### Optional View Port Customization
29
+ #### Stylesheets
30
+ Default setting is none
31
+
32
+ ```ruby
33
+ ActiveAdmin.register Page do
34
+ redactorable stylesheets: ["fonts", "application"]
35
+ end
36
+ ```
37
+
38
+ ### Optional Redactor Customization
39
+ #### [iframe](http://imperavi.com/redactor/examples/iframe/)
40
+ Default setting is false
41
+
42
+ ```ruby
43
+ ActiveAdmin.register Page do
44
+ redactorable redactor: {iframe: true}
45
+ end
46
+ ```
47
+ #### [css](http://imperavi.com/redactor/examples/css/)
48
+ Default setting is none
49
+
50
+ ```ruby
51
+ ActiveAdmin.register Page do
52
+ redactorable redactor: {css: ['application', 'override']}
53
+ end
54
+ ```
55
+
56
+ #### minHeight
57
+ Default setting is false
58
+
59
+ ```ruby
60
+ ActiveAdmin.register Page do
61
+ redactorable redactor: {minheight: 200}
62
+ end
63
+ ```
64
+
26
65
  ## Contributing
27
66
 
28
67
  1. Fork it ( https://github.com/[my-github-username]/activeadmin-redactor/fork )
@@ -18,4 +18,5 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_dependency 'activeadmin', '~> 0.4'
21
+ spec.add_development_dependency 'rspec'
21
22
  end
@@ -0,0 +1,7 @@
1
+ module RedactorHelper
2
+ def redactor_css(sources)
3
+ sources.uniq.map do |source|
4
+ path_to_stylesheet(source)
5
+ end
6
+ end
7
+ end
@@ -4,22 +4,26 @@
4
4
  <title>Redactor</title>
5
5
  <meta charset="utf-8">
6
6
  <script type="text/javascript" src="//code.jquery.com/jquery-latest.min.js"></script>
7
- <%= stylesheet_link_tag 'activeadmin-redactor' %>
7
+ <%= stylesheet_link_tag *@stylesheets %>
8
8
  </head>
9
9
 
10
10
  <body>
11
- <%= form_for(resource, url: resource_path(resource)) do |f| %>
12
- <%= f.submit %>
13
- <%= f.text_area :redactorable, id: 'redactor' %>
14
- <%= f.submit %>
15
- <% end %>
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>
16
18
 
17
19
  <%= javascript_include_tag 'activeadmin-redactor' %>
18
20
  <script type="text/javascript">
19
21
  $(function()
20
22
  {
21
23
  $('#redactor').redactor({
22
- focus: true
24
+ iframe: <%= @redactor_opts.iframe %>,
25
+ css: <%=raw redactor_css(@redactor_opts.css) %>,
26
+ minHeight: window.innerHeight - 100,
23
27
  });
24
28
  });
25
29
  </script>
@@ -1,12 +1,15 @@
1
1
  require 'activeadmin/redactor/version'
2
+ require 'activeadmin/redactor_opts'
2
3
  require 'activeadmin'
3
4
  require 'rails/engine'
4
5
 
5
6
  module Activeadmin
6
7
  module Redactor
7
8
  module ControllerActions
8
- def redactorable
9
+ def redactorable(opts={})
9
10
  member_action :redactor do
11
+ @redactor_opts = RedactorOpts.new(opts[:redactor])
12
+ @stylesheets = (opts[:stylesheets] || []).unshift("activeadmin-redactor")
10
13
  render 'redactor/editor', layout: false
11
14
  end
12
15
  end
@@ -1,5 +1,5 @@
1
1
  module Activeadmin
2
2
  module Redactor
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -0,0 +1,25 @@
1
+ module Activeadmin
2
+ module Redactor
3
+ class RedactorOpts
4
+ def initialize(opts={})
5
+ @opts = opts
6
+ end
7
+
8
+ def iframe
9
+ opts[:iframe] == true
10
+ end
11
+
12
+ def css
13
+ opts[:css] || []
14
+ end
15
+
16
+ def minheight
17
+ opts[:minheight] || false
18
+ end
19
+
20
+ private
21
+
22
+ attr_reader :opts
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+ require_relative '../../lib/activeadmin/redactor_opts.rb'
3
+
4
+ describe Activeadmin::Redactor::RedactorOpts do
5
+ subject { described_class.new(options) }
6
+
7
+ describe '#iframe' do
8
+ context 'no options passed' do
9
+ let(:options) {Hash.new}
10
+ it 'returns false' do
11
+ expect(subject.iframe).to eql(false)
12
+ end
13
+ end
14
+
15
+ context 'options passed' do
16
+ let(:options) {{iframe: true}}
17
+ it 'returns true' do
18
+ expect(subject.iframe).to eql(true)
19
+ end
20
+ end
21
+ end
22
+
23
+ describe '#css' do
24
+ context 'no options passed' do
25
+ let(:options) {Hash.new}
26
+ it 'returns empty array' do
27
+ expect(subject.css).to eql([])
28
+ end
29
+ end
30
+
31
+ context 'options passed' do
32
+ let(:options) {{css: ['application.css', 'http://www.example.com/style.css']}}
33
+ it 'returns unmodified array' do
34
+ expect(subject.css).to eql(
35
+ ['application.css', 'http://www.example.com/style.css']
36
+ )
37
+ end
38
+ end
39
+ end
40
+
41
+ describe '#minheight' do
42
+ context 'no options passed' do
43
+ let(:options) {Hash.new}
44
+ it 'returns false' do
45
+ expect(subject.minheight).to eql(false)
46
+ end
47
+ end
48
+
49
+ context 'options passed' do
50
+ let(:options) {{minheight: 'window.innerHeight - 100'}}
51
+ it 'returns unmodified string' do
52
+ expect(subject.minheight).to eql('window.innerHeight - 100')
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,2 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
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.0.1
4
+ version: 0.0.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-26 00:00:00.000000000 Z
11
+ date: 2014-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
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'
27
41
  description:
28
42
  email:
29
43
  - karl.entwistle@unboxedconsulting.com
@@ -37,9 +51,13 @@ files:
37
51
  - README.md
38
52
  - Rakefile
39
53
  - activeadmin-redactor.gemspec
54
+ - app/helpers/redactor_helper.rb
40
55
  - app/views/redactor/editor.html.erb
41
56
  - lib/activeadmin/redactor.rb
42
57
  - lib/activeadmin/redactor/version.rb
58
+ - lib/activeadmin/redactor_opts.rb
59
+ - spec/activeadmin/redactor_opts_spec.rb
60
+ - spec/spec_helper.rb
43
61
  - vendor/assets/javascripts/activeadmin-redactor.js
44
62
  - vendor/assets/stylesheets/activeadmin-redactor.css
45
63
  homepage: http://imperavi.com/redactor/
@@ -66,4 +84,6 @@ rubygems_version: 2.2.2
66
84
  signing_key:
67
85
  specification_version: 4
68
86
  summary: Redactor WYSIWYG Editor Integration for ActiveAdmin resources.
69
- test_files: []
87
+ test_files:
88
+ - spec/activeadmin/redactor_opts_spec.rb
89
+ - spec/spec_helper.rb