alchemy_cms 3.6.1 → 3.6.6

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
  SHA1:
3
- metadata.gz: a8743fb03c7e20c7e5843e13f70a7a15b0b6d3c0
4
- data.tar.gz: 5edc6d41f2f0931328f8d1f62d9391f1f0096a33
3
+ metadata.gz: 2d08ddeba7c6d9ee72222fdbd1076a7e15bf0cd7
4
+ data.tar.gz: f1b8bf8976c1072862a962bbff039a9700aeea3e
5
5
  SHA512:
6
- metadata.gz: c9edf891ac572e4114b897991df000622ba4703119bc01b9752859ffb8c4ef31130c9c84930605b5bbc8eacc4fdc60d0fd2d155233a3036e081a9a013744db10
7
- data.tar.gz: a850e8c5eee3b9f8def3d21201477eaef9217b54937fa3717e8750310c86fe99aade5ed7f72ce9998a08af7c2b1b4b4666d620387bb579a27744859b58a19aa7
6
+ metadata.gz: 20578df18e78b1f0d54bcaff824f6679b3f929d347d1c2316f85d5cbb956789c15804325cf3fdd7e3993bb9cb2ad8915ec95df157360ce6f4a675778afde1c51
7
+ data.tar.gz: 656afe41082692275283b7fb664490637f4a536c024bda2c0272525b032a0434c72808e954f6769e1e34cefe7cac9a3c6bcf603f53266aa6a73f55ed33a913e6
@@ -1,13 +1,15 @@
1
1
  language: ruby
2
2
  sudo: false
3
+ services:
4
+ - mysql
5
+ - postgresql
3
6
  cache:
4
7
  bundler: true
5
8
  directories:
6
9
  - "travis_phantomjs"
7
10
  rvm:
8
- - 2.1
9
- - 2.2
10
- - 2.3.0
11
+ - 2.3
12
+ - 2.4
11
13
  branches:
12
14
  only:
13
15
  - 3.6-stable
@@ -20,7 +22,7 @@ before_install:
20
22
  - "if [ $(phantomjs --version) != '2.1.1' ]; then wget https://assets.membergetmember.co/software/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O $PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2; fi"
21
23
  - "if [ $(phantomjs --version) != '2.1.1' ]; then tar -xvf $PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis_phantomjs; fi"
22
24
  - "phantomjs --version"
23
- - gem install bundler
25
+ - gem install bundler -v "< 2"
24
26
  before_script: bundle exec rake alchemy:spec:prepare
25
27
  script: bundle exec rspec
26
28
  after_success: bundle exec codeclimate-test-reporter
@@ -1,5 +1,27 @@
1
1
  # Change Log
2
2
 
3
+ ## 3.6.6 (2020-10-08)
4
+
5
+ - Allow AwesomeNestedSet >= 3.0 [#1619](https://github.com/AlchemyCMS/alchemy_cms/pull/1619) by [tvdeyen](https://github.com/tvdeyen)
6
+
7
+ ## 3.6.5 (2018-05-08)
8
+
9
+ - Fix for drag'n'drop trashed elements into pages with cells [#1430](https://github.com/AlchemyCMS/alchemy_cms/pull/1430) by [tvdeyen](https://github.com/tvdeyen)
10
+
11
+ ## 3.6.4 (2018-04-23)
12
+
13
+ - Allows `Symbol`, `Regexp` and `Date` in all YAML config files [#1333](https://github.com/AlchemyCMS/alchemy_cms/pull/1333) by [robinboening](https://github.com/robinboening)
14
+
15
+ ## 3.6.3 (2017-10-24)
16
+
17
+ * Remove `:display` cancan alias [#1318](https://github.com/AlchemyCMS/alchemy_cms/pull/1318) by [tvdeyen](https://github.com/tvdeyen)
18
+
19
+ ## 3.6.2 (2017-09-01)
20
+
21
+ * Handle custom errors in `Alchemy::Picture#url` [#1305](https://github.com/AlchemyCMS/alchemy_cms/pull/1305) by [tvdeyen](https://github.com/tvdeyen)
22
+ * Do not move elements in tidy cells task [#1303](https://github.com/AlchemyCMS/alchemy_cms/pull/1303) by [tvdeyen](https://github.com/tvdeyen)
23
+ * Add a store image file format rake task [#1302](https://github.com/AlchemyCMS/alchemy_cms/pull/1302) by [tvdeyen](https://github.com/tvdeyen)
24
+
3
25
  ## 3.6.1 (2017-08-16)
4
26
 
5
27
  * Do not ask `systempage?` everytime we load the page definition [#1239](https://github.com/AlchemyCMS/alchemy_cms/pull/1283) by [tvdeyen](https://github.com/tvdeyen)
data/Gemfile CHANGED
@@ -5,15 +5,16 @@ gemspec
5
5
  # Profiling
6
6
  gem 'rack-mini-profiler', group: :development, require: false
7
7
 
8
- gem 'sqlite3' if ENV['DB'].nil? || ENV['DB'] == 'sqlite'
8
+ gem 'sqlite3', '~> 1.3.6' if ENV['DB'].nil? || ENV['DB'] == 'sqlite'
9
9
  gem 'mysql2', '~> 0.3.18' if ENV['DB'] == 'mysql'
10
- gem 'pg' if ENV['DB'] == 'postgresql'
10
+ gem 'pg', '~> 0.21' if ENV['DB'] == 'postgresql'
11
11
  gem 'sassc-rails'
12
12
 
13
13
  group :development, :test do
14
14
  gem 'jasmine-rails', github: 'searls/jasmine-rails'
15
15
  gem 'jasmine-jquery-rails', github: 'travisjeffery/jasmine-jquery-rails'
16
16
  gem 'simplecov', require: false
17
+ gem 'sassc', '~> 2.1.0'
17
18
  if ENV['TRAVIS']
18
19
  gem 'codeclimate-test-reporter', '~> 1.0', require: false
19
20
  end
@@ -41,9 +42,3 @@ end
41
42
  group :development, :production do
42
43
  gem 'quiet_assets'
43
44
  end
44
-
45
- # We need this if we want to start the dummy app in production, ie on Teatro.io
46
- group :production do
47
- gem 'uglifier', '>= 1.0.3'
48
- gem 'therubyracer'
49
- end
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
21
21
  gem.add_runtime_dependency 'active_model_serializers', ['~> 0.9.0']
22
22
  gem.add_runtime_dependency 'acts_as_list', ['~> 0.3']
23
23
  gem.add_runtime_dependency 'acts-as-taggable-on', ['~> 4.0']
24
- gem.add_runtime_dependency 'awesome_nested_set', ['~> 3.1']
24
+ gem.add_runtime_dependency 'awesome_nested_set', ['~> 3.0']
25
25
  gem.add_runtime_dependency 'bourbon', ['~> 4.2']
26
26
  gem.add_runtime_dependency 'cancancan', ['~> 1.9']
27
27
  gem.add_runtime_dependency 'coffee-rails', ['~> 4.0']
@@ -145,7 +145,10 @@ module Alchemy
145
145
 
146
146
  def paste_element_from_clipboard
147
147
  @source_element = Element.find(element_from_clipboard['id'])
148
- new_attributes = {page_id: @page.id}
148
+ new_attributes = {
149
+ parent_element_id: params[:element][:parent_element_id],
150
+ page_id: @page.id
151
+ }
149
152
  if @page.can_have_cells?
150
153
  new_attributes = new_attributes.merge({cell_id: find_or_create_cell.try(:id)})
151
154
  end
@@ -56,7 +56,7 @@ module Alchemy
56
56
  private
57
57
 
58
58
  def read_yml_file
59
- ::YAML.safe_load(ERB.new(File.read(yml_file_path)).result, [], [], true) || []
59
+ ::YAML.safe_load(ERB.new(File.read(yml_file_path)).result, YAML_WHITELIST_CLASSES, [], true) || []
60
60
  end
61
61
 
62
62
  def yml_file_path
@@ -26,7 +26,7 @@ module Alchemy
26
26
  #
27
27
  def read_definitions_file
28
28
  if ::File.exist?(definitions_file_path)
29
- ::YAML.safe_load(ERB.new(File.read(definitions_file_path)).result, [Regexp, Date], [], true) || []
29
+ ::YAML.safe_load(ERB.new(File.read(definitions_file_path)).result, YAML_WHITELIST_CLASSES, [], true) || []
30
30
  else
31
31
  raise LoadError, "Could not find elements.yml file! Please run `rails generate alchemy:scaffold`"
32
32
  end
@@ -1,5 +1,7 @@
1
1
  module Alchemy
2
2
  module Picture::Url
3
+ include Alchemy::Logger
4
+
3
5
  TRANSFORMATION_OPTIONS = [
4
6
  :crop,
5
7
  :crop_from,
@@ -28,6 +30,9 @@ module Alchemy
28
30
  image = encoded_image(image, options)
29
31
 
30
32
  image.url(options.except(*TRANSFORMATION_OPTIONS).merge(name: name))
33
+ rescue MissingImageFileError, WrongImageFormatError => e
34
+ log_warning e.message
35
+ nil
31
36
  end
32
37
 
33
38
  private
@@ -53,7 +58,10 @@ module Alchemy
53
58
  #
54
59
  def encoded_image(image, options = {})
55
60
  target_format = options[:format] || default_render_format
56
- raise WrongImageFormatError if !target_format.in?(Alchemy::Picture.allowed_filetypes)
61
+
62
+ unless target_format.in?(Alchemy::Picture.allowed_filetypes)
63
+ raise WrongImageFormatError.new(self, target_format)
64
+ end
57
65
 
58
66
  options = {
59
67
  flatten: target_format != 'gif' && image_file_format == 'gif'
@@ -24,7 +24,7 @@ module Alchemy
24
24
  scope :published, -> { where(public: true) }
25
25
 
26
26
  # Callbacks
27
- before_create :create_default_language!, unless: -> { languages.any? }
27
+ before_create :create_default_language!
28
28
 
29
29
  # concerns
30
30
  include Alchemy::Site::Layout
@@ -10,7 +10,9 @@
10
10
  </li>
11
11
  <% end %>
12
12
  </ul>
13
- <div id="cell_for_other_elements" class="sortable_cell for_other_elements_cell">
13
+ <div id="cell_for_other_elements"
14
+ class="sortable_cell for_other_elements_cell"
15
+ data-droppable-elements="<%= @page.element_names_from_definition.join(' ') %>">
14
16
  <%= render partial: 'alchemy/admin/elements/element',
15
17
  collection: @page.elements.not_trashed.not_in_cell %>
16
18
  </div>
@@ -18,7 +20,7 @@
18
20
  <%= content_tag :div,
19
21
  id: "cell_#{cell.name}",
20
22
  class: ["sortable_cell", "#{cell.name}_cell"].join(' '),
21
- data: {'cell-id' => cell.id, 'data-droppable-elements' => cell.element_definitions.join(' ')} do %>
23
+ data: {'cell-id' => cell.id, 'droppable-elements' => cell.element_definitions.join(' ')} do %>
22
24
  <%= render partial: 'alchemy/admin/elements/element', collection: elements %>
23
25
  <% end %>
24
26
  <% end %>
@@ -11,7 +11,8 @@
11
11
  </div>
12
12
  <div id="paste_element_tab">
13
13
  <%= alchemy_form_for([:admin, @element]) do |f| %>
14
- <%= f.hidden_field(:page_id) %>
14
+ <%= f.hidden_field :page_id %>
15
+ <%= f.hidden_field :parent_element_id, value: @parent_element.try(:id) %>
15
16
  <div class="input select">
16
17
  <label for="paste_from_clipboard" class="control-label"><%= Alchemy.t("Element") %></label>
17
18
  <%= select_tag 'paste_from_clipboard',
@@ -1,18 +1,6 @@
1
1
  class AddImageFileFormatToAlchemyPictures < ActiveRecord::Migration
2
2
  def up
3
3
  add_column :alchemy_pictures, :image_file_format, :string
4
-
5
- say_with_time "Storing file format of existing pictures" do
6
- Alchemy::Picture.all.each do |pic|
7
- begin
8
- format = pic.image_file.identify('-ping -format "%m"')
9
- pic.update_column('image_file_format', format.to_s.chomp.downcase)
10
- rescue Dragonfly::Job::Fetch::NotFound => e
11
- say(e.message, true)
12
- end
13
- end
14
- Alchemy::Picture.count
15
- end
16
4
  end
17
5
 
18
6
  def down
@@ -46,7 +46,8 @@ module Alchemy
46
46
  # If it does not exist, or its empty, it returns an empty Hash.
47
47
  #
48
48
  def read_file(file)
49
- return YAML.load_file(file) || {} if File.exist?(file) # YAML.load_file returns false if file is empty.
49
+ YAML.safe_load(ERB.new(File.read(file)).result, YAML_WHITELIST_CLASSES, [], true) || {}
50
+ rescue Errno::ENOENT
50
51
  {}
51
52
  end
52
53
 
@@ -55,9 +55,14 @@ module Alchemy
55
55
 
56
56
  # Raised if calling +image_file+ on a Picture object returns nil.
57
57
  class WrongImageFormatError < StandardError
58
+ def initialize(image, requested_format)
59
+ @image = image
60
+ @requested_format = requested_format
61
+ end
62
+
58
63
  def message
59
64
  allowed_filetypes = Alchemy::Picture.allowed_filetypes.map(&:upcase).to_sentence
60
- "Requested image format is not one of allowed filetypes (#{allowed_filetypes})."
65
+ "Requested image format (#{@requested_format.inspect}) for #{@image.inspect} is not one of allowed filetypes (#{allowed_filetypes})."
61
66
  end
62
67
  end
63
68
 
@@ -7,7 +7,7 @@ module Alchemy
7
7
  end
8
8
 
9
9
  def log_warning(message)
10
- Alchemy::Logger.warn(message, caller(0..0))
10
+ Alchemy::Logger.warn(message, caller(1..1))
11
11
  end
12
12
  end
13
13
  end
@@ -157,7 +157,7 @@ module Alchemy
157
157
  #
158
158
  def read_definitions_file
159
159
  if File.exist?(layouts_file_path)
160
- YAML.safe_load(ERB.new(File.read(layouts_file_path)).result, [Date], [], true) || []
160
+ YAML.safe_load(ERB.new(File.read(layouts_file_path)).result, YAML_WHITELIST_CLASSES, [], true) || []
161
161
  else
162
162
  raise LoadError, "Could not find page_layouts.yml file! Please run `rails generate alchemy:scaffold`"
163
163
  end
@@ -35,7 +35,6 @@ module Alchemy
35
35
  def alchemy_guest_user_rules
36
36
  can([:show, :download], Alchemy::Attachment) { |a| !a.restricted? }
37
37
  can :see, Alchemy::Page, restricted: false, visible: true
38
- can(:display, Alchemy::Picture) { |p| !p.restricted? }
39
38
 
40
39
  can :read, Alchemy::Content, Alchemy::Content.available.not_restricted do |c|
41
40
  c.public? && !c.restricted? && !c.trashed?
@@ -65,7 +64,6 @@ module Alchemy
65
64
  can [:show, :download], Alchemy::Attachment
66
65
  can :read, Alchemy::Page, Alchemy::Page.published, &:public?
67
66
  can :see, Alchemy::Page, restricted: true, visible: true
68
- can :display, Alchemy::Picture
69
67
 
70
68
  can :read, Alchemy::Content, Alchemy::Content.available do |c|
71
69
  c.public? && !c.trashed?
@@ -215,11 +213,6 @@ module Alchemy
215
213
  :unlock,
216
214
  :visit,
217
215
  to: :edit_content
218
-
219
- alias_action :show,
220
- :thumbnail,
221
- :zoom,
222
- to: :display
223
216
  end
224
217
 
225
218
  # Include the role specific permissions.
@@ -0,0 +1,130 @@
1
+ require 'alchemy/shell'
2
+
3
+ module Alchemy
4
+ class Tidy
5
+ extend Shell
6
+
7
+ class << self
8
+ def create_missing_cells(page_layouts, cells)
9
+ page_layouts.each do |layout|
10
+ next if layout['cells'].blank?
11
+ cells_for_layout = cells.select { |cell| layout['cells'].include? cell['name'] }
12
+ Alchemy::Page.where(page_layout: layout['name']).each do |page|
13
+ cells_for_layout.each do |cell_for_layout|
14
+ cell = Alchemy::Cell.find_or_initialize_by(name: cell_for_layout['name'], page_id: page.id)
15
+ if cell.new_record?
16
+ log "Creating cell #{cell.name} for page #{page.name}"
17
+ else
18
+ log "Cell #{cell.name} for page #{page.name} already present", :skip
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ def update_element_positions
26
+ Alchemy::Page.all.each do |page|
27
+ if page.elements.any?
28
+ puts "\n## Updating element positions of page `#{page.name}`"
29
+ end
30
+ page.elements.group_by(&:cell_id).each do |_cell_id, elements|
31
+ elements.each_with_index do |element, idx|
32
+ position = idx + 1
33
+ if element.position != position
34
+ log "Updating position for element ##{element.id} to #{position}"
35
+ element.update_column(:position, position)
36
+ else
37
+ log "Position for element ##{element.id} is already correct (#{position})", :skip
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ def update_content_positions
45
+ Alchemy::Element.all.each do |element|
46
+ if element.contents.any?
47
+ puts "\n## Updating content positions of element `#{element.name}`"
48
+ end
49
+ element.contents.group_by(&:essence_type).each do |essence_type, contents|
50
+ puts "-> Contents of type `#{essence_type}`"
51
+ contents.each_with_index do |content, idx|
52
+ position = idx + 1
53
+ if content.position != position
54
+ log "Updating position for content ##{content.id} to #{position}"
55
+ content.update_column(:position, position)
56
+ else
57
+ log "Position for content ##{content.id} is already correct (#{position})", :skip
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ def remove_orphaned_cells
65
+ puts "\n## Removing orphaned cells"
66
+ cells = Alchemy::Cell.unscoped.all
67
+ if cells.any?
68
+ orphaned_cells = cells.select do |cell|
69
+ cell.page.nil? && cell.page_id.present?
70
+ end
71
+ if orphaned_cells.any?
72
+ log "Found #{orphaned_cells.size} orphaned cells"
73
+ destroy_orphaned_records(orphaned_cells, 'cell')
74
+ else
75
+ log "No orphaned cells found", :skip
76
+ end
77
+ else
78
+ log "No cells found", :skip
79
+ end
80
+ end
81
+
82
+ def remove_orphaned_elements
83
+ puts "\n## Removing orphaned elements"
84
+ elements = Alchemy::Element.unscoped.all
85
+ if elements.any?
86
+ orphaned_elements = elements.select do |element|
87
+ element.page.nil? && element.page_id.present? ||
88
+ element.cell.nil? && element.cell_id.present?
89
+ end
90
+ if orphaned_elements.any?
91
+ log "Found #{orphaned_elements.size} orphaned elements"
92
+ destroy_orphaned_records(orphaned_elements, 'element')
93
+ else
94
+ log "No orphaned elements found", :skip
95
+ end
96
+ else
97
+ log "No elements found", :skip
98
+ end
99
+ end
100
+
101
+ def remove_orphaned_contents
102
+ puts "\n## Removing orphaned contents"
103
+ contents = Alchemy::Content.unscoped.all
104
+ if contents.any?
105
+ orphaned_contents = contents.select do |content|
106
+ content.essence.nil? && content.essence_id.present? ||
107
+ content.element.nil? && content.element_id.present?
108
+ end
109
+ if orphaned_contents.any?
110
+ log "Found #{orphaned_contents.size} orphaned contents"
111
+ destroy_orphaned_records(orphaned_contents, 'content')
112
+ else
113
+ log "No orphaned contents found", :skip
114
+ end
115
+ else
116
+ log "No contents found", :skip
117
+ end
118
+ end
119
+
120
+ private
121
+
122
+ def destroy_orphaned_records(records, class_name)
123
+ records.each do |record|
124
+ log "Destroy orphaned #{class_name}: #{record.inspect}"
125
+ record.destroy
126
+ end
127
+ end
128
+ end
129
+ end
130
+ end
@@ -6,5 +6,30 @@ module Alchemy
6
6
  desc 'Install asset manifests into `vendor/assets`'
7
7
  Alchemy::Upgrader::Tasks::InstallAssetManifests.new.install
8
8
  end
9
+
10
+ def self.store_image_file_format
11
+ desc 'Store image file format'
12
+ pictures = Alchemy::Picture.where(image_file_format: nil)
13
+ count = pictures.size
14
+ converted_pics = 0
15
+ errored_pics = 0
16
+ puts "-- Storing file format of #{count} pictures"
17
+ pictures.find_each(batch_size: 100).with_index do |pic, i|
18
+ begin
19
+ puts " -> Reading file format of #{pic.image_file_name} (#{i + 1}/#{count})"
20
+ format = pic.image_file.identify('-ping -format "%m"')
21
+ pic.update_column('image_file_format', format.to_s.chomp.downcase)
22
+ converted_pics += 1
23
+ rescue Dragonfly::Job::Fetch::NotFound => e
24
+ puts " -> #{e.message}"
25
+ errored_pics += 1
26
+ end
27
+ end
28
+ puts "-- Done! Converted #{converted_pics} images."
29
+ unless errored_pics.zero?
30
+ puts " !! But #{errored_pics} images caused errors."
31
+ puts " Please check errors above and re-run `rake alchemy:upgrade:3.4:store_image_file_format`"
32
+ end
33
+ end
9
34
  end
10
35
  end
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
- VERSION = "3.6.1"
2
+ VERSION = "3.6.6"
3
3
 
4
4
  def self.version
5
5
  VERSION
@@ -1,5 +1,6 @@
1
1
  # Instantiate the global Alchemy namespace
2
2
  module Alchemy
3
+ Alchemy::YAML_WHITELIST_CLASSES = %w(Symbol Date Regexp)
3
4
  end
4
5
 
5
6
  # Require globally used external libraries
@@ -32,7 +32,7 @@ module Alchemy
32
32
  end
33
33
 
34
34
  def load_alchemy_yaml(name)
35
- YAML.safe_load(ERB.new(File.read("#{Rails.root}/config/alchemy/#{name}")).result, [Regexp], [], true)
35
+ YAML.safe_load(ERB.new(File.read("#{Rails.root}/config/alchemy/#{name}")).result, YAML_WHITELIST_CLASSES, [], true)
36
36
  rescue Errno::ENOENT
37
37
  puts "\nERROR: Could not read config/alchemy/#{name} file. Please run: rails generate alchemy:scaffold"
38
38
  end
@@ -1,4 +1,4 @@
1
- require 'alchemy/shell'
1
+ require 'alchemy/tasks/tidy'
2
2
 
3
3
  namespace :alchemy do
4
4
  namespace :tidy do
@@ -58,131 +58,3 @@ namespace :alchemy do
58
58
  end
59
59
  end
60
60
  end
61
-
62
- module Alchemy
63
- class Tidy
64
- extend Shell
65
-
66
- class << self
67
- def create_missing_cells(page_layouts, cells)
68
- page_layouts.each do |layout|
69
- next if layout['cells'].blank?
70
- cells_for_layout = cells.select { |cell| layout['cells'].include? cell['name'] }
71
- Alchemy::Page.where(page_layout: layout['name']).each do |page|
72
- cells_for_layout.each do |cell_for_layout|
73
- cell = Alchemy::Cell.find_or_initialize_by(name: cell_for_layout['name'], page_id: page.id)
74
- cell.elements << page.elements.select { |element| cell_for_layout['elements'].include?(element.name) }
75
- if cell.new_record?
76
- cell.save
77
- log "Creating cell #{cell.name} for page #{page.name}"
78
- else
79
- log "Cell #{cell.name} for page #{page.name} already present", :skip
80
- end
81
- end
82
- end
83
- end
84
- end
85
-
86
- def update_element_positions
87
- Alchemy::Page.all.each do |page|
88
- if page.elements.any?
89
- puts "\n## Updating element positions of page `#{page.name}`"
90
- end
91
- page.elements.group_by(&:cell_id).each do |_cell_id, elements|
92
- elements.each_with_index do |element, idx|
93
- position = idx + 1
94
- if element.position != position
95
- log "Updating position for element ##{element.id} to #{position}"
96
- element.update_column(:position, position)
97
- else
98
- log "Position for element ##{element.id} is already correct (#{position})", :skip
99
- end
100
- end
101
- end
102
- end
103
- end
104
-
105
- def update_content_positions
106
- Alchemy::Element.all.each do |element|
107
- if element.contents.any?
108
- puts "\n## Updating content positions of element `#{element.name}`"
109
- end
110
- element.contents.group_by(&:essence_type).each do |essence_type, contents|
111
- puts "-> Contents of type `#{essence_type}`"
112
- contents.each_with_index do |content, idx|
113
- position = idx + 1
114
- if content.position != position
115
- log "Updating position for content ##{content.id} to #{position}"
116
- content.update_column(:position, position)
117
- else
118
- log "Position for content ##{content.id} is already correct (#{position})", :skip
119
- end
120
- end
121
- end
122
- end
123
- end
124
-
125
- def remove_orphaned_cells
126
- puts "\n## Removing orphaned cells"
127
- cells = Alchemy::Cell.unscoped.all
128
- if cells.any?
129
- orphaned_cells = cells.select do |cell|
130
- cell.page.nil? && cell.page_id.present?
131
- end
132
- if orphaned_cells.any?
133
- destroy_orphaned_records(orphaned_cells, 'cell')
134
- else
135
- log "No orphaned cells found", :skip
136
- end
137
- else
138
- log "No cells found", :skip
139
- end
140
- end
141
-
142
- def remove_orphaned_elements
143
- puts "\n## Removing orphaned elements"
144
- elements = Alchemy::Element.unscoped.all
145
- if elements.any?
146
- orphaned_elements = elements.select do |element|
147
- element.page.nil? && element.page_id.present? ||
148
- element.cell.nil? && element.cell_id.present?
149
- end
150
- if orphaned_elements.any?
151
- destroy_orphaned_records(orphaned_elements, 'element')
152
- else
153
- log "No orphaned elements found", :skip
154
- end
155
- else
156
- log "No elements found", :skip
157
- end
158
- end
159
-
160
- def remove_orphaned_contents
161
- puts "\n## Removing orphaned contents"
162
- contents = Alchemy::Content.unscoped.all
163
- if contents.any?
164
- orphaned_contents = contents.select do |content|
165
- content.essence.nil? && content.essence_id.present? ||
166
- content.element.nil? && content.element_id.present?
167
- end
168
- if orphaned_contents.any?
169
- destroy_orphaned_records(orphaned_contents, 'content')
170
- else
171
- log "No orphaned contents found", :skip
172
- end
173
- else
174
- log "No contents found", :skip
175
- end
176
- end
177
-
178
- private
179
-
180
- def destroy_orphaned_records(records, class_name)
181
- records.each do |record|
182
- log "Destroy orphaned #{class_name}: #{record.id}"
183
- record.destroy
184
- end
185
- end
186
- end
187
- end
188
- end
@@ -148,12 +148,20 @@ namespace :alchemy do
148
148
  task '3.4' => ['alchemy:upgrade:prepare', 'alchemy:upgrade:3.4:run']
149
149
 
150
150
  namespace '3.4' do
151
- task run: ['alchemy:upgrade:3.4:install_asset_manifests']
151
+ task run: [
152
+ 'alchemy:upgrade:3.4:install_asset_manifests',
153
+ 'alchemy:upgrade:3.4:store_image_file_format'
154
+ ]
152
155
 
153
156
  desc 'Install asset manifests into `vendor/assets`'
154
157
  task install_asset_manifests: [:environment] do
155
158
  Alchemy::Upgrader::ThreePointFour.install_asset_manifests
156
159
  end
160
+
161
+ desc 'Store image file format on Alchemy pictures.'
162
+ task store_image_file_format: [:environment] do
163
+ Alchemy::Upgrader::ThreePointFour.store_image_file_format
164
+ end
157
165
  end
158
166
 
159
167
  desc 'Upgrade Alchemy to v3.5'
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: 3.6.1
4
+ version: 3.6.6
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: 2017-08-16 00:00:00.000000000 Z
16
+ date: 2020-10-08 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: active_model_serializers
@@ -63,14 +63,14 @@ dependencies:
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: '3.1'
66
+ version: '3.0'
67
67
  type: :runtime
68
68
  prerelease: false
69
69
  version_requirements: !ruby/object:Gem::Requirement
70
70
  requirements:
71
71
  - - "~>"
72
72
  - !ruby/object:Gem::Version
73
- version: '3.1'
73
+ version: '3.0'
74
74
  - !ruby/object:Gem::Dependency
75
75
  name: bourbon
76
76
  requirement: !ruby/object:Gem::Requirement
@@ -847,6 +847,7 @@ files:
847
847
  - lib/alchemy/shell.rb
848
848
  - lib/alchemy/ssl_protection.rb
849
849
  - lib/alchemy/tasks/helpers.rb
850
+ - lib/alchemy/tasks/tidy.rb
850
851
  - lib/alchemy/test_support/config_stubbing.rb
851
852
  - lib/alchemy/test_support/controller_requests.rb
852
853
  - lib/alchemy/test_support/essence_shared_examples.rb
@@ -993,9 +994,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
993
994
  version: '0'
994
995
  requirements:
995
996
  - ImageMagick (libmagick), v6.6 or greater.
996
- rubyforge_project:
997
- rubygems_version: 2.6.11
998
- signing_key:
997
+ rubyforge_project:
998
+ rubygems_version: 2.6.14.4
999
+ signing_key:
999
1000
  specification_version: 4
1000
1001
  summary: A powerful, userfriendly and flexible CMS for Rails 4
1001
1002
  test_files: []
1003
+ ...