Commit b5af58d17debc3e57a2d6fc244d6d9e5af0c8f04
1 parent
15720094
Exists in
master
and in
29 other branches
[comments-refactor-review] Small refactor on content_viewer_helper
Showing
1 changed file
with
3 additions
and
8 deletions
Show diff stats
app/helpers/content_viewer_helper.rb
@@ -2,19 +2,14 @@ module ContentViewerHelper | @@ -2,19 +2,14 @@ module ContentViewerHelper | ||
2 | 2 | ||
3 | include BlogHelper | 3 | include BlogHelper |
4 | include ForumHelper | 4 | include ForumHelper |
5 | - | ||
6 | - def display_number_of_comments(n) | ||
7 | - base_str = "<span class='comment-count hide'>#{n}</span>" | ||
8 | 5 | ||
6 | + def number_of_comments(article) | ||
7 | + n = article.comments.without_spam.count | ||
8 | + base_str = "<span class='comment-count hide'>#{n}</span>" | ||
9 | amount_str = n == 0 ? _('no comments yet') : (n == 1 ? _('One comment') : _('%s comments') % n) | 9 | amount_str = n == 0 ? _('no comments yet') : (n == 1 ? _('One comment') : _('%s comments') % n) |
10 | - | ||
11 | base_str + "<span class='comment-count-write-out'>#{amount_str}</span>" | 10 | base_str + "<span class='comment-count-write-out'>#{amount_str}</span>" |
12 | end | 11 | end |
13 | 12 | ||
14 | - def number_of_comments(article) | ||
15 | - display_number_of_comments(article.comments.without_spam.count) | ||
16 | - end | ||
17 | - | ||
18 | def article_title(article, args = {}) | 13 | def article_title(article, args = {}) |
19 | title = article.display_title if article.kind_of?(UploadedFile) && article.image? | 14 | title = article.display_title if article.kind_of?(UploadedFile) && article.image? |
20 | title = article.title if title.blank? | 15 | title = article.title if title.blank? |