refinerycms-page-menus 2.0.3 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/app/assets/javascripts/refinery/backend.js.coffee +24 -0
  2. data/app/assets/stylesheets/refinery/select_form.css.scss +182 -0
  3. data/app/controllers/refinery/admin/page_menus_controller.rb +57 -1
  4. data/app/controllers/refinery/admin/page_positions_controller.rb +19 -39
  5. data/app/helpers/refinery/page_positions_helper.rb +66 -0
  6. data/app/models/refinery/page_menu.rb +3 -15
  7. data/app/models/refinery/page_position.rb +87 -15
  8. data/app/views/refinery/admin/page_menus/_form.html.erb +27 -35
  9. data/app/views/refinery/admin/page_menus/_form_actions.html.erb +23 -0
  10. data/app/views/refinery/admin/page_menus/_page_menu.html.erb +16 -0
  11. data/app/views/refinery/admin/page_menus/_page_menus.html.erb +2 -0
  12. data/app/views/refinery/admin/page_menus/_records.html.erb +18 -0
  13. data/app/views/refinery/admin/page_menus/_sortable_list.html.erb +5 -0
  14. data/app/views/refinery/admin/page_menus/edit.html.erb +12 -1
  15. data/app/views/refinery/admin/page_menus/index.html.erb +3 -0
  16. data/app/views/refinery/admin/page_positions/_custom_link.html.erb +14 -0
  17. data/app/views/refinery/admin/page_positions/_page_position.html.erb +25 -48
  18. data/app/views/refinery/admin/page_positions/_resource_link.html.erb +14 -0
  19. data/app/views/refinery/admin/page_positions/_resource_link_editor_box.html.erb +21 -0
  20. data/app/views/refinery/admin/page_positions/create.js.erb +5 -0
  21. data/app/views/refinery/admin/page_positions/destroy.js.erb +3 -0
  22. data/config/locales/da.yml +9 -5
  23. data/config/locales/en.yml +25 -82
  24. data/config/locales/fr.yml +37 -0
  25. data/config/routes.rb +15 -4
  26. data/db/migrate/{20120406121839_create_page_menus.rb → 01_create_page_menus.rb} +0 -0
  27. data/db/migrate/{20120411133453_add_permatitle_to_page_menus.rb → 02_add_permatitle_to_page_menus.rb} +0 -0
  28. data/db/migrate/{20120411134419_add_menu_match_to_page_positions.rb → 03_add_menu_match_to_page_positions.rb} +0 -0
  29. data/db/migrate/04_add_flex_fields_to_page_positions.rb +9 -0
  30. data/db/migrate/05_remove_refinery_page_id_from_refinery_page_positions.rb +9 -0
  31. data/db/seeds.rb +18 -0
  32. data/lib/generators/refinery/page_menus/page_menus_generator.rb +12 -2
  33. data/lib/generators/refinery/page_menus/templates/config/initializers/refinery/page_menus.rb.erb +11 -0
  34. data/lib/refinery/page_menus/configuration.rb +24 -3
  35. data/lib/refinery/page_menus/controller_extension.rb +7 -3
  36. data/lib/refinery/page_menus/engine.rb +9 -9
  37. data/lib/refinery/page_menus/instance_methods.rb +1 -1
  38. data/lib/refinery/page_menus/version.rb +18 -0
  39. data/lib/refinery/page_menus.rb +1 -2
  40. data/readme.md +66 -1
  41. metadata +91 -52
  42. data/.gitignore +0 -2
  43. data/app/views/refinery/admin/page_positions/_actions.html.erb +0 -45
  44. data/app/views/refinery/admin/page_positions/_records.html.erb +0 -14
  45. data/app/views/refinery/admin/page_positions/_sortable_list.html.erb +0 -4
  46. data/app/views/refinery/admin/page_positions/index.html.erb +0 -11
  47. data/app/views/refinery/admin/pages/_actions.html.erb +0 -40
  48. data/app/views/refinery/admin/pages/_list_actions.html.erb +0 -28
  49. data/app/views/refinery/admin/pages/_list_page.html.erb +0 -46
  50. data/app/views/refinery/admin/pages/_list_records.html.erb +0 -16
  51. data/app/views/refinery/admin/pages/list.html.erb +0 -8
  52. data/app/views/refinery/admin/pages_shared/_submenu.html.erb +0 -65
  53. data/lib/refinery/page_menus/model_extension.rb +0 -14
  54. data/license.md +0 -21
  55. data/refinerycms-page-menus.gemspec +0 -25
  56. data/spec/factories/pages.rb +0 -5
  57. data/spec/helpers/refinery/pages/content_pages_helper_spec.rb +0 -44
  58. data/spec/lib/generators/refinery/pages/pages_generator_spec.rb +0 -29
  59. data/spec/lib/pages/content_page_presenter_spec.rb +0 -43
  60. data/spec/lib/pages/content_presenter_spec.rb +0 -111
  61. data/spec/lib/pages/page_part_section_presenter_spec.rb +0 -35
  62. data/spec/lib/pages/section_presenter_spec.rb +0 -86
  63. data/spec/lib/pages/title_section_presenter_spec.rb +0 -21
  64. data/spec/lib/pages_spec.rb +0 -26
  65. data/spec/models/refinery/page_spec.rb +0 -415
  66. data/spec/requests/refinery/admin/pages_spec.rb +0 -613
  67. data/spec/requests/refinery/pages_spec.rb +0 -302
@@ -1,44 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Refinery
4
- module Pages
5
- describe ContentPagesHelper do
6
- let(:content_presenter) { double(ContentPresenter, :hide_sections => nil, :fetch_template_overrides => nil, :to_html => nil) }
7
-
8
- describe "when rendering content presenter" do
9
- it "asks to content presenter to hide sections if told to" do
10
- content_presenter.should_receive(:hide_sections).with(['foo', 'bar'])
11
- render_content_presenter(content_presenter, :hide_sections => ['foo', 'bar'])
12
- end
13
-
14
- it "attempts to fetch template overrides declared elsewhere via content_for" do
15
- content_presenter.should_receive(:fetch_template_overrides).and_yield(12)
16
- self.should_receive(:content_for).with(12)
17
- render_content_presenter(content_presenter)
18
- end
19
-
20
- it "outputs the html rendered by the content presenter" do
21
- content_presenter.should_receive(:to_html).and_return('foobar')
22
- render_content_presenter(content_presenter).should == 'foobar'
23
- end
24
-
25
- it "passes can_use_fallback option through to html rendering" do
26
- content_presenter.should_receive(:to_html).with(true)
27
- render_content_presenter(content_presenter, :can_use_fallback => true)
28
- end
29
- end
30
-
31
- describe "when rendering page" do
32
- let(:page) { double(Page) }
33
-
34
- it "builds a content page presenter and returns its html" do
35
- self.should_receive(:page_title).and_return('some title')
36
- Refinery::Pages::ContentPagePresenter.should_receive(:new).with(page, 'some title').and_return(content_presenter)
37
- content_presenter.should_receive(:to_html).and_return('barfoo')
38
-
39
- render_content_page(page).should == 'barfoo'
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,29 +0,0 @@
1
- require 'spec_helper'
2
- require 'generator_spec/test_case'
3
- require 'generators/refinery/pages/pages_generator'
4
-
5
- module Refinery
6
- describe PagesGenerator do
7
- include GeneratorSpec::TestCase
8
- destination File.expand_path("../../../../tmp", __FILE__)
9
-
10
- before(:each) do
11
- prepare_destination
12
- run_generator
13
- end
14
-
15
- specify do
16
- destination_root.should have_structure {
17
- directory "config" do
18
- directory "initializers" do
19
- directory "refinery" do
20
- file "pages.rb" do
21
- contains "Refinery::Pages.configure"
22
- end
23
- end
24
- end
25
- end
26
- }
27
- end
28
- end
29
- end
@@ -1,43 +0,0 @@
1
- require "spec_helper"
2
-
3
- module Refinery
4
- module Pages
5
- describe ContentPagePresenter do
6
- let(:part) { double(PagePart, :body => 'part_body', :title => 'A Wonderful Page Part') }
7
- let(:part2) { double(PagePart, :body => 'part_body2', :title => 'Another Wonderful Page Part') }
8
- let(:title) { 'This Great Page' }
9
-
10
- describe "when building for page" do
11
- let(:page_with_one_part) { double(Page, :parts => [part]) }
12
-
13
- it "adds page title section before page parts" do
14
- content = ContentPagePresenter.new(page_with_one_part, title)
15
- content.get_section(0).fallback_html.should == title
16
- end
17
-
18
- it "adds a section for each page part" do
19
- page = double(Page, :parts => [part, part2])
20
- content = ContentPagePresenter.new(page, title)
21
- content.get_section(1).fallback_html.should == 'part_body'
22
- content.get_section(2).fallback_html.should == 'part_body2'
23
- end
24
-
25
- it "adds body content left and right after page parts" do
26
- content = ContentPagePresenter.new(page_with_one_part, title)
27
- content.get_section(2).id.should == :body
28
- content.get_section(3).id.should == :side_body
29
- end
30
-
31
- it "doesnt add page parts if page is nil" do
32
- content = ContentPagePresenter.new(nil, title)
33
- content.get_section(1).id.should == :body
34
- end
35
-
36
- it "doesnt add title if it is blank" do
37
- content = ContentPagePresenter.new(nil, '')
38
- content.get_section(0).id.should == :body
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,111 +0,0 @@
1
- require "spec_helper"
2
-
3
- module Refinery
4
- module Pages
5
- describe ContentPresenter do
6
- let(:section1) { double(SectionPresenter, :id => 'foo', :has_content? => true) }
7
- let(:section2) { double(SectionPresenter, :id => 'bar', :has_content? => true) }
8
-
9
- describe "when building css classes for blank sections" do
10
- let(:section) { double(SectionPresenter, :not_present_css_class => 'no_section1') }
11
-
12
- it "includes css class for any section which doesnt have content" do
13
- section.stub(:has_content?).with(true).and_return(false)
14
- content = ContentPresenter.new
15
- content.add_section section
16
-
17
- content.blank_section_css_classes(true).should == ['no_section1']
18
- end
19
-
20
- it "doesnt include sections which have content" do
21
- section.stub(:has_content?).with(true).and_return(true)
22
- content = ContentPresenter.new
23
- content.add_section section
24
-
25
- content.blank_section_css_classes(true).should be_empty
26
- end
27
- end
28
-
29
- describe "when hiding sections" do
30
- before do
31
- @content = ContentPresenter.new
32
- @content.add_section section1
33
- @content.add_section section2
34
- end
35
-
36
- it "hides a section specified by id" do
37
- section2.should_receive :hide
38
- @content.hide_sections 'bar'
39
- end
40
-
41
- # Regression for https://github.com/resolve/refinerycms/issues/1516
42
- it "accepts an array" do
43
- section2.should_receive :hide
44
- @content.hide_sections ['bar']
45
- end
46
-
47
- it "hides nothing if nil" do
48
- section1.stub(:hidden?).and_return false
49
- section2.stub(:hidden?).and_return false
50
- @content.hide_sections nil
51
- @content.hidden_sections.count.should == 0
52
- end
53
-
54
- end
55
-
56
- describe "when fetching template overrides" do
57
- before do
58
- @content = ContentPresenter.new
59
- end
60
-
61
- it "yields a section with an id and stores the result in its override html" do
62
- section = double(SectionPresenter, :id => 'foo')
63
- section.should_receive(:override_html=).with('some override')
64
- @content.add_section section
65
-
66
- @content.fetch_template_overrides do |section_id|
67
- section_id.should == 'foo'
68
- 'some override'
69
- end
70
- end
71
-
72
- it "doesnt yield a section without an id" do
73
- section = double(SectionPresenter, :id => nil)
74
- section.should_receive(:override_html=).never
75
- @content.add_section section
76
-
77
- @content.fetch_template_overrides do |section_id|
78
- raise "this should not occur"
79
- end
80
- end
81
- end
82
-
83
- describe "when rendering as html" do
84
- it "is empty section tag if it has no sections" do
85
- content = ContentPresenter.new
86
- content.to_html.should == "<section class=\"\" id=\"body_content\"></section>"
87
- end
88
-
89
- it "returns sections joined by a newline inside section tag" do
90
- section1.stub(:wrapped_html).and_return('foo')
91
- section2.stub(:wrapped_html).and_return('bar')
92
- content = ContentPresenter.new([section1, section2])
93
- content.to_html.should == "<section class=\"\" id=\"body_content\">foo\nbar</section>"
94
- end
95
-
96
- it "passes can_use_fallback option on to sections" do
97
- section1.should_receive(:wrapped_html).with(false).and_return('foo')
98
- content = ContentPresenter.new([section1])
99
- content.to_html(false)
100
- end
101
-
102
- it "doesnt include sections with nil content" do
103
- section1.stub(:wrapped_html).and_return('foo')
104
- section2.stub(:wrapped_html).and_return(nil)
105
- content = ContentPresenter.new([section1, section2])
106
- content.to_html.should == "<section class=\"\" id=\"body_content\">foo</section>"
107
- end
108
- end
109
- end
110
- end
111
- end
@@ -1,35 +0,0 @@
1
- require "spec_helper"
2
-
3
- module Refinery
4
- module Pages
5
- describe PagePartSectionPresenter do
6
- it "can be built from a page part" do
7
- part = double(PagePart, :body => 'part_body', :title => 'A Wonderful Page Part')
8
- section = PagePartSectionPresenter.new(part)
9
- section.fallback_html.should == 'part_body'
10
- section.id.should == :a_wonderful_page_part
11
- end
12
-
13
- it "marks the body as html safe" do
14
- part = double(PagePart, :body => '<p>part_body</p>', :title => nil)
15
- section = PagePartSectionPresenter.new(part)
16
- section.fallback_html.should be_html_safe
17
- section.wrapped_html.should == "<section><div class=\"inner\"><p>part_body</p></div></section>"
18
- end
19
-
20
- it "handles a nil page body" do
21
- part = double(PagePart, :body => nil, :title => nil)
22
- section = PagePartSectionPresenter.new(part)
23
- section.fallback_html.should be_nil
24
- section.wrapped_html.should be_nil
25
- section.has_content?.should be_false
26
- end
27
-
28
- it "has no id if title is nil" do
29
- part = double(PagePart, :body => 'foobar', :title => nil)
30
- section = PagePartSectionPresenter.new(part)
31
- section.id.should be_nil
32
- end
33
- end
34
- end
35
- end
@@ -1,86 +0,0 @@
1
- require "spec_helper"
2
-
3
- module Refinery
4
- module Pages
5
- describe SectionPresenter do
6
- it "can build a css class for when it is not present based on id" do
7
- section = SectionPresenter.new(:fallback_html => 'foobar', :id => 'mynode')
8
- section.not_present_css_class.should == 'no_mynode'
9
- end
10
-
11
- it "allows access to constructor arguments" do
12
- section = SectionPresenter.new(:fallback_html => 'foobar', :id => 'mynode', :hidden => true)
13
- section.fallback_html.should == 'foobar'
14
- section.id.should == 'mynode'
15
- section.should be_hidden
16
- end
17
-
18
- it "should be visible if not hidden" do
19
- section = SectionPresenter.new(:hidden => false)
20
- section.should be_visible
21
- end
22
-
23
- it "should be not visible if hidden" do
24
- section = SectionPresenter.new(:hidden => true)
25
- section.should_not be_visible
26
- end
27
-
28
- describe "when building html for a section" do
29
- it "wont show a hidden section" do
30
- section = SectionPresenter.new(:fallback_html => 'foobar', :hidden => true)
31
- section.has_content?(true).should be_false
32
- section.wrapped_html(true).should be_nil
33
- end
34
-
35
- it "can be hidden with the hide method" do
36
- section = SectionPresenter.new(:fallback_html => 'foobar')
37
- section.hide
38
- section.has_content?(true).should be_false
39
- section.wrapped_html(true).should be_nil
40
- end
41
-
42
- it "will use the specified id" do
43
- section = SectionPresenter.new(:fallback_html => 'foobar', :id => 'mynode')
44
- section.has_content?(true).should be_true
45
- section.wrapped_html(true).should == '<section id="mynode"><div class="inner">foobar</div></section>'
46
- end
47
-
48
- describe "if allowed to use fallback html" do
49
- it "wont show a section with no fallback or override" do
50
- section = SectionPresenter.new
51
- section.has_content?(true).should be_false
52
- section.wrapped_html(true).should be_nil
53
- end
54
-
55
- it "uses wrapped fallback html" do
56
- section = SectionPresenter.new(:fallback_html => 'foobar')
57
- section.has_content?(true).should be_true
58
- section.wrapped_html(true).should == '<section><div class="inner">foobar</div></section>'
59
- end
60
-
61
- it "uses wrapped override html if present" do
62
- section = SectionPresenter.new(:fallback_html => 'foobar')
63
- section.override_html = 'hello world'
64
- section.has_content?(true).should be_true
65
- section.wrapped_html(true).should == '<section><div class="inner">hello world</div></section>'
66
- end
67
- end
68
-
69
- describe "if not allowed to use fallback html" do
70
- it "wont show a section with no override" do
71
- section = SectionPresenter.new(:fallback_html => 'foobar')
72
- section.has_content?(false).should be_false
73
- section.wrapped_html(false).should be_nil
74
- end
75
-
76
- it "uses wrapped override html if present" do
77
- section = SectionPresenter.new(:fallback_html => 'foobar')
78
- section.override_html = 'hello world'
79
- section.has_content?(false).should be_true
80
- section.wrapped_html(false).should == '<section><div class="inner">hello world</div></section>'
81
- end
82
- end
83
- end
84
- end
85
- end
86
- end
@@ -1,21 +0,0 @@
1
- require "spec_helper"
2
-
3
- module Refinery
4
- module Pages
5
- describe TitleSectionPresenter do
6
- describe "when building html for a section" do
7
- it "wraps a title section in a title element" do
8
- section = TitleSectionPresenter.new(:fallback_html => 'foobar')
9
- section.has_content?(true).should be_true
10
- section.wrapped_html(true).should == '<h1>foobar</h1>'
11
- end
12
-
13
- it "will use the specified id" do
14
- section = TitleSectionPresenter.new(:fallback_html => 'foobar', :id => 'mynode')
15
- section.has_content?(true).should be_true
16
- section.wrapped_html(true).should == '<h1 id="mynode">foobar</h1>'
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,26 +0,0 @@
1
- require "spec_helper"
2
-
3
- module Refinery
4
- describe Pages do
5
- describe ".valid_templates" do
6
- before do
7
- File.open(File.join(subject.root, "spec", "ugisozols.html"), "w+") do
8
- end
9
- end
10
-
11
- after { File.delete(File.join(subject.root, "spec", "ugisozols.html")) }
12
-
13
- context "when pattern match valid templates" do
14
- it "returns an array of valid templates" do
15
- subject.valid_templates('spec', '*html*').should include("ugisozols")
16
- end
17
- end
18
-
19
- context "when pattern doesn't match valid templates" do
20
- it "returns empty array" do
21
- subject.valid_templates('huh', '*html*').should == []
22
- end
23
- end
24
- end
25
- end
26
- end