move explore links to sidebar, fix popular searches action

This commit is contained in:
r888888888
2017-11-13 11:14:09 -08:00
parent e739dc77d7
commit 36948bbf33
8 changed files with 45 additions and 22 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -1,6 +1,7 @@
<div id="c-explore-posts">
<div id="a-missed-searches">
<h1>Missed Searches (past seven days)</h1>
<h1>Missed Searches</h1>
<p>Over the past seven days.</p>
<table class="striped" width="100%">
<thead>

View File

@@ -1,6 +1,6 @@
<div id="c-explore-posts">
<div id="a-searches">
<h1>Popular Searches: <%= @search_service.date %> (by <%= @search_service.scale %>)</h1>
<h1>Popular Searches - <%= @search_service.date %></h1>
<table class="striped" width="100%">
<thead>
@@ -19,11 +19,12 @@
</tbody>
</table>
<p style="margin-top: 2em;">
<%= link_to "< Previous", searches_explore_posts_path(:date => 1.day.ago(@date)) %>
<%= link_to "Next >", searches_explore_posts_path(:date => 1.day.since(@date)) %>
</p>
<div class="paginator">
<menu>
<li><%= link_to "< Previous", searches_explore_posts_path(:date => 1.day.ago(@date).to_date), :class => "arrow" %></li>
<li><%= link_to "Next >", searches_explore_posts_path(:date => 1.day.since(@date).to_date), :class => "arrow" %></li>
</menu>
</div>
</div>
</div>

View File

@@ -1,12 +1,17 @@
<div id="c-explore-posts">
<div id="a-popular">
<h1>Most Viewed: <%= @post_set.presenter.date %></h1>
<%= @post_set.presenter.nav_links(self) %>
<h1>Most Viewed - <%= @post_set.presenter.date %></h1>
<%= render "posts/partials/common/inline_blacklist" %>
<%= @post_set.presenter.post_previews_html(self) %>
<div class="paginator">
<menu>
<li><%= link_to "< Previous", viewed_explore_posts_path(:date => 1.day.ago(@date).to_date) %></li>
<li><%= link_to "Next >", viewed_explore_posts_path(:date => 1.day.since(@date).to_date) %></li>
</menu>
</div>
</div>
</div>

View File

@@ -2,14 +2,10 @@
<menu>
<li><%= link_to "Listing", posts_path %></li>
<li id="secondary-links-posts-upload" class="nonessential"><%= link_to "Upload", new_upload_path %></li>
<li id="secondary-links-posts-popular"><%= link_to "Popular", popular_explore_posts_path %></li>
<li id="secondary-links-posts-hot"><%= link_to "Hot", posts_path(:tags => "order:rank") %></li>
<% if PopularSearchService.enabled? %>
<li id="secondary-links-posts-searches"><%= link_to "Searches", searches_explore_posts_path %></li>
<% end %>
<li id="secondary-links-posts-hot"><%= link_to "Hot", posts_path(:tags => "order:rank", :d => "1") %></li>
<% unless CurrentUser.is_anonymous? %>
<li id="secondary-links-posts-favorites"><%= link_to "Favorites", favorites_path %></li>
<li id="secondary-links-posts-favorite-groups"><%= link_to "Favorite groups", favorite_groups_path %></li>
<li id="secondary-links-posts-favorite-groups"><%= link_to "Fav groups", favorite_groups_path %></li>
<% if CurrentUser.has_saved_searches? %>
<li id="secondary-links-posts-saved-searches"><%= link_to "Saved searches", posts_path(:tags => "search:all") %></li>
<% end %>

View File

@@ -1,10 +1,21 @@
<section id="related-box">
<h1>Related</h1>
<ul id="related-list">
<li><%= link_to "Deleted posts", posts_path(:tags => "#{params[:tags]} status:deleted"), :rel => "nofollow" %></li>
<% if discover_mode? %>
<li id="secondary-links-posts-hot"><%= link_to "Hot", posts_path(:tags => "order:rank") %></li>
<li id="secondary-links-posts-popular"><%= link_to "Popular", popular_explore_posts_path %></li>
<% if PopularSearchService.enabled? %>
<li><%= link_to "Searches", searches_explore_posts_path %></li>
<% end %>
<% if PostViewCountService.enabled? %>
<li><%= link_to "Viewed", viewed_explore_posts_path %></li>
<% end %>
<% end %>
<li><%= link_to "Random post", random_posts_path(:tags => params[:tags]), :id => "random-post", :rel => "nofollow" %></li>
<li><%= link_to "Deleted", posts_path(:tags => "#{params[:tags]} status:deleted"), :rel => "nofollow" %></li>
<li><%= link_to "Post count", posts_counts_path(:tags => params[:tags]) %></li>
<li><%= link_to "Random", random_posts_path(:tags => params[:tags]), :id => "random-post", :rel => "nofollow" %></li>
<li><%= link_to "Count", posts_counts_path(:tags => params[:tags]) %></li>
</ul>
</section>