split out tag types in pots/show page

This commit is contained in:
albert
2012-10-02 18:37:06 -04:00
parent fbdf0d9679
commit 7a8ea0456a
5 changed files with 78 additions and 9 deletions

View File

@@ -75,6 +75,10 @@ div#c-posts {
color: #666; color: #666;
} }
} }
aside#sidebar > section > ul {
margin-bottom: 1em;
}
aside#sidebar > section > ul li { aside#sidebar > section > ul li {
list-style-type: none; list-style-type: none;

View File

@@ -43,6 +43,11 @@ class PostPresenter < Presenter
@tag_set_presenter.tag_list_html(template, options.merge(:show_extra_links => CurrentUser.user.is_privileged?)) @tag_set_presenter.tag_list_html(template, options.merge(:show_extra_links => CurrentUser.user.is_privileged?))
end end
def split_tag_list_html(template, options = {})
@tag_set_presenter ||= TagSetPresenter.new(@post.tag_array)
@tag_set_presenter.split_tag_list_html(template, options.merge(:show_extra_links => CurrentUser.user.is_privileged?))
end
def post_footer_for_pool_html(template) def post_footer_for_pool_html(template)
if template.params[:pool_id] if template.params[:pool_id]
pool = Pool.where(:id => template.params[:pool_id]).first pool = Pool.where(:id => template.params[:pool_id]).first
@@ -91,7 +96,7 @@ class PostPresenter < Presenter
end end
html << " " html << " "
html << template.link_to(pool.name, template.pool_path(pool)) html << template.link_to(pool.pretty_name, template.pool_path(pool))
html << "</li>" html << "</li>"
html html
end end

View File

@@ -11,15 +11,76 @@ class TagSetPresenter < Presenter
def tag_list_html(template, options = {}) def tag_list_html(template, options = {})
html = "" html = ""
html << "<ul>" if @tags.present?
Array(@tags).each do |tag| html << "<ul>"
html << build_list_item(tag, template, options) @tags.each do |tag|
html << build_list_item(tag, template, options)
end
html << "</ul>"
end end
html << "</ul>"
html.html_safe
end
def split_tag_list_html(template, options = {})
html = ""
if copyright_tags.any?
html << '<h1>Copyrights</h1>'
html << "<ul>"
copyright_tags.keys.each do |tag|
html << build_list_item(tag, template, options)
end
html << "</ul>"
end
if character_tags.any?
html << '<h1>Characters</h1>'
html << "<ul>"
character_tags.keys.each do |tag|
html << build_list_item(tag, template, options)
end
html << "</ul>"
end
if artist_tags.any?
html << '<h1>Artist</h1>'
html << "<ul>"
artist_tags.keys.each do |tag|
html << build_list_item(tag, template, options)
end
html << "</ul>"
end
if general_tags.any?
html << '<h1>Tags</h1>'
html << "<ul>"
general_tags.keys.each do |tag|
html << build_list_item(tag, template, options)
end
html << "</ul>"
end
html.html_safe html.html_safe
end end
private private
def general_tags
@general_tags ||= categories.select {|k, v| v == Tag.categories.general}
end
def copyright_tags
@copyright_tags ||= categories.select {|k, v| v == Tag.categories.copyright}
end
def character_tags
@character_tags ||= categories.select {|k, v| v == Tag.categories.character}
end
def artist_tags
@artist_tags ||= categories.select {|k, v| v == Tag.categories.artist}
end
def categories def categories
@categories ||= Tag.categories_for(@tags) @categories ||= Tag.categories_for(@tags)
end end
@@ -37,7 +98,7 @@ private
current_query = template.params[:tags] || "" current_query = template.params[:tags] || ""
unless options[:name_only] unless options[:name_only]
if categories[tag] == 1 if categories[tag] == Tag.categories.artist
html << %{<a class="wiki-link" href="/artists/show_or_new?name=#{u(tag)}">?</a> } html << %{<a class="wiki-link" href="/artists/show_or_new?name=#{u(tag)}">?</a> }
else else
html << %{<a class="wiki-link" href="/wiki_pages?title=#{u(tag)}">?</a> } html << %{<a class="wiki-link" href="/wiki_pages?title=#{u(tag)}">?</a> }

View File

@@ -5,7 +5,7 @@
<% end %> <% end %>
<%= form_for(post, :html => {:class => "simple_form"}) do |f| %> <%= form_for(post, :html => {:class => "simple_form"}) do |f| %>
<%= f.hidden_field :old_tags, :value => post.tag_string %> <%= f.hidden_field :old_tag_string, :value => post.tag_string %>
<div class="input"> <div class="input">
<% if post.is_rating_locked? %> <% if post.is_rating_locked? %>

View File

@@ -11,8 +11,7 @@
<% end %> <% end %>
<section> <section>
<h1>Tags</h1> <%= @post.presenter.split_tag_list_html(self) %>
<%= @post.presenter.tag_list_html(self) %>
</section> </section>
<section> <section>