alchemy-dragonfly-s3 5.0.4 → 5.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: 07b85abda41c799474122920cea92e2fddfa003314bca025bf29ab055b62061c
4
- data.tar.gz: 182e4d22390fee03f7c652fc6fe6ad925a811e1768ce09e2028315830cd72d00
3
+ metadata.gz: 67600fb3185cda4968bc3afc93e00209d196f92be2183499cebaffc2b9f70e6b
4
+ data.tar.gz: 6b7b797cbb3f0f0671dbac17670aad87abba125864da0fe72d86c29fc5bfd84c
5
5
  SHA512:
6
- metadata.gz: 82976ed6c263722910b05bbdd3cb0dd9a1434d1f767967c7ae49e9fa2eda75bff7fe9d9795f8af45d2718ce9afb0a00b4674c743f144de0db938992a630aebb4
7
- data.tar.gz: 2c0fdccf15ac1fd8870e47255e51b90738bacb43828bef8edb19d9b46186fb10dfa1b5b6beb6ef08244b5d9e0db62210c95d897b5bca226147c256f9095b195b
6
+ metadata.gz: 8350ee48b41e406e1abf57b3bc99daeaae738c560a8ed3b5e952fb624768ad4ee0c8de5047a064a39af81f6817fab9cf3db4a6cd3c69c0bbf3c1e7814ec6fa49
7
+ data.tar.gz: 38462e8f9b701908f4afe7c66bf40a2d547441a8885bdd2e1c1541d7126157c19dfabb293205dc1ab37396997664b1af29f56100b367e47dd6aa013fd1b73764
data/README.md CHANGED
@@ -1,23 +1,29 @@
1
- [![Build Status](https://travis-ci.com/AlchemyCMS/alchemy-dragonfly-s3.svg?branch=alchemy-5)](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 5.0 only.
9
+ This branch works with Alchemy 5.1 only.
10
10
 
11
- - For a Alchemy 5.1 compatible version use the `master` branch.
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.
13
- - For a Alchemy 3.6 compatible version use the `alchemy-3` branch.
13
+ - For a Alchemy 3 compatible version use the `alchemy-3` branch.
14
14
 
15
15
  ## Installation
16
16
 
17
17
  Add this line to your application's Gemfile:
18
18
 
19
19
  ```ruby
20
- gem 'alchemy-dragonfly-s3', github: 'AlchemyCMS/alchemy-dragonfly-s3', branch: 'alchemy-5'
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'
21
27
  ```
22
28
 
23
29
  And then execute:
@@ -26,10 +32,10 @@ And then execute:
26
32
  $ bundle install
27
33
  ```
28
34
 
29
- Install the picture thumbs migration
35
+ Install the picture thumbs migration from Alchemy 5.1
30
36
 
31
37
  ```
32
- $ bin/rake alchemy_dragonfly_s3:install:migrations
38
+ $ bin/rake alchemy:install:migrations
33
39
  $ bin/rake db:migrate
34
40
  ```
35
41
 
@@ -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 = "5.0.4"
6
+ VERSION = "5.1.3"
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: 5.0.4
4
+ version: 5.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 5.0.0.beta1
19
+ version: 5.1.0.alpha
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '5.1'
22
+ version: '6'
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.0.0.beta1
29
+ version: 5.1.0.alpha
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '5.1'
32
+ version: '6'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: dragonfly-s3_data_store
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -44,20 +44,6 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '1.3'
47
- - !ruby/object:Gem::Dependency
48
- name: capybara
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '3.0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '3.0'
61
47
  - !ruby/object:Gem::Dependency
62
48
  name: rspec-rails
63
49
  requirement: !ruby/object:Gem::Requirement
@@ -78,14 +64,14 @@ dependencies:
78
64
  requirements:
79
65
  - - "~>"
80
66
  - !ruby/object:Gem::Version
81
- version: '5'
67
+ version: '6.0'
82
68
  type: :development
83
69
  prerelease: false
84
70
  version_requirements: !ruby/object:Gem::Requirement
85
71
  requirements:
86
72
  - - "~>"
87
73
  - !ruby/object:Gem::Version
88
- version: '5'
74
+ version: '6.0'
89
75
  - !ruby/object:Gem::Dependency
90
76
  name: simplecov
91
77
  requirement: !ruby/object:Gem::Requirement
@@ -100,20 +86,6 @@ dependencies:
100
86
  - - "~>"
101
87
  - !ruby/object:Gem::Version
102
88
  version: '0.17'
103
- - !ruby/object:Gem::Dependency
104
- name: shoulda-matchers
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - "~>"
108
- - !ruby/object:Gem::Version
109
- version: '4.0'
110
- type: :development
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - "~>"
115
- - !ruby/object:Gem::Version
116
- version: '4.0'
117
89
  description: AlchemyCMS Integration for the Dragonfly S3 datastore.
118
90
  email:
119
91
  - thomas@vondeyen.com
@@ -124,12 +96,9 @@ files:
124
96
  - MIT-LICENSE
125
97
  - README.md
126
98
  - lib/alchemy-dragonfly-s3.rb
127
- - lib/alchemy/attachment_monkey_patch.rb
99
+ - lib/alchemy/dragonfly/s3/create_picture_thumb.rb
128
100
  - lib/alchemy/dragonfly/s3/engine.rb
129
101
  - lib/alchemy/dragonfly/s3/version.rb
130
- - lib/alchemy/essence_picture_monkey_patch.rb
131
- - lib/alchemy/picture_monkey_patch.rb
132
- - lib/tasks/alchemy_dragonfly_s3/generate.rake
133
102
  homepage: https://alchemy-cms.com
134
103
  licenses:
135
104
  - MIT
@@ -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
10
- super || "alchemy/missing-image.svg"
11
- end
12
-
13
- def allow_image_cropping?
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