Module: CommentsHelper

Defined in:
app/helpers/comments_helper.rb

Instance Method Summary collapse

Instance Method Details

#comment_form_hidden_fields(commentable) ⇒ Object



56
57
58
59
60
# File 'app/helpers/comments_helper.rb', line 56

def comment_form_hidden_fields(commentable)
  hidden_field_tag('return_to', request.fullpath) + "\n" +
  hidden_field_tag('comment[commentable_type]', commentable.class.name, :id => 'comment_commentable_type') + "\n" +
  hidden_field_tag('comment[commentable_id]', commentable.id, :id => 'comment_commentable_id') + "\n"
end

#comments_feed_title(*owners) ⇒ Object



2
3
4
5
6
# File 'app/helpers/comments_helper.rb', line 2

def comments_feed_title(*owners)
  options = owners.extract_options!
  separator = options[:separator] || ' » '
  I18n.t(:'adva.titles.comments') + ': ' + owners.compact.uniq.map(&:title).join(separator)
end


45
46
47
48
49
# File 'app/helpers/comments_helper.rb', line 45

def link_to_content_comment(*args)
  options = args.extract_options!
  args.insert(args.size - 1, args.last.commentable)
  link_to_content_comments(*args << options)
end


33
34
35
36
37
38
39
40
41
42
43
# File 'app/helpers/comments_helper.rb', line 33

def link_to_content_comments(*args)
  options = args.extract_options!
  text = args.shift if args.first.is_a?(String) || args.first.is_a?(Symbol)
  content, comment = *args
  return unless content.approved_comments_count > 0 || content.accept_comments?

  text = t(text) if text.is_a?(Symbol)
  text ||= t(:'adva.comments.titles.comment_with_count', :count => content.approved_comments_count)
  options.merge! :anchor => (comment ? dom_id(comment) : 'comments')
  link_to text, [content.section, content], options
end


21
22
23
24
25
26
27
28
29
30
31
# File 'app/helpers/comments_helper.rb', line 21

def link_to_content_comments_count(content, options = {:total => true})
  total = content.comments_count
  approved = content.approved_comments_count
  return options[:alt] || t(:'adva.common.none') if approved == 0
  text = if total == approved or !options[:total]
    "#{approved.to_s.rjust(2, '0')}"
  else
    "#{approved.to_s.rjust(2, '0')} (#{total.to_s.rjust(2, '0')})"
  end
  link_to_content_comments(text, content)
end


51
52
53
54
# File 'app/helpers/comments_helper.rb', line 51

def link_to_remote_comment_preview
  link_to(I18n.t(:'adva.titles.preview'), preview_comments_path, :id => 'preview_comment', :style => "display:none;") +
    image_tag('adva_cms/indicator.gif', :alt => '', :id => 'comment_preview_spinner', :style => 'display:none;')
end