administrate-field-ckeditor 0.0.2 → 0.0.3

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: 43ba8cf1e9ae897501ba602158eabf8f38925ed6
4
- data.tar.gz: 6bdc720e73cf34b696d01f77a83d3d0f0a54d5de
3
+ metadata.gz: a8527d029056c2a4e38b30f47e0c3548ed317cf9
4
+ data.tar.gz: 6c2e86bfefcd21b87890a5773887d7aa99c1ea4f
5
5
  SHA512:
6
- metadata.gz: 692ad92838eac7a6299e100fb4b4a1b1d1ff6db4e98eafd820839920888f6559a40c843f39110c8957166dbfb213050c950fd037b767ecb5815cc9fc602f965d
7
- data.tar.gz: 37c116a866a89a5e7e76723ef50fd6dff00283152542662e06c2788b8159fb8e6d18ca38cecb0033a8971d6b85f97d098997f0864e797224387d2f202a953d86
6
+ metadata.gz: 92170f7dd129854b9cdcbf24814c9b6b2bc0a6027f12dc4b57bdaecc596640da666e8480613dfe90c1117a0cc15bfbf68fc23633154ed70bee168bcb7102fdbe
7
+ data.tar.gz: 5c8280b44ca8eb277ae6d30fe318cfb73e0fa2578bac4e4076bf2dad18872e7aee0a5538b043b0daa0ee0a33aeb2483b4bcd92de3687d338517924be250998a3
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/README.md CHANGED
@@ -26,12 +26,19 @@ ATTRIBUTE_TYPES = [
26
26
  ]
27
27
  ```
28
28
 
29
+ Or with ckeditor options:
30
+ ```ruby
31
+ ATTRIBUTE_TYPES = [
32
+ quxes: Field::Ckeditor.with_options({ckeditor: {uiColor: '#800000'}}),
33
+ ]
34
+ ```
35
+
29
36
  [Ckeditor]: https://github.com/galetahub/ckeditor
30
37
  [Administrate]: https://github.com/thoughtbot/administrate
31
38
 
32
39
  ## About Jemcode
33
40
 
34
- <img src="https://www.jemco.de/logo.svg" width="400" alt="Jemcode">
41
+ [<img src="https://www.jemco.de/logo.svg" width="400" alt="Jemcode">][hire]
35
42
 
36
43
  Administrate::Field::Ckeditor is maintained and funded by Jemcode Limited. We are [available for hire][hire].
37
44
 
@@ -1,10 +1,8 @@
1
1
  $:.push File.expand_path("../lib", __FILE__)
2
2
 
3
- require "administrate/field/ckeditor"
4
-
5
3
  Gem::Specification.new do |gem|
6
4
  gem.name = "administrate-field-ckeditor"
7
- gem.version = Administrate::Field::Ckeditor::VERSION
5
+ gem.version = "0.0.3"
8
6
  gem.authors = ["Rikki Pitt"]
9
7
  gem.email = ["rikkipitt@gmail.com"]
10
8
  gem.homepage = "https://github.com/jemcode/administrate-field-ckeditor"
@@ -17,6 +15,6 @@ Gem::Specification.new do |gem|
17
15
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
16
 
19
17
  gem.add_dependency "administrate", "~> 0.2.1"
20
- gem.add_dependency "rails", "~> 4.2"
18
+ gem.add_dependency "rails", ">= 4.2"
21
19
  gem.add_dependency "ckeditor", "~> 4.1"
22
20
  end
@@ -2,5 +2,5 @@
2
2
  <%= f.label field.attribute %>
3
3
  </div>
4
4
  <div class="field-unit__field">
5
- <%= f.cktext_area field.attribute %>
5
+ <%= f.cktext_area field.attribute, ckeditor: field.ckeditor_options %>
6
6
  </div>
@@ -1 +1 @@
1
- <%= field.truncate %>
1
+ <%= field.truncate_stripped %>
@@ -1 +1 @@
1
- <span class="preserve-whitespace"><%= field.data %></span>
1
+ <%= field.to_html %>
@@ -6,11 +6,24 @@ require "ckeditor"
6
6
  module Administrate
7
7
  module Field
8
8
  class Ckeditor < Administrate::Field::Text
9
- VERSION = "0.0.2"
10
-
11
9
  class Engine < ::Rails::Engine
12
10
  Administrate::Engine.add_javascript "administrate-field-ckeditor/application"
13
11
  end
12
+
13
+ include ActionView::Helpers::SanitizeHelper
14
+ include ActionView::Helpers::OutputSafetyHelper
15
+
16
+ def truncate_stripped
17
+ strip_tags(data.to_s)[0..truncation_length]
18
+ end
19
+
20
+ def to_html
21
+ raw(data.to_s)
22
+ end
23
+
24
+ def ckeditor_options
25
+ options.fetch(:ckeditor, {})
26
+ end
14
27
  end
15
28
  end
16
29
  end
@@ -1,14 +1,25 @@
1
1
  require "administrate/field/ckeditor"
2
2
 
3
3
  describe Administrate::Field::Ckeditor do
4
+
5
+ let(:page) { :show }
6
+ let(:data) { "<h1>Hello!</h1>\n<p>This is an exciting piece of data!</p>" }
7
+ subject { Administrate::Field::Ckeditor.new(:relation, "/a.jpg", page) }
8
+ before(:each) do
9
+ allow(subject).to receive(:data).and_return(data)
10
+ allow(subject).to receive(:truncation_length).and_return(10)
11
+ end
12
+
4
13
  describe "#to_partial_path" do
5
14
  it "returns a partial based on the page being rendered" do
6
- page = :show
7
- field = Administrate::Field::Ckeditor.new(:relation, "/a.jpg", page)
8
-
9
- path = field.to_partial_path
10
-
11
- expect(path).to eq("/fields/ckeditor/#{page}")
15
+ expect(subject.to_partial_path).to eq("/fields/ckeditor/#{page}")
16
+ end
17
+ end
18
+
19
+ describe '#truncate_stripped' do
20
+ it 'strips out HTML and truncates to the truncation length' do
21
+ expect(subject.truncate_stripped).to eq("Hello!\nThis")
12
22
  end
13
23
  end
24
+
14
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: administrate-field-ckeditor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rikki Pitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-20 00:00:00.000000000 Z
11
+ date: 2016-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: administrate
@@ -28,14 +28,14 @@ dependencies:
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '4.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '4.2'
41
41
  - !ruby/object:Gem::Dependency
@@ -59,6 +59,7 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - ".gitignore"
62
63
  - README.md
63
64
  - administrate-field-ckeditor.gemspec
64
65
  - app/assets/javascripts/administrate-field-ckeditor/application.js
@@ -87,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
88
  version: '0'
88
89
  requirements: []
89
90
  rubyforge_project:
90
- rubygems_version: 2.6.4
91
+ rubygems_version: 2.6.8
91
92
  signing_key:
92
93
  specification_version: 4
93
94
  summary: Plugin for adding ckeditor support in Administrate