alchemy-dragonfly-s3 5.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +74 -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.rb +5 -0
- data/lib/alchemy/dragonfly/s3/create_picture_thumb.rb +29 -0
- data/lib/alchemy/dragonfly/s3/engine.rb +17 -0
- data/lib/alchemy/dragonfly/s3/version.rb +9 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ec1c13a542a1b63dd195077cd647d1e1bc0bdfaeae8a4eb51b702566d5202c12
|
4
|
+
data.tar.gz: 646fe1fa7a99c9ee7cb68eb8cc1bbddbd78640624cfafb168f5fb9371239bce0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c16231755be826fc40a78542cfb864753a0403eed16feb51186d9e526c2c76dc450810a228105644a0233844fa97171e7a83d35bd52ecedcbdaf7205d639961a
|
7
|
+
data.tar.gz: 946cf698073d4940257b251f8f53eb1ef189b53c4bf91ea081ff3142360cef5ef05cbf97631a5fad8c2c51cc58a98f1048b41e3c5e6093439ddc323786181f03
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2020 Thomas von Deyen
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
[![Build Status](https://travis-ci.com/AlchemyCMS/alchemy-dragonfly-s3.svg?branch=master)](https://travis-ci.com/AlchemyCMS/alchemy-dragonfly-s3)
|
2
|
+
|
3
|
+
# AlchemyCMS AWS S3
|
4
|
+
|
5
|
+
Provides classes for storing Alchemy pictures and file attachments on Amazon AWS S3.
|
6
|
+
|
7
|
+
## Alchemy Version
|
8
|
+
|
9
|
+
This branch works with Alchemy 5.1 only.
|
10
|
+
|
11
|
+
- For a Alchemy 5.0 compatible version use the `alchemy-5` branch.
|
12
|
+
- For a Alchemy 4 compatible version use the `alchemy-4` branch.
|
13
|
+
- For a Alchemy 3 compatible version use the `alchemy-3` branch.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Add this line to your application's Gemfile:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'alchemy-dragonfly-s3', github: 'AlchemyCMS/alchemy-dragonfly-s3'
|
21
|
+
```
|
22
|
+
|
23
|
+
For now you also need the master branch of AlchemyCMS*
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
gem 'alchemy_cms', github: 'AlchemyCMS/alchemy_cms', branch: 'master'
|
27
|
+
```
|
28
|
+
|
29
|
+
*only necessary until Alchemy 5.1 has been released.
|
30
|
+
|
31
|
+
And then execute:
|
32
|
+
|
33
|
+
```
|
34
|
+
$ bundle install
|
35
|
+
```
|
36
|
+
|
37
|
+
Install the picture thumbs migration from Alchemy 5.1
|
38
|
+
|
39
|
+
```
|
40
|
+
$ bin/rake alchemy:install:migrations
|
41
|
+
$ bin/rake db:migrate
|
42
|
+
```
|
43
|
+
|
44
|
+
## Setup
|
45
|
+
|
46
|
+
Configure a S3 datastore for Dragonfly
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
# config/initializers/dragonfly
|
50
|
+
|
51
|
+
require "dragonfly/s3_data_store"
|
52
|
+
|
53
|
+
Dragonfly.app(:alchemy_pictures).configure do
|
54
|
+
plugin :imagemagick
|
55
|
+
plugin :svg
|
56
|
+
|
57
|
+
datastore :s3,
|
58
|
+
bucket_name: ENV.fetch("ALCHEMY_S3_BUCKET_NAME"),
|
59
|
+
access_key_id: ENV.fetch("ALCHEMY_S3_ACCESS_KEY_ID"),
|
60
|
+
secret_access_key: ENV.fetch("ALCHEMY_S3_SECRET_ACCESS_KEY"),
|
61
|
+
region: ENV.fetch("ALCHEMY_S3_REGION")
|
62
|
+
end
|
63
|
+
|
64
|
+
Dragonfly.app(:alchemy_attachments).configure do
|
65
|
+
datastore :s3,
|
66
|
+
bucket_name: ENV.fetch("ALCHEMY_S3_BUCKET_NAME"),
|
67
|
+
access_key_id: ENV.fetch("ALCHEMY_S3_ACCESS_KEY_ID"),
|
68
|
+
secret_access_key: ENV.fetch("ALCHEMY_S3_SECRET_ACCESS_KEY"),
|
69
|
+
region: ENV.fetch("ALCHEMY_S3_REGION")
|
70
|
+
end
|
71
|
+
```
|
72
|
+
|
73
|
+
## License
|
74
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -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
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Alchemy
|
4
|
+
module Dragonfly
|
5
|
+
module S3
|
6
|
+
class CreatePictureThumb
|
7
|
+
def self.call(variant, signature, uid)
|
8
|
+
# create the thumb before uploading
|
9
|
+
# to prevent db race conditions
|
10
|
+
thumb = variant.picture.thumbs.create!(
|
11
|
+
picture: variant.picture,
|
12
|
+
signature: signature,
|
13
|
+
uid: uid,
|
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
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Alchemy
|
4
|
+
module Dragonfly
|
5
|
+
module S3
|
6
|
+
class Engine < ::Rails::Engine
|
7
|
+
engine_name "alchemy_dragonfly_s3"
|
8
|
+
|
9
|
+
config.after_initialize do
|
10
|
+
Alchemy::Attachment.url_class = Alchemy::Attachment::S3Url
|
11
|
+
Alchemy::Picture.url_class = Alchemy::Picture::S3Url
|
12
|
+
Alchemy::PictureThumb.generator_class = Alchemy::Dragonfly::S3::CreatePictureThumb
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: alchemy-dragonfly-s3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 5.1.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Thomas von Deyen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: alchemy_cms
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.1.0.alpha
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '6'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 5.1.0.alpha
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '6'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: dragonfly-s3_data_store
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.3'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.3'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec-rails
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '4.0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '4.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: factory_bot_rails
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '6.0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '6.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: simplecov
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0.17'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0.17'
|
89
|
+
description: AlchemyCMS Integration for the Dragonfly S3 datastore.
|
90
|
+
email:
|
91
|
+
- thomas@vondeyen.com
|
92
|
+
executables: []
|
93
|
+
extensions: []
|
94
|
+
extra_rdoc_files: []
|
95
|
+
files:
|
96
|
+
- MIT-LICENSE
|
97
|
+
- README.md
|
98
|
+
- app/models/alchemy/attachment/s3_url.rb
|
99
|
+
- app/models/alchemy/picture/s3_url.rb
|
100
|
+
- lib/alchemy-dragonfly-s3.rb
|
101
|
+
- lib/alchemy/dragonfly/s3/create_picture_thumb.rb
|
102
|
+
- lib/alchemy/dragonfly/s3/engine.rb
|
103
|
+
- lib/alchemy/dragonfly/s3/version.rb
|
104
|
+
homepage: https://alchemy-cms.com
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubygems_version: 3.0.3
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: AlchemyCMS Dragonfly S3.
|
127
|
+
test_files: []
|