alchemy_cms 4.5.0 → 4.5.1

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: 6fd79c1d49d2d3ee4bb6f47b7ec4a9ec294bc890f9a217ee30cdac569eef0780
4
- data.tar.gz: baec6c36ea7c500185bade60f79fda54f3464055903375de4b43bc3a11c2457a
3
+ metadata.gz: 4f640cf9df17528d45476a6edb303f9d4d3fadc0e78f6bb8bbbe0a0b79f57059
4
+ data.tar.gz: '09d6e935c44b7fede23439298f68ee9055118bd6b0a645a2294ad05161271a8e'
5
5
  SHA512:
6
- metadata.gz: 705b4473ea1d26a3c168b9a7e3592d9b14ad77b1e1802d227127f4a26ee6e4665a26ae6bc7357ffe0681d5f79ea5b1ebee75289db63e252fce61170be6325678
7
- data.tar.gz: ef27de44013eeb6f04f98ba2af578b07912f8386d8c1240300561e9bbdc803be69ff0f57c2ca12a5090cf380f461834570be23cddcb11361c54984dd451ad76f
6
+ metadata.gz: 9975ccf31bd9e74791149c2426e6dbf350d6cb4df000018bcba509f9bed88c23808e8fc0a2f690bfcb791c550384fd3d18c9f1f73b3a08115b5251efae2a3559
7
+ data.tar.gz: a315453502650bbddf31e4c60cf1ff1abf7797b2ed9a8d12a502cfc02e91bb2fde457ede616769a06ce9f2cc805a6ad5bc252bc90003a5894daa1a9c0d95f252
@@ -19,9 +19,9 @@ jobs:
19
19
  - postgresql
20
20
  env:
21
21
  DB: ${{ matrix.database }}
22
- MYSQL_PASSWORD: root
23
- POSTGRES_USER: postgres
24
- POSTGRES_PASSWORD: password
22
+ DB_USER: alchemy_user
23
+ DB_PASSWORD: password
24
+ DB_HOST: '127.0.0.1'
25
25
  RAILS_ENV: test
26
26
  RAILS_VERSION: ${{ matrix.rails }}
27
27
  CC_TEST_REPORTER_ID: bca4349e32f97919210ac8a450b04904b90683fcdd57d65a22c0f5065482bc22
@@ -29,11 +29,20 @@ jobs:
29
29
  postgres:
30
30
  image: postgres:11
31
31
  env:
32
- POSTGRES_USER: postgres
32
+ POSTGRES_USER: alchemy_user
33
33
  POSTGRES_PASSWORD: password
34
34
  POSTGRES_DB: alchemy_cms_dummy_test
35
35
  ports: ['5432:5432']
36
36
  options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
37
+ mysql:
38
+ image: mysql:latest
39
+ ports: ['3306:3306']
40
+ env:
41
+ MYSQL_USER: alchemy_user
42
+ MYSQL_PASSWORD: password
43
+ MYSQL_DATABASE: alchemy_cms_dummy_test
44
+ MYSQL_ROOT_PASSWORD: password
45
+ options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
37
46
  steps:
38
47
  - uses: actions/checkout@v1
39
48
  - name: Set up Ruby
data/CHANGELOG.md CHANGED
@@ -1,4 +1,11 @@
1
- ## 5.0.0 (unreleased)
1
+ ## 4.5.1 (2021-11-17)
2
+
3
+ - Set stampable user_class_name without root identifier ([tvdeyen](https://github.com/tvdeyen))
4
+ - Use relative path for tinymce font-face ([tvdeyen](https://github.com/tvdeyen))
5
+ - Use symbols in polymorphic routes for resources ([tvdeyen](https://github.com/tvdeyen))
6
+ - make the fixed element upgrader more robust ([darkswoop](https://github.com/darkswoop))
7
+ - don't use existing element names when migrating from cells ([darkswoop](https://github.com/darkswoop))
8
+ - enhance regexp in partial name upgrader ([darkswoop](https://github.com/darkswoop))
2
9
 
3
10
  ## 4.5.0 (2020-03-30)
4
11
 
@@ -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'
@@ -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.5.0"
4
+ VERSION = "4.5.1"
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: 4.5.0
4
+ version: 4.5.1
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-03-30 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
@@ -1107,6 +1107,7 @@ files:
1107
1107
  - lib/alchemy/upgrader/tasks/cells_upgrader.rb
1108
1108
  - lib/alchemy/upgrader/tasks/element_partial_name_variable_updater.rb
1109
1109
  - lib/alchemy/upgrader/tasks/element_views_updater.rb
1110
+ - lib/alchemy/upgrader/tasks/fixed_element_name_finder.rb
1110
1111
  - lib/alchemy/upgrader/tasks/harden_acts_as_taggable_on_migrations.rb
1111
1112
  - lib/alchemy/upgrader/tasks/picture_gallery_migration.rb
1112
1113
  - lib/alchemy/upgrader/tasks/picture_gallery_upgrader.rb
@@ -1241,8 +1242,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1241
1242
  version: '0'
1242
1243
  requirements:
1243
1244
  - ImageMagick (libmagick), v6.6 or greater.
1244
- rubygems_version: 3.0.3
1245
- signing_key:
1245
+ rubygems_version: 3.1.6
1246
+ signing_key:
1246
1247
  specification_version: 4
1247
1248
  summary: A powerful, userfriendly and flexible CMS for Rails 5
1248
1249
  test_files: []
1250
+ ...