alchemy_cms 6.0.9 → 6.0.10

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: 23531a0233f0633efb7c6c17b3bb79eb6a0fd5536e34766aa76840a43c594c9b
4
- data.tar.gz: 3d8a8f2a8266b3fa5982de4009b9703d3ef3b585e1cb35ed2381daedfd110395
3
+ metadata.gz: 03cfa47992384280268b398c712c0d2fe88402482c1acd514406ba784e5e74d0
4
+ data.tar.gz: 9793cf56d7592cdd552009efac7f065d0ee1c6511b4d4d2e6307997c850c88d8
5
5
  SHA512:
6
- metadata.gz: 8ceb3ac0a3f6f833f5c15bfe3bc91d1e42970a03f32c373941d57574405395906fcfa16e373f2cc6db71648a93cfa6e7d37f479dc230f716270aba6539dcc62d
7
- data.tar.gz: 02d7428a535cef3b642edec8cdfb2cc7ed77360ea5033de128c2da899d28a24819cbe3026b2dd21a98f280faf505caa76745a103800a0401c5d96f42ae31fcd4
6
+ metadata.gz: d3600a98fec4301d4d5ed8dd156ecde606a1857cdd028e5c97318ca3284d19e54e13614e1192ef69bff3805037c325d8a57821efbebf449101cda575559c6874
7
+ data.tar.gz: e0d22ac66fb2b8d75a5bc3719372f12be3332dedad315f5f8758850407b7690a98d5eb24ac0b905199de40a7ba9f13930ef6c79c36304b02ee894f7410ad1273
@@ -9,11 +9,9 @@ jobs:
9
9
  fail-fast: false
10
10
  matrix:
11
11
  rails:
12
- - "6.0"
13
12
  - "6.1"
14
13
  - "7.0"
15
14
  ruby:
16
- - "2.6"
17
15
  - "2.7"
18
16
  - "3.0"
19
17
  - "3.1"
@@ -21,25 +19,6 @@ jobs:
21
19
  - mysql
22
20
  - postgresql
23
21
  - mariadb
24
- exclude:
25
- - rails: "6.0"
26
- ruby: "3.1"
27
- database: mysql
28
- - rails: "6.0"
29
- ruby: "3.1"
30
- database: postgresql
31
- - rails: "6.0"
32
- ruby: "3.1"
33
- database: mariadb
34
- - rails: "7.0"
35
- ruby: "2.6"
36
- database: mysql
37
- - rails: "7.0"
38
- ruby: "2.6"
39
- database: postgresql
40
- - rails: "7.0"
41
- ruby: "2.6"
42
- database: mariadb
43
22
  env:
44
23
  DB: ${{ matrix.database }}
45
24
  DB_USER: alchemy_user
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 6.0.10 (2022-09-04)
2
+
3
+ - Deprecate essence classes [#2371](https://github.com/AlchemyCMS/alchemy_cms/pull/2371) ([tvdeyen](https://github.com/tvdeyen))
4
+ - Deprecate full_url_for_element helper [#2368](https://github.com/AlchemyCMS/alchemy_cms/pull/2368) ([tvdeyen](https://github.com/tvdeyen))
5
+ - Deprecate element_dom_id helper [#2368](https://github.com/AlchemyCMS/alchemy_cms/pull/2368) ([tvdeyen](https://github.com/tvdeyen))
6
+ - Use position instead of id for element dom_id [#2368](https://github.com/AlchemyCMS/alchemy_cms/pull/2368) ([tvdeyen](https://github.com/tvdeyen))
7
+ - Fix ingredient boolean preview text [#2367](https://github.com/AlchemyCMS/alchemy_cms/pull/2367) ([tvdeyen](https://github.com/tvdeyen))
8
+ - Decide locale prefix with page language in show_alchemy_page_url helper [#2366](https://github.com/AlchemyCMS/alchemy_cms/pull/2366) ([tvdeyen](https://github.com/tvdeyen))
9
+ - Use cache_key_with_version in page_etag [#2365](https://github.com/AlchemyCMS/alchemy_cms/pull/2365) ([tvdeyen](https://github.com/tvdeyen))
10
+ - Fix author edit_content permissions [#2364](https://github.com/AlchemyCMS/alchemy_cms/pull/2364) ([tvdeyen](https://github.com/tvdeyen))
11
+
1
12
  ## 6.0.9 (2022-07-25)
2
13
 
3
14
  - Allow Site managers to remove page locks [#2360](https://github.com/AlchemyCMS/alchemy_cms/pull/2360) ([mamhoff](https://github.com/mamhoff))
@@ -8,14 +8,9 @@ module Alchemy
8
8
  # Returns all pages as json object
9
9
  #
10
10
  def index
11
- # Fix for cancancan not able to merge multiple AR scopes for logged in users
12
- if can? :edit_content, Alchemy::Page
13
- @pages = Alchemy::Page.all
14
- else
15
- language = Alchemy::Language.find_by(id: params[:language_id]) || Alchemy::Language.current
16
- @pages = Alchemy::Page.accessible_by(current_ability, :index)
17
- @pages = @pages.where(language: language)
18
- end
11
+ language = Alchemy::Language.find_by(id: params[:language_id]) || Alchemy::Language.current
12
+ @pages = Alchemy::Page.accessible_by(current_ability, :index)
13
+ @pages = @pages.where(language: language)
19
14
  @pages = @pages.includes(*page_includes)
20
15
  @pages = @pages.ransack(params[:q]).result
21
16
 
@@ -218,12 +218,12 @@ module Alchemy
218
218
  #
219
219
  # IMPORTANT:
220
220
  #
221
- # If your user does not have a +cache_key+ method (i.e. it's not an ActiveRecord model),
221
+ # If your user does not have a +cache_key_with_version+ method (i.e. it's not an ActiveRecord model),
222
222
  # you have to ensure to implement it and return a unique identifier for that particular user.
223
223
  # Otherwise all users will see the same cached page, regardless of user's state.
224
224
  #
225
225
  def page_etag
226
- @page.cache_key + current_alchemy_user.try(:cache_key).to_s
226
+ [@page, current_alchemy_user]
227
227
  end
228
228
 
229
229
  # We only render the page if either the cache is disabled for this page
@@ -29,9 +29,16 @@ module Alchemy
29
29
  # If the element uses +ingredients+ it renders the ingredient record.
30
30
  #
31
31
  def render(name, options = {}, html_options = {})
32
- renderable = element.ingredient_by_role(name) || content(name)
32
+ renderable = element.ingredient_by_role(name) || Alchemy::Deprecation.silence { content(name) }
33
33
  return if renderable.nil?
34
34
 
35
+ if Alchemy::DEPRECATED_ESSENCE_CLASSES.include?(renderable.try(:essence)&.class&.name)
36
+ Alchemy::Deprecation.warn(
37
+ "Using a '#{renderable.essence.class.name.demodulize}' content is deprecated. " \
38
+ "Please use a '#{Alchemy::DEPRECATED_ESSENCE_CLASS_MAPPING[renderable.essence.class.name].demodulize}' ingredient instead."
39
+ )
40
+ end
41
+
35
42
  helpers.render(renderable, {
36
43
  options: options,
37
44
  html_options: html_options,
@@ -66,7 +73,9 @@ module Alchemy
66
73
  if element.ingredient_definitions.any?
67
74
  element.has_value_for?(name)
68
75
  else
69
- element.has_ingredient?(name)
76
+ Alchemy::Deprecation.silence do
77
+ element.has_ingredient?(name)
78
+ end
70
79
  end
71
80
  end
72
81
 
@@ -128,7 +137,7 @@ module Alchemy
128
137
  def element_view_for(element, options = {})
129
138
  options = {
130
139
  tag: :div,
131
- id: element_dom_id(element),
140
+ id: element.dom_id,
132
141
  class: element.name,
133
142
  tags_formatter: ->(tags) { tags.join(" ") },
134
143
  }.merge(options)
@@ -167,12 +167,13 @@ module Alchemy
167
167
  end
168
168
 
169
169
  # Returns a string for the id attribute of a html element for the given element
170
+ # @deprecated
170
171
  def element_dom_id(element)
171
- return "" if element.nil?
172
-
173
- "#{element.name}_#{element.id}".html_safe
172
+ element&.dom_id
174
173
  end
175
174
 
175
+ deprecate element_dom_id: "element.dom_id", deprecator: Alchemy::Deprecation
176
+
176
177
  # Renders the HTML tag attributes required for preview mode.
177
178
  def element_preview_code(element)
178
179
  tag_builder.tag_options(element_preview_code_attributes(element))
@@ -20,8 +20,8 @@ module Alchemy
20
20
  def show_page_path_params(page, optional_params = {})
21
21
  raise ArgumentError, "Page is nil" if page.nil?
22
22
 
23
- url_params = {urlname: page.urlname}.update(optional_params)
24
- prefix_locale? ? url_params.update(locale: page.language_code) : url_params
23
+ url_params = { urlname: page.urlname }.update(optional_params)
24
+ prefix_locale?(page.language_code) ? url_params.update(locale: page.language_code) : url_params
25
25
  end
26
26
 
27
27
  # Returns the path for downloading an alchemy attachment
@@ -35,8 +35,11 @@ module Alchemy
35
35
  end
36
36
 
37
37
  # Returns the full url containing host, page and anchor for the given element
38
+ # @deprecated
38
39
  def full_url_for_element(element)
39
- "#{current_server}/#{element.page.urlname}##{element_dom_id(element)}"
40
+ "#{current_server}/#{element.page.urlname}##{element.dom_id}"
40
41
  end
42
+
43
+ deprecate :full_url_for_element, deprecator: Alchemy::Deprecation
41
44
  end
42
45
  end
@@ -19,6 +19,7 @@
19
19
  require_dependency "alchemy/content/factory"
20
20
 
21
21
  module Alchemy
22
+ # @deprecated
22
23
  class Content < BaseRecord
23
24
  include Alchemy::Logger
24
25
  include Alchemy::Hints
@@ -82,7 +82,7 @@ module Alchemy
82
82
  # Returns a dom id used for elements html id tag.
83
83
  #
84
84
  def dom_id
85
- "#{name}_#{id}"
85
+ [parent_element&.dom_id, name, position].compact.join("-")
86
86
  end
87
87
 
88
88
  # The content that's used for element's preview text.
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemy
4
+ # @deprecated
4
5
  class EssenceAudio < ActiveRecord::Base
5
6
  acts_as_essence(
6
7
  ingredient_column: :attachment,
@@ -13,6 +13,7 @@
13
13
  # Stores boolean values.
14
14
  # Provides a checkbox in the editor views.
15
15
  module Alchemy
16
+ # @deprecated
16
17
  class EssenceBoolean < BaseRecord
17
18
  acts_as_essence ingredient_column: "value"
18
19
  end
@@ -11,6 +11,7 @@
11
11
  #
12
12
 
13
13
  module Alchemy
14
+ # @deprecated
14
15
  class EssenceDate < BaseRecord
15
16
  acts_as_essence ingredient_column: "date"
16
17
 
@@ -14,6 +14,7 @@
14
14
  #
15
15
 
16
16
  module Alchemy
17
+ # @deprecated
17
18
  class EssenceFile < BaseRecord
18
19
  belongs_to :attachment, optional: true
19
20
  acts_as_essence ingredient_column: "attachment"
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemy
4
+ # @deprecated
4
5
  class EssenceHeadline < BaseRecord
5
6
  acts_as_essence
6
7
 
@@ -11,6 +11,7 @@
11
11
  #
12
12
 
13
13
  module Alchemy
14
+ # @deprecated
14
15
  class EssenceHtml < BaseRecord
15
16
  acts_as_essence ingredient_column: "source"
16
17
 
@@ -14,6 +14,7 @@
14
14
  #
15
15
 
16
16
  module Alchemy
17
+ # @deprecated
17
18
  class EssenceLink < BaseRecord
18
19
  acts_as_essence ingredient_column: "link"
19
20
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemy
4
+ # @deprecated
4
5
  class EssenceNode < BaseRecord
5
6
  acts_as_essence(
6
7
  ingredient_column: :node,
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemy
4
+ # @deprecated
4
5
  class EssencePage < BaseRecord
5
6
  acts_as_essence(
6
7
  ingredient_column: :page,
@@ -22,6 +22,7 @@
22
22
  #
23
23
 
24
24
  module Alchemy
25
+ # @deprecated
25
26
  class EssencePicture < BaseRecord
26
27
  include Alchemy::PictureThumbnails
27
28
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Alchemy
4
4
  # Renders an essence picture view
5
+ # @deprecated
5
6
  class EssencePictureView
6
7
  include ActionView::Helpers::AssetTagHelper
7
8
  include ActionView::Helpers::UrlHelper
@@ -13,6 +13,7 @@
13
13
  #
14
14
 
15
15
  module Alchemy
16
+ # @deprecated
16
17
  class EssenceRichtext < BaseRecord
17
18
  acts_as_essence preview_text_column: "stripped_body"
18
19
 
@@ -12,6 +12,7 @@
12
12
 
13
13
  # Provides a select box that stores string values.
14
14
  module Alchemy
15
+ # @deprecated
15
16
  class EssenceSelect < BaseRecord
16
17
  acts_as_essence ingredient_column: "value"
17
18
  end
@@ -16,6 +16,7 @@
16
16
  #
17
17
 
18
18
  module Alchemy
19
+ # @deprecated
19
20
  class EssenceText < BaseRecord
20
21
  acts_as_essence
21
22
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemy
4
+ # @deprecated
4
5
  class EssenceVideo < ActiveRecord::Base
5
6
  acts_as_essence(
6
7
  ingredient_column: :attachment,
@@ -14,7 +14,9 @@ module Alchemy
14
14
  # Used by the Element#preview_text method.
15
15
  #
16
16
  def preview_text(_max_length = nil)
17
- Alchemy.t(value, scope: "ingredient_values.boolean")
17
+ return if value.nil?
18
+
19
+ Alchemy.t(value.to_s, scope: "ingredient_values.boolean")
18
20
  end
19
21
  end
20
22
  end
@@ -13,8 +13,8 @@ xml.rss version: "2.0" do
13
13
  if element.has_ingredient?("date")
14
14
  xml.pubDate element.ingredient("date").to_s(:rfc822)
15
15
  end
16
- xml.link show_alchemy_page_url(@page, anchor: element_dom_id(element))
17
- xml.guid show_alchemy_page_url(@page, anchor: element_dom_id(element))
16
+ xml.link show_alchemy_page_url(@page, anchor: "##{element.dom_id}")
17
+ xml.guid show_alchemy_page_url(@page, anchor: "##{element.dom_id}")
18
18
  end
19
19
  end
20
20
  end
@@ -23,8 +23,12 @@ module Alchemy #:nodoc:
23
23
  # The column the the validations run against.
24
24
  # @option options [String || Symbol] preview_text_column (ingredient_column)
25
25
  # Specify the column for the preview_text method.
26
- #
26
+ # @deprecated
27
27
  def acts_as_essence(options = {})
28
+ if !DEPRECATED_ESSENCE_CLASSES.include?(name)
29
+ Alchemy::Deprecation.warn "Please create a custom Alchemy::Ingredient for #{name} instead"
30
+ end
31
+
28
32
  register_as_essence_association!
29
33
 
30
34
  configuration = {
@@ -121,7 +121,9 @@ module Alchemy
121
121
  can :manage, Alchemy::Node
122
122
  can [:read, :url], Alchemy::Picture
123
123
  can [:read, :autocomplete], Alchemy::Tag
124
- can(:edit_content, Alchemy::Page) { |p| p.editable_by?(@user) }
124
+ can :edit_content, Alchemy::Page, Alchemy::Page.all do |page|
125
+ page.editable_by?(@user)
126
+ end
125
127
  end
126
128
  end
127
129
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemy
4
- VERSION = "6.0.9"
4
+ VERSION = "6.0.10"
5
5
 
6
6
  def self.version
7
7
  VERSION
data/lib/alchemy.rb CHANGED
@@ -5,6 +5,25 @@ require "alchemy/admin/preview_url"
5
5
  module Alchemy
6
6
  YAML_PERMITTED_CLASSES = %w[Symbol Date Regexp]
7
7
 
8
+ DEPRECATED_ESSENCE_CLASS_MAPPING = {
9
+ "Alchemy::EssenceAudio" => "Alchemy::Ingredients::Audio",
10
+ "Alchemy::EssenceBoolean" => "Alchemy::Ingredients::Boolean",
11
+ "Alchemy::EssenceDate" => "Alchemy::Ingredients::Date",
12
+ "Alchemy::EssenceFile" => "Alchemy::Ingredients::File",
13
+ "Alchemy::EssenceHeadline" => "Alchemy::Ingredients::Headline",
14
+ "Alchemy::EssenceHtml" => "Alchemy::Ingredients::Html",
15
+ "Alchemy::EssenceLink" => "Alchemy::Ingredients::Link",
16
+ "Alchemy::EssenceNode" => "Alchemy::Ingredients::Node",
17
+ "Alchemy::EssencePage" => "Alchemy::Ingredients::Page",
18
+ "Alchemy::EssencePicture" => "Alchemy::Ingredients::Picture",
19
+ "Alchemy::EssenceRichtext" => "Alchemy::Ingredients::Richtext",
20
+ "Alchemy::EssenceSelect" => "Alchemy::Ingredients::Select",
21
+ "Alchemy::EssenceText" => "Alchemy::Ingredients::Text",
22
+ "Alchemy::EssenceVideo" => "Alchemy::Ingredients::Video",
23
+ }
24
+
25
+ DEPRECATED_ESSENCE_CLASSES = DEPRECATED_ESSENCE_CLASS_MAPPING.keys
26
+
8
27
  # Define page preview sources
9
28
  #
10
29
  # A preview source is a Ruby class returning an URL
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alchemy_cms/admin",
3
- "version": "6.0.9",
3
+ "version": "6.0.10",
4
4
  "description": "AlchemyCMS",
5
5
  "browser": "package/admin.js",
6
6
  "files": [
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: 6.0.9
4
+ version: 6.0.10
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: 2022-07-25 00:00:00.000000000 Z
16
+ date: 2022-09-04 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: actionmailer
@@ -1525,7 +1525,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1525
1525
  version: '0'
1526
1526
  requirements:
1527
1527
  - ImageMagick (libmagick), v6.6 or greater.
1528
- rubygems_version: 3.1.6
1528
+ rubygems_version: 3.3.7
1529
1529
  signing_key:
1530
1530
  specification_version: 4
1531
1531
  summary: A powerful, userfriendly and flexible CMS for Rails