From 83c64282085cec42efe40f6dc3fd0aff0b217dfc Mon Sep 17 00:00:00 2001 From: Toks Date: Sun, 7 Jul 2013 19:04:27 -0400 Subject: [PATCH 1/4] artist excerpt --- app/assets/javascripts/posts.js | 18 +++--- app/logical/post_sets/post.rb | 2 +- app/views/posts/index.html.erb | 8 ++- .../posts/partials/index/_excerpt.html.erb | 59 +++++++++++++++++++ 4 files changed, 74 insertions(+), 13 deletions(-) create mode 100644 app/views/posts/partials/index/_excerpt.html.erb diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js index b84b15d43..b6fadaa1a 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) { @@ -383,30 +383,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..1edcf6510 100644 --- a/app/logical/post_sets/post.rb +++ b/app/logical/post_sets/post.rb @@ -55,7 +55,7 @@ module PostSets end def has_artist? - tag_array.any? && ::Artist.name_equals(tag_string).exists? + tag_array.any? && ::Artist.name_matches(tag_string).exists? end def artist diff --git a/app/views/posts/index.html.erb b/app/views/posts/index.html.erb index ddd84eba2..36ffe6c9b 100644 --- a/app/views/posts/index.html.erb +++ b/app/views/posts/index.html.erb @@ -19,13 +19,15 @@
  • 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" %>
  • <% 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..5d6558f2e --- /dev/null +++ b/app/views/posts/partials/index/_excerpt.html.erb @@ -0,0 +1,59 @@ + + + From 3afcd48925b3c2dd291cf6c7c675b1105d8005f6 Mon Sep 17 00:00:00 2001 From: Toks Date: Tue, 9 Jul 2013 13:03:51 -0400 Subject: [PATCH 2/4] fixes #1734 --- app/logical/post_sets/post.rb | 28 +++++++++++++------ app/views/posts/index.html.erb | 2 ++ .../posts/partials/index/_excerpt.html.erb | 16 +++++++++-- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/app/logical/post_sets/post.rb b/app/logical/post_sets/post.rb index 1edcf6510..46281a42b 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+)$/).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_matches(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 36ffe6c9b..784591434 100644 --- a/app/views/posts/index.html.erb +++ b/app/views/posts/index.html.erb @@ -23,6 +23,8 @@
  • <%= 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 %> diff --git a/app/views/posts/partials/index/_excerpt.html.erb b/app/views/posts/partials/index/_excerpt.html.erb index 5d6558f2e..c5053108e 100644 --- a/app/views/posts/partials/index/_excerpt.html.erb +++ b/app/views/posts/partials/index/_excerpt.html.erb @@ -3,7 +3,7 @@ --> <% elsif post_set.has_wiki? %>
    @@ -49,7 +49,7 @@ <%= wiki_page_alias_and_implication_list(post_set.wiki_page) %> -

    Read the <%= link_to "full article", wiki_page_path(post_set.wiki_page.id) %>.

    +

    <%= link_to "View wiki page", wiki_page_path(post_set.wiki_page.id) %>

    <% elsif post_set.has_pool? %>

    @@ -63,6 +63,8 @@
    <%= format_text(post_set.pool.description) %>
    + +

    <%= link_to "View pool", pool_path(post_set.pool.id) %>

    <% else %> <% if post_set.tag_string.present? %>

    There is currently no wiki page for the tag "<%= post_set.tag_string %>". You can <%= link_to "create one", new_wiki_page_path(:wiki_page => {:title => post_set.tag_string}) %>.