refinerycms-pages 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,12 @@ Refinery::Pages.configure do |config|
7
7
  # Configure global page default parts
8
8
  # config.default_parts = <%= Refinery::Pages.default_parts.inspect %>
9
9
 
10
+ # Configure whether to allow adding new page parts
11
+ # config.new_page_parts = <%= Refinery::Pages.new_page_parts.inspect %>
12
+
13
+ # Configure whether to enable marketable_urls
14
+ # config.marketable_urls = <%= Refinery::Pages.marketable_urls.inspect %>
15
+
10
16
  # Configure how many pages per page should be displayed when a dialog is presented that contains a links to pages
11
17
  # config.pages_per_dialog = <%= Refinery::Pages.pages_per_dialog.inspect %>
12
18
 
@@ -40,5 +46,7 @@ Refinery::Pages.configure do |config|
40
46
 
41
47
  # config.use_view_templates = <%= Refinery::Pages.use_view_templates.inspect %>
42
48
 
49
+ # config.page_title = <%= Refinery::Pages.page_title.inspect %>
50
+
43
51
  # config.absolute_page_links = <%= Refinery::Pages.absolute_page_links.inspect %>
44
52
  end
@@ -1,9 +1,9 @@
1
1
  module Refinery
2
2
  module Pages
3
- # A type of ContentPresenter which specifically knows how to render the html for a Refinery CMS
4
- # page object. Pass the page object into the constructor, and it will build sections from the
5
- # page's parts. The page is not retained internally, so if the page changes, you need to rebuild
6
- # this ContentPagePresenter.
3
+ # A type of ContentPresenter which specifically knows how to render the html
4
+ # for a Refinery::Page object. Pass the page object into the constructor,
5
+ # and it will build sections from the page's parts. The page is not retained
6
+ # internally, so if the page changes, you need to rebuild this ContentPagePresenter.
7
7
  class ContentPagePresenter < ContentPresenter
8
8
  def initialize(page, page_title)
9
9
  super()
@@ -12,22 +12,22 @@ module Refinery
12
12
  add_default_post_page_sections
13
13
  end
14
14
 
15
- private
15
+ private
16
16
 
17
- def add_default_title_section(title)
18
- add_section TitleSectionPresenter.new(:id => :body_content_title, :fallback_html => title)
19
- end
17
+ def add_default_title_section(title)
18
+ add_section TitleSectionPresenter.new(:id => :body_content_title, :fallback_html => title)
19
+ end
20
20
 
21
- def add_default_post_page_sections
22
- add_section_if_missing(:id => :body_content_left)
23
- add_section_if_missing(:id => :body_content_right)
24
- end
21
+ def add_default_post_page_sections
22
+ add_section_if_missing(:id => :body_content_left)
23
+ add_section_if_missing(:id => :body_content_right)
24
+ end
25
25
 
26
- def add_page_parts(parts)
27
- parts.each do |part|
28
- add_section PagePartSectionPresenter.new(part)
29
- end
26
+ def add_page_parts(parts)
27
+ parts.each do |part|
28
+ add_section PagePartSectionPresenter.new(part)
30
29
  end
30
+ end
31
31
  end
32
32
  end
33
33
  end
@@ -1,8 +1,9 @@
1
1
  module Refinery
2
2
  module Pages
3
- # Knows how to render a set of sections as html. This can be used in any refinery view that is built from
4
- # a group of sections. Pass the sections into the constructor or call add_section on the instance,
5
- # then render by calling to_html.
3
+ # Knows how to render a set of sections as html. This can be used in any
4
+ # Refinery view that is built from a group of sections. Pass the sections
5
+ # into the constructor or call add_section on the instance, then render by
6
+ # calling 'to_html'.
6
7
  class ContentPresenter
7
8
  include ActionView::Helpers::TagHelper
8
9
 
@@ -14,15 +15,13 @@ module Refinery
14
15
  @sections.reject {|section| section.has_content?(can_use_fallback)}.map(&:not_present_css_class)
15
16
  end
16
17
 
17
- def hide_sections(ids_to_hide)
18
- @sections.select {|section| ids_to_hide.include?(section.id)}.each(&:hide) unless ids_to_hide.empty?
18
+ def hide_sections(*ids_to_hide)
19
+ @sections.select {|section| ids_to_hide.include?(section.id)}.each(&:hide) if ids_to_hide.any?
19
20
  end
20
21
 
21
22
  def fetch_template_overrides
22
23
  @sections.each do |section|
23
- if section.id.present?
24
- section.override_html = yield section.id
25
- end
24
+ section.override_html = yield section.id if section.id.present?
26
25
  end
27
26
  end
28
27
 
@@ -35,22 +34,24 @@ module Refinery
35
34
  end
36
35
 
37
36
  def to_html(can_use_fallback = true)
38
- content_tag :section, sections_html(can_use_fallback), :id => 'body_content', :class => blank_section_css_classes(can_use_fallback).join(' ')
37
+ content_tag :section, sections_html(can_use_fallback),
38
+ :id => 'body_content',
39
+ :class => blank_section_css_classes(can_use_fallback).join(' ')
39
40
  end
40
41
 
41
- private
42
+ private
42
43
 
43
- def sections_html(can_use_fallback)
44
- @sections.map {|section| section.wrapped_html(can_use_fallback)}.compact.join("\n").html_safe
45
- end
44
+ def sections_html(can_use_fallback)
45
+ @sections.map {|section| section.wrapped_html(can_use_fallback)}.compact.join("\n").html_safe
46
+ end
46
47
 
47
- def add_section_if_missing(options)
48
- add_section SectionPresenter.new(options) unless has_section?(options[:id])
49
- end
48
+ def add_section_if_missing(options)
49
+ add_section SectionPresenter.new(options) unless has_section?(options[:id])
50
+ end
50
51
 
51
- def has_section?(id)
52
- @sections.detect {|section| section.id == id}
53
- end
52
+ def has_section?(id)
53
+ @sections.detect {|section| section.id == id}
54
+ end
54
55
  end
55
56
  end
56
57
  end
@@ -4,6 +4,7 @@ module Refinery
4
4
 
5
5
  def self.included(base)
6
6
  base.send :helper_method, :refinery_menu_pages
7
+ base.send :alias_method_chain, :render, :presenters
7
8
  end
8
9
 
9
10
  def error_404(exception=nil)
@@ -22,9 +23,9 @@ module Refinery
22
23
  end
23
24
 
24
25
  protected
25
- def render(*args)
26
+ def render_with_presenters(*args)
26
27
  present(@page) unless admin? or @meta.present?
27
- super
28
+ render_without_presenters(*args)
28
29
  end
29
30
 
30
31
  private
@@ -9,11 +9,11 @@ module Refinery
9
9
  self.id = convert_title_to_id(page_part.title) if page_part.title
10
10
  end
11
11
 
12
- private
12
+ private
13
13
 
14
- def convert_title_to_id(title)
15
- title.to_s.gsub(/\ /, '').underscore.to_sym
16
- end
14
+ def convert_title_to_id(title)
15
+ title.to_s.gsub(/\ /, '').underscore.to_sym
16
+ end
17
17
  end
18
18
  end
19
19
  end
@@ -47,23 +47,27 @@ module Refinery
47
47
  "no_#{id}"
48
48
  end
49
49
 
50
- protected
50
+ protected
51
51
 
52
- def content_html(can_use_fallback)
53
- override_html.present? ? override_html : html_from_fallback(can_use_fallback)
52
+ def content_html(can_use_fallback)
53
+ if override_html.present?
54
+ override_html
55
+ else
56
+ html_from_fallback(can_use_fallback)
54
57
  end
58
+ end
55
59
 
56
- def html_from_fallback(can_use_fallback)
57
- fallback_html if fallback_html.present? && can_use_fallback
58
- end
60
+ def html_from_fallback(can_use_fallback)
61
+ fallback_html if fallback_html.present? && can_use_fallback
62
+ end
59
63
 
60
- private
64
+ private
61
65
 
62
- attr_writer :id, :fallback_html, :hidden
66
+ attr_writer :id, :fallback_html, :hidden
63
67
 
64
- def wrap_content_in_tag(content)
65
- content_tag(:section, content_tag(:div, content, :class => 'inner'), :id => id)
66
- end
68
+ def wrap_content_in_tag(content)
69
+ content_tag(:section, content_tag(:div, content, :class => 'inner'), :id => id)
70
+ end
67
71
  end
68
72
  end
69
73
  end
@@ -4,11 +4,11 @@ module Refinery
4
4
  # a title. These are much like normal sections except they are wrapped in
5
5
  # a h1 tag rather than a div.
6
6
  class TitleSectionPresenter < SectionPresenter
7
- private
7
+ private
8
8
 
9
- def wrap_content_in_tag(content)
10
- content_tag(:h1, content, :id => id)
11
- end
9
+ def wrap_content_in_tag(content)
10
+ content_tag(:h1, content, :id => id)
11
+ end
12
12
  end
13
13
  end
14
14
  end
@@ -20,7 +20,6 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.files = `git ls-files`.split("\n")
22
22
  s.test_files = `git ls-files -- spec/*`.split("\n")
23
- s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
24
23
 
25
24
  s.add_dependency 'awesome_nested_set', '~> 2.1.0'
26
25
  s.add_dependency 'seo_meta', '~> 1.2.0'
@@ -474,6 +474,26 @@ module Refinery
474
474
  end
475
475
  end
476
476
  end
477
+
478
+ describe "new page part", :js => true do
479
+ before do
480
+ Refinery::Pages.stub(:new_page_parts).and_return(true)
481
+ end
482
+
483
+ it "adds new page part" do
484
+ visit refinery.new_admin_page_path
485
+ click_link "add_page_part"
486
+
487
+ within "#new_page_part_dialog" do
488
+ fill_in "new_page_part_title", :with => "testy"
489
+ click_button "Save"
490
+ end
491
+
492
+ within "#page_parts" do
493
+ page.should have_content("testy")
494
+ end
495
+ end
496
+ end
477
497
  end
478
498
 
479
499
  describe "TranslatePages" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-pages
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 1
10
- version: 2.0.1
9
+ - 2
10
+ version: 2.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Philip Arndt
@@ -59,12 +59,12 @@ dependencies:
59
59
  requirements:
60
60
  - - "="
61
61
  - !ruby/object:Gem::Version
62
- hash: 13
62
+ hash: 11
63
63
  segments:
64
64
  - 2
65
65
  - 0
66
- - 1
67
- version: 2.0.1
66
+ - 2
67
+ version: 2.0.2
68
68
  version_requirements: *id003
69
69
  name: refinerycms-core
70
70
  type: :runtime