From ed6b08e65bd9fe143aef158178473406e722aa58 Mon Sep 17 00:00:00 2001 From: Toks Date: Mon, 13 Oct 2014 17:44:40 -0400 Subject: [PATCH] Make large wiki/artist/pool title link to tag search --- app/models/artist.rb | 8 ++++++++ app/views/artists/show.html.erb | 2 +- app/views/pools/show.html.erb | 2 +- app/views/wiki_pages/show.html.erb | 2 +- app/views/wiki_pages/show_or_new.html.erb | 4 +++- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/models/artist.rb b/app/models/artist.rb index f12dfa551..72f9751ec 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -77,6 +77,10 @@ class Artist < ActiveRecord::Base self.name = Artist.normalize_name(name) end + def pretty_name + name.tr("_", " ") + end + def other_names_array other_names.try(:split, /\s/) end @@ -223,6 +227,10 @@ class Artist < ActiveRecord::Base TagAlias.active.find_by_antecedent_name(name).consequent_name end + def category_name + Tag.category_for(name) + end + def categorize_tag if new_record? || name_changed? Tag.find_or_create_by_name("artist:#{name}") diff --git a/app/views/artists/show.html.erb b/app/views/artists/show.html.erb index 26b42dddd..ec90c9f8c 100644 --- a/app/views/artists/show.html.erb +++ b/app/views/artists/show.html.erb @@ -1,6 +1,6 @@
-

Artist: <%= @artist.name.tr("_", " ") %>

+

Artist: <%= link_to @artist.pretty_name, posts_path(:tags => @artist.name), :class => "tag-type-#{@artist.category_name}" %>

<% if @artist.notes.present? && (!@artist.is_banned? || CurrentUser.user.is_member?) %>
diff --git a/app/views/pools/show.html.erb b/app/views/pools/show.html.erb index dfddb2ee6..8db7850fa 100644 --- a/app/views/pools/show.html.erb +++ b/app/views/pools/show.html.erb @@ -2,7 +2,7 @@

<%= @pool.pretty_category %>: - <%= link_to @pool.pretty_name, pool_path(@pool), :class => "pool-category-#{@pool.category}" %> + <%= link_to @pool.pretty_name, posts_path(:tags => "pool:#{@pool.id}"), :class => "pool-category-#{@pool.category}" %> <% if @pool.is_deleted? %> (deleted) <% end %> diff --git a/app/views/wiki_pages/show.html.erb b/app/views/wiki_pages/show.html.erb index 167e12f05..e8d260d2d 100644 --- a/app/views/wiki_pages/show.html.erb +++ b/app/views/wiki_pages/show.html.erb @@ -5,7 +5,7 @@

- <%= link_to @wiki_page.pretty_title, wiki_page_path(@wiki_page), :class => "tag-type-#{@wiki_page.category_name}" %> + <%= link_to @wiki_page.pretty_title, posts_path(:tags => @wiki_page.title), :class => "tag-type-#{@wiki_page.category_name}" %> <% if @wiki_page.is_locked? %> (locked) diff --git a/app/views/wiki_pages/show_or_new.html.erb b/app/views/wiki_pages/show_or_new.html.erb index e42ddce5a..7d0ddfd7a 100644 --- a/app/views/wiki_pages/show_or_new.html.erb +++ b/app/views/wiki_pages/show_or_new.html.erb @@ -3,7 +3,9 @@ <%= render "sidebar" %>
-

<%= @wiki_page.pretty_title %>

+

+ <%= link_to @wiki_page.pretty_title, posts_path(:tags => @wiki_page.title), :class => "tag-type-#{@wiki_page.category_name}" %> +

This wiki page does not exist. <%= link_to "Create new wiki page", new_wiki_page_path(:wiki_page => {:title => params[:title]}) %>.