Module: RenderCommentsTreeHelper::Render
- Defined in:
- app/helpers/render_comments_tree_helper.rb
Class Attribute Summary collapse
-
.h ⇒ Object
Returns the value of attribute h.
-
.options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
- .avatar ⇒ Object
- .children ⇒ Object
-
.controller ⇒ Object
Main Helpers.
- .controls ⇒ Object
- .draft_comment ⇒ Object
- .moderator? ⇒ Boolean
- .moderator_controls ⇒ Object
- .published_comment ⇒ Object
-
.render_node(h, options) ⇒ Object
Render Methods.
- .reply ⇒ Object
- .t(str) ⇒ Object
- .userbar ⇒ Object
-
.visible_draft? ⇒ Boolean
Render Helpers.
Class Attribute Details
.h ⇒ Object
Returns the value of attribute h.
13 14 15 |
# File 'app/helpers/render_comments_tree_helper.rb', line 13 def h @h end |
.options ⇒ Object
Returns the value of attribute options.
13 14 15 |
# File 'app/helpers/render_comments_tree_helper.rb', line 13 def @options end |
Class Method Details
.avatar ⇒ Object
77 78 79 80 81 82 |
# File 'app/helpers/render_comments_tree_helper.rb', line 77 def avatar "<div class='userpic'> <img src='#{ @comment.avatar_url }' alt='userpic' /> #{ controls } </div>" end |
.children ⇒ Object
106 107 108 |
# File 'app/helpers/render_comments_tree_helper.rb', line 106 def children "<ol class='nested_set'>#{ [:children] }</ol>" end |
.controller ⇒ Object
Main Helpers
16 17 18 |
# File 'app/helpers/render_comments_tree_helper.rb', line 16 def controller @options[:controller] end |
.controls ⇒ Object
102 103 104 |
# File 'app/helpers/render_comments_tree_helper.rb', line 102 def controls "<div class='controls'>#{ moderator_controls }</div>" end |
.draft_comment ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/helpers/render_comments_tree_helper.rb', line 47 def draft_comment if visible_draft? || moderator? published_comment else "<li class='draft'> <div class='comment draft' id='comment_#{@comment.anchor}'> #{ t('the_comments.waiting_for_moderation') } #{ h.link_to '#', '#comment_' + @comment.anchor } </div> #{ children } </li>" end end |
.moderator? ⇒ Boolean
29 30 31 |
# File 'app/helpers/render_comments_tree_helper.rb', line 29 def moderator? controller.try(:current_user).try(:comments_moderator?, @comment) end |
.moderator_controls ⇒ Object
90 91 92 93 94 |
# File 'app/helpers/render_comments_tree_helper.rb', line 90 def moderator_controls if moderator? h.link_to(t('the_comments.edit'), h.edit_comment_url(@comment), class: :edit) end end |
.published_comment ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/helpers/render_comments_tree_helper.rb', line 61 def published_comment "<li> <div id='comment_#{@comment.anchor}' class='comment #{@comment.state}' data-comment-id='#{@comment.to_param}'> <div> #{ avatar } #{ } <div class='cbody'>#{ @comment.content }</div> #{ reply } </div> </div> <div class='form_holder'></div> #{ children } </li>" end |
.render_node(h, options) ⇒ Object
Render Methods
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/helpers/render_comments_tree_helper.rb', line 34 def render_node(h, ) @h, @options = h, @comment = [:node] @max_reply_depth = [:max_reply_depth] || TheComments.config.max_reply_depth if @comment.draft? draft_comment else @comment.published? published_comment end end |
.reply ⇒ Object
96 97 98 99 100 |
# File 'app/helpers/render_comments_tree_helper.rb', line 96 def reply if @comment.depth < (@max_reply_depth - 1) "<p class='reply'><a href='#' class='reply_link'>#{ t('the_comments.reply') }</a>" end end |
.t(str) ⇒ Object
20 21 22 |
# File 'app/helpers/render_comments_tree_helper.rb', line 20 def t str controller.t str end |
.userbar ⇒ Object
84 85 86 87 88 |
# File 'app/helpers/render_comments_tree_helper.rb', line 84 def anchor = h.link_to('#', '#comment_' + @comment.anchor) title = @comment.title.blank? ? t('the_comments.guest_name') : @comment.title "<div class='userbar'>#{ title } #{ anchor }</div>" end |
.visible_draft? ⇒ Boolean
Render Helpers
25 26 27 |
# File 'app/helpers/render_comments_tree_helper.rb', line 25 def visible_draft? controller.try(:comments_view_token) == @comment.view_token end |