alchemy_cms 4.6.1 → 4.6.5

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: 69fbb4c2306ffe7e79ec7b884a125707476d01f94d0e28ad8cdfe5edab029d3b
4
- data.tar.gz: 42a64be665c2fbb42fb4403d8d6b7840d3771c22197f8c8c5a9b68abf65cf594
3
+ metadata.gz: 252654553b59bae763586b46125e8f1ebd621639fc03393c9351ca7984864a79
4
+ data.tar.gz: 75262fba1d9d9dd36543fb3f10c2fc36fa5d27b2415d27e6379790ba5e2a575b
5
5
  SHA512:
6
- metadata.gz: 99d83cc2ad6c592aac39a5f1c9c0bc68994fc6f3a15e6b8ce61d8736239dca47e4ae63e85d080ced9f7137e8bf52b5a6e09aeb495fac7c96f304c91e0fdc1de5
7
- data.tar.gz: cc4010a02dc1053ea024ab099bdb884e8a7ffd80a81de6bcc070587998aaf050a7e3a228bc36ff809c5414b84e2e512c6659f50df2269f03ed2b84e873194a90
6
+ metadata.gz: b7c12139368b27f65aac476391aa826033f25bd826c36bf9abef052474c28af364cd115b96e294632c5ee5a1e6922c2d31ffae117fb004d7a5b03e2d9da7c5f9
7
+ data.tar.gz: 990082f879013f1ce4215992e286a5c28ecefcde47c26a001197d0a927ef38bef8ee83373af4333942718c17d6ccb33794fac6aa63fa60369360ec4557fc0e67
data/CHANGELOG.md CHANGED
@@ -1,4 +1,23 @@
1
- ## 5.0.0 (unreleased)
1
+ ## 4.6.5 (2021-11-17)
2
+
3
+ - Set stampable user_class_name without root identifier ([tvdeyen](https://github.com/tvdeyen))
4
+
5
+ ## 4.6.4 (2021-11-15)
6
+
7
+ - Use relative path for tinymce font-face ([tvdeyen](https://github.com/tvdeyen))
8
+ - make the fixed element upgrader more robust ([darkswoop](https://github.com/darkswoop))
9
+ - don't use existing element names when migrating from cells ([darkswoop](https://github.com/darkswoop))
10
+ - enhance regexp in partial name upgrader ([darkswoop](https://github.com/darkswoop))
11
+
12
+ ## 4.6.3 (2020-05-06)
13
+
14
+ - Use symbols in polymorphic routes for resources [#2087](https://github.com/AlchemyCMS/alchemy_cms/pull/2087) ([tvdeyen](https://github.com/tvdeyen))
15
+ - Fix convert:page_trees:to_menus task [#2033](https://github.com/AlchemyCMS/alchemy_cms/pull/2033) ([afdev82](https://github.com/afdev82))
16
+ - fix 4.6 upgrader tasks [#1995](https://github.com/AlchemyCMS/alchemy_cms/pull/1995) ([afdev82](https://github.com/afdev82))
17
+
18
+ ## 4.6.2 (2020-09-07)
19
+
20
+ - Fix tri-Boolean check in PageNaming Module [#1931](https://github.com/AlchemyCMS/alchemy_cms/pull/1931) ([mamhoff](https://github.com/mamhoff))
2
21
 
3
22
  ## 4.6.1 (2020-06-04)
4
23
 
@@ -1566,18 +1566,18 @@ i.mce-i-resize {
1566
1566
 
1567
1567
  @font-face {
1568
1568
  font-family: 'tinymce';
1569
- src: url('fonts/tinymce.woff') format('woff'),
1570
- url('fonts/tinymce.ttf') format('truetype'),
1571
- url('fonts/tinymce.svg#tinymce') format('svg');
1569
+ src: url('./fonts/tinymce.woff') format('woff'),
1570
+ url('./fonts/tinymce.ttf') format('truetype'),
1571
+ url('./fonts/tinymce.svg#tinymce') format('svg');
1572
1572
  font-weight: normal;
1573
1573
  font-style: normal;
1574
1574
  }
1575
1575
 
1576
1576
  @font-face {
1577
1577
  font-family: 'tinymce-small';
1578
- src: url('fonts/tinymce-small.woff') format('woff'),
1579
- url('fonts/tinymce-small.ttf') format('truetype'),
1580
- url('fonts/tinymce-small.svg#tinymce') format('svg');
1578
+ src: url('./fonts/tinymce-small.woff') format('woff'),
1579
+ url('./fonts/tinymce-small.ttf') format('truetype'),
1580
+ url('./fonts/tinymce-small.svg#tinymce') format('svg');
1581
1581
  font-weight: normal;
1582
1582
  font-style: normal;
1583
1583
  }
@@ -28,7 +28,7 @@ module Alchemy
28
28
  after_assign { |f| write_attribute(:file_mime_type, f.mime_type) }
29
29
  end
30
30
 
31
- stampable stamper_class_name: Alchemy.user_class_name
31
+ stampable stamper_class_name: Alchemy.user_class.name
32
32
 
33
33
  has_many :essence_files, class_name: 'Alchemy::EssenceFile', foreign_key: 'attachment_id'
34
34
  has_many :contents, through: :essence_files
@@ -28,7 +28,7 @@ module Alchemy
28
28
  belongs_to :element, touch: true, inverse_of: :contents
29
29
  has_one :page, through: :element
30
30
 
31
- stampable stamper_class_name: Alchemy.user_class_name
31
+ stampable stamper_class_name: Alchemy.user_class.name
32
32
 
33
33
  acts_as_list scope: [:element_id]
34
34
 
@@ -58,7 +58,7 @@ module Alchemy
58
58
  #
59
59
  acts_as_list scope: [:page_id, :fixed, :parent_element_id]
60
60
 
61
- stampable stamper_class_name: Alchemy.user_class_name
61
+ stampable stamper_class_name: Alchemy.user_class.name
62
62
 
63
63
  has_many :contents, -> { order(:position) }, dependent: :destroy, inverse_of: :element
64
64
 
@@ -5,7 +5,7 @@ module Alchemy
5
5
  VALID_URL_REGEX = /\A(\/|\D[a-z\+\d\.\-]+:)/
6
6
 
7
7
  acts_as_nested_set scope: "language_id", touch: true
8
- stampable stamper_class_name: Alchemy.user_class_name
8
+ stampable stamper_class_name: Alchemy.user_class.name
9
9
 
10
10
  belongs_to :site, class_name: "Alchemy::Site"
11
11
  belongs_to :language, class_name: "Alchemy::Language"
@@ -68,7 +68,7 @@ module Alchemy
68
68
  base.push(parent) if parent.visible?
69
69
  end
70
70
  else
71
- ancestors.visible.contentpages.where(language_root: nil).to_a
71
+ ancestors.visible.contentpages.where(language_root: [nil, false]).to_a
72
72
  end
73
73
  end
74
74
 
@@ -85,7 +85,7 @@ module Alchemy
85
85
 
86
86
  acts_as_nested_set(dependent: :destroy)
87
87
 
88
- stampable stamper_class_name: Alchemy.user_class_name
88
+ stampable stamper_class_name: Alchemy.user_class.name
89
89
 
90
90
  belongs_to :language, optional: true
91
91
 
@@ -74,7 +74,7 @@ module Alchemy
74
74
  case_sensitive: false,
75
75
  message: Alchemy.t("not a valid image")
76
76
 
77
- stampable stamper_class_name: Alchemy.user_class_name
77
+ stampable stamper_class_name: Alchemy.user_class.name
78
78
 
79
79
  scope :named, ->(name) {
80
80
  where("#{table_name}.name LIKE ?", "%#{name}%")
@@ -48,7 +48,7 @@ module Alchemy #:nodoc:
48
48
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
49
49
  attr_writer :validation_errors
50
50
  include Alchemy::Essence::InstanceMethods
51
- stampable stamper_class_name: Alchemy.user_class_name
51
+ stampable stamper_class_name: Alchemy.user_class.name
52
52
  validate :validate_ingredient, on: :update, if: -> { validations.any? }
53
53
 
54
54
  has_one :content, as: :essence, class_name: "Alchemy::Content", inverse_of: :essence
@@ -131,21 +131,23 @@ module Alchemy
131
131
  end
132
132
 
133
133
  def namespaced_resource_name
134
- @_namespaced_resource_name ||= namespaced_resources_name.singularize
134
+ @_namespaced_resource_name ||= begin
135
+ namespaced_resources_name.to_s.singularize
136
+ end.to_sym # Rails >= 6.0.3.7 needs symbols in polymorphic routes
135
137
  end
136
138
 
137
139
  def namespaced_resources_name
138
140
  @_namespaced_resources_name ||= begin
139
141
  resource_name_array = resource_array.dup
140
142
  resource_name_array.delete(engine_name) if in_engine?
141
- resource_name_array.join('_')
142
- end
143
+ resource_name_array.join("_")
144
+ end.to_sym # Rails >= 6.0.3.7 needs symbols in polymorphic routes
143
145
  end
144
146
 
145
147
  def namespace_for_scope
146
148
  namespace_array = namespace_diff
147
149
  namespace_array.delete(engine_name) if in_engine?
148
- namespace_array
150
+ namespace_array.map(&:to_sym) # Rails >= 6.0.3.7 needs symbols in polymorphic routes
149
151
  end
150
152
 
151
153
  # Returns an array of underscored association names
@@ -1,5 +1,6 @@
1
1
  require_relative 'tasks/picture_gallery_upgrader'
2
2
  require_relative 'tasks/picture_gallery_migration'
3
+ require_relative 'tasks/fixed_element_name_finder'
3
4
  require_relative 'tasks/cells_upgrader'
4
5
  require_relative 'tasks/cells_migration'
5
6
  require_relative 'tasks/element_partial_name_variable_updater'
@@ -8,6 +8,7 @@ module Alchemy::Upgrader::Tasks
8
8
  def migrate_cells
9
9
  if ActiveRecord::Base.connection.data_source_exists?('alchemy_cells')
10
10
  cells = Cell.all
11
+ @fixed_element_name_finder = FixedElementNameFinder.new
11
12
 
12
13
  if cells.any?
13
14
  cells.each do |cell|
@@ -26,7 +27,7 @@ module Alchemy::Upgrader::Tasks
26
27
  def migrate_cell!(cell)
27
28
  # bust element definitions insta cache
28
29
  Alchemy::Element.instance_variable_set('@definitions', nil)
29
- fixed_element = Alchemy::Element.find_or_initialize_by(fixed: true, name: cell.name, page: cell.page)
30
+ fixed_element = Alchemy::Element.find_or_initialize_by(fixed: true, name: @fixed_element_name_finder.call(cell.name), page: cell.page)
30
31
  elements = Alchemy::Element.where(cell_id: cell.id).order(position: :asc)
31
32
 
32
33
  if fixed_element.new_record?
@@ -72,12 +72,13 @@ module Alchemy::Upgrader::Tasks
72
72
 
73
73
  def convert_cell_config
74
74
  puts '-- Converting cells into unique fixed nestable elements.'
75
+ fixed_element_name_finder = FixedElementNameFinder.new
75
76
 
76
77
  YAML.load_file(cells_config_file).each do |cell|
77
78
  append_to_file Rails.root.join('config', 'alchemy', 'elements.yml') do
78
79
  <<-CELL.strip_heredoc
79
80
 
80
- - name: #{cell['name']}
81
+ - name: #{fixed_element_name_finder.call(cell['name'])}
81
82
  fixed: true
82
83
  unique: true
83
84
  nestable_elements: [#{cell['elements'].join(', ')}]
@@ -128,8 +129,25 @@ module Alchemy::Upgrader::Tasks
128
129
  puts "-- Update render_cell calls"
129
130
  Dir.glob("#{alchemy_views_folder}/**/*").each do |view|
130
131
  next if File.directory?(view)
131
- gsub_file(view, /render_cell[\(\s]?([:'"]?[a-z_]+['"]?)\)?/, 'render_elements(only: \1, fixed: true)')
132
- gsub_file(view, /render_elements[\(\s](.*):?from_cell:?\s?(=>)?\s?(['"][a-z_]+['"])\)?/, 'render_elements(\1only: \3, fixed: true)')
132
+ # <%= render_cell 'test' %>
133
+ # <%= render_cell('test') %>
134
+ # <%= render_cell("test", options: true) %>
135
+ content = File.binread(view)
136
+ content.gsub!(/render_cell([\s(]+)(['":])(\w+)([^\w])(.*?)/) do
137
+ element_name = CellNameMigrator.call($3)
138
+ "render_elements#{$1}only: #{$2}#{element_name}#{$4}, fixed: true#{$5}"
139
+ end
140
+
141
+ # <%= render_elements from_cell: 'page_intro' %>
142
+ # <%= render_elements testing: 'blubb', from_cell: :page_intro %>
143
+ # <%= render_elements from_cell: "page_intro", testing: 'blubb' %>
144
+ # <%= render_elements(from_cell: "page_intro", testing: 'blubb') %>
145
+ # <%= render_elements(testing: 'blubb', from_cell: "page_intro") %>
146
+ content.gsub!(/render_elements(.*?)from_cell[:\s=>]+([:'"])(\w+)(['"]?)(.*)/) do
147
+ element_name = CellNameMigrator.call($3)
148
+ "render_elements#{$1}only: #{$2}#{element_name}#{$4}, fixed: true#{$5}"
149
+ end
150
+ File.open(view, "wb") { |file| file.write(content) }
133
151
  end
134
152
  end
135
153
 
@@ -11,10 +11,14 @@ module Alchemy::Upgrader::Tasks
11
11
  puts "-- Update element views local variable to partial name"
12
12
  Dir.glob("#{elements_view_folder}/*_view.*").each do |view|
13
13
  variable_name = File.basename(view).gsub(/^_([\w-]*)\..*$/, '\1')
14
- gsub_file(view, /cache\(?element([,\s\w:\-,=>'"\?\/]*)\)?/, "cache(#{variable_name}\\1)")
15
- gsub_file(view, /render_essence_view_by_name\(?element([,\s\w:\-,=>'"\?\/]*)\)?/, "render_essence_view_by_name(#{variable_name}\\1)")
16
- gsub_file(view, /element_view_for\(?element([,\s\w:\-,=>'"\?\/]*)\)?/, "element_view_for(#{variable_name}\\1)")
17
- gsub_file(view, /element\.([\w\?]+)/, "#{variable_name}.\\1")
14
+ %w[
15
+ cache
16
+ render_essence_view_by_name
17
+ element_view_for
18
+ ].each do |method_name|
19
+ gsub_file(view, /#{method_name}([\s(]+)element([^\w])/, "#{method_name}\\1#{variable_name}\\2")
20
+ end
21
+ gsub_file(view, /([\s(%={]+)element([^\w:"'])/, "\\1#{variable_name}\\2")
18
22
  end
19
23
  end
20
24
  end
@@ -0,0 +1,31 @@
1
+ module Alchemy::Upgrader::Tasks
2
+ class FixedElementNameFinder
3
+
4
+ def call(cell_name)
5
+ return cell_name if fixed_elements.include?(cell_name)
6
+ return "#{cell_name}_elements" if unfixed_elements.include?(cell_name)
7
+ cell_name
8
+ end
9
+
10
+ private
11
+
12
+ def fixed_elements
13
+ @_fixed_element_names ||= begin
14
+ definitions.select { |element| element['fixed'] }.map { |element| element['name'] }
15
+ end
16
+ end
17
+
18
+ def unfixed_elements
19
+ @_unfixed_elements ||= begin
20
+ definitions.reject { |element| element['fixed'] }.map { |element| element['name'] }
21
+ end
22
+ end
23
+
24
+ def definitions
25
+ @_definitions ||= begin
26
+ elements_file_path = Rails.root.join('config', 'alchemy', 'elements.yml')
27
+ YAML.load_file(elements_file_path)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -7,6 +7,6 @@
7
7
  if Alchemy.user_class < ActiveRecord::Base
8
8
  Alchemy.user_class.class_eval do
9
9
  model_stamper
10
- stampable stamper_class_name: Alchemy.user_class_name
10
+ stampable stamper_class_name: Alchemy.user_class.name
11
11
  end
12
12
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemy
4
- VERSION = "4.6.1"
4
+ VERSION = "4.6.5"
5
5
 
6
6
  def self.version
7
7
  VERSION
@@ -60,15 +60,17 @@ namespace :alchemy do
60
60
  def convert_to_nodes(children, node:)
61
61
  children.each do |page|
62
62
  has_children = page.children.any?
63
- next unless page.visible || has_children
64
63
 
65
64
  Alchemy::Deprecation.silence do
65
+ next unless page.visible || has_children
66
+
66
67
  new_node = node.children.create!(
67
68
  name: name_for_node(page),
68
69
  page: page_for_node(page),
69
- url: page.definition['redirects_to_external'] ? page.urlname : nil,
70
- external: page.definition['redirects_to_external'] && Alchemy::Config.get(:open_external_links_in_new_tab),
71
- language_id: page.language_id
70
+ url: !!page.definition['redirects_to_external'] ? page.urlname : nil,
71
+ external: !!page.definition['redirects_to_external'] && Alchemy::Config.get(:open_external_links_in_new_tab),
72
+ language_id: page.language_id,
73
+ site_id: page.language.site_id
72
74
  )
73
75
  print "."
74
76
  if has_children
@@ -82,9 +84,8 @@ namespace :alchemy do
82
84
  puts "\n- Converting #{menu_count} page #{'tree'.pluralize(menu_count)} into #{'menu'.pluralize(menu_count)}."
83
85
  Alchemy::BaseRecord.transaction do
84
86
  Alchemy::Language.all.each do |language|
85
- locale = language.locale.presence || I18n.default_locale
86
- menu_name = I18n.t('Main Navigation', scope: 'alchemy.menu_names', default: 'Main Navigation', locale: locale)
87
- root_node = Alchemy::Node.create(language: language, name: menu_name)
87
+ menu_name = 'main_menu'
88
+ root_node = Alchemy::Node.create(language: language, name: menu_name, site: language.site, external: false)
88
89
  language.pages.language_roots.each do |root_page|
89
90
  convert_to_nodes(root_page.children, node: root_node)
90
91
  end
@@ -143,7 +143,11 @@ namespace :alchemy do
143
143
  desc "Upgrade Alchemy to v4.6"
144
144
  task "4.6" => [
145
145
  "alchemy:upgrade:prepare",
146
- ]
146
+ "alchemy:upgrade:4.6:run",
147
+ "alchemy:upgrade:4.6:todo",
148
+ ] do
149
+ Alchemy::Upgrader.display_todos
150
+ end
147
151
 
148
152
  namespace "4.6" do
149
153
  task run: []
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: 4.6.1
4
+ version: 4.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
@@ -10,10 +10,10 @@ authors:
10
10
  - Hendrik Mans
11
11
  - Carsten Fregin
12
12
  - Martin Meyerhoff
13
- autorequire:
13
+ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2020-06-04 00:00:00.000000000 Z
16
+ date: 2021-11-17 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: active_model_serializers
@@ -1110,6 +1110,7 @@ files:
1110
1110
  - lib/alchemy/upgrader/tasks/cells_upgrader.rb
1111
1111
  - lib/alchemy/upgrader/tasks/element_partial_name_variable_updater.rb
1112
1112
  - lib/alchemy/upgrader/tasks/element_views_updater.rb
1113
+ - lib/alchemy/upgrader/tasks/fixed_element_name_finder.rb
1113
1114
  - lib/alchemy/upgrader/tasks/harden_acts_as_taggable_on_migrations.rb
1114
1115
  - lib/alchemy/upgrader/tasks/picture_gallery_migration.rb
1115
1116
  - lib/alchemy/upgrader/tasks/picture_gallery_upgrader.rb
@@ -1244,8 +1245,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1244
1245
  version: '0'
1245
1246
  requirements:
1246
1247
  - ImageMagick (libmagick), v6.6 or greater.
1247
- rubygems_version: 3.0.3
1248
- signing_key:
1248
+ rubygems_version: 3.1.6
1249
+ signing_key:
1249
1250
  specification_version: 4
1250
1251
  summary: A powerful, userfriendly and flexible CMS for Rails 5
1251
1252
  test_files: []