Module: Commontator::SharedHelper

Included in:
SubscriptionsMailer
Defined in:
lib/commontator/shared_helper.rb

Instance Method Summary collapse

Instance Method Details

#commontator_email(user) ⇒ Object



18
19
20
21
22
# File 'lib/commontator/shared_helper.rb', line 18

def commontator_email(user)
  return '' if user.nil?
  config = user.commontator_config
  config.user_email_method.blank? ? '' : user.send(config.user_email_method)
end

#commontator_gravatar_image(user, options = {}) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/commontator/shared_helper.rb', line 34

def commontator_gravatar_image(user, options = {})
  name = commontator_name(user)
  image_tag(commontator_gravatar_url(user, options), 
            { :alt => name, 
              :title => name,
              :border => 1 })
end

#commontator_gravatar_url(user, options = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/commontator/shared_helper.rb', line 24

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

#commontator_name(user) ⇒ Object



11
12
13
14
15
16
# File 'lib/commontator/shared_helper.rb', line 11

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

#commontator_thread(commontable) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/commontator/shared_helper.rb', line 3

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