Skip to content

Commit

Permalink
[webui] let's see how people react to wavatar instead of fuzzy
Browse files Browse the repository at this point in the history
default_face
  • Loading branch information
coolo committed Feb 4, 2012
1 parent 0c869a4 commit c2e2304
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/webui/app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ def index

def icon
user = params[:id]
size = params[:size]
Rails.cache.delete("home_face_#{user}") if discard_cache?
content = Rails.cache.fetch("home_face_#{user}", :expires_in => 1.hour) do
size = params[:size] || '20'
key = "home_face_#{user}_#{size}"
Rails.cache.delete(key) if discard_cache?
content = Rails.cache.fetch(key, :expires_in => 5.hour) do

email = Person.email_for_login(user)
hash = Digest::MD5.hexdigest(email.downcase)
http = Net::HTTP.new("www.gravatar.com")
begin
http.start
response, content = http.get "/avatar/#{hash}?s=#{size}&d=404"
response, content = http.get "/avatar/#{hash}?s=#{size}&d=wavatar"
content = nil unless response.is_a?(Net::HTTPSuccess)
rescue SocketError, Errno::EINTR, Errno::EPIPE, EOFError, Net::HTTPBadResponse, IOError => err
logger.debug "#{err} when fetching http://www.gravatar.com/avatar/#{hash}?s=#{size}"
Expand Down

0 comments on commit c2e2304

Please sign in to comment.