Sha256: 3f0ab3665ba36abbb55e39a629b50b4eebdb6a2a27f40a41da7e64003752b903

Contents?: true

Size: 1.33 KB

Versions: 14

Compression:

Stored size: 1.33 KB

Contents

module Commontator
  module SharedHelper
    def commontator_thread(commontable)
      user = self.send Commontator.current_user_method
      
      render(:partial => 'commontator/shared/thread',
             :locals => {:thread => commontable.thread,
                         :user => user}).html_safe
    end
    
    def commontator_name(user)
      return Commontator.user_missing_name if user.nil?
      config = user.commontator_config
      config.user_name_method.blank? ? config.user_missing_name : \
        user.send(config.user_name_method)
    end
    
    def commontator_email(user)
      return '' if user.nil?
      config = user.commontator_config
      config.user_email_method.blank? ? '' : user.send(config.user_email_method)
    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

14 entries across 14 versions & 1 rubygems

Version Path
commontator-2.0.2 lib/commontator/shared_helper.rb
commontator-2.0.1 lib/commontator/shared_helper.rb
commontator-2.0.0 lib/commontator/shared_helper.rb
commontator-1.1.3 lib/commontator/shared_helper.rb
commontator-1.1.2 lib/commontator/shared_helper.rb
commontator-1.1.1 lib/commontator/shared_helper.rb
commontator-1.1.0 lib/commontator/shared_helper.rb
commontator-1.0.6 lib/commontator/shared_helper.rb
commontator-1.0.5 lib/commontator/shared_helper.rb
commontator-1.0.4 lib/commontator/shared_helper.rb
commontator-1.0.3 lib/commontator/shared_helper.rb
commontator-1.0.2 lib/commontator/shared_helper.rb
commontator-1.0.1 lib/commontator/shared_helper.rb
commontator-1.0.0 lib/commontator/shared_helper.rb