alchemy-dragonfly-s3 5.1.3 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -0
- data/README.md +13 -32
- data/alchemy-dragonfly-s3.gemspec +33 -0
- data/app/models/alchemy/attachment/s3_url.rb +11 -0
- data/app/models/alchemy/picture/s3_url.rb +13 -0
- data/lib/alchemy/dragonfly/s3/create_picture_thumb.rb +13 -3
- data/lib/alchemy/dragonfly/s3/engine.rb +1 -1
- data/lib/alchemy/dragonfly/s3/version.rb +1 -1
- metadata +11 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af1ac6f6e94915b4f4109740dc57784db1d23ea7e143e3f0baeed2d3cbc98444
|
4
|
+
data.tar.gz: 11a260d68a5557e38e58ee134eb757c7ceb7e394acf6236de15c14815fb8d3a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 991203f9ad893a0f9d67357b48cc5dbccc612e0aa2d0d1e2332bead56972b54d5e2d4058463a5eb895e5a8f6be2e02afea376e4feeb327dab9e01e268ae48a05
|
7
|
+
data.tar.gz: 41ebab2ea26481a01e1866da5ab9de1538da882c42472df0477c2251bc61338bca5b4803116b5b2de4ee357b4c47f90c9298f4771b4bc1997b246d4678f2e083
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
## v5.2.0
|
2
|
+
|
3
|
+
- Fix loading of Alchemy factories
|
4
|
+
- Allow Alchemy 6
|
5
|
+
- Use config.to_prepare as hook to register classes
|
6
|
+
|
7
|
+
## v5.1.5
|
8
|
+
|
9
|
+
- Prevent db race conditions while creating thumbs
|
10
|
+
|
11
|
+
## v5.1.4
|
12
|
+
|
13
|
+
- Include necessary files in gem package
|
14
|
+
|
15
|
+
## v5.1.3
|
16
|
+
|
17
|
+
- Use Alchemy 5.1.0.alpha
|
18
|
+
|
19
|
+
## v5.1.2
|
20
|
+
|
21
|
+
- Add support for file attachments stored on S3
|
22
|
+
|
23
|
+
## v5.1.1
|
24
|
+
|
25
|
+
- Ensure to create new thumbs on in memory picture
|
26
|
+
|
27
|
+
## v5.1.0
|
28
|
+
|
29
|
+
- Alchemy 5.1 support
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[![Build Status](https://travis-ci.com/AlchemyCMS/alchemy-dragonfly-s3.svg?branch=
|
1
|
+
[![Build Status](https://travis-ci.com/AlchemyCMS/alchemy-dragonfly-s3.svg?branch=main)](https://travis-ci.com/AlchemyCMS/alchemy-dragonfly-s3)
|
2
2
|
|
3
3
|
# AlchemyCMS AWS S3
|
4
4
|
|
@@ -6,7 +6,7 @@ Provides classes for storing Alchemy pictures and file attachments on Amazon AWS
|
|
6
6
|
|
7
7
|
## Alchemy Version
|
8
8
|
|
9
|
-
This branch works with Alchemy 5.1
|
9
|
+
This branch works with Alchemy 5.1 and above.
|
10
10
|
|
11
11
|
- For a Alchemy 5.0 compatible version use the `alchemy-5` branch.
|
12
12
|
- For a Alchemy 4 compatible version use the `alchemy-4` branch.
|
@@ -20,25 +20,12 @@ Add this line to your application's Gemfile:
|
|
20
20
|
gem 'alchemy-dragonfly-s3', github: 'AlchemyCMS/alchemy-dragonfly-s3'
|
21
21
|
```
|
22
22
|
|
23
|
-
For now you also need a special AlchemyCMS branch
|
24
|
-
|
25
|
-
```ruby
|
26
|
-
gem 'alchemy_cms', github: 'tvdeyen/alchemy_cms', branch: 'remote-images'
|
27
|
-
```
|
28
|
-
|
29
23
|
And then execute:
|
30
24
|
|
31
25
|
```
|
32
26
|
$ bundle install
|
33
27
|
```
|
34
28
|
|
35
|
-
Install the picture thumbs migration from Alchemy 5.1
|
36
|
-
|
37
|
-
```
|
38
|
-
$ bin/rake alchemy:install:migrations
|
39
|
-
$ bin/rake db:migrate
|
40
|
-
```
|
41
|
-
|
42
29
|
## Setup
|
43
30
|
|
44
31
|
Configure a S3 datastore for Dragonfly
|
@@ -48,23 +35,17 @@ Configure a S3 datastore for Dragonfly
|
|
48
35
|
|
49
36
|
require "dragonfly/s3_data_store"
|
50
37
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
Dragonfly.app(:alchemy_attachments).configure do
|
63
|
-
datastore :s3,
|
64
|
-
bucket_name: ENV.fetch("ALCHEMY_S3_BUCKET_NAME"),
|
65
|
-
access_key_id: ENV.fetch("ALCHEMY_S3_ACCESS_KEY_ID"),
|
66
|
-
secret_access_key: ENV.fetch("ALCHEMY_S3_SECRET_ACCESS_KEY"),
|
67
|
-
region: ENV.fetch("ALCHEMY_S3_REGION")
|
38
|
+
Rails.application.credentials.aws.tap do |aws_config|
|
39
|
+
Dragonfly.app(:alchemy_pictures).configure do
|
40
|
+
plugin :imagemagick
|
41
|
+
plugin :svg
|
42
|
+
secret: Rails.application.credentials.secret_key_base
|
43
|
+
datastore :s3, aws_config
|
44
|
+
end
|
45
|
+
|
46
|
+
Dragonfly.app(:alchemy_attachments).configure do
|
47
|
+
datastore :s3, aws_config
|
48
|
+
end
|
68
49
|
end
|
69
50
|
```
|
70
51
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$:.push File.expand_path("lib", __dir__)
|
4
|
+
|
5
|
+
require "alchemy/dragonfly/s3/version"
|
6
|
+
|
7
|
+
# Describe your gem and declare its dependencies:
|
8
|
+
Gem::Specification.new do |s|
|
9
|
+
s.name = "alchemy-dragonfly-s3"
|
10
|
+
s.version = Alchemy::Dragonfly::S3::VERSION
|
11
|
+
s.authors = ["Thomas von Deyen"]
|
12
|
+
s.email = ["thomas@vondeyen.com"]
|
13
|
+
s.homepage = "https://alchemy-cms.com"
|
14
|
+
s.summary = "AlchemyCMS Dragonfly S3."
|
15
|
+
s.description = "AlchemyCMS Integration for the Dragonfly S3 datastore."
|
16
|
+
s.license = "MIT"
|
17
|
+
|
18
|
+
s.files = Dir[
|
19
|
+
"app/**/*",
|
20
|
+
"lib/**/*",
|
21
|
+
"alchemy-dragonfly-s3.gemspec",
|
22
|
+
"CHANGELOG.md",
|
23
|
+
"MIT-LICENSE",
|
24
|
+
"README.md",
|
25
|
+
]
|
26
|
+
|
27
|
+
s.add_dependency "alchemy_cms", [">= 5.1.0", "< 6.1"]
|
28
|
+
s.add_dependency "dragonfly-s3_data_store", "~> 1.3"
|
29
|
+
|
30
|
+
s.add_development_dependency "rspec-rails", "~> 4.0"
|
31
|
+
s.add_development_dependency "factory_bot_rails", "~> 6.0"
|
32
|
+
s.add_development_dependency "simplecov", "~> 0.17"
|
33
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Alchemy
|
4
|
+
class Picture < BaseRecord
|
5
|
+
class S3Url < Url
|
6
|
+
def call(*)
|
7
|
+
return variant.image.remote_url unless processible_image?
|
8
|
+
|
9
|
+
::Dragonfly.app(:alchemy_pictures).remote_url_for(uid)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -5,13 +5,23 @@ module Alchemy
|
|
5
5
|
module S3
|
6
6
|
class CreatePictureThumb
|
7
7
|
def self.call(variant, signature, uid)
|
8
|
-
|
9
|
-
|
10
|
-
variant.picture.thumbs.create!(
|
8
|
+
# create the thumb before uploading
|
9
|
+
# to prevent db race conditions
|
10
|
+
thumb = variant.picture.thumbs.create!(
|
11
11
|
picture: variant.picture,
|
12
12
|
signature: signature,
|
13
13
|
uid: uid,
|
14
14
|
)
|
15
|
+
begin
|
16
|
+
# fetch and process the image
|
17
|
+
image = variant.image
|
18
|
+
# upload the processed image
|
19
|
+
image.store(path: uid)
|
20
|
+
rescue RuntimeError, Excon::Error => e
|
21
|
+
Rails.logger.warn(e)
|
22
|
+
# destroy the thumb if processing or upload fails
|
23
|
+
thumb.destroy
|
24
|
+
end
|
15
25
|
end
|
16
26
|
end
|
17
27
|
end
|
@@ -6,7 +6,7 @@ module Alchemy
|
|
6
6
|
class Engine < ::Rails::Engine
|
7
7
|
engine_name "alchemy_dragonfly_s3"
|
8
8
|
|
9
|
-
config.
|
9
|
+
config.to_prepare do
|
10
10
|
Alchemy::Attachment.url_class = Alchemy::Attachment::S3Url
|
11
11
|
Alchemy::Picture.url_class = Alchemy::Picture::S3Url
|
12
12
|
Alchemy::PictureThumb.generator_class = Alchemy::Dragonfly::S3::CreatePictureThumb
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alchemy-dragonfly-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas von Deyen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alchemy_cms
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 5.1.0
|
19
|
+
version: 5.1.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '6'
|
22
|
+
version: '6.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 5.1.0
|
29
|
+
version: 5.1.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '6'
|
32
|
+
version: '6.1'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: dragonfly-s3_data_store
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,8 +93,12 @@ executables: []
|
|
93
93
|
extensions: []
|
94
94
|
extra_rdoc_files: []
|
95
95
|
files:
|
96
|
+
- CHANGELOG.md
|
96
97
|
- MIT-LICENSE
|
97
98
|
- README.md
|
99
|
+
- alchemy-dragonfly-s3.gemspec
|
100
|
+
- app/models/alchemy/attachment/s3_url.rb
|
101
|
+
- app/models/alchemy/picture/s3_url.rb
|
98
102
|
- lib/alchemy-dragonfly-s3.rb
|
99
103
|
- lib/alchemy/dragonfly/s3/create_picture_thumb.rb
|
100
104
|
- lib/alchemy/dragonfly/s3/engine.rb
|
@@ -118,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
122
|
- !ruby/object:Gem::Version
|
119
123
|
version: '0'
|
120
124
|
requirements: []
|
121
|
-
rubygems_version: 3.
|
125
|
+
rubygems_version: 3.1.6
|
122
126
|
signing_key:
|
123
127
|
specification_version: 4
|
124
128
|
summary: AlchemyCMS Dragonfly S3.
|