Module: MuckCommentsHelper
- Defined in:
- app/helpers/muck_comments_helper.rb
Instance Method Summary collapse
-
#comment_form(parent, comment = nil, render_new = false, comment_button_class = 'comment-submit', comment_button_text = nil) ⇒ Object
parent is the object to which the comments will be attached comment is the optional parent comment for the new comment.
-
#delete_comment(comment, button_type = :button, button_text = t("muck.activities.delete")) ⇒ Object
Renders a delete button for a comment.
-
#disqus(disqus_short_name) ⇒ Object
outputs a partial that will embed disqus into any page with a unique url Extra instructions from the disqus site: Append #disqus_thread to the end of permalinks.
- #latest_comments(limit = 5, truncate_comment = true, length = 30, omission = '...') ⇒ Object
- #latest_simple_comments(limit = 5, truncate_comment = true, length = 30, omission = '...') ⇒ Object
- #limit_comment(text, truncate_comment = false, length = 30, omission = '...') ⇒ Object
-
#new_comment_for_path(parent) ⇒ Object
Generates a link to the ‘new’ page for a comment.
-
#new_comment_path_with_parent(parent) ⇒ Object
make_muck_parent_params is defined in muck-engine and used by many of the engines.
- #show_comments(comments, truncate_comment = false, length = 30, omission = '...') ⇒ Object
-
#tiny_mce_comment_form(parent, comment = nil, render_new = false, comment_button_class = 'comment-submit', comment_button_text = nil) ⇒ Object
Render a comment for using the tiny mce editor.
Instance Method Details
#comment_form(parent, comment = nil, render_new = false, comment_button_class = 'comment-submit', comment_button_text = nil) ⇒ Object
parent is the object to which the comments will be attached comment is the optional parent comment for the new comment.
17 18 19 20 21 22 23 |
# File 'app/helpers/muck_comments_helper.rb', line 17 def comment_form(parent, comment = nil, render_new = false, = 'comment-submit', = nil) render :partial => 'comments/form', :locals => {:parent => parent, :comment => comment, :render_new => render_new, :comment_button_class => , :comment_button_text => } end |
#delete_comment(comment, button_type = :button, button_text = t("muck.activities.delete")) ⇒ Object
Renders a delete button for a comment
52 53 54 55 56 57 58 |
# File 'app/helpers/muck_comments_helper.rb', line 52 def delete_comment(comment, = :button, = t("muck.activities.delete")) render :partial => 'shared/delete', :locals => { :delete_object => comment, :button_type => , :button_text => , :form_class => 'comment-delete', :delete_path => comment_path(comment, :format => 'js') } end |
#disqus(disqus_short_name) ⇒ Object
outputs a partial that will embed disqus into any page with a unique url
Extra instructions from the disqus site: Append #disqus_thread to the end of permalinks. The comment count code will replace the text of these links with the comment count. For example, you may have a link with this HTML: <a href=“example.com/my_article.html#disqus_thread”>Comments</a> The comment count code will replace the text “Comments” with the number of comments on the page example.com/my_article.html
disqus_short_name: The short name you selected when setting up your site.
76 77 78 |
# File 'app/helpers/muck_comments_helper.rb', line 76 def disqus(disqus_short_name) render :partial => 'external/disqus', :locals => { :disqus_short_name => disqus_short_name } end |
#latest_comments(limit = 5, truncate_comment = true, length = 30, omission = '...') ⇒ Object
7 8 9 |
# File 'app/helpers/muck_comments_helper.rb', line 7 def latest_comments(limit = 5, truncate_comment = true, length = 30, omission = '...') render :partial => 'comments/comment', :collection => Comment.by_newest.limit(limit), :locals => { :truncate_comment => truncate_comment, :length => length, :omission => omission } end |
#latest_simple_comments(limit = 5, truncate_comment = true, length = 30, omission = '...') ⇒ Object
3 4 5 |
# File 'app/helpers/muck_comments_helper.rb', line 3 def latest_simple_comments(limit = 5, truncate_comment = true, length = 30, omission = '...') render :partial => 'comments/simple_comment', :collection => Comment.by_newest.limit(limit), :locals => { :truncate_comment => truncate_comment, :length => length, :omission => omission } end |
#limit_comment(text, truncate_comment = false, length = 30, omission = '...') ⇒ Object
60 61 62 63 64 65 66 |
# File 'app/helpers/muck_comments_helper.rb', line 60 def limit_comment(text, truncate_comment = false, length = 30, omission = '...') if truncate_comment html_summarize(text, length, omission) else text end end |
#new_comment_for_path(parent) ⇒ Object
Generates a link to the ‘new’ page for a comment
47 48 49 |
# File 'app/helpers/muck_comments_helper.rb', line 47 def new_comment_for_path(parent) new_comment_path(make_muck_parent_params(parent)) end |
#new_comment_path_with_parent(parent) ⇒ Object
make_muck_parent_params is defined in muck-engine and used by many of the engines. This will generate a url suitable for a form to post a create to.
42 43 44 |
# File 'app/helpers/muck_comments_helper.rb', line 42 def new_comment_path_with_parent(parent) comments_path(make_muck_parent_params(parent)) end |
#show_comments(comments, truncate_comment = false, length = 30, omission = '...') ⇒ Object
11 12 13 |
# File 'app/helpers/muck_comments_helper.rb', line 11 def show_comments(comments, truncate_comment = false, length = 30, omission = '...') render :partial => 'comments/comment', :collection => comments, :locals => { :truncate_comment => truncate_comment, :length => length, :omission => omission } end |
#tiny_mce_comment_form(parent, comment = nil, render_new = false, comment_button_class = 'comment-submit', comment_button_text = nil) ⇒ Object
Render a comment for using the tiny mce editor. Note that this method requires that muck-contents be installed and configured correctly and that the controller that calls the page where this method is called have ‘uses_tiny_mce’ defined ie:
uses_tiny_mce(:options => MuckContents.configuration.,
:only => [:new, :create, :edit, :update])
parent is the object to which the comments will be attached comment is the optional parent comment for the new comment.
32 33 34 35 36 37 38 |
# File 'app/helpers/muck_comments_helper.rb', line 32 def tiny_mce_comment_form(parent, comment = nil, render_new = false, = 'comment-submit', = nil) render :partial => 'comments/tiny_mce_form', :locals => {:parent => parent, :comment => comment, :render_new => render_new, :comment_button_class => , :comment_button_text => } end |