diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index caf2f54b1..e6665c117 100644 --- a/app/assets/javascripts/posts.js +++ b/app/assets/javascripts/posts.js @@ -17,7 +17,7 @@ } if ($("#c-posts").length && $("#a-index").length) { - this.initialize_wiki_page_excerpt(); + this.initialize_excerpt(); } if ($("#c-posts").length && $("#a-show").length) { @@ -411,30 +411,30 @@ }); } - Danbooru.Post.initialize_wiki_page_excerpt = function() { - $("#wiki-page-excerpt").hide(); + Danbooru.Post.initialize_excerpt = function() { + $("#excerpt").hide(); $("#show-posts-link").click(function(e) { $("#show-posts-link").parent("li").addClass("active"); - $("#show-wiki-excerpt-link").parent("li").removeClass("active"); + $("#show-excerpt-link").parent("li").removeClass("active"); $("#posts").show(); - $("#wiki-page-excerpt").hide(); + $("#excerpt").hide(); e.preventDefault(); }); - $("#show-wiki-excerpt-link").click(function(e) { + $("#show-excerpt-link").click(function(e) { if ($(this).parent("li").hasClass("active")) { return; } $("#show-posts-link").parent("li").removeClass("active"); - $("#show-wiki-excerpt-link").parent("li").addClass("active"); + $("#show-excerpt-link").parent("li").addClass("active"); $("#posts").hide(); - $("#wiki-page-excerpt").show(); + $("#excerpt").show(); e.preventDefault(); }); if (/Nobody here but us chickens/.test($("#posts").html()) && !/Deleted posts/.test($("#related-box").html())) { - $("#show-wiki-excerpt-link").click(); + $("#show-excerpt-link").click(); } } diff --git a/app/logical/post_sets/post.rb b/app/logical/post_sets/post.rb index 4cbd53d00..cee8c4968 100644 --- a/app/logical/post_sets/post.rb +++ b/app/logical/post_sets/post.rb @@ -30,6 +30,26 @@ module PostSets end end + def has_artist? + tag_array.any? && ::Artist.name_matches(tag_string).exists? + end + + def artist + ::Artist.name_matches(tag_string).first + end + + def pool_name + tag_string.match(/^pool:(\S+)$/i).try(:[], 1) + end + + def has_pool? + tag_array.size == 1 && pool_name && pool + end + + def pool + ::Pool.find(::Pool.name_to_id(pool_name)) + end + def has_deleted? CurrentUser.is_gold? && tag_string !~ /status/ && ::Post.tag_match("#{tag_string} status:deleted").exists? end @@ -54,14 +74,6 @@ module PostSets end end - def has_artist? - tag_array.any? && ::Artist.name_equals(tag_string).exists? - end - - def artist - ::Artist.name_matches(tag_string).first - end - def is_single_tag? tag_array.size == 1 end diff --git a/app/views/posts/index.html.erb b/app/views/posts/index.html.erb index ddd84eba2..784591434 100644 --- a/app/views/posts/index.html.erb +++ b/app/views/posts/index.html.erb @@ -19,13 +19,17 @@
  • Posts
  • - <% if @post_set.has_wiki? %> -
  • <%= link_to "Wiki", wiki_page_path(@post_set.wiki_page), :id => "show-wiki-excerpt-link" %>
  • + <% if @post_set.has_artist? %> +
  • <%= link_to "Artist", artist_path(@post_set.artist), :id => "show-excerpt-link" %>
  • + <% elsif @post_set.has_wiki? %> +
  • <%= link_to "Wiki", wiki_page_path(@post_set.wiki_page), :id => "show-excerpt-link" %>
  • + <% elsif @post_set.has_pool? %> +
  • <%= link_to "Pool", pool_path(@post_set.pool), :id => "show-excerpt-link" %>
  • <% end %>
    <%= render "posts/partials/index/edit" %> - <%= render "wiki_pages/excerpt", :post_set => @post_set %> + <%= render "posts/partials/index/excerpt", :post_set => @post_set %> <%= render "posts/partials/index/posts", :post_set => @post_set %> diff --git a/app/views/posts/partials/index/_excerpt.html.erb b/app/views/posts/partials/index/_excerpt.html.erb new file mode 100644 index 000000000..2cb93b36c --- /dev/null +++ b/app/views/posts/partials/index/_excerpt.html.erb @@ -0,0 +1,73 @@ + + + diff --git a/app/views/wiki_pages/_excerpt.html.erb b/app/views/wiki_pages/_excerpt.html.erb deleted file mode 100644 index 9a449c6f1..000000000 --- a/app/views/wiki_pages/_excerpt.html.erb +++ /dev/null @@ -1,23 +0,0 @@ - - -