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 << %{
  • } @@ -35,7 +42,9 @@ private end humanized_tag = tag.tr("_", " ") - html << %{#{h(humanized_tag)}} + html << %{#{h(humanized_tag)} } + html << %{} + counts[tag].to_s + %{} + html << "
  • " html end diff --git a/app/views/artists/show.html.erb b/app/views/artists/show.html.erb index 13694b388..545956818 100644 --- a/app/views/artists/show.html.erb +++ b/app/views/artists/show.html.erb @@ -70,7 +70,7 @@ -
    +

    Recent Posts

    <%= @post_set.presenter.post_previews_html(self) %> diff --git a/config/deploy.rb b/config/deploy.rb index 3e82cb598..5a89c4cf2 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -75,6 +75,11 @@ namespace :deploy do end end + desc "Precompiles assets" + task :precompile_assets do + rake "assets:precompile" + end + desc "Restart the application" task :restart do run "touch #{current_path}/tmp/restart.txt"