radiant-page_factory-extension 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/EXAMPLES.md +136 -0
  2. data/README.md +59 -0
  3. data/Rakefile +136 -0
  4. data/VERSION +1 -0
  5. data/app/controllers/admin/page_factories_controller.rb +42 -0
  6. data/app/helpers/admin/part_description_helper.rb +9 -0
  7. data/app/views/admin/page_factories/_page_factory.html.haml +4 -0
  8. data/app/views/admin/page_factories/index.haml +0 -0
  9. data/app/views/admin/page_parts/_part_description.html.haml +2 -0
  10. data/app/views/admin/pages/_add_child_column.html.haml +3 -0
  11. data/app/views/admin/pages/_edit_header.html.haml +1 -0
  12. data/app/views/admin/pages/_page_factories.html.haml +4 -0
  13. data/app/views/admin/pages/_page_factory_field.html.haml +1 -0
  14. data/config/locales/en.yml +3 -0
  15. data/config/routes.rb +5 -0
  16. data/db/migrate/20100321222140_add_page_factory.rb +9 -0
  17. data/lib/page_factory.rb +12 -0
  18. data/lib/page_factory/base.rb +81 -0
  19. data/lib/page_factory/manager.rb +120 -0
  20. data/lib/page_factory/page_extensions.rb +25 -0
  21. data/lib/page_factory/page_part_extensions.rb +9 -0
  22. data/lib/page_factory/pages_controller_extensions.rb +32 -0
  23. data/lib/tasks/page_factory_extension_tasks.rake +95 -0
  24. data/page_factory_extension.rb +25 -0
  25. data/public/javascripts/admin/dropdown.js +153 -0
  26. data/public/javascripts/admin/pagefactory.js +30 -0
  27. data/public/stylesheets/admin/page_factory.css +14 -0
  28. data/public/stylesheets/sass/admin/dropdown.sass +32 -0
  29. data/public/stylesheets/sass/modules/_gradient.sass +47 -0
  30. data/public/stylesheets/sass/modules/_rounded.sass +41 -0
  31. data/public/stylesheets/sass/modules/_shadow.sass +9 -0
  32. data/spec/controllers/admin/page_factories_controller_spec.rb +47 -0
  33. data/spec/controllers/admin/pages_controller_spec.rb +63 -0
  34. data/spec/helpers/admin/part_description_helper_spec.rb +42 -0
  35. data/spec/lib/manager_spec.rb +218 -0
  36. data/spec/lib/page_extensions_spec.rb +15 -0
  37. data/spec/models/page_factory_spec.rb +95 -0
  38. data/spec/models/page_spec.rb +27 -0
  39. data/spec/spec.opts +6 -0
  40. data/spec/spec_helper.rb +36 -0
  41. metadata +128 -0
@@ -0,0 +1,15 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe PageFactory::PageExtensions do
4
+ class OverridingPageFactory < PageFactory::Base
5
+ part 'alpha'
6
+ part 'beta'
7
+ end
8
+
9
+ it "should override Page.default_page_parts" do
10
+ PageFactory.current_factory = OverridingPageFactory
11
+ page = Page.new_with_defaults(Radiant::Config)
12
+ page.parts.map(&:name).should eql(%w(alpha beta))
13
+ end
14
+
15
+ end
@@ -0,0 +1,95 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe PageFactory do
4
+
5
+ class SubPageFactory < PageFactory::Base
6
+ end
7
+
8
+ it "should have the default page parts" do
9
+ PageFactory::Base.parts.should == Page.new_with_defaults(Radiant::Config).parts
10
+ end
11
+
12
+ it "should inherit page_parts" do
13
+ SubPageFactory.parts.should == PageFactory::Base.parts
14
+ end
15
+
16
+ it "should inherit page_class and layout" do
17
+ SubPageFactory.layout = 'LayoutName'
18
+ SubPageFactory.page_class = 'ClassName'
19
+ class ThirdPageFactory < SubPageFactory ; end
20
+
21
+ ThirdPageFactory.layout.should eql('LayoutName')
22
+ ThirdPageFactory.page_class.should eql('ClassName')
23
+ end
24
+
25
+ describe '.part' do
26
+ it "should add a part to page_parts" do
27
+ SubPageFactory.part 'Sidebar'
28
+ SubPageFactory.parts.find { |p| p.name == 'Sidebar'}.should be_a(PagePart)
29
+ end
30
+
31
+ it "should add a part with attributes" do
32
+ SubPageFactory.part 'Filtered', :filter_id => 'markdown'
33
+ SubPageFactory.parts.find { |p| p.name == 'Filtered'}.filter_id.should eql('markdown')
34
+ end
35
+
36
+ it "should override a part" do
37
+ SubPageFactory.part 'Override', :filter_id => 'old id'
38
+ SubPageFactory.part 'Override', :filter_id => 'new id'
39
+ SubPageFactory.parts.find { |p| p.name == 'Override'}.filter_id.should eql('new id')
40
+ end
41
+ end
42
+
43
+ describe '.remove' do
44
+ class FullPageFactory < PageFactory::Base
45
+ part 'one'
46
+ part 'two'
47
+ end
48
+
49
+ class EmptyPageFactory < FullPageFactory
50
+ end
51
+
52
+ it "should remove a part" do
53
+ EmptyPageFactory.remove 'one'
54
+ EmptyPageFactory.parts.map(&:name).should_not include('one')
55
+ end
56
+
57
+ it "should not be case sensitive" do
58
+ EmptyPageFactory.remove 'TWO'
59
+ EmptyPageFactory.parts.map(&:name).should_not include('two')
60
+ end
61
+
62
+ it "should remove any number of parts" do
63
+ FullPageFactory.remove 'one', 'two'
64
+ FullPageFactory.parts.should be_empty
65
+ end
66
+ end
67
+
68
+ describe ".current_factory" do
69
+ class DefinedPageFactory < PageFactory::Base
70
+ part 'alpha'
71
+ part 'beta'
72
+ end
73
+
74
+ it "should return parts from the currently specified factory" do
75
+ PageFactory.current_factory = DefinedPageFactory
76
+ PageFactory.current_factory.parts.should eql(DefinedPageFactory.parts)
77
+ end
78
+
79
+ it "should not override other factories" do
80
+ PageFactory.current_factory = DefinedPageFactory
81
+ SubPageFactory.parts.should_not eql(DefinedPageFactory.parts)
82
+ end
83
+
84
+ it "should return base class by default" do
85
+ PageFactory.current_factory = nil
86
+ PageFactory.current_factory.parts.should eql(PageFactory::Base.parts)
87
+ end
88
+
89
+ it "should should accept a string" do
90
+ PageFactory.current_factory = 'DefinedPageFactory'
91
+ PageFactory.current_factory.should eql(DefinedPageFactory)
92
+ end
93
+ end
94
+
95
+ end
@@ -0,0 +1,27 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Page do
4
+ class ConstantizedPageFactory < PageFactory::Base
5
+ end
6
+
7
+ before do
8
+ @page = Page.new
9
+ end
10
+
11
+ describe ".page_factory" do
12
+ it "should constantize the factory" do
13
+ @page.page_factory = 'ConstantizedPageFactory'
14
+ @page.page_factory.should eql(ConstantizedPageFactory)
15
+ end
16
+
17
+ it "should return nil if no factory is set" do
18
+ @page.page_factory = nil
19
+ @page.page_factory.should be_nil
20
+ end
21
+
22
+ it "should not blow up if the factory has gone missing" do
23
+ @page.page_factory = 'BogusPageFactory'
24
+ @page.page_factory.should be_nil
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,6 @@
1
+ --colour
2
+ --format
3
+ progress
4
+ --loadby
5
+ mtime
6
+ --reverse
@@ -0,0 +1,36 @@
1
+ unless defined? RADIANT_ROOT
2
+ ENV["RAILS_ENV"] = "test"
3
+ case
4
+ when ENV["RADIANT_ENV_FILE"]
5
+ require ENV["RADIANT_ENV_FILE"]
6
+ when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
7
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../../")}/config/environment"
8
+ else
9
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../")}/config/environment"
10
+ end
11
+ end
12
+ require "#{RADIANT_ROOT}/spec/spec_helper"
13
+
14
+ Dataset::Resolver.default << (File.dirname(__FILE__) + "/datasets")
15
+
16
+ if File.directory?(File.dirname(__FILE__) + "/matchers")
17
+ Dir[File.dirname(__FILE__) + "/matchers/*.rb"].each {|file| require file }
18
+ end
19
+
20
+ Spec::Runner.configure do |config|
21
+ # config.use_transactional_fixtures = true
22
+ # config.use_instantiated_fixtures = false
23
+ # config.fixture_path = RAILS_ROOT + '/spec/fixtures'
24
+
25
+ # You can declare fixtures for each behaviour like this:
26
+ # describe "...." do
27
+ # fixtures :table_a, :table_b
28
+ #
29
+ # Alternatively, if you prefer to declare them only once, you can
30
+ # do so here, like so ...
31
+ #
32
+ # config.global_fixtures = :table_a, :table_b
33
+ #
34
+ # If you declare global fixtures, be aware that they will be declared
35
+ # for all of your examples, even those that don't use them.
36
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: radiant-page_factory-extension
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Josh French
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-16 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: radiant
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 59
30
+ segments:
31
+ - 0
32
+ - 9
33
+ - 0
34
+ version: 0.9.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: Page Factory is a small DSL for intelligently defining content types in Radiant CMS.
38
+ email: josh@vitamin-j.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - README.md
45
+ files:
46
+ - EXAMPLES.md
47
+ - README.md
48
+ - Rakefile
49
+ - VERSION
50
+ - app/controllers/admin/page_factories_controller.rb
51
+ - app/helpers/admin/part_description_helper.rb
52
+ - app/views/admin/page_factories/_page_factory.html.haml
53
+ - app/views/admin/page_factories/index.haml
54
+ - app/views/admin/page_parts/_part_description.html.haml
55
+ - app/views/admin/pages/_add_child_column.html.haml
56
+ - app/views/admin/pages/_edit_header.html.haml
57
+ - app/views/admin/pages/_page_factories.html.haml
58
+ - app/views/admin/pages/_page_factory_field.html.haml
59
+ - config/locales/en.yml
60
+ - config/routes.rb
61
+ - db/migrate/20100321222140_add_page_factory.rb
62
+ - lib/page_factory.rb
63
+ - lib/page_factory/base.rb
64
+ - lib/page_factory/manager.rb
65
+ - lib/page_factory/page_extensions.rb
66
+ - lib/page_factory/page_part_extensions.rb
67
+ - lib/page_factory/pages_controller_extensions.rb
68
+ - lib/tasks/page_factory_extension_tasks.rake
69
+ - page_factory_extension.rb
70
+ - public/javascripts/admin/dropdown.js
71
+ - public/javascripts/admin/pagefactory.js
72
+ - public/stylesheets/admin/page_factory.css
73
+ - public/stylesheets/sass/admin/dropdown.sass
74
+ - public/stylesheets/sass/modules/_gradient.sass
75
+ - public/stylesheets/sass/modules/_rounded.sass
76
+ - public/stylesheets/sass/modules/_shadow.sass
77
+ - spec/controllers/admin/page_factories_controller_spec.rb
78
+ - spec/controllers/admin/pages_controller_spec.rb
79
+ - spec/helpers/admin/part_description_helper_spec.rb
80
+ - spec/lib/manager_spec.rb
81
+ - spec/lib/page_extensions_spec.rb
82
+ - spec/models/page_factory_spec.rb
83
+ - spec/models/page_spec.rb
84
+ - spec/spec.opts
85
+ - spec/spec_helper.rb
86
+ has_rdoc: true
87
+ homepage: http://github.com/joshfrench/radiant-page_factory-extension
88
+ licenses: []
89
+
90
+ post_install_message:
91
+ rdoc_options:
92
+ - --charset=UTF-8
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ hash: 3
101
+ segments:
102
+ - 0
103
+ version: "0"
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ hash: 3
110
+ segments:
111
+ - 0
112
+ version: "0"
113
+ requirements: []
114
+
115
+ rubyforge_project:
116
+ rubygems_version: 1.3.7
117
+ signing_key:
118
+ specification_version: 3
119
+ summary: Page Factory Extension for Radiant CMS
120
+ test_files:
121
+ - spec/controllers/admin/page_factories_controller_spec.rb
122
+ - spec/controllers/admin/pages_controller_spec.rb
123
+ - spec/helpers/admin/part_description_helper_spec.rb
124
+ - spec/lib/manager_spec.rb
125
+ - spec/lib/page_extensions_spec.rb
126
+ - spec/models/page_factory_spec.rb
127
+ - spec/models/page_spec.rb
128
+ - spec/spec_helper.rb