Move letter avatars out of upload system

FIX: S3 issues around system avatars
FIX: reduced backup file size
This commit is contained in:
Sam
2014-05-30 14:17:35 +10:00
parent a2a834dae0
commit fa6f22dd39
18 changed files with 367 additions and 331 deletions

View File

@ -3,7 +3,7 @@ require_dependency 'letter_avatar'
class UserAvatarsController < ApplicationController
DOT = Base64.decode64("R0lGODlhAQABALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//wBiZCH5BAEAAA8ALAAAAAABAAEAAAQC8EUAOw==")
skip_before_filter :check_xhr, :verify_authenticity_token, only: :show
skip_before_filter :check_xhr, :verify_authenticity_token, only: [:show, :show_letter]
def refresh_gravatar
@ -20,6 +20,20 @@ class UserAvatarsController < ApplicationController
end
end
def show_letter
params.require(:username)
params.require(:version)
params.require(:size)
if params[:version].to_i > LetterAvatar::VERSION
return render_dot
end
image = LetterAvatar.generate(params[:username].to_s, params[:size].to_i)
expires_in 1.year, public: true
send_file image, disposition: nil
end
def show
# we need multisite support to keep a single origin pull for CDNs
RailsMultisite::ConnectionManagement.with_hostname(params[:hostname]) do