radiant-children_config-extension 1.1.1 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2394f7cb402e519fba5b7c917ec00ea0680a22b6d77b18f991c68f98b5ec94e2
4
+ data.tar.gz: bf9c9fa66f24b505dd75d5070fa3b757b2a2eecb753be929d89d56978ff807db
5
+ SHA512:
6
+ metadata.gz: 3cb3c980a718f2ab64de4a45be0b28287d67e56b021f8d5e72e86c1abb72f4694282fd611eaec436a8dd1e257f84aaded681cb6cf4e57732e5dce0d829a51b01
7
+ data.tar.gz: 1d87344d2dbf3ae5a2f903844259894f49df2362415586101181e6e1b7efe6111c9b8e314b70319b27625ce43ce0ccfcbc00190f5470dede2d4599c76ab1ab0d
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
1
  # Children Config
2
2
 
3
- Allows you to define new default page parts on every page.
3
+ Allows you to define new default page properties for every new child of a certain page.
4
+ Most commonly used to set new default page parts or fields, but you could also put 'template' content in page parts or create new children for the child page.
5
+
4
6
  Based on the [default\_page\_parts extension](https://github.com/santry/radiant-default-page-parts-extension), originally created by Sean Santry.
5
7
 
6
- ## How to use
8
+ ## Examples
7
9
 
8
10
  Let's say you want all pages under "Events" to have the page parts "location", "description" and "date" by default.
9
11
  Simply add a "children_config" page part to the "Events" page. In the content of that page part, put:
@@ -2,7 +2,7 @@ module ChildrenConfig::PageExtensions
2
2
  def self.included(base)
3
3
  base.class_eval do
4
4
  after_save :create_children
5
-
5
+
6
6
  def self.new_with_children_config(config = Radiant::Config, parts = String)
7
7
  begin
8
8
  unless parts.empty?
@@ -21,9 +21,9 @@ module ChildrenConfig::PageExtensions
21
21
  end
22
22
  end
23
23
  if config.select{|c| c.has_key? "layout"}.size > 0
24
- config.select{|c| c.has_key? "layout"}.first["layout"].each do |field|
25
- page.layout = Layout.find_by_name(field)
26
- end
24
+ page.layout = Layout.find_by_name(
25
+ config.select{|c| c.has_key? "layout"}.first["layout"]
26
+ )
27
27
  end
28
28
  page
29
29
  end
@@ -34,10 +34,10 @@ module ChildrenConfig::PageExtensions
34
34
  new_with_defaults(config)
35
35
  end
36
36
  end
37
-
37
+
38
38
  end
39
39
  end
40
-
40
+
41
41
  def create_children
42
42
  if updated_at == created_at and parent and children_config = parent.part(:children_config).try(:content)
43
43
  config = YAML::load(children_config)
@@ -67,11 +67,11 @@ module ChildrenConfig::PageExtensions
67
67
  raise page.errors.full_messages.join ", " unless page.valid?
68
68
  page.save
69
69
  end
70
-
70
+
71
71
  end
72
72
  end
73
73
  end
74
-
74
+
75
75
  def parts_from_config(config)
76
76
  result, options = [], {}
77
77
  config.select{|c| c.has_key? "parts"}.first["parts"].each do |part|
@@ -87,5 +87,5 @@ module ChildrenConfig::PageExtensions
87
87
  end
88
88
  result
89
89
  end
90
-
91
- end
90
+
91
+ end
@@ -1,19 +1,21 @@
1
1
  module ChildrenConfig::PagesControllerExtensions
2
2
  def self.included(base)
3
3
  base.class_eval do
4
- alias :original_new :new
5
-
6
- def new
7
- unless params[:page_id].blank?
8
- parent_page = Page.find(params[:page_id])
9
- child_parts = parent_page.part("children_config").try(:content)
10
- self.model = model_class.new_with_children_config(config, child_parts)
11
- else
12
- self.model = model_class.new_with_defaults(config)
13
- self.model.slug = '/'
14
- end
15
- response_for :singular
16
- end
4
+ alias_method_chain :new, :children_config
5
+
17
6
  end
18
7
  end
19
- end
8
+
9
+ def new_with_children_config
10
+ unless params[:page_id].blank?
11
+ parent_page = Page.find(params[:page_id])
12
+ yaml_config = parent_page.part("children_config").try(:content)
13
+ @page = self.model = model_class.new_with_children_config(config, yaml_config)
14
+ assign_page_attributes
15
+ response_for :new
16
+ else
17
+ new_without_children_config
18
+ end
19
+
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module RadiantChildrenConfigExtension
2
- VERSION = '1.1.1'
3
- end
2
+ VERSION = '1.1.3'
3
+ end
metadata CHANGED
@@ -1,28 +1,24 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: radiant-children_config-extension
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.1.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.3
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - Benny Degezelle
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
-
13
- date: 2012-10-12 00:00:00 Z
11
+ date: 2022-12-07 00:00:00.000000000 Z
14
12
  dependencies: []
15
-
16
13
  description: Allows you to define new defaults on a page per page basis.
17
- email:
14
+ email:
18
15
  - rubygems@monkeypatch.be
19
16
  executables: []
20
-
21
17
  extensions: []
22
-
23
18
  extra_rdoc_files: []
24
-
25
- files:
19
+ files:
20
+ - README.md
21
+ - Rakefile
26
22
  - children_config_extension.rb
27
23
  - config/initializers/radiant_config.rb
28
24
  - config/locales/en.yml
@@ -33,48 +29,42 @@ files:
33
29
  - features/support/paths.rb
34
30
  - lib/children_config/page_extensions.rb
35
31
  - lib/children_config/pages_controller_extensions.rb
36
- - lib/radiant-children_config-extension/version.rb
37
32
  - lib/radiant-children_config-extension.rb
33
+ - lib/radiant-children_config-extension/version.rb
38
34
  - lib/tasks/children_config_extension_tasks.rake
39
35
  - radiant-children_config-extension.gemspec
40
- - Rakefile
41
- - README.md
42
36
  - spec/controllers/admin/pages_controller_spec.rb
43
37
  - spec/datasets/children_config_dataset.rb
44
38
  - spec/spec.opts
45
39
  - spec/spec_helper.rb
46
40
  homepage: https://github.com/jomz/radiant-children_config-extension
47
41
  licenses: []
48
-
49
- post_install_message: "\n Add this to your radiant project by putting this line in your Gemfile:\n gem \"radiant-children_config-extension\", \"~> 1.1.1\"\n "
42
+ metadata: {}
43
+ post_install_message: "\n Add this to your radiant project by putting this line in
44
+ your Gemfile:\n gem \"radiant-children_config-extension\", \"~> 1.1.3\"\n "
50
45
  rdoc_options: []
51
-
52
- require_paths:
46
+ require_paths:
53
47
  - lib
54
- required_ruby_version: !ruby/object:Gem::Requirement
55
- none: false
56
- requirements:
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
57
50
  - - ">="
58
- - !ruby/object:Gem::Version
59
- version: "0"
60
- required_rubygems_version: !ruby/object:Gem::Requirement
61
- none: false
62
- requirements:
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
63
55
  - - ">="
64
- - !ruby/object:Gem::Version
65
- version: "0"
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
66
58
  requirements: []
67
-
68
- rubyforge_project:
69
- rubygems_version: 1.8.24
59
+ rubygems_version: 3.1.6
70
60
  signing_key:
71
- specification_version: 3
61
+ specification_version: 4
72
62
  summary: Children Config extension for Radiant CMS
73
- test_files:
63
+ test_files:
74
64
  - spec/controllers/admin/pages_controller_spec.rb
65
+ - spec/spec_helper.rb
75
66
  - spec/datasets/children_config_dataset.rb
76
67
  - spec/spec.opts
77
- - spec/spec_helper.rb
78
68
  - features/admin/children_config.feature
79
69
  - features/support/env.rb
80
70
  - features/support/paths.rb