Sha256: fb0343834c946ae45e9b2df2ee2960f1581bdeb66c242cdd05863f4b324bbd06

Contents?: true

Size: 1.09 KB

Versions: 5

Compression:

Stored size: 1.09 KB

Contents

module Commontator
  module SharedHelper
    def commontator_thread(commontable)
      user = Commontator.current_user_proc.call(self)
      
      render(:partial => 'commontator/shared/thread',
             :locals => {:thread => commontable.thread,
                         :user => user}).html_safe
    end
    
    def commontator_name(user)
      user.commontator_config.user_name_proc.call(user)
    end
    
    def commontator_email(user)
      user.commontator_config.user_email_proc.call(user)
    end
    
    def commontator_gravatar_url(user, options = {})
      options[:secure] ||= request.ssl?
      options[:size] ||= 50
    
      hash = Digest::MD5.hexdigest(commontator_email(user))
      base = options[:secure] ? "s://secure" : "://www"
      
      "http#{base}.gravatar.com/avatar/#{hash}?s=#{options[:size]}"
    end
  
    def commontator_gravatar_image(user, options = {})
      name = commontator_name(user)
      image_tag(commontator_gravatar_url(user, options), 
                { :alt => name, 
                  :title => name,
                  :border => 1 })
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
commontator-4.2.2 lib/commontator/shared_helper.rb
commontator-4.2.1 lib/commontator/shared_helper.rb
commontator-4.2.0 lib/commontator/shared_helper.rb
commontator-4.1.2 lib/commontator/shared_helper.rb
commontator-4.1.1 lib/commontator/shared_helper.rb