alchemy_cms 6.1.1 → 6.1.3

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: 143bb006641791929e37a72fd82d200d10084c85e9685934776e54dc61e08f58
4
- data.tar.gz: 2a8a82d5f452822f394ee9af1d55eca46efa4772a269e09583de154addc8be5f
3
+ metadata.gz: 3f4631fa484db8a523e27e3200b1e1911b145d10dbd3dd2ff065f97b72dbf6d4
4
+ data.tar.gz: 5ccb79a30a2f55110e954b9a19632f2dd73862b202e237d46afc120f0cad45f1
5
5
  SHA512:
6
- metadata.gz: fd987d8e08a1813c1f6b3ae50904910e1cb8c60c2a1a0ad5906ef9b0cdd3a233c71871e7c3b6b00f10b5caa8f56169c060cd61f03a1f0231b8ae85d7b1ff44b6
7
- data.tar.gz: 9dae2d9dabe3c81da44d17ddfc4ddb8713a328927e07caef81d6c42aba2445a9854262fa12f55f74e3cd11960197ed183bbb898a363c7ff9b3dd5ef175b91743
6
+ metadata.gz: 92bd96d81e63b05fbf655009f84d14c3007fd06fdee71331871ae53e28bfc28a457ac0942fd735671790ed10317421bac695418a45a52b004bb5d869ef2259c2
7
+ data.tar.gz: 1624a01a069cae4153859a9140df190e0de942ddcc739572b7c3efcd08c74242e326fba6a43fe89d97467a92cfeff838a7f505514f2f79d8d32b827d8125067a
@@ -82,6 +82,9 @@ jobs:
82
82
  sudo apt update -qq
83
83
  sudo apt install -qq --fix-missing libmysqlclient-dev -o dir::cache::archives="/home/runner/apt/cache"
84
84
  sudo chown -R runner /home/runner/apt/cache
85
+ - uses: actions/setup-node@v3
86
+ with:
87
+ node-version: 16
85
88
  - name: Restore node modules cache
86
89
  id: yarn-cache
87
90
  uses: actions/cache@v2.1.3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.1.3 (2023-03-29)
4
+
5
+ - Fix installer: Add seeds file if not exists [#2446](https://github.com/AlchemyCMS/alchemy_cms/pull/2446) ([tvdeyen](https://github.com/tvdeyen))
6
+ - Integrate non_stupid_digest_assets gem [#2430](https://github.com/AlchemyCMS/alchemy_cms/pull/2430) ([afdev82](https://github.com/afdev82))
7
+
8
+ ## 6.1.2 (2023-02-27)
9
+
10
+ - [6.1] Fix thumbnail writing for multi-concurrent and multi-db setups [#2434](https://github.com/AlchemyCMS/alchemy_cms/pull/2434) ([tvdeyen](https://github.com/tvdeyen))
11
+
3
12
  ## 6.1.1 (2023-01-23)
4
13
 
5
14
  - Re-introduce deleted methods [#2422](https://github.com/AlchemyCMS/alchemy_cms/pull/2422) ([tvdeyen](https://github.com/tvdeyen))
data/alchemy_cms.gemspec CHANGED
@@ -45,7 +45,6 @@ Gem::Specification.new do |gem|
45
45
  gem.add_runtime_dependency "jquery-ui-rails", ["~> 6.0"]
46
46
  gem.add_runtime_dependency "kaminari", ["~> 1.1"]
47
47
  gem.add_runtime_dependency "originator", ["~> 3.1"]
48
- gem.add_runtime_dependency "non-stupid-digest-assets", ["~> 1.0.8"]
49
48
  gem.add_runtime_dependency "ransack", [">= 1.8", "< 4.0"]
50
49
  gem.add_runtime_dependency "request_store", ["~> 1.2"]
51
50
  gem.add_runtime_dependency "responders", [">= 2.0", "< 4.0"]
@@ -3,7 +3,7 @@
3
3
  module Alchemy
4
4
  class Picture < BaseRecord
5
5
  class Url
6
- attr_reader :variant
6
+ attr_reader :variant, :thumb
7
7
 
8
8
  # @param [Alchemy::PictureVariant]
9
9
  #
@@ -31,14 +31,23 @@ module Alchemy
31
31
 
32
32
  def uid
33
33
  signature = PictureThumb::Signature.call(variant)
34
- thumb = variant.picture.thumbs.detect { |t| t.signature == signature }
35
- if thumb
36
- uid = thumb.uid
34
+ if find_thumb_by(signature)
35
+ thumb.uid
37
36
  else
38
37
  uid = PictureThumb::Uid.call(signature, variant)
39
- PictureThumb.generator_class.call(variant, signature, uid)
38
+ ActiveRecord::Base.connected_to(role: ActiveRecord::Base.writing_role) do
39
+ PictureThumb.generator_class.call(variant, signature, uid)
40
+ end
41
+ uid
40
42
  end
41
- uid
43
+ end
44
+
45
+ def find_thumb_by(signature)
46
+ @thumb = if variant.picture.thumbs.loaded?
47
+ variant.picture.thumbs.find { |t| t.signature == signature }
48
+ else
49
+ variant.picture.thumbs.find_by(signature: signature)
50
+ end
42
51
  end
43
52
  end
44
53
  end
@@ -19,11 +19,10 @@ module Alchemy
19
19
 
20
20
  # create the thumb before storing
21
21
  # to prevent db race conditions
22
- thumb = Alchemy::PictureThumb.create!(
23
- picture: variant.picture,
24
- signature: signature,
25
- uid: uid,
26
- )
22
+ @thumb = Alchemy::PictureThumb.create_or_find_by!(signature: signature) do |thumb|
23
+ thumb.picture = variant.picture
24
+ thumb.uid = uid
25
+ end
27
26
  begin
28
27
  # process the image
29
28
  image = variant.image
@@ -32,7 +31,7 @@ module Alchemy
32
31
  rescue RuntimeError => e
33
32
  ErrorTracking.notification_handler.call(e)
34
33
  # destroy the thumb if processing or storing fails
35
- thumb&.destroy
34
+ @thumb&.destroy
36
35
  end
37
36
  end
38
37
 
@@ -31,7 +31,13 @@ module Alchemy
31
31
  end
32
32
 
33
33
  def inject_seeder
34
- append_file "./db/seeds.rb", "Alchemy::Seeder.seed!\n"
34
+ seed_file = Rails.root.join("db", "seeds.rb")
35
+ args = [seed_file, "Alchemy::Seeder.seed!\n"]
36
+ if File.exist?(seed_file)
37
+ append_file(*args)
38
+ else
39
+ add_file(*args)
40
+ end
35
41
  end
36
42
  end
37
43
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alchemy
4
- VERSION = "6.1.1"
4
+ VERSION = "6.1.3"
5
5
 
6
6
  def self.version
7
7
  VERSION
data/lib/alchemy_cms.rb CHANGED
@@ -15,7 +15,7 @@ require "handlebars_assets"
15
15
  require "jquery-rails"
16
16
  require "jquery-ui-rails"
17
17
  require "kaminari"
18
- require "non-stupid-digest-assets"
18
+ require "non_stupid_digest_assets"
19
19
  require "ransack"
20
20
  require "request_store"
21
21
  require "responders"
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "sprockets/manifest"
4
+ require "active_support/core_ext/module/attribute_accessors"
5
+
6
+ module NonStupidDigestAssets
7
+ mattr_accessor :whitelist
8
+ @@whitelist = []
9
+
10
+ class << self
11
+ def assets(assets)
12
+ return assets if whitelist.empty?
13
+
14
+ whitelisted_assets(assets)
15
+ end
16
+
17
+ private
18
+
19
+ def whitelisted_assets(assets)
20
+ assets.select do |logical_path, _digest_path|
21
+ whitelist.any? do |item|
22
+ item =~ logical_path
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ module CompileWithNonDigest
29
+ def compile(*args)
30
+ paths = super
31
+ NonStupidDigestAssets.assets(assets).each do |(logical_path, digest_path)|
32
+ full_digest_path = File.join dir, digest_path
33
+ full_digest_gz_path = "#{full_digest_path}.gz"
34
+ full_non_digest_path = File.join dir, logical_path
35
+ full_non_digest_gz_path = "#{full_non_digest_path}.gz"
36
+
37
+ if File.exist? full_digest_path
38
+ logger.debug "Writing #{full_non_digest_path}"
39
+ FileUtils.copy_file full_digest_path, full_non_digest_path, :preserve_attributes
40
+ else
41
+ logger.debug "Could not find: #{full_digest_path}"
42
+ end
43
+ if File.exist? full_digest_gz_path
44
+ logger.debug "Writing #{full_non_digest_gz_path}"
45
+ FileUtils.copy_file full_digest_gz_path, full_non_digest_gz_path, :preserve_attributes
46
+ else
47
+ logger.debug "Could not find: #{full_digest_gz_path}"
48
+ end
49
+ end
50
+ paths
51
+ end
52
+ end
53
+ end
54
+
55
+ Sprockets::Manifest.prepend NonStupidDigestAssets::CompileWithNonDigest
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alchemy_cms/admin",
3
- "version": "6.1.1",
3
+ "version": "6.1.3",
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.1.1
4
+ version: 6.1.3
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: 2023-01-23 00:00:00.000000000 Z
16
+ date: 2023-03-29 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: actionmailer
@@ -387,20 +387,6 @@ dependencies:
387
387
  - - "~>"
388
388
  - !ruby/object:Gem::Version
389
389
  version: '3.1'
390
- - !ruby/object:Gem::Dependency
391
- name: non-stupid-digest-assets
392
- requirement: !ruby/object:Gem::Requirement
393
- requirements:
394
- - - "~>"
395
- - !ruby/object:Gem::Version
396
- version: 1.0.8
397
- type: :runtime
398
- prerelease: false
399
- version_requirements: !ruby/object:Gem::Requirement
400
- requirements:
401
- - - "~>"
402
- - !ruby/object:Gem::Version
403
- version: 1.0.8
404
390
  - !ruby/object:Gem::Dependency
405
391
  name: ransack
406
392
  requirement: !ruby/object:Gem::Requirement
@@ -1432,6 +1418,7 @@ files:
1432
1418
  - lib/generators/alchemy/site_layouts/templates/layout.html.haml
1433
1419
  - lib/generators/alchemy/site_layouts/templates/layout.html.slim
1434
1420
  - lib/generators/alchemy/views/views_generator.rb
1421
+ - lib/non_stupid_digest_assets.rb
1435
1422
  - lib/tasks/alchemy/db.rake
1436
1423
  - lib/tasks/alchemy/install.rake
1437
1424
  - lib/tasks/alchemy/thumbnails.rake
@@ -1538,7 +1525,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1538
1525
  version: '0'
1539
1526
  requirements:
1540
1527
  - ImageMagick (libmagick), v6.6 or greater.
1541
- rubygems_version: 3.3.26
1528
+ rubygems_version: 3.4.6
1542
1529
  signing_key:
1543
1530
  specification_version: 4
1544
1531
  summary: A powerful, userfriendly and flexible CMS for Rails