alchemy_cms 5.2.0.rc1 → 5.2.0

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
  SHA256:
3
- metadata.gz: 0fa742b5807adac37f8b9912eee024cdc10fcfb74a202e5a230b85109cfb7959
4
- data.tar.gz: 30b3036533cdda4330ce8c89dbfad621d23980ce382aaca46f52df50294b56c4
3
+ metadata.gz: 80ac30c5b218ae66fdfc00afbaf2185829f52e94b32b76c4b6af8a19c5ec2ac8
4
+ data.tar.gz: 3da61ba5c95787cd3524ffad4e36f774b238fcf0456732a0cf69dac24dcbf0e7
5
5
  SHA512:
6
- metadata.gz: 57745756593a15e0bcdf2558918ee89721f8adc6612f02043f3f066634f7b458078b0bd21c518b6dd082c396b324483691c7c2fa02c249d829c8e021f05a61cb
7
- data.tar.gz: 3a9121c8ed3753b1892d098088085e7b35b81857121b0449690c045ad43c3efc6ef65892bc8969fc7750cb51b6b26a3af4862efc6c29ad903f107d518615ed1a
6
+ metadata.gz: 690da4b19ddbc96671c403bb616da433c37b35eeb0eee142de4f1ebe957f4f7ad9cd0da1e8e8e9e37cb773fbe1aec858166089673921b1ff463bc1dd0028bf91
7
+ data.tar.gz: 9f937fdb379c6df8c64976ec52ae4aef56bf597533e1d3ece0c987ef4604d91dfdb75eb246ce9aa68338d1a1814941f53d982093b378ab8089b3026f8997582b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 5.2.0 (2021-05-06)
2
+
3
+ - Backport #2049 to 5.2 [#2086](https://github.com/AlchemyCMS/alchemy_cms/pull/2086) ([rickythefox](https://github.com/rickythefox))
4
+ - hotfix and deprecate page_active? helper [#2073](https://github.com/AlchemyCMS/alchemy_cms/pull/2073) ([robinboening](https://github.com/robinboening))
5
+
1
6
  ## 5.2.0.rc1 (2021-02-17)
2
7
 
3
8
  ### Changes
@@ -8,6 +8,17 @@ module Alchemy
8
8
  "alchemy/admin/elements/element"
9
9
  end
10
10
 
11
+ # Returns content editor instances for defined contents
12
+ #
13
+ # Creates contents on demand if the content is not yet present on the element
14
+ #
15
+ # @return Array<Alchemy::ContentEditor>
16
+ def contents
17
+ element.definition.fetch(:contents, []).map do |content|
18
+ Alchemy::ContentEditor.new(find_or_create_content(content[:name]))
19
+ end
20
+ end
21
+
11
22
  # CSS classes for the element editor partial.
12
23
  def css_classes
13
24
  [
@@ -78,5 +89,19 @@ module Alchemy
78
89
  default: Alchemy.t(:element_deprecated))
79
90
  end
80
91
  end
92
+
93
+ private
94
+
95
+ def find_or_create_content(name)
96
+ find_content(name) || create_content(name)
97
+ end
98
+
99
+ def find_content(name)
100
+ element.contents.find { |content| content.name == name }
101
+ end
102
+
103
+ def create_content(name)
104
+ Alchemy::Content.create(element: element, name: name)
105
+ end
81
106
  end
82
107
  end
@@ -100,7 +100,9 @@ module Alchemy
100
100
 
101
101
  # Returns true if page is in the active branch
102
102
  def page_active?(page)
103
- @_page_ancestors ||= Page.ancestors_for(@page)
103
+ Alchemy::Deprecation.warn("page_active? helper is deprecated and will be removed from Alchemy 6.0")
104
+
105
+ @_page_ancestors ||= @page.self_and_ancestors.contentpages
104
106
  @_page_ancestors.include?(page)
105
107
  end
106
108
 
@@ -25,7 +25,7 @@
25
25
  <div id="element_<%= element.id %>_errors" class="element_errors"></div>
26
26
 
27
27
  <div id="element_<%= element.id %>_content" class="element-content-editors">
28
- <%= render element.contents.map { |content| Alchemy::ContentEditor.new(content) } %>
28
+ <%= render element.contents %>
29
29
  </div>
30
30
 
31
31
  <% if element.taggable? %>
@@ -132,7 +132,9 @@ module Alchemy
132
132
  end
133
133
 
134
134
  def namespaced_resource_name
135
- @_namespaced_resource_name ||= namespaced_resources_name.singularize
135
+ @_namespaced_resource_name ||= begin
136
+ namespaced_resources_name.to_s.singularize
137
+ end.to_sym # Rails >= 6.0.3.7 needs symbols in polymorphic routes
136
138
  end
137
139
 
138
140
  def namespaced_resources_name
@@ -140,13 +142,13 @@ module Alchemy
140
142
  resource_name_array = resource_array.dup
141
143
  resource_name_array.delete(engine_name) if in_engine?
142
144
  resource_name_array.join("_")
143
- end
145
+ end.to_sym # Rails >= 6.0.3.7 needs symbols in polymorphic routes
144
146
  end
145
147
 
146
148
  def namespace_for_scope
147
149
  namespace_array = namespace_diff
148
150
  namespace_array.delete(engine_name) if in_engine?
149
- namespace_array
151
+ namespace_array.map(&:to_sym) # Rails >= 6.0.3.7 needs symbols in polymorphic routes
150
152
  end
151
153
 
152
154
  # Returns an array of underscored association names
@@ -2,10 +2,17 @@
2
2
 
3
3
  module Alchemy
4
4
  module TestSupport
5
- def self.factory_paths
6
- Dir[
7
- ::Alchemy::Engine.root.join("lib", "alchemy", "test_support", "factories", "*_factory.rb")
8
- ].map { |path| path.sub(/.rb\z/, "") }
5
+ class << self
6
+ def factory_paths
7
+ Dir[
8
+ ::Alchemy::Engine.root.join("lib", "alchemy", "test_support", "factories", "*_factory.rb")
9
+ ].map { |path| path.sub(/.rb\z/, "") }
10
+ end
11
+ deprecate factory_paths: :factories_path, deprecator: Alchemy::Deprecation
12
+
13
+ def factories_path
14
+ ::Alchemy::Engine.root.join("lib", "alchemy", "test_support", "factories")
15
+ end
9
16
  end
10
17
  end
11
18
  end
@@ -7,8 +7,8 @@ Alchemy::Deprecation.warn <<~MSG
7
7
 
8
8
  require 'alchemy/test_support'
9
9
 
10
- FactoryBot.definition_file_paths.concat(Alchemy::TestSupport.factory_paths)
11
- FactoryBot.reload
10
+ FactoryBot.definition_file_paths.append(Alchemy::TestSupport.factories_path)
11
+ FactoryBot.find_definitions
12
12
  MSG
13
13
 
14
14
  Dir["#{File.dirname(__FILE__)}/factories/*.rb"].sort.each do |file|
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemy
4
- VERSION = "5.2.0.rc1"
4
+ VERSION = "5.2.0"
5
5
 
6
6
  def self.version
7
7
  VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.0.rc1
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2021-02-17 00:00:00.000000000 Z
16
+ date: 2021-05-06 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: active_model_serializers
@@ -1275,9 +1275,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
1275
1275
  version: 2.3.0
1276
1276
  required_rubygems_version: !ruby/object:Gem::Requirement
1277
1277
  requirements:
1278
- - - ">"
1278
+ - - ">="
1279
1279
  - !ruby/object:Gem::Version
1280
- version: 1.3.1
1280
+ version: '0'
1281
1281
  requirements:
1282
1282
  - ImageMagick (libmagick), v6.6 or greater.
1283
1283
  rubygems_version: 3.1.4