rosa-build/app/helpers/users_helper.rb

22 lines
611 B
Ruby
Raw Normal View History

# -*- encoding : utf-8 -*-
module UsersHelper
2012-03-11 17:06:41 +00:00
def avatar_url_by_email(email, size = :small)
avatar_url(User.where(:email => email).first || User.new(:email => email), size)
2012-03-11 17:06:41 +00:00
end
def avatar_url(subject, size = :small)
if subject.try('avatar?')
subject.avatar.url(size)
elsif subject.kind_of? Group
image_path('ava-big.png')
else
gravatar_url(subject.email, subject.avatar.styles[size].geometry.split('x').first)
end
end
def gravatar_url(email, size = 30)
"https://secure.gravatar.com/avatar/#{Digest::MD5.hexdigest(email.downcase)}?s=#{size}&r=pg"
end
end