Commit f818f402e5f8c945879528d0106a38109461c5f8
1 parent
4e483e9c
Exists in
staging
and in
42 other branches
Add more popular to articles menus
Showing
3 changed files
with
14 additions
and
9 deletions
Show diff stats
app/controllers/public/search_controller.rb
| ... | ... | @@ -34,7 +34,7 @@ class SearchController < PublicController |
| 34 | 34 | if !@empty_query |
| 35 | 35 | full_text_search ['public:true'] |
| 36 | 36 | elsif params[:filter] |
| 37 | - @results[@asset] = @environment.articles.more_recent.paginate(paginate_options) | |
| 37 | + @results[@asset] = @environment.articles.public.send(@filter).paginate(paginate_options) | |
| 38 | 38 | end |
| 39 | 39 | end |
| 40 | 40 | |
| ... | ... | @@ -228,7 +228,7 @@ class SearchController < PublicController |
| 228 | 228 | def filter_description(asset, filter) |
| 229 | 229 | { |
| 230 | 230 | 'articles_more_recent' => _('More recent contents from network'), |
| 231 | - 'articles_more_popular' => _('More popular contents from network'), | |
| 231 | + 'articles_more_popular' => _('More read contents from network'), | |
| 232 | 232 | 'people_more_recent' => _('More recent people from network'), |
| 233 | 233 | 'people_more_active' => _('More active people from network'), |
| 234 | 234 | 'people_more_popular' => _('More popular people from network'), | ... | ... |
app/helpers/application_helper.rb
| ... | ... | @@ -1093,7 +1093,7 @@ module ApplicationHelper |
| 1093 | 1093 | def search_contents_menu |
| 1094 | 1094 | links = [ |
| 1095 | 1095 | {s_('contents|More Recent') => {:href => url_for({:controller => 'search', :action => 'contents', :filter => 'more_recent'})}}, |
| 1096 | - #{s_('contents|More Popular') => {:href => url_for({:controller => 'search', :action => 'contents', :filter => 'more_popular'})}} | |
| 1096 | + {s_('contents|More Read') => {:href => url_for({:controller => 'search', :action => 'contents', :filter => 'more_popular'})}} | |
| 1097 | 1097 | ] |
| 1098 | 1098 | if logged_in? |
| 1099 | 1099 | links.push(_('New Content') => lightbox_options({:href => url_for({:controller => 'cms', :action => 'new', :profile => current_user.login, :cms => true})})) | ... | ... |
app/models/article.rb
| ... | ... | @@ -139,6 +139,9 @@ class Article < ActiveRecord::Base |
| 139 | 139 | {:conditions => [ 'parent_id is null and profile_id = ?', profile.id ]} |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | + named_scope :public, | |
| 143 | + :conditions => [ "advertise = ? AND published = ? AND profiles.visible = ? AND profiles.public_profile = ?", true, true, true, true ] | |
| 144 | + | |
| 142 | 145 | named_scope :more_recent, |
| 143 | 146 | :conditions => [ "advertise = ? AND published = ? AND profiles.visible = ? AND profiles.public_profile = ? AND |
| 144 | 147 | ((articles.type != ?) OR articles.type is NULL)", |
| ... | ... | @@ -146,6 +149,14 @@ class Article < ActiveRecord::Base |
| 146 | 149 | ], |
| 147 | 150 | :order => 'articles.published_at desc, articles.id desc' |
| 148 | 151 | |
| 152 | + # retrives the most commented articles, sorted by the comment count (largest | |
| 153 | + # first) | |
| 154 | + def self.most_commented(limit) | |
| 155 | + paginate(:order => 'comments_count DESC', :page => 1, :per_page => limit) | |
| 156 | + end | |
| 157 | + | |
| 158 | + named_scope :more_popular, :order => 'hits DESC' | |
| 159 | + | |
| 149 | 160 | # retrieves the latest +limit+ articles, sorted from the most recent to the |
| 150 | 161 | # oldest. |
| 151 | 162 | # |
| ... | ... | @@ -178,12 +189,6 @@ class Article < ActiveRecord::Base |
| 178 | 189 | end |
| 179 | 190 | end |
| 180 | 191 | |
| 181 | - # retrives the most commented articles, sorted by the comment count (largest | |
| 182 | - # first) | |
| 183 | - def self.most_commented(limit) | |
| 184 | - paginate(:order => 'comments_count DESC', :page => 1, :per_page => limit) | |
| 185 | - end | |
| 186 | - | |
| 187 | 192 | # produces the HTML code that is to be displayed as this article's contents. |
| 188 | 193 | # |
| 189 | 194 | # The implementation in this class just provides the +body+ attribute as the | ... | ... |