diff --git a/app/assets/stylesheets/specific/explore.css.scss b/app/assets/stylesheets/specific/explore.css.scss index 283129beb..62b76e2d6 100644 --- a/app/assets/stylesheets/specific/explore.css.scss +++ b/app/assets/stylesheets/specific/explore.css.scss @@ -5,11 +5,15 @@ div#c-explore-posts { h1 { font-size: 3em; } + + p.byline { + font-size: 1.2em; + font-style: italic; + } } div.posts { padding: 1em; margin-bottom: 2em; - background: #EEF; } } diff --git a/app/models/tag.rb b/app/models/tag.rb index 0c05a80a3..3a78a2794 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -117,6 +117,27 @@ class Tag < ActiveRecord::Base end module StatisticsMethods + def trending + Cache.get("popular-tags", 1.hour) do + CurrentUser.scoped(User.admins.first, "127.0.0.1") do + n = 1 + results = [] + + while results.empty? && n < 256 + query = n.days.ago.strftime("date:>%Y-%m-%d") + results = RelatedTagCalculator.calculate_from_sample_to_array(query) + n *= 2 + end + + results.map! do |tag_name, recent_count| + tag = Tag.find_or_create_by_name(tag_name) + [tag_name, recent_count.to_f / tag.post_count.to_f] + end + + results.sort_by! {|x| -x[1]}.map(&:first) + end + end + end end module NameMethods diff --git a/app/presenters/intro_presenter.rb b/app/presenters/intro_presenter.rb index d405e196d..1bb0607af 100644 --- a/app/presenters/intro_presenter.rb +++ b/app/presenters/intro_presenter.rb @@ -1,6 +1,6 @@ class IntroPresenter def popular_tags - Tag.order("post_count desc").limit(8).map(&:name) + Tag.where("category in (3, 4)").order("post_count desc").limit(8).map(&:name) end def each diff --git a/app/presenters/post_set_presenters/post.rb b/app/presenters/post_set_presenters/post.rb index 4d5058018..f360e7254 100644 --- a/app/presenters/post_set_presenters/post.rb +++ b/app/presenters/post_set_presenters/post.rb @@ -23,25 +23,7 @@ module PostSetPresenters end def popular_tags - Cache.get("popular-tags", 1.hour) do - CurrentUser.scoped(User.admins.first, "127.0.0.1") do - n = 1 - results = [] - - while results.empty? && n < 256 - query = n.days.ago.strftime("date:>%Y-%m-%d") - results = RelatedTagCalculator.calculate_from_sample_to_array(query) - n *= 2 - end - - results.map! do |tag_name, recent_count| - tag = Tag.find_or_create_by_name(tag_name) - [tag_name, recent_count.to_f / tag.post_count.to_f] - end - - results.sort_by! {|x| -x[1]}.map(&:first) - end - end + Tag.trending end def pattern_tags diff --git a/app/views/explore/posts/intro.html.erb b/app/views/explore/posts/intro.html.erb index 8d3a8fcfb..cc81f5613 100644 --- a/app/views/explore/posts/intro.html.erb +++ b/app/views/explore/posts/intro.html.erb @@ -10,6 +10,8 @@ <% end %> +

Type in your favorite anime, manga, or character (last name first). Here are some examples:

+ <% @presenter.each do |tag, post_set| %>

<%= link_to tag, posts_path(:tags => tag) %>

@@ -19,3 +21,7 @@ <% end %>
+ +<% content_for(:page_title) do %> + <%= Danbooru.config.app_name %> +<% end %>