mirror of https://github.com/Siphonay/mastodon
Upgrade Paperclip to 5, AWS-SDK to 2, do not generate medium/small versions of avatars
This commit is contained in:
parent
cc70f28f19
commit
5973ca3d11
|
@ -25,3 +25,10 @@ SMTP_FROM_ADDRESS=notifications@example.com
|
||||||
|
|
||||||
# Optional asset host for multi-server setups
|
# Optional asset host for multi-server setups
|
||||||
# CDN_HOST=assets.example.com
|
# CDN_HOST=assets.example.com
|
||||||
|
|
||||||
|
# S3 (optional)
|
||||||
|
S3_ENABLED=false
|
||||||
|
S3_BUCKET=
|
||||||
|
AWS_ACCESS_KEY_ID=
|
||||||
|
AWS_SECRET_ACCESS_KEY=
|
||||||
|
S3_REGION=
|
||||||
|
|
4
Gemfile
4
Gemfile
|
@ -17,9 +17,9 @@ gem 'pghero'
|
||||||
gem 'dotenv-rails'
|
gem 'dotenv-rails'
|
||||||
gem 'font-awesome-rails'
|
gem 'font-awesome-rails'
|
||||||
|
|
||||||
gem 'paperclip', '~> 4.3'
|
gem 'paperclip', '~> 5.0'
|
||||||
gem 'paperclip-av-transcoder'
|
gem 'paperclip-av-transcoder'
|
||||||
gem 'aws-sdk', '< 2.0'
|
gem 'aws-sdk', '>= 2.0'
|
||||||
|
|
||||||
gem 'http'
|
gem 'http'
|
||||||
gem 'httplog'
|
gem 'httplog'
|
||||||
|
|
28
Gemfile.lock
28
Gemfile.lock
|
@ -70,11 +70,14 @@ GEM
|
||||||
execjs
|
execjs
|
||||||
av (0.9.0)
|
av (0.9.0)
|
||||||
cocaine (~> 0.5.3)
|
cocaine (~> 0.5.3)
|
||||||
aws-sdk (1.66.0)
|
aws-sdk (2.6.28)
|
||||||
aws-sdk-v1 (= 1.66.0)
|
aws-sdk-resources (= 2.6.28)
|
||||||
aws-sdk-v1 (1.66.0)
|
aws-sdk-core (2.6.28)
|
||||||
json (~> 1.4)
|
aws-sigv4 (~> 1.0)
|
||||||
nokogiri (>= 1.4.4)
|
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-source (5.8.35)
|
||||||
babel-transpiler (0.7.0)
|
babel-transpiler (0.7.0)
|
||||||
babel-source (>= 4.0, < 6)
|
babel-source (>= 4.0, < 6)
|
||||||
|
@ -184,6 +187,7 @@ GEM
|
||||||
jbuilder (2.6.0)
|
jbuilder (2.6.0)
|
||||||
activesupport (>= 3.0.0, < 5.1)
|
activesupport (>= 3.0.0, < 5.1)
|
||||||
multi_json (~> 1.2)
|
multi_json (~> 1.2)
|
||||||
|
jmespath (1.3.1)
|
||||||
jquery-rails (4.1.1)
|
jquery-rails (4.1.1)
|
||||||
rails-dom-testing (>= 1, < 3)
|
rails-dom-testing (>= 1, < 3)
|
||||||
railties (>= 4.2.0)
|
railties (>= 4.2.0)
|
||||||
|
@ -208,7 +212,7 @@ GEM
|
||||||
mime-types (3.1)
|
mime-types (3.1)
|
||||||
mime-types-data (~> 3.2015)
|
mime-types-data (~> 3.2015)
|
||||||
mime-types-data (3.2016.0521)
|
mime-types-data (3.2016.0521)
|
||||||
mimemagic (0.3.0)
|
mimemagic (0.3.2)
|
||||||
mini_portile2 (2.1.0)
|
mini_portile2 (2.1.0)
|
||||||
minitest (5.9.1)
|
minitest (5.9.1)
|
||||||
multi_json (1.12.1)
|
multi_json (1.12.1)
|
||||||
|
@ -221,12 +225,12 @@ GEM
|
||||||
addressable (~> 2.4)
|
addressable (~> 2.4)
|
||||||
http (~> 2.0)
|
http (~> 2.0)
|
||||||
nokogiri (~> 1.6)
|
nokogiri (~> 1.6)
|
||||||
paperclip (4.3.7)
|
paperclip (5.1.0)
|
||||||
activemodel (>= 3.2.0)
|
activemodel (>= 4.2.0)
|
||||||
activesupport (>= 3.2.0)
|
activesupport (>= 4.2.0)
|
||||||
cocaine (~> 0.5.5)
|
cocaine (~> 0.5.5)
|
||||||
mime-types
|
mime-types
|
||||||
mimemagic (= 0.3.0)
|
mimemagic (~> 0.3.0)
|
||||||
paperclip-av-transcoder (0.6.4)
|
paperclip-av-transcoder (0.6.4)
|
||||||
av (~> 0.9.0)
|
av (~> 0.9.0)
|
||||||
paperclip (>= 2.5.2)
|
paperclip (>= 2.5.2)
|
||||||
|
@ -402,7 +406,7 @@ DEPENDENCIES
|
||||||
active_record_query_trace
|
active_record_query_trace
|
||||||
addressable
|
addressable
|
||||||
autoprefixer-rails
|
autoprefixer-rails
|
||||||
aws-sdk (< 2.0)
|
aws-sdk (>= 2.0)
|
||||||
better_errors
|
better_errors
|
||||||
binding_of_caller
|
binding_of_caller
|
||||||
browserify-rails
|
browserify-rails
|
||||||
|
@ -431,7 +435,7 @@ DEPENDENCIES
|
||||||
nokogiri
|
nokogiri
|
||||||
oj
|
oj
|
||||||
ostatus2
|
ostatus2
|
||||||
paperclip (~> 4.3)
|
paperclip (~> 5.0)
|
||||||
paperclip-av-transcoder
|
paperclip-av-transcoder
|
||||||
pg
|
pg
|
||||||
pg_search
|
pg_search
|
||||||
|
|
|
@ -116,9 +116,9 @@ module AtomBuilderHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_avatar(xml, account)
|
def link_avatar(xml, account)
|
||||||
single_link_avatar(xml, account, :large, 300)
|
single_link_avatar(xml, account, :large, 300)
|
||||||
single_link_avatar(xml, account, :medium, 96)
|
# single_link_avatar(xml, account, :medium, 96)
|
||||||
single_link_avatar(xml, account, :small, 48)
|
# single_link_avatar(xml, account, :small, 48)
|
||||||
end
|
end
|
||||||
|
|
||||||
def logo(xml, url)
|
def logo(xml, url)
|
||||||
|
|
|
@ -13,12 +13,12 @@ class Account < ApplicationRecord
|
||||||
validates :username, presence: true, uniqueness: { scope: :domain, case_sensitive: true }, unless: 'local?'
|
validates :username, presence: true, uniqueness: { scope: :domain, case_sensitive: true }, unless: 'local?'
|
||||||
|
|
||||||
# Avatar upload
|
# 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_content_type :avatar, content_type: IMAGE_MIME_TYPES
|
||||||
validates_attachment_size :avatar, less_than: 2.megabytes
|
validates_attachment_size :avatar, less_than: 2.megabytes
|
||||||
|
|
||||||
# Header upload
|
# 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_content_type :header, content_type: IMAGE_MIME_TYPES
|
||||||
validates_attachment_size :header, less_than: 2.megabytes
|
validates_attachment_size :header, less_than: 2.megabytes
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
if ENV['S3_ENABLED'] == 'true'
|
if ENV['S3_ENABLED'] == 'true'
|
||||||
|
Aws.eager_autoload!(services: %w(S3))
|
||||||
|
|
||||||
Paperclip::Attachment.default_options[:storage] = :s3
|
Paperclip::Attachment.default_options[:storage] = :s3
|
||||||
Paperclip::Attachment.default_options[:s3_protocol] = 'https'
|
Paperclip::Attachment.default_options[:s3_protocol] = 'https'
|
||||||
Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
|
Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
|
||||||
|
@ -9,6 +11,6 @@ if ENV['S3_ENABLED'] == 'true'
|
||||||
bucket: ENV.fetch('S3_BUCKET'),
|
bucket: ENV.fetch('S3_BUCKET'),
|
||||||
access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
|
access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
|
||||||
secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'),
|
secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'),
|
||||||
s3_region: ENV.fetch('S3_REGION')
|
s3_region: ENV.fetch('S3_REGION'),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue