refinerycms-pages 3.0.2 → 3.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: 2e83dbfdfba885ff0dd0f31a0b23f226c01483b0
4
- data.tar.gz: 1eb13220474770daf946ab20955393fab25e7388
3
+ metadata.gz: 4933d54bda49d54b6458ba369411b14d07c4296d
4
+ data.tar.gz: 7d9b0ffdaa544522cd7e58c2aa262795ba722ae2
5
5
  SHA512:
6
- metadata.gz: 94f97db5e16189f54615a2fdc27000554583c2704ef9cf8a3261ae87e6e08034892bff197c36f2758aabf53f807abf8645db29ad7e74ad4bb80d460f17f5073f
7
- data.tar.gz: 6ea014c7893bf92120a23aece4e6b8d005f75c2cc37a2bdb644dcdbf60d719f2e0773c13195ca24159c840e32ed2a098457db8bf319b8c4b840f1ceea01bed2d
6
+ metadata.gz: 7930a05fc308a3d86bfb85e606bcdd8e672c6c44aed78ba99ca47aff029421cde7031fa766a3d0f23c8941944f20c49adc5eada1dd797b37f57bc566e1890104
7
+ data.tar.gz: 3e26bcbe3eb57580e81276f6e1750081b1c72f07fde92387692094d8aefe59cd212eb1768c0ffd5476cb427a104efbb0319e8208fe5b222363826bde76bbccbd
@@ -64,8 +64,8 @@ module Refinery
64
64
 
65
65
  def wrap_content_in_tag(content)
66
66
  content = sanitize(content,
67
- tags: Loofah::HTML5::WhiteList::ALLOWED_ELEMENTS,
68
- attributes: Loofah::HTML5::WhiteList::ALLOWED_ATTRIBUTES
67
+ tags: Refinery::Pages::whitelist_elements,
68
+ attributes: Refinery::Pages::whitelist_attributes
69
69
  )
70
70
  content_tag(:section, content_tag(:div, content, :class => 'inner'), :id => id)
71
71
  end
@@ -40,10 +40,9 @@ Refinery::Pages.configure do |config|
40
40
  # and will no longer be nested as children.
41
41
  # config.scope_slug_by_parent = <%= Refinery::Pages.scope_slug_by_parent.inspect %>
42
42
 
43
- # Set this to true if you want backend pages to be cached
44
- # config.cache_pages_backend = <%= Refinery::Pages.cache_pages_backend.inspect %>
45
-
46
- # Set this to true to activate full-page-cache
43
+ # Set this to true to activate full-page-cache.
44
+ # If you use Rails 4.0+ and set config.cache_pages_full to true, you have to add this gem in your Gemfile:
45
+ # gem 'actionpack-page_caching'
47
46
  # config.cache_pages_full = <%= Refinery::Pages.cache_pages_full.inspect %>
48
47
 
49
48
  # Set this to true to fully expand the page hierarchy in the admin
@@ -66,4 +65,8 @@ Refinery::Pages.configure do |config|
66
65
  # config.absolute_page_links = <%= Refinery::Pages.absolute_page_links.inspect %>
67
66
 
68
67
  # config.show_title_in_body = <%= Refinery::Pages.show_title_in_body.inspect %>
68
+
69
+ # config.add_whitelist_elements = <%= Refinery::Pages.add_whitelist_elements.inspect %>
70
+
71
+ # config.add_whitelist_attributes = <%= Refinery::Pages.add_whitelist_attributes.inspect %>
69
72
  end
@@ -5,10 +5,11 @@ module Refinery
5
5
  config_accessor :pages_per_dialog, :pages_per_admin_index, :new_page_parts,
6
6
  :marketable_urls, :approximate_ascii, :strip_non_ascii,
7
7
  :default_parts, :use_custom_slugs, :scope_slug_by_parent,
8
- :cache_pages_backend, :cache_pages_full, :layout_template_whitelist,
8
+ :cache_pages_full, :layout_template_whitelist,
9
9
  :use_layout_templates, :page_title, :absolute_page_links, :types,
10
10
  :auto_expand_admin_tree, :show_title_in_body,
11
- :friendly_id_reserved_words, :layout_templates_pattern, :view_templates_pattern
11
+ :friendly_id_reserved_words, :layout_templates_pattern, :view_templates_pattern,
12
+ :add_whitelist_elements, :add_whitelist_attributes, :whitelist_elements, :whitelist_attributes
12
13
 
13
14
  self.pages_per_dialog = 14
14
15
  self.pages_per_admin_index = 20
@@ -19,10 +20,21 @@ module Refinery
19
20
  self.default_parts = [{ title: "Body", slug: "body" }, { title: "Side Body", slug: "side_body" }]
20
21
  self.use_custom_slugs = false
21
22
  self.scope_slug_by_parent = true
22
- self.cache_pages_backend = false
23
23
  self.cache_pages_full = false
24
24
  self.layout_template_whitelist = ["application"]
25
+ self.add_whitelist_elements = %w[ source track ]
26
+ self.add_whitelist_attributes = %w[ kind srclang placeholder controls ]
27
+
28
+
25
29
  class << self
30
+ def whitelist_elements
31
+ Loofah::HTML5::WhiteList::ALLOWED_ELEMENTS.merge(config.add_whitelist_elements)
32
+ end
33
+
34
+ def whitelist_attributes
35
+ Loofah::HTML5::WhiteList::ALLOWED_ATTRIBUTES.merge(config.add_whitelist_attributes)
36
+ end
37
+
26
38
  def layout_template_whitelist
27
39
  Array(config.layout_template_whitelist).map(&:to_s)
28
40
  end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory :page_part, class: Refinery::PagePart do
3
+ title 'Body'
4
+ slug 'side_body'
5
+ end
6
+ end
@@ -1,5 +1,11 @@
1
1
  FactoryGirl.define do
2
- factory :page, :class => Refinery::Page do
2
+ factory :page, class: Refinery::Page do
3
3
  sequence(:title, "a") { |n| "Test title #{n}" }
4
+
5
+ factory :page_with_page_part do
6
+ after(:create) do |page|
7
+ page.parts << FactoryGirl.create(:page_part)
8
+ end
9
+ end
4
10
  end
5
11
  end
@@ -2,6 +2,8 @@ require "spec_helper"
2
2
 
3
3
  module Refinery
4
4
  module Pages
5
+
6
+
5
7
  describe SectionPresenter do
6
8
  it "can build a css class for when it is not present based on id" do
7
9
  section = SectionPresenter.new(:fallback_html => 'foobar', :id => 'mynode')
@@ -45,6 +47,56 @@ module Refinery
45
47
  expect(section.wrapped_html(true)).to xml_eq('<section id="mynode"><div class="inner">foobar</div></section>')
46
48
  end
47
49
 
50
+
51
+ # Regression tests for https://github.com/refinery/refinerycms-inquiries/issues/168
52
+ describe "#whitelist_elements" do
53
+ context "when an element is not in a whitelist" do
54
+ it "will not return those elements" do
55
+ allow(Refinery::Pages).to receive(:whitelist_elements) {%w()}
56
+ section = SectionPresenter.new
57
+ section.override_html = %Q{<dummy></dummy>}
58
+ expect(section.wrapped_html(true)).to xml_eq(
59
+ %Q{<section><div class="inner"></div></section>}
60
+ )
61
+ end
62
+ end
63
+
64
+ context "when an extra element is included in the whitelist" do
65
+ it "will contain the whitelisted element" do
66
+ allow(Refinery::Pages).to receive(:whitelist_elements) {%w(dummy)}
67
+ section = SectionPresenter.new
68
+ section.override_html = %Q{<dummy></dummy>}
69
+ expect(section.wrapped_html(true)).to xml_eq(
70
+ %Q{<section><div class="inner"><dummy></dummy></div></section>}
71
+ )
72
+ end
73
+ end
74
+ end
75
+
76
+ describe "#whitelist_attributes" do
77
+ context "when an attribute is not in a whitelist" do
78
+ it "will not return those attributes" do
79
+ allow(Refinery::Pages).to receive(:whitelist_attributes) {%w()}
80
+ section = SectionPresenter.new
81
+ section.override_html = %Q{<a attribute="value"></a>}
82
+ expect(section.wrapped_html(true)).to xml_eq(
83
+ %Q{<section><div class="inner"><a></a></div></section>}
84
+ )
85
+ end
86
+ end
87
+
88
+ context "when extra attributes are included in the whitelist" do
89
+ it "will contain the whitelisted attributes" do
90
+ allow(Refinery::Pages).to receive(:whitelist_attributes) {%w(attribute)}
91
+ section = SectionPresenter.new
92
+ section.override_html = %Q{<a attribute="value"></a>}
93
+ expect(section.wrapped_html(true)).to xml_eq(
94
+ %Q{<section><div class="inner"><a attribute="value"></a></div></section>}
95
+ )
96
+ end
97
+ end
98
+ end
99
+
48
100
  describe "if allowed to use fallback html" do
49
101
  it "wont show a section with no fallback or override" do
50
102
  section = SectionPresenter.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Arndt
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-03-16 00:00:00.000000000 Z
13
+ date: 2016-04-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: friendly_id
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - '='
88
88
  - !ruby/object:Gem::Version
89
- version: 3.0.2
89
+ version: 3.0.3
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
- version: 3.0.2
96
+ version: 3.0.3
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: babosa
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -223,6 +223,7 @@ files:
223
223
  - refinerycms-pages.gemspec
224
224
  - spec/controllers/refinery/admin/pages_controller_spec.rb
225
225
  - spec/controllers/refinery/pages_controller_spec.rb
226
+ - spec/factories/page_parts.rb
226
227
  - spec/factories/pages.rb
227
228
  - spec/features/refinery/admin/pages_spec.rb
228
229
  - spec/features/refinery/pages_spec.rb
@@ -265,13 +266,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
265
266
  version: '0'
266
267
  requirements: []
267
268
  rubyforge_project: refinerycms
268
- rubygems_version: 2.5.1
269
+ rubygems_version: 2.6.4
269
270
  signing_key:
270
271
  specification_version: 4
271
272
  summary: Pages extension for Refinery CMS
272
273
  test_files:
273
274
  - spec/controllers/refinery/admin/pages_controller_spec.rb
274
275
  - spec/controllers/refinery/pages_controller_spec.rb
276
+ - spec/factories/page_parts.rb
275
277
  - spec/factories/pages.rb
276
278
  - spec/features/refinery/admin/pages_spec.rb
277
279
  - spec/features/refinery/pages_spec.rb