diff --git a/app/assets/stylesheets/specific/artists.css.scss b/app/assets/stylesheets/specific/artists.css.scss index b6ff3e559..4612c5332 100644 --- a/app/assets/stylesheets/specific/artists.css.scss +++ b/app/assets/stylesheets/specific/artists.css.scss @@ -1,3 +1,5 @@ +@import "../common/000_vars.css.scss"; + div#c-artists { span.new-artist { font-weight: bold; @@ -19,4 +21,13 @@ div#c-artists { height: 5em; } } + + div.recent-posts { + margin-top: 1em; + + h1 { + font-size: $h2_size; + margin: 0; + } + } } diff --git a/app/assets/stylesheets/specific/posts.css.scss b/app/assets/stylesheets/specific/posts.css.scss index 6bec460ee..af336a166 100644 --- a/app/assets/stylesheets/specific/posts.css.scss +++ b/app/assets/stylesheets/specific/posts.css.scss @@ -20,6 +20,11 @@ article.post-preview.blacklisted-active { } div#c-posts { + span.post-count { + color: #CCC; + margin-left: 0.2em; + } + div.notice { font-size: 0.8em; padding: 1em; diff --git a/app/models/tag.rb b/app/models/tag.rb index 01ceeac05..670ec6d30 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -21,7 +21,13 @@ class Tag < ActiveRecord::Base Danbooru.config.tag_category_mapping[string.downcase] || 0 end end - + + module CountMethods + def counts_for(tag_names) + select_all_sql("SELECT name, post_count FROM tags WHERE name IN (?)", tag_names) + end + end + module ViewCountMethods def increment_view_count(name) Cache.incr("tvc:#{Cache.sanitize(name)}") @@ -353,6 +359,7 @@ class Tag < ActiveRecord::Base end end + extend CountMethods extend ViewCountMethods include CategoryMethods extend StatisticsMethods diff --git a/app/presenters/tag_set_presenter.rb b/app/presenters/tag_set_presenter.rb index e6fc2f74d..94b5b9f53 100644 --- a/app/presenters/tag_set_presenter.rb +++ b/app/presenters/tag_set_presenter.rb @@ -24,6 +24,13 @@ private @categories ||= Tag.categories_for(@tags) end + def counts + @counts ||= Tag.counts_for(@tags).inject({}) do |hash, x| + hash[x["name"]] = x["post_count"] + hash + end + end + def build_list_item(tag, template, options) html = "" html << %{