From 8da4eabb962ac8b0c93df935b53e81a0c384ef52 Mon Sep 17 00:00:00 2001 From: albert Date: Fri, 2 Nov 2012 18:22:08 -0400 Subject: [PATCH] add humanized tag string for posts --- app/logical/post_sets/favorite.rb | 4 ++++ app/logical/post_sets/pool.rb | 4 ++++ app/logical/post_sets/post.rb | 4 ++++ app/presenters/post_presenter.rb | 2 +- app/views/posts/index.html.erb | 2 +- app/views/posts/show.html.erb | 2 +- 6 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/logical/post_sets/favorite.rb b/app/logical/post_sets/favorite.rb index a45f9734f..3d84bb45f 100644 --- a/app/logical/post_sets/favorite.rb +++ b/app/logical/post_sets/favorite.rb @@ -15,6 +15,10 @@ module PostSets tag_array.uniq.join(" ") end + def humanized_tag_string + "fav:#{user.pretty_name}" + end + def posts favorites.order("favorites.id desc").includes(:post).map(&:post) end diff --git a/app/logical/post_sets/pool.rb b/app/logical/post_sets/pool.rb index 0d345b5f4..888075e65 100644 --- a/app/logical/post_sets/pool.rb +++ b/app/logical/post_sets/pool.rb @@ -37,6 +37,10 @@ module PostSets tag_array.join("") end + def humanized_tag_string + "pool:#{pool.pretty_name}" + end + def presenter @presenter ||= PostSetPresenters::Pool.new(self) end diff --git a/app/logical/post_sets/post.rb b/app/logical/post_sets/post.rb index 4534fc9dc..50ff5990f 100644 --- a/app/logical/post_sets/post.rb +++ b/app/logical/post_sets/post.rb @@ -11,6 +11,10 @@ module PostSets @tag_string ||= tag_array.uniq.join(" ") end + def humanized_tag_string + tag_array.slice(0, 25).join(" ").tr("_", " ") + end + def has_wiki? tag_array.any? && ::WikiPage.titled(tag_string).exists? end diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index 486a7c4e3..af375de66 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -28,7 +28,7 @@ class PostPresenter < Presenter end def humanized_tag_string - @post.tag_string.split(/ /).join(", ").tr("_", " ") + @post.tag_string.split(/ /).slice(0, 25).join(", ").tr("_", " ") end def humanized_essential_tag_string diff --git a/app/views/posts/index.html.erb b/app/views/posts/index.html.erb index 13ec74449..59155319b 100644 --- a/app/views/posts/index.html.erb +++ b/app/views/posts/index.html.erb @@ -29,7 +29,7 @@ <% content_for(:page_title) do %> <% if @post_set.tag_string.present? %> - <%= @post_set.tag_string %> - <%= Danbooru.config.app_name %> + <%= @post_set.humanized_tag_string %> - <%= Danbooru.config.app_name %> <% else %> <%= Danbooru.config.app_name %> <% end %> diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb index c8d48e442..05be07e06 100644 --- a/app/views/posts/show.html.erb +++ b/app/views/posts/show.html.erb @@ -80,7 +80,7 @@ <% content_for(:page_title) do %> - <%= @post.tag_string %> - <%= Danbooru.config.app_name %> + <%= @post.presenter.humanized_tag_string %> - <%= Danbooru.config.app_name %> <% end %> <% content_for(:html_header) do %>