alchemy-dragonfly-s3 4.0.3 → 5.1.4

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: 5282390f9bee229c6deb6d78740307924c3ad12b6ed1ff964cb351b38896e1c9
4
- data.tar.gz: 559baa3bee41168030536cb7d19c925399b422b1ecb72c2886dc455369b71998
3
+ metadata.gz: b7973574aa59a65ad12a8861ac4ce24825aa04780d2cf43e1ee7f0c3b4f91777
4
+ data.tar.gz: db0c7a9674dd17ae160aa7342da1dfa09760415d9549ad89c74ccf6bdc85d223
5
5
  SHA512:
6
- metadata.gz: b1f5f13dedeea05be74e6889c7dcb6b021e02c48adcb0f0f1a991f4a709e24cdf9825cfbd1ec207100cd08aec8993a352a1ac1edb47dd1034106a4c07bb8caa2
7
- data.tar.gz: 5a7371ad6b0e4d04ce7d1463c931a3dd350d89d5547c7cb2b83bb90c6bbd85af517cfea57f47e6606dd1004df0919c034966caa4ee6455ef5ec89bd44f6a83fc
6
+ metadata.gz: 9e6e47191ff8914f98781a22751823e9070a1cc6aae57c8156e88ca44b4236a2ff18b801f885a463f8720cc99348d88c1b56938a3390828f7109d3ace235e571
7
+ data.tar.gz: c1f4312d09b87cf37bf37778c681f9d0f45b68adaba6613096eb43a5ac1897f5d076685ec5e982183f270406d78150deceb9a30ceeda3fdde9acd57992aed813
data/README.md CHANGED
@@ -1,22 +1,29 @@
1
- [![Build Status](https://travis-ci.com/AlchemyCMS/alchemy-dragonfly-s3.svg?branch=alchemy-4)](https://travis-ci.com/AlchemyCMS/alchemy-dragonfly-s3)
1
+ [![Build Status](https://travis-ci.com/AlchemyCMS/alchemy-dragonfly-s3.svg?branch=master)](https://travis-ci.com/AlchemyCMS/alchemy-dragonfly-s3)
2
2
 
3
3
  # AlchemyCMS AWS S3
4
4
 
5
- Adds support for file attachments and rendered Alchemy thumbnails stored on Amazon AWS S3.
5
+ Provides classes for storing Alchemy pictures and file attachments on Amazon AWS S3.
6
6
 
7
7
  ## Alchemy Version
8
8
 
9
- This branch works with Alchemy 4 only.
9
+ This branch works with Alchemy 5.1 only.
10
10
 
11
- - For a Alchemy 5 compatible version use the `master` branch.
12
- - For a Alchemy 3.6 compatible version use the `alchemy-3` branch.
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.
13
14
 
14
15
  ## Installation
15
16
 
16
17
  Add this line to your application's Gemfile:
17
18
 
18
19
  ```ruby
19
- gem 'alchemy-dragonfly-s3', github: 'AlchemyCMS/alchemy-dragonfly-s3', branch: 'alchemy-4'
20
+ gem 'alchemy-dragonfly-s3', github: 'AlchemyCMS/alchemy-dragonfly-s3'
21
+ ```
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'
20
27
  ```
21
28
 
22
29
  And then execute:
@@ -25,10 +32,10 @@ And then execute:
25
32
  $ bundle install
26
33
  ```
27
34
 
28
- Install the picture thumbs migration
35
+ Install the picture thumbs migration from Alchemy 5.1
29
36
 
30
37
  ```
31
- $ bin/rake alchemy_dragonfly_s3:install:migrations
38
+ $ bin/rake alchemy:install:migrations
32
39
  $ bin/rake db:migrate
33
40
  ```
34
41
 
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Alchemy
4
+ class Attachment < BaseRecord
5
+ class S3Url < Url
6
+ def call(*)
7
+ @attachment.file.remote_url
8
+ end
9
+ end
10
+ end
11
+ 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
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "alchemy_cms"
4
+ require "alchemy/dragonfly/s3/create_picture_thumb"
4
5
  require "alchemy/dragonfly/s3/engine"
@@ -0,0 +1,19 @@
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
+ image = variant.image
9
+ image.store(path: uid)
10
+ variant.picture.thumbs.create!(
11
+ picture: variant.picture,
12
+ signature: signature,
13
+ uid: uid,
14
+ )
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -6,19 +6,10 @@ module Alchemy
6
6
  class Engine < ::Rails::Engine
7
7
  engine_name "alchemy_dragonfly_s3"
8
8
 
9
- initializer "alchemy_dragonfly_s3.assets" do
10
- Rails.application.config.assets.precompile << "alchemy_dragonfly_s3_manifest.js"
11
- end
12
-
13
- config.to_prepare do
14
- files = [
15
- "attachment_monkey_patch.rb",
16
- "picture_monkey_patch.rb",
17
- "essence_picture_monkey_patch.rb",
18
- ].each do |filename|
19
- file = Alchemy::Dragonfly::S3::Engine.root.join("lib", "alchemy", filename)
20
- Rails.application.config.cache_classes ? require(file) : load(file)
21
- end
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
22
13
  end
23
14
  end
24
15
  end
@@ -3,7 +3,7 @@
3
3
  module Alchemy
4
4
  module Dragonfly
5
5
  module S3
6
- VERSION = "4.0.3"
6
+ VERSION = "5.1.4"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy-dragonfly-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.3
4
+ version: 5.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
@@ -14,16 +14,22 @@ dependencies:
14
14
  name: alchemy_cms
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: 5.1.0.alpha
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '6'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '4.0'
29
+ version: 5.1.0.alpha
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '6'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: dragonfly-s3_data_store
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -38,20 +44,6 @@ dependencies:
38
44
  - - "~>"
39
45
  - !ruby/object:Gem::Version
40
46
  version: '1.3'
41
- - !ruby/object:Gem::Dependency
42
- name: capybara
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '3.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '3.0'
55
47
  - !ruby/object:Gem::Dependency
56
48
  name: rspec-rails
57
49
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +64,14 @@ dependencies:
72
64
  requirements:
73
65
  - - "~>"
74
66
  - !ruby/object:Gem::Version
75
- version: '5'
67
+ version: '6.0'
76
68
  type: :development
77
69
  prerelease: false
78
70
  version_requirements: !ruby/object:Gem::Requirement
79
71
  requirements:
80
72
  - - "~>"
81
73
  - !ruby/object:Gem::Version
82
- version: '5'
74
+ version: '6.0'
83
75
  - !ruby/object:Gem::Dependency
84
76
  name: simplecov
85
77
  requirement: !ruby/object:Gem::Requirement
@@ -94,20 +86,6 @@ dependencies:
94
86
  - - "~>"
95
87
  - !ruby/object:Gem::Version
96
88
  version: '0.17'
97
- - !ruby/object:Gem::Dependency
98
- name: shoulda-matchers
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '4.0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '4.0'
111
89
  description: AlchemyCMS Integration for the Dragonfly S3 datastore.
112
90
  email:
113
91
  - thomas@vondeyen.com
@@ -117,13 +95,12 @@ extra_rdoc_files: []
117
95
  files:
118
96
  - MIT-LICENSE
119
97
  - README.md
98
+ - app/models/alchemy/attachment/s3_url.rb
99
+ - app/models/alchemy/picture/s3_url.rb
120
100
  - lib/alchemy-dragonfly-s3.rb
121
- - lib/alchemy/attachment_monkey_patch.rb
101
+ - lib/alchemy/dragonfly/s3/create_picture_thumb.rb
122
102
  - lib/alchemy/dragonfly/s3/engine.rb
123
103
  - lib/alchemy/dragonfly/s3/version.rb
124
- - lib/alchemy/essence_picture_monkey_patch.rb
125
- - lib/alchemy/picture_monkey_patch.rb
126
- - lib/tasks/alchemy_dragonfly_s3/generate.rake
127
104
  homepage: https://alchemy-cms.com
128
105
  licenses:
129
106
  - MIT
@@ -143,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
120
  - !ruby/object:Gem::Version
144
121
  version: '0'
145
122
  requirements: []
146
- rubygems_version: 3.1.4
123
+ rubygems_version: 3.0.3
147
124
  signing_key:
148
125
  specification_version: 4
149
126
  summary: AlchemyCMS Dragonfly S3.
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Alchemy
4
- module AttachmentMonkeyPatch
5
- def url
6
- if file
7
- Alchemy::Attachment::S3Url.call(self)
8
- end
9
- end
10
-
11
- Attachment.prepend(self)
12
- end
13
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Alchemy
4
- module EssencePictureMonkeyPatch
5
- def picture_url(options = {})
6
- super || "missing-image.png"
7
- end
8
-
9
- def thumbnail_url(options = {})
10
- super || "alchemy/missing-image.svg"
11
- end
12
-
13
- def allow_image_cropping?(options = {})
14
- super && !!picture.image_file
15
- end
16
-
17
- EssencePicture.prepend(self)
18
- end
19
- end
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Alchemy
4
- module PictureMonkeyPatch
5
- def self.prepended(klass)
6
- klass.has_many :thumbs, class_name: "Alchemy::PictureThumb", dependent: :destroy
7
- klass.after_create -> { PictureThumb.generate_thumbs!(self) }
8
- end
9
-
10
- # Returns an url (or relative path) to a processed image for use inside an image_tag helper.
11
- #
12
- # Any additional options are passed to the url method, so you can add params to your url.
13
- #
14
- # Example:
15
- #
16
- # <%= image_tag picture.url(size: '320x200', format: 'png') %>
17
- #
18
- # @see Alchemy::PictureVariant#call for transformation options
19
- # @see Alchemy::Picture::Url#call for url options
20
- # @return [String|Nil]
21
- def url(options = {})
22
- return unless image_file
23
-
24
- variant = PictureVariant.new(self, options.slice(*Picture::TRANSFORMATION_OPTIONS))
25
- Picture::S3Url.new(variant).call(options.except(*Picture::TRANSFORMATION_OPTIONS).merge(
26
- basename: name,
27
- ext: variant.render_format,
28
- name: name,
29
- ))
30
- rescue ::Dragonfly::Job::Fetch::NotFound => e
31
- log_warning(e.message)
32
- nil
33
- end
34
-
35
- Picture::THUMBNAIL_SIZES = {
36
- small: "80x60",
37
- medium: "160x120",
38
- large: "240x180",
39
- }.with_indifferent_access.freeze
40
-
41
- Picture.prepend(self)
42
- end
43
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- namespace :alchemy_dragonfly_s3 do
4
- namespace :generate do
5
- desc "Generates all thumbnails for Alchemy Pictures and EssencePictures."
6
- task thumbnails: [
7
- "alchemy_dragonfly_s3:generate:picture_thumbnails",
8
- "alchemy_dragonfly_s3:generate:essence_picture_thumbnails"
9
- ]
10
-
11
- desc "Generates thumbnails for Alchemy Pictures."
12
- task picture_thumbnails: :environment do
13
- puts "Regenerate #{Alchemy::Picture.count} picture thumbnails."
14
- puts "Please wait..."
15
-
16
- Alchemy::Picture.find_each do |picture|
17
- puts Alchemy::PictureThumb.generate_thumbs!(picture)
18
- end
19
-
20
- puts "Done!"
21
- end
22
-
23
- desc "Generates thumbnails for Alchemy EssencePictures."
24
- task essence_picture_thumbnails: :environment do
25
- essence_pictures = Alchemy::EssencePicture.joins(:content, :ingredient_association)
26
- puts "Regenerate #{essence_pictures.count} essence picture thumbnails."
27
- puts "Please wait..."
28
-
29
- essence_pictures.find_each do |essence_picture|
30
- puts essence_picture.picture_url
31
- puts essence_picture.thumbnail_url
32
- end
33
-
34
- puts "Done!"
35
- end
36
- end
37
- end