alchemy_cms 3.6.7 → 4.0.0.beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 9a490428d0bd7ad0bc938fa1390975de5764e222fc4a6cde1cfccdaf13901d3f
4
- data.tar.gz: e2297acd723cbef927d578306de473f3b20125801757c569a09774234d3ba128
2
+ SHA1:
3
+ metadata.gz: fea49a75834c1e4de115b939c2fd04639ca77174
4
+ data.tar.gz: e4c83f37c9a929cfa9044d8d6a022cf3b0e5947d
5
5
  SHA512:
6
- metadata.gz: b364510cd94a41a52fdbbbc8543c99a478be43d90bda1d506ca87f11dbd8a93a069293b042b0a4774e314971a7b9c1823217d874deb9208582ab7a02f8750e56
7
- data.tar.gz: a96c75c5bbc4a44daa3ad82ec26b005cbcf11920c695793935cd1a40683cb98497cd2bd255054687c554a1ff37d6abeb691f819fb90b375eefad78d1e4ed265a
6
+ metadata.gz: a41485fcb8985472b02ba15ab4e9cadde62d74aa1623f8e4280e13f38fcc6bac2ad88f8d885aefffb8a49f8ffee3aba5264652260cb2496b587df24bec5607ef
7
+ data.tar.gz: aa3e7483fc33c9ae6bc502958ba65173d3d17df086b1a0eb377627daac908c35bea8e4a65fc2667cfb0a739c0aa74a4228c2f4d2a64504060fcd602d7ed73226
data/.travis.yml CHANGED
@@ -1,18 +1,16 @@
1
1
  language: ruby
2
2
  sudo: false
3
- services:
4
- - mysql
5
- - postgresql
6
3
  cache:
7
4
  bundler: true
8
5
  directories:
9
6
  - "travis_phantomjs"
10
7
  rvm:
11
- - 2.3
12
- - 2.4
8
+ - 2.2.6
9
+ - 2.3.3
10
+ - 2.4.0
13
11
  branches:
14
12
  only:
15
- - 3.6-stable
13
+ - master
16
14
 
17
15
  before_install:
18
16
  - "phantomjs --version"
@@ -22,7 +20,7 @@ before_install:
22
20
  - "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"
23
21
  - "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"
24
22
  - "phantomjs --version"
25
- - gem install bundler -v "< 2"
23
+ - gem install bundler
26
24
  before_script: bundle exec rake alchemy:spec:prepare
27
25
  script: bundle exec rspec
28
26
  after_success: bundle exec codeclimate-test-reporter
data/CHANGELOG.md CHANGED
@@ -1,35 +1,8 @@
1
1
  # Change Log
2
2
 
3
- ## 3.6.7 (2021-04-13)
3
+ ## 4.0.0.beta (2017-06-20)
4
4
 
5
- - Allow "data" key for module navigations
6
-
7
- ## 3.6.6 (2020-10-08)
8
-
9
- - Allow AwesomeNestedSet >= 3.0 [#1619](https://github.com/AlchemyCMS/alchemy_cms/pull/1619) by [tvdeyen](https://github.com/tvdeyen)
10
-
11
- ## 3.6.5 (2018-05-08)
12
-
13
- - 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)
14
-
15
- ## 3.6.4 (2018-04-23)
16
-
17
- - 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)
18
-
19
- ## 3.6.3 (2017-10-24)
20
-
21
- * Remove `:display` cancan alias [#1318](https://github.com/AlchemyCMS/alchemy_cms/pull/1318) by [tvdeyen](https://github.com/tvdeyen)
22
-
23
- ## 3.6.2 (2017-09-01)
24
-
25
- * Handle custom errors in `Alchemy::Picture#url` [#1305](https://github.com/AlchemyCMS/alchemy_cms/pull/1305) by [tvdeyen](https://github.com/tvdeyen)
26
- * Do not move elements in tidy cells task [#1303](https://github.com/AlchemyCMS/alchemy_cms/pull/1303) by [tvdeyen](https://github.com/tvdeyen)
27
- * Add a store image file format rake task [#1302](https://github.com/AlchemyCMS/alchemy_cms/pull/1302) by [tvdeyen](https://github.com/tvdeyen)
28
-
29
- ## 3.6.1 (2017-08-16)
30
-
31
- * 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)
32
- This speeds up rendering large sitemaps by about 6 times.
5
+ * Rails 5
33
6
 
34
7
  ## 3.6.0 (2017-06-20)
35
8
 
data/Gemfile CHANGED
@@ -5,16 +5,15 @@ gemspec
5
5
  # Profiling
6
6
  gem 'rack-mini-profiler', group: :development, require: false
7
7
 
8
- gem 'sqlite3', '~> 1.3.6' if ENV['DB'].nil? || ENV['DB'] == 'sqlite'
8
+ gem 'sqlite3' if ENV['DB'].nil? || ENV['DB'] == 'sqlite'
9
9
  gem 'mysql2', '~> 0.3.18' if ENV['DB'] == 'mysql'
10
- gem 'pg', '~> 0.21' if ENV['DB'] == 'postgresql'
10
+ gem 'pg' 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'
18
17
  if ENV['TRAVIS']
19
18
  gem 'codeclimate-test-reporter', '~> 1.0', require: false
20
19
  end
@@ -36,9 +35,11 @@ group :development, :test do
36
35
  gem 'rspec-activemodel-mocks', '~> 1.0'
37
36
  gem 'rspec-rails', '~> 3.0'
38
37
  gem 'shoulda-matchers', '~> 3.1'
38
+ gem 'rails-controller-testing', '~> 1.0'
39
39
  end
40
40
 
41
- # We need this if we want to start the dummy app in development mode
42
- group :development, :production do
43
- gem 'quiet_assets'
41
+ # We need this if we want to start the dummy app in production, ie on Teatro.io
42
+ group :production do
43
+ gem 'uglifier', '>= 1.0.3'
44
+ gem 'therubyracer'
44
45
  end
data/README.md CHANGED
@@ -34,8 +34,9 @@ Read more about Alchemy on the [website](https://alchemy-cms.com) and in the [gu
34
34
 
35
35
  ## Rails Version
36
36
 
37
- **This version of Alchemy CMS runs with Rails 4.2**
37
+ **This version of Alchemy CMS runs with Rails 5.0 only**
38
38
 
39
+ * For a Rails 4.2 compatible version use the [`3.6-stable` branch](https://github.com/AlchemyCMS/alchemy_cms/tree/3.6-stable).
39
40
  * For a Rails 4.0/4.1 compatible version use the [`3.1-stable` branch](https://github.com/AlchemyCMS/alchemy_cms/tree/3.1-stable).
40
41
  * For a Rails 3.2 compatible version use the [`2.8-stable` branch](https://github.com/AlchemyCMS/alchemy_cms/tree/2.8-stable).
41
42
  * For a Rails 3.1 compatible version use the [`2.1-stable` branch](https://github.com/AlchemyCMS/alchemy_cms/tree/2.1-stable).
@@ -45,7 +46,9 @@ Read more about Alchemy on the [website](https://alchemy-cms.com) and in the [gu
45
46
 
46
47
  ## Ruby Version
47
48
 
48
- Alchemy runs with Ruby >= 2.1.0.
49
+ Alchemy runs with Ruby >= 2.2.2.
50
+
51
+ For a Ruby 2.1 compatible version use the [`3.6-stable` branch](https://github.com/AlchemyCMS/alchemy_cms/tree/3.6-stable).
49
52
 
50
53
  For a Ruby 2.0.0 compatible version use the [`3.2-stable` branch](https://github.com/AlchemyCMS/alchemy_cms/tree/3.2-stable).
51
54
 
data/Rakefile CHANGED
@@ -39,7 +39,13 @@ namespace :alchemy do
39
39
  namespace :spec do
40
40
  desc "Prepares database for testing Alchemy"
41
41
  task :prepare do
42
- system 'cd spec/dummy && RAILS_ENV=test bundle exec rake db:drop db:create db:migrate:reset && cd -'
42
+ system <<-BASH
43
+ cd spec/dummy
44
+ export RAILS_ENV=test
45
+ bin/rake db:environment:set
46
+ bin/rake db:migrate:reset
47
+ cd -
48
+ BASH
43
49
  end
44
50
  end
45
51
  end
data/alchemy_cms.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.summary = 'A powerful, userfriendly and flexible CMS for Rails 4'
14
14
  gem.description = 'Alchemy is a powerful, userfriendly and flexible Rails 4 CMS.'
15
15
  gem.requirements << 'ImageMagick (libmagick), v6.6 or greater.'
16
- gem.required_ruby_version = '>= 2.0.0'
16
+ gem.required_ruby_version = '>= 2.2.2'
17
17
  gem.license = 'BSD New'
18
18
  gem.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/}) }
19
19
  gem.require_paths = ['lib']
@@ -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.0']
24
+ gem.add_runtime_dependency 'awesome_nested_set', ['~> 3.1']
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']
@@ -33,7 +33,7 @@ Gem::Specification.new do |gem|
33
33
  gem.add_runtime_dependency 'kaminari', ['~> 0.15']
34
34
  gem.add_runtime_dependency 'magiclabs-userstamp', ['~> 3.0']
35
35
  gem.add_runtime_dependency 'non-stupid-digest-assets', ['~> 1.0.8']
36
- gem.add_runtime_dependency 'rails', ['>= 4.2.0', '< 5.0']
36
+ gem.add_runtime_dependency 'rails', ['~> 5.0.0']
37
37
  gem.add_runtime_dependency 'ransack', ['~> 1.4']
38
38
  gem.add_runtime_dependency 'request_store', ['~> 1.2']
39
39
  gem.add_runtime_dependency 'responders', ['~> 2.0']
@@ -145,10 +145,7 @@ module Alchemy
145
145
 
146
146
  def paste_element_from_clipboard
147
147
  @source_element = Element.find(element_from_clipboard['id'])
148
- new_attributes = {
149
- parent_element_id: params[:element][:parent_element_id],
150
- page_id: @page.id
151
- }
148
+ new_attributes = {page_id: @page.id}
152
149
  if @page.can_have_cells?
153
150
  new_attributes = new_attributes.merge({cell_id: find_or_create_cell.try(:id)})
154
151
  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, YAML_WHITELIST_CLASSES, [], true) || []
59
+ ::YAML.safe_load(ERB.new(File.read(yml_file_path)).result, [], [], 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, YAML_WHITELIST_CLASSES, [], true) || []
29
+ ::YAML.safe_load(ERB.new(File.read(definitions_file_path)).result, [Regexp, Date], [], true) || []
30
30
  else
31
31
  raise LoadError, "Could not find elements.yml file! Please run `rails generate alchemy:scaffold`"
32
32
  end
@@ -96,6 +96,7 @@ module Alchemy
96
96
 
97
97
  # Returns the self#page_layout definition from config/alchemy/page_layouts.yml file.
98
98
  def definition
99
+ return {} if systempage?
99
100
  definition = PageLayout.get(page_layout)
100
101
  if definition.nil?
101
102
  log_warning "Page definition for `#{page_layout}` not found. Please check `page_layouts.yml` file."
@@ -1,7 +1,5 @@
1
1
  module Alchemy
2
2
  module Picture::Url
3
- include Alchemy::Logger
4
-
5
3
  TRANSFORMATION_OPTIONS = [
6
4
  :crop,
7
5
  :crop_from,
@@ -30,9 +28,6 @@ module Alchemy
30
28
  image = encoded_image(image, options)
31
29
 
32
30
  image.url(options.except(*TRANSFORMATION_OPTIONS).merge(name: name))
33
- rescue MissingImageFileError, WrongImageFormatError => e
34
- log_warning e.message
35
- nil
36
31
  end
37
32
 
38
33
  private
@@ -58,10 +53,7 @@ module Alchemy
58
53
  #
59
54
  def encoded_image(image, options = {})
60
55
  target_format = options[:format] || default_render_format
61
-
62
- unless target_format.in?(Alchemy::Picture.allowed_filetypes)
63
- raise WrongImageFormatError.new(self, target_format)
64
- end
56
+ raise WrongImageFormatError if !target_format.in?(Alchemy::Picture.allowed_filetypes)
65
57
 
66
58
  options = {
67
59
  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!
27
+ before_create :create_default_language!, unless: -> { languages.any? }
28
28
 
29
29
  # concerns
30
30
  include Alchemy::Site::Layout
@@ -10,9 +10,7 @@
10
10
  </li>
11
11
  <% end %>
12
12
  </ul>
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(' ') %>">
13
+ <div id="cell_for_other_elements" class="sortable_cell for_other_elements_cell">
16
14
  <%= render partial: 'alchemy/admin/elements/element',
17
15
  collection: @page.elements.not_trashed.not_in_cell %>
18
16
  </div>
@@ -20,7 +18,7 @@
20
18
  <%= content_tag :div,
21
19
  id: "cell_#{cell.name}",
22
20
  class: ["sortable_cell", "#{cell.name}_cell"].join(' '),
23
- data: {'cell-id' => cell.id, 'droppable-elements' => cell.element_definitions.join(' ')} do %>
21
+ data: {'cell-id' => cell.id, 'data-droppable-elements' => cell.element_definitions.join(' ')} do %>
24
22
  <%= render partial: 'alchemy/admin/elements/element', collection: elements %>
25
23
  <% end %>
26
24
  <% end %>
@@ -11,8 +11,7 @@
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 %>
15
- <%= f.hidden_field :parent_element_id, value: @parent_element.try(:id) %>
14
+ <%= f.hidden_field(:page_id) %>
16
15
  <div class="input select">
17
16
  <label for="paste_from_clipboard" class="control-label"><%= Alchemy.t("Element") %></label>
18
17
  <%= select_tag 'paste_from_clipboard',
@@ -1,5 +1,5 @@
1
1
  <% if can? *navigate_module(navigation) %>
2
- <%= content_tag :div, class: main_navigation_css_classes(navigation), data: navigation["data"] do %>
2
+ <%= content_tag :div, class: main_navigation_css_classes(navigation) do %>
3
3
  <%= link_to url_for_module(alchemy_module) do %>
4
4
  <% if navigation["image"] %>
5
5
  <%= image_tag(navigation["image"]) %>
data/bin/spring CHANGED
@@ -7,9 +7,10 @@ unless defined?(Spring)
7
7
  require 'rubygems'
8
8
  require 'bundler'
9
9
 
10
- if (match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m))
11
- Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq.join(Gem.path_separator) }
12
- gem 'spring', match[1]
10
+ lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
11
+ if spring = lockfile.specs.detect { |spec| spec.name == "spring" }
12
+ Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
13
+ gem 'spring', spring.version
13
14
  require 'spring/binstub'
14
15
  end
15
16
  end
@@ -1,6 +1,18 @@
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
4
16
  end
5
17
 
6
18
  def down
@@ -46,8 +46,7 @@ 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
- YAML.safe_load(ERB.new(File.read(file)).result, YAML_WHITELIST_CLASSES, [], true) || {}
50
- rescue Errno::ENOENT
49
+ return YAML.load_file(file) || {} if File.exist?(file) # YAML.load_file returns false if file is empty.
51
50
  {}
52
51
  end
53
52
 
@@ -55,14 +55,9 @@ 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
-
63
58
  def message
64
59
  allowed_filetypes = Alchemy::Picture.allowed_filetypes.map(&:upcase).to_sentence
65
- "Requested image format (#{@requested_format.inspect}) for #{@image.inspect} is not one of allowed filetypes (#{allowed_filetypes})."
60
+ "Requested image format is not one of allowed filetypes (#{allowed_filetypes})."
66
61
  end
67
62
  end
68
63
 
@@ -7,7 +7,7 @@ module Alchemy
7
7
  end
8
8
 
9
9
  def log_warning(message)
10
- Alchemy::Logger.warn(message, caller(1..1))
10
+ Alchemy::Logger.warn(message, caller(0..0))
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, YAML_WHITELIST_CLASSES, [], true) || []
160
+ YAML.safe_load(ERB.new(File.read(layouts_file_path)).result, [Date], [], 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,6 +35,7 @@ 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? }
38
39
 
39
40
  can :read, Alchemy::Content, Alchemy::Content.available.not_restricted do |c|
40
41
  c.public? && !c.restricted? && !c.trashed?
@@ -64,6 +65,7 @@ module Alchemy
64
65
  can [:show, :download], Alchemy::Attachment
65
66
  can :read, Alchemy::Page, Alchemy::Page.published, &:public?
66
67
  can :see, Alchemy::Page, restricted: true, visible: true
68
+ can :display, Alchemy::Picture
67
69
 
68
70
  can :read, Alchemy::Content, Alchemy::Content.available do |c|
69
71
  c.public? && !c.trashed?
@@ -213,6 +215,11 @@ module Alchemy
213
215
  :unlock,
214
216
  :visit,
215
217
  to: :edit_content
218
+
219
+ alias_action :show,
220
+ :thumbnail,
221
+ :zoom,
222
+ to: :display
216
223
  end
217
224
 
218
225
  # Include the role specific permissions.
@@ -6,30 +6,5 @@ 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
34
9
  end
35
10
  end
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
- VERSION = "3.6.7"
2
+ VERSION = "4.0.0.beta"
3
3
 
4
4
  def self.version
5
5
  VERSION
data/lib/alchemy_cms.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  # Instantiate the global Alchemy namespace
2
2
  module Alchemy
3
- Alchemy::YAML_WHITELIST_CLASSES = %w(Symbol Date Regexp)
4
3
  end
5
4
 
6
5
  # 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, YAML_WHITELIST_CLASSES, [], true)
35
+ YAML.safe_load(ERB.new(File.read("#{Rails.root}/config/alchemy/#{name}")).result, [Regexp], [], 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/tasks/tidy'
1
+ require 'alchemy/shell'
2
2
 
3
3
  namespace :alchemy do
4
4
  namespace :tidy do
@@ -58,3 +58,131 @@ 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,20 +148,12 @@ 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: [
152
- 'alchemy:upgrade:3.4:install_asset_manifests',
153
- 'alchemy:upgrade:3.4:store_image_file_format'
154
- ]
151
+ task run: ['alchemy:upgrade:3.4:install_asset_manifests']
155
152
 
156
153
  desc 'Install asset manifests into `vendor/assets`'
157
154
  task install_asset_manifests: [:environment] do
158
155
  Alchemy::Upgrader::ThreePointFour.install_asset_manifests
159
156
  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
165
157
  end
166
158
 
167
159
  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.7
4
+ version: 4.0.0.beta
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-04-13 00:00:00.000000000 Z
16
+ date: 2017-06-20 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.0'
66
+ version: '3.1'
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.0'
73
+ version: '3.1'
74
74
  - !ruby/object:Gem::Dependency
75
75
  name: bourbon
76
76
  requirement: !ruby/object:Gem::Requirement
@@ -229,22 +229,16 @@ dependencies:
229
229
  name: rails
230
230
  requirement: !ruby/object:Gem::Requirement
231
231
  requirements:
232
- - - ">="
233
- - !ruby/object:Gem::Version
234
- version: 4.2.0
235
- - - "<"
232
+ - - "~>"
236
233
  - !ruby/object:Gem::Version
237
- version: '5.0'
234
+ version: 5.0.0
238
235
  type: :runtime
239
236
  prerelease: false
240
237
  version_requirements: !ruby/object:Gem::Requirement
241
238
  requirements:
242
- - - ">="
243
- - !ruby/object:Gem::Version
244
- version: 4.2.0
245
- - - "<"
239
+ - - "~>"
246
240
  - !ruby/object:Gem::Version
247
- version: '5.0'
241
+ version: 5.0.0
248
242
  - !ruby/object:Gem::Dependency
249
243
  name: ransack
250
244
  requirement: !ruby/object:Gem::Requirement
@@ -847,7 +841,6 @@ files:
847
841
  - lib/alchemy/shell.rb
848
842
  - lib/alchemy/ssl_protection.rb
849
843
  - lib/alchemy/tasks/helpers.rb
850
- - lib/alchemy/tasks/tidy.rb
851
844
  - lib/alchemy/test_support/config_stubbing.rb
852
845
  - lib/alchemy/test_support/controller_requests.rb
853
846
  - lib/alchemy/test_support/essence_shared_examples.rb
@@ -986,16 +979,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
986
979
  requirements:
987
980
  - - ">="
988
981
  - !ruby/object:Gem::Version
989
- version: 2.0.0
982
+ version: 2.2.2
990
983
  required_rubygems_version: !ruby/object:Gem::Requirement
991
984
  requirements:
992
- - - ">="
985
+ - - ">"
993
986
  - !ruby/object:Gem::Version
994
- version: '0'
987
+ version: 1.3.1
995
988
  requirements:
996
989
  - ImageMagick (libmagick), v6.6 or greater.
997
990
  rubyforge_project:
998
- rubygems_version: 2.7.6.2
991
+ rubygems_version: 2.6.12
999
992
  signing_key:
1000
993
  specification_version: 4
1001
994
  summary: A powerful, userfriendly and flexible CMS for Rails 4
@@ -1,130 +0,0 @@
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