Keep a blank line before and after private Keep a blank line before and after protected Remove extra empty line at class body end Remove extra blank line Add final newline Use 2 (not 3) spaces for indentation Use 2 (not 4) spaces for indentation Remove space before comma Add space after comma Remove trailing whitespaces Remove unnecessary spacing Use snake_case for variable names Do not use then for multi-line if Remove unused block argument - i Use the new Ruby 1.9 hash syntax Remove unused assignment to variable Indent when as deep as case Align attributes Align end with def
43 lines
1.0 KiB
Ruby
43 lines
1.0 KiB
Ruby
module CommentsHelper
|
|
|
|
def comment_link_text(parent_id)
|
|
parent_id.present? ? t("comments_helper.reply_link") : t("comments_helper.comment_link")
|
|
end
|
|
|
|
def comment_button_text(parent_id)
|
|
parent_id.present? ? t("comments_helper.reply_button") : t("comments_helper.comment_button")
|
|
end
|
|
|
|
def parent_or_commentable_dom_id(parent_id, commentable)
|
|
parent_id.blank? ? dom_id(commentable) : "comment_#{parent_id}"
|
|
end
|
|
|
|
def child_comments_of(parent)
|
|
if @comment_tree.present?
|
|
@comment_tree.ordered_children_of(parent)
|
|
else
|
|
parent.children
|
|
end
|
|
end
|
|
|
|
def user_level_class(comment)
|
|
if comment.as_administrator?
|
|
"is-admin"
|
|
elsif comment.as_moderator?
|
|
"is-moderator"
|
|
elsif comment.user.official?
|
|
"level-#{comment.user.official_level}"
|
|
else
|
|
"" # Default no special user class
|
|
end
|
|
end
|
|
|
|
def comment_author_class(comment, author_id)
|
|
if comment.user_id == author_id
|
|
"is-author"
|
|
else
|
|
"" # Default not author class
|
|
end
|
|
end
|
|
|
|
end |