diff --git a/app/controllers/explore/posts_controller.rb b/app/controllers/explore/posts_controller.rb index eadbb4533..35a396ce2 100644 --- a/app/controllers/explore/posts_controller.rb +++ b/app/controllers/explore/posts_controller.rb @@ -1,6 +1,7 @@ module Explore class PostsController < ApplicationController respond_to :html, :xml, :json + before_filter :set_date, only: [:searches, :viewed] def popular @post_set = PostSets::Popular.new(params[:date], params[:scale]) @@ -9,13 +10,12 @@ module Explore end def viewed - @post_set = PostSets::MostViewed.new(params[:date]) + @post_set = PostSets::MostViewed.new(@date.to_s) @posts = @post_set.posts respond_with(@posts) end def searches - @date = params[:date] ? Date.parse(params[:date]) : Date.today @search_service = PopularSearchService.new(@date) end @@ -27,5 +27,10 @@ module Explore @presenter = IntroPresenter.new render :layout => "blank" end + + private + def set_date + @date = params[:date] ? Date.parse(params[:date]) : Date.today + end end end diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb index 39e358433..64ce28c6c 100644 --- a/app/helpers/posts_helper.rb +++ b/app/helpers/posts_helper.rb @@ -1,4 +1,8 @@ module PostsHelper + def discover_mode? + params[:tags] =~ /order:rank/ || params[:action] =~ /searches|viewed/ + end + def next_page_url current_page = (params[:page] || 1).to_i dup_params = params.dup diff --git a/app/logical/post_view_count_service.rb b/app/logical/post_view_count_service.rb index b0d7436d8..95f23eecc 100644 --- a/app/logical/post_view_count_service.rb +++ b/app/logical/post_view_count_service.rb @@ -33,6 +33,6 @@ class PostViewCountService def popular_posts(date = Date.today) ranking = fetch_rank(date) || [] - ranking.map {|x| Post.find(x[0])} + ranking.slice(0, 50).map {|x| Post.find(x[0])} end end diff --git a/app/views/explore/posts/missed_searches.html.erb b/app/views/explore/posts/missed_searches.html.erb index b676aa125..3bedafae6 100644 --- a/app/views/explore/posts/missed_searches.html.erb +++ b/app/views/explore/posts/missed_searches.html.erb @@ -1,6 +1,7 @@
-

Missed Searches (past seven days)

+

Missed Searches

+

Over the past seven days.

diff --git a/app/views/explore/posts/searches.html.erb b/app/views/explore/posts/searches.html.erb index 51ac184d3..67e6410ca 100644 --- a/app/views/explore/posts/searches.html.erb +++ b/app/views/explore/posts/searches.html.erb @@ -1,6 +1,6 @@
-

Popular Searches: <%= @search_service.date %> (by <%= @search_service.scale %>)

+

Popular Searches - <%= @search_service.date %>

@@ -19,11 +19,12 @@
-

- <%= link_to "< Previous", searches_explore_posts_path(:date => 1.day.ago(@date)) %> - - <%= link_to "Next >", searches_explore_posts_path(:date => 1.day.since(@date)) %> -

+
+ +
  • <%= link_to "< Previous", searches_explore_posts_path(:date => 1.day.ago(@date).to_date), :class => "arrow" %>
  • +
  • <%= link_to "Next >", searches_explore_posts_path(:date => 1.day.since(@date).to_date), :class => "arrow" %>
  • +
    +
    diff --git a/app/views/explore/posts/viewed.html.erb b/app/views/explore/posts/viewed.html.erb index b2d412b3f..4d19bfb5b 100644 --- a/app/views/explore/posts/viewed.html.erb +++ b/app/views/explore/posts/viewed.html.erb @@ -1,12 +1,17 @@
    diff --git a/app/views/posts/partials/common/_secondary_links.html.erb b/app/views/posts/partials/common/_secondary_links.html.erb index 319b24f4f..754dac440 100644 --- a/app/views/posts/partials/common/_secondary_links.html.erb +++ b/app/views/posts/partials/common/_secondary_links.html.erb @@ -2,14 +2,10 @@
  • <%= link_to "Listing", posts_path %>
  • - - - <% if PopularSearchService.enabled? %> - - <% end %> + <% unless CurrentUser.is_anonymous? %> - + <% if CurrentUser.has_saved_searches? %> <% end %> diff --git a/app/views/posts/partials/index/_related.html.erb b/app/views/posts/partials/index/_related.html.erb index c6f70806d..8d69bfdd9 100644 --- a/app/views/posts/partials/index/_related.html.erb +++ b/app/views/posts/partials/index/_related.html.erb @@ -1,10 +1,21 @@