Module: Commontator::CommentsHelper

Included in:
SubscriptionsMailer
Defined in:
app/helpers/commontator/comments_helper.rb

Instance Method Summary collapse

Instance Method Details

#comment_timestamp(comment) ⇒ Object



19
20
21
22
23
24
# File 'app/helpers/commontator/comments_helper.rb', line 19

def comment_timestamp(comment)
  config = comment.thread.config
  (comment.is_modified? ? 'Last modified on ' : \
    config.comment_create_verb_past.capitalize + \
    ' on ') + comment.updated_at.strftime(config.timestamp_format)
end

#commontator_name(comment) ⇒ Object



3
4
5
6
7
8
9
# File 'app/helpers/commontator/comments_helper.rb', line 3

def commontator_name(comment)
  commontator = comment.commontator
  return Commontator.commontator_missing_name if commontator.nil?
  config = commontator.commontator_config
  config.commontator_name_method.blank? ? config.commontator_missing_name : \
    commontator.send(config.commontator_name_method)
end

#deleter_name(comment) ⇒ Object



11
12
13
14
15
16
17
# File 'app/helpers/commontator/comments_helper.rb', line 11

def deleter_name(comment)
  deleter = comment.deleter
  return Commontator.commontator_missing_name if deleter.nil?
  config = deleter.commontator_config
  config.commontator_name_method.blank? ? config.commontator_missing_name : \
    deleter.send(config.commontator_name_method)
end

#gravatar_image(comment, options = {}) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'app/helpers/commontator/comments_helper.rb', line 40

def gravatar_image(comment, options = {})
  commontator = comment.commontator
  return '' if commontator.nil?
  config = commontator.commontator_config
  name = commontator.send(config.commontator_name_method)
  image_tag(gravatar_url(comment, options), 
            { :alt => name, 
              :title => name,
              :border => 1 })
end

#gravatar_url(comment, options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/helpers/commontator/comments_helper.rb', line 26

def gravatar_url(comment, options = {})
  commontator = comment.commontator
  return '' if commontator.nil?
  config = commontator.commontator_config
  
  options[:secure] ||= request.ssl?
  options[:size] ||= 50

  hash = Digest::MD5.hexdigest(commontator.send(config.commontator_email_method))
  base = options[:secure] ? "s://secure" : "://www"
  
  "http#{base}.gravatar.com/avatar/#{hash}?s=#{options[:size]}"
end