Sha256: c0849caa883f189f99718e3606d7e05cba99ade2ff76b58e6e7195466670ef1b

Contents?: true

Size: 1.96 KB

Versions: 4

Compression:

Stored size: 1.96 KB

Contents

module Commontator
  module CommentsHelper
    def commontator_name(comment)
      commontator = comment.commontator
      config = commontator.commontator_config
      config.commontator_name_method.blank? ? config.anonymous_name : \
      commontator.send(config.commontator_name_method)
    end
    
    def deleter_name(comment)
      deleter = comment.deleter
      config = deleter.commontator_config
      config.commontator_name_method.blank? ? config.anonymous_name : \
      deleter.send(config.commontator_name_method)
    end
    
    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
    
    def gravatar_url(comment, options = {})
      commontator = comment.commontator
      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
  
    def gravatar_image(comment, options = {})
      commontator = comment.commontator
      config = commontator.commontator_config
      name = commontator.send(config.commontator_name_method)
      image_tag(gravatar_url(comment, options), 
                { :alt => name, 
                  :title => name,
                  :border => 1 })
    end
    
    def refresh_comment_actions(thread)
      output = ""
      thread.comments.each do |comment|
        output << "$('#comment_#{comment.id.to_s}_actions_span').html('" + \
                    escape_javascript(
                      render :partial => :actions,
                             :locals => { :comment => comment }) + "');\n\n"
      end
      output.slice(0..-3).html_safe
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
commontator-0.3.10 app/helpers/commontator/comments_helper.rb~
commontator-0.2.4 app/helpers/commontator/comments_helper.rb~
commontator-0.2.0 app/helpers/commontator/comments_helper.rb~
commontator-0.1.46 app/helpers/commontator/comments_helper.rb~