Upgrade Paperclip to 5, AWS-SDK to 2, do not generate medium/small versions of avatars

shrike
Eugen Rochko 2016-11-29 14:20:15 +01:00
parent cc70f28f19
commit 5973ca3d11
6 changed files with 33 additions and 20 deletions

View File

@ -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=

View File

@ -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'

View File

@ -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

View File

@ -117,8 +117,8 @@ module AtomBuilderHelper
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, :medium, 96)
# single_link_avatar(xml, account, :small, 48)
end
def logo(xml, url)

View File

@ -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

View File

@ -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