commit: 5973ca3d111e65385299d47b6b82df48a0a5f67b
parent: cc70f28f195335f4775f7b6aafe7d90210e8b700
Author: Eugen Rochko <eugen@zeonfederated.com>
Date: Tue, 29 Nov 2016 14:20:15 +0100
Upgrade Paperclip to 5, AWS-SDK to 2, do not generate medium/small versions of avatars
Diffstat:
6 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/.env.production.sample b/.env.production.sample
@@ -25,3 +25,10 @@ SMTP_FROM_ADDRESS=notifications@example.com
# Optional asset host for multi-server setups
# CDN_HOST=assets.example.com
+
+# S3 (optional)
+S3_ENABLED=false
+S3_BUCKET=
+AWS_ACCESS_KEY_ID=
+AWS_SECRET_ACCESS_KEY=
+S3_REGION=
diff --git a/Gemfile b/Gemfile
@@ -17,9 +17,9 @@ gem 'pghero'
gem 'dotenv-rails'
gem 'font-awesome-rails'
-gem 'paperclip', '~> 4.3'
+gem 'paperclip', '~> 5.0'
gem 'paperclip-av-transcoder'
-gem 'aws-sdk', '< 2.0'
+gem 'aws-sdk', '>= 2.0'
gem 'http'
gem 'httplog'
diff --git a/Gemfile.lock b/Gemfile.lock
@@ -70,11 +70,14 @@ GEM
execjs
av (0.9.0)
cocaine (~> 0.5.3)
- aws-sdk (1.66.0)
- aws-sdk-v1 (= 1.66.0)
- aws-sdk-v1 (1.66.0)
- json (~> 1.4)
- nokogiri (>= 1.4.4)
+ aws-sdk (2.6.28)
+ aws-sdk-resources (= 2.6.28)
+ aws-sdk-core (2.6.28)
+ aws-sigv4 (~> 1.0)
+ jmespath (~> 1.0)
+ aws-sdk-resources (2.6.28)
+ aws-sdk-core (= 2.6.28)
+ aws-sigv4 (1.0.0)
babel-source (5.8.35)
babel-transpiler (0.7.0)
babel-source (>= 4.0, < 6)
@@ -184,6 +187,7 @@ GEM
jbuilder (2.6.0)
activesupport (>= 3.0.0, < 5.1)
multi_json (~> 1.2)
+ jmespath (1.3.1)
jquery-rails (4.1.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
@@ -208,7 +212,7 @@ GEM
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
- mimemagic (0.3.0)
+ mimemagic (0.3.2)
mini_portile2 (2.1.0)
minitest (5.9.1)
multi_json (1.12.1)
@@ -221,12 +225,12 @@ GEM
addressable (~> 2.4)
http (~> 2.0)
nokogiri (~> 1.6)
- paperclip (4.3.7)
- activemodel (>= 3.2.0)
- activesupport (>= 3.2.0)
+ paperclip (5.1.0)
+ activemodel (>= 4.2.0)
+ activesupport (>= 4.2.0)
cocaine (~> 0.5.5)
mime-types
- mimemagic (= 0.3.0)
+ mimemagic (~> 0.3.0)
paperclip-av-transcoder (0.6.4)
av (~> 0.9.0)
paperclip (>= 2.5.2)
@@ -402,7 +406,7 @@ DEPENDENCIES
active_record_query_trace
addressable
autoprefixer-rails
- aws-sdk (< 2.0)
+ aws-sdk (>= 2.0)
better_errors
binding_of_caller
browserify-rails
@@ -431,7 +435,7 @@ DEPENDENCIES
nokogiri
oj
ostatus2
- paperclip (~> 4.3)
+ paperclip (~> 5.0)
paperclip-av-transcoder
pg
pg_search
diff --git a/app/helpers/atom_builder_helper.rb b/app/helpers/atom_builder_helper.rb
@@ -116,9 +116,9 @@ module AtomBuilderHelper
end
def link_avatar(xml, account)
- single_link_avatar(xml, account, :large, 300)
- single_link_avatar(xml, account, :medium, 96)
- single_link_avatar(xml, account, :small, 48)
+ single_link_avatar(xml, account, :large, 300)
+ # single_link_avatar(xml, account, :medium, 96)
+ # single_link_avatar(xml, account, :small, 48)
end
def logo(xml, url)
diff --git a/app/models/account.rb b/app/models/account.rb
@@ -13,12 +13,12 @@ class Account < ApplicationRecord
validates :username, presence: true, uniqueness: { scope: :domain, case_sensitive: true }, unless: 'local?'
# Avatar upload
- has_attached_file :avatar, styles: { large: '300x300#', medium: '96x96#', small: '48x48#' }
+ has_attached_file :avatar, styles: { large: '300x300#' }, convert_options: { all: '-strip' }
validates_attachment_content_type :avatar, content_type: IMAGE_MIME_TYPES
validates_attachment_size :avatar, less_than: 2.megabytes
# Header upload
- has_attached_file :header, styles: { medium: '700x335#' }
+ has_attached_file :header, styles: { medium: '700x335#' }, convert_options: { all: '-strip' }
validates_attachment_content_type :header, content_type: IMAGE_MIME_TYPES
validates_attachment_size :header, less_than: 2.megabytes
diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb
@@ -1,4 +1,6 @@
if ENV['S3_ENABLED'] == 'true'
+ Aws.eager_autoload!(services: %w(S3))
+
Paperclip::Attachment.default_options[:storage] = :s3
Paperclip::Attachment.default_options[:s3_protocol] = 'https'
Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
@@ -9,6 +11,6 @@ if ENV['S3_ENABLED'] == 'true'
bucket: ENV.fetch('S3_BUCKET'),
access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'),
- s3_region: ENV.fetch('S3_REGION')
+ s3_region: ENV.fetch('S3_REGION'),
}
end