alchemy-dragonfly-s3 3.6.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: 05f9d46cef8e86758e9e4175dce188b36a9e0551f69df001102ecd6eb8f3bf05
4
+ data.tar.gz: 8a2682cd225f9f38f166fad1960ac102367c594cd0c01e8b3e3c27c3beb7d911
5
+ SHA512:
6
+ metadata.gz: 24d6e51ddc7ebed221e97aa99e1a395e2be5d836509fba5191a21c3b27a08ec9b53232cd14e34443eea2562a11cde61ceed486d30bbeae98b71cc7b13f160a74
7
+ data.tar.gz: 1a5e9bb750d9af7ef6ff4fef9101f9260110d08f62664dee95863040727342227e1b6e3a5dc6847f5eb8b13124d78063d43e1206fbdc23ed8ab7af3ccb46f859
@@ -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,64 @@
1
+ [![Build Status](https://travis-ci.com/AlchemyCMS/alchemy-dragonfly-s3.svg?branch=alchemy-3)](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 3.6 only.
10
+
11
+ - For a Alchemy 5 compatible version use the `master` branch.
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'alchemy-dragonfly-s3', github: 'AlchemyCMS/alchemy-dragonfly-s3', branch: 'alchemy-3'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ ```
24
+ $ bundle install
25
+ ```
26
+
27
+ Install the picture thumbs migration
28
+
29
+ ```
30
+ $ bin/rake alchemy_dragonfly_s3:install:migrations
31
+ $ bin/rake db:migrate
32
+ ```
33
+
34
+ ## Setup
35
+
36
+ Configure a S3 datastore for Dragonfly
37
+
38
+ ```ruby
39
+ # config/initializers/dragonfly
40
+
41
+ require "dragonfly/s3_data_store"
42
+
43
+ Dragonfly.app(:alchemy_pictures).configure do
44
+ plugin :imagemagick
45
+ plugin :svg
46
+
47
+ datastore :s3,
48
+ bucket_name: ENV.fetch("ALCHEMY_S3_BUCKET_NAME"),
49
+ access_key_id: ENV.fetch("ALCHEMY_S3_ACCESS_KEY_ID"),
50
+ secret_access_key: ENV.fetch("ALCHEMY_S3_SECRET_ACCESS_KEY"),
51
+ region: ENV.fetch("ALCHEMY_S3_REGION")
52
+ end
53
+
54
+ Dragonfly.app(:alchemy_attachments).configure do
55
+ datastore :s3,
56
+ bucket_name: ENV.fetch("ALCHEMY_S3_BUCKET_NAME"),
57
+ access_key_id: ENV.fetch("ALCHEMY_S3_ACCESS_KEY_ID"),
58
+ secret_access_key: ENV.fetch("ALCHEMY_S3_SECRET_ACCESS_KEY"),
59
+ region: ENV.fetch("ALCHEMY_S3_REGION")
60
+ end
61
+ ```
62
+
63
+ ## License
64
+ 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 = "3.6.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(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
@@ -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,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alchemy-dragonfly-s3
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.6.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: '3.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: dragonfly-s3_data_store
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ 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
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: factory_girl_rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.5'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.5'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.17'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ 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
+ description: AlchemyCMS Integration for the Dragonfly S3 datastore.
112
+ email:
113
+ - thomas@vondeyen.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - MIT-LICENSE
119
+ - README.md
120
+ - lib/alchemy-dragonfly-s3.rb
121
+ - lib/alchemy/attachment_monkey_patch.rb
122
+ - lib/alchemy/dragonfly/s3/engine.rb
123
+ - 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
+ homepage: https://alchemy-cms.com
128
+ licenses:
129
+ - MIT
130
+ metadata: {}
131
+ post_install_message:
132
+ rdoc_options: []
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ requirements: []
146
+ rubygems_version: 3.1.4
147
+ signing_key:
148
+ specification_version: 4
149
+ summary: AlchemyCMS Dragonfly S3.
150
+ test_files: []