Module: UsersHelper
- Defined in:
- app/helpers/users_helper.rb
Instance Method Summary collapse
- #gravatar_img(user, options = {}) ⇒ Object
- #gravatar_url(email = nil, size = 80) ⇒ Object
- #link_to_author(resource, options = {}) ⇒ Object
- #who(name) ⇒ Object
Instance Method Details
#gravatar_img(user, options = {}) ⇒ Object
7 8 9 |
# File 'app/helpers/users_helper.rb', line 7 def gravatar_img(user, = {}) image_tag gravatar_url(user.email), {:class => 'avatar'}.merge() end |
#gravatar_url(email = nil, size = 80) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'app/helpers/users_helper.rb', line 11 def gravatar_url(email = nil, size = 80) default = '/assets/adva_cms/avatar.gif' return default if Rails.env.test? return default if email.blank? require 'digest/md5' digest = Digest::MD5.hexdigest(email) # TODO #{ActionController::AbstractRequest.relative_url_root} missing in Rails 2.2 "http://www.gravatar.com/avatar.php?size=#{size}&gravatar_id=#{digest}&default=http://#{request.host_with_port}/assets/adva_cms/avatar.gif" end |
#link_to_author(resource, options = {}) ⇒ Object
21 22 23 24 25 26 27 |
# File 'app/helpers/users_helper.rb', line 21 def resource, = {} include_email = [:include_email] && resource.respond_to?(:author_email) name = resource. text = resource..blank? ? name : link_to(h(name), h(resource.)) text = "#{text} (#{resource.})" if include_email text.html_safe end |
#who(name) ⇒ Object
2 3 4 5 |
# File 'app/helpers/users_helper.rb', line 2 def who(name) name = name.name if name.is_a? User return current_user.name == name ? "You" : name end |