mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: show letter avatars even if NGINX is not running in Dev mode
This commit is contained in:
@@ -1,5 +1,18 @@
|
||||
class LetterAvatar
|
||||
|
||||
class Identity
|
||||
attr_accessor :color, :letter
|
||||
|
||||
def self.from_username(username)
|
||||
identity = new
|
||||
identity.color = LetterAvatar::COLORS[
|
||||
Digest::MD5.hexdigest(username)[0...15].to_i(16) % LetterAvatar::COLORS.length
|
||||
]
|
||||
identity.letter = username[0].upcase
|
||||
identity
|
||||
end
|
||||
end
|
||||
|
||||
# BUMP UP if avatar algorithm changes
|
||||
VERSION = 5
|
||||
|
||||
@@ -9,19 +22,6 @@ class LetterAvatar
|
||||
|
||||
class << self
|
||||
|
||||
class Identity
|
||||
attr_accessor :color, :letter
|
||||
|
||||
def self.from_username(username)
|
||||
identity = new
|
||||
identity.color = LetterAvatar::COLORS[
|
||||
Digest::MD5.hexdigest(username)[0...15].to_i(16) % LetterAvatar::COLORS.length
|
||||
]
|
||||
identity.letter = username[0].upcase
|
||||
identity
|
||||
end
|
||||
end
|
||||
|
||||
def version
|
||||
"#{VERSION}_#{image_magick_version}"
|
||||
end
|
||||
@@ -32,7 +32,7 @@ class LetterAvatar
|
||||
|
||||
def generate(username, size, opts = nil)
|
||||
DistributedMutex.synchronize("letter_avatar_#{version}_#{username}") do
|
||||
identity = Identity.from_username(username)
|
||||
identity = (opts && opts[:identity]) || LetterAvatar::Identity.from_username(username)
|
||||
|
||||
cache = true
|
||||
cache = false if opts && opts[:cache] == false
|
||||
|
||||
Reference in New Issue
Block a user