alchemy-dragonfly-s3 5.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 07b85abda41c799474122920cea92e2fddfa003314bca025bf29ab055b62061c
4
+ data.tar.gz: 182e4d22390fee03f7c652fc6fe6ad925a811e1768ce09e2028315830cd72d00
5
+ SHA512:
6
+ metadata.gz: 82976ed6c263722910b05bbdd3cb0dd9a1434d1f767967c7ae49e9fa2eda75bff7fe9d9795f8af45d2718ce9afb0a00b4674c743f144de0db938992a630aebb4
7
+ data.tar.gz: 2c0fdccf15ac1fd8870e47255e51b90738bacb43828bef8edb19d9b46186fb10dfa1b5b6beb6ef08244b5d9e0db62210c95d897b5bca226147c256f9095b195b
@@ -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.
@@ -0,0 +1,66 @@
1
+ [![Build Status](https://travis-ci.com/AlchemyCMS/alchemy-dragonfly-s3.svg?branch=alchemy-5)](https://travis-ci.com/AlchemyCMS/alchemy-dragonfly-s3)
2
+
3
+ # AlchemyCMS AWS S3
4
+
5
+ Adds support for file attachments and rendered Alchemy thumbnails stored on Amazon AWS S3.
6
+
7
+ ## Alchemy Version
8
+
9
+ This branch works with Alchemy 5.0 only.
10
+
11
+ - For a Alchemy 5.1 compatible version use the `master` branch.
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.
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', branch: 'alchemy-5'
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ ```
26
+ $ bundle install
27
+ ```
28
+
29
+ Install the picture thumbs migration
30
+
31
+ ```
32
+ $ bin/rake alchemy_dragonfly_s3:install:migrations
33
+ $ bin/rake db:migrate
34
+ ```
35
+
36
+ ## Setup
37
+
38
+ Configure a S3 datastore for Dragonfly
39
+
40
+ ```ruby
41
+ # config/initializers/dragonfly
42
+
43
+ require "dragonfly/s3_data_store"
44
+
45
+ Dragonfly.app(:alchemy_pictures).configure do
46
+ plugin :imagemagick
47
+ plugin :svg
48
+
49
+ datastore :s3,
50
+ bucket_name: ENV.fetch("ALCHEMY_S3_BUCKET_NAME"),
51
+ access_key_id: ENV.fetch("ALCHEMY_S3_ACCESS_KEY_ID"),
52
+ secret_access_key: ENV.fetch("ALCHEMY_S3_SECRET_ACCESS_KEY"),
53
+ region: ENV.fetch("ALCHEMY_S3_REGION")
54
+ end
55
+
56
+ Dragonfly.app(:alchemy_attachments).configure do
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
+
65
+ ## License
66
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "alchemy_cms"
4
+ require "alchemy/dragonfly/s3/engine"
@@ -0,0 +1,13 @@
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
@@ -0,0 +1,26 @@
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
+ 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
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Alchemy
4
+ module Dragonfly
5
+ module S3
6
+ VERSION = "5.0.4"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,19 @@
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
@@ -0,0 +1,43 @@
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
@@ -0,0 +1,37 @@
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
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alchemy-dragonfly-s3
3
+ version: !ruby/object:Gem::Version
4
+ version: 5.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Thomas von Deyen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-07-17 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.0.0.beta1
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.1'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 5.0.0.beta1
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.1'
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: 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
+ - !ruby/object:Gem::Dependency
62
+ name: rspec-rails
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '4.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '4.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: factory_bot_rails
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '5'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '5'
89
+ - !ruby/object:Gem::Dependency
90
+ name: simplecov
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '0.17'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ 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
+ description: AlchemyCMS Integration for the Dragonfly S3 datastore.
118
+ email:
119
+ - thomas@vondeyen.com
120
+ executables: []
121
+ extensions: []
122
+ extra_rdoc_files: []
123
+ files:
124
+ - MIT-LICENSE
125
+ - README.md
126
+ - lib/alchemy-dragonfly-s3.rb
127
+ - lib/alchemy/attachment_monkey_patch.rb
128
+ - lib/alchemy/dragonfly/s3/engine.rb
129
+ - 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
+ homepage: https://alchemy-cms.com
134
+ licenses:
135
+ - MIT
136
+ metadata: {}
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubygems_version: 3.0.3
153
+ signing_key:
154
+ specification_version: 4
155
+ summary: AlchemyCMS Dragonfly S3.
156
+ test_files: []