Merge branch 'more-excerpts'
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -19,13 +19,17 @@
|
||||
<menu id="post-sections">
|
||||
<li class="active"><a href="#" id="show-posts-link">Posts</a></li>
|
||||
|
||||
<% if @post_set.has_wiki? %>
|
||||
<li><%= link_to "Wiki", wiki_page_path(@post_set.wiki_page), :id => "show-wiki-excerpt-link" %></li>
|
||||
<% if @post_set.has_artist? %>
|
||||
<li><%= link_to "Artist", artist_path(@post_set.artist), :id => "show-excerpt-link" %></li>
|
||||
<% elsif @post_set.has_wiki? %>
|
||||
<li><%= link_to "Wiki", wiki_page_path(@post_set.wiki_page), :id => "show-excerpt-link" %></li>
|
||||
<% elsif @post_set.has_pool? %>
|
||||
<li><%= link_to "Pool", pool_path(@post_set.pool), :id => "show-excerpt-link" %></li>
|
||||
<% end %>
|
||||
</menu>
|
||||
|
||||
<%= 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 %>
|
||||
</section>
|
||||
|
||||
|
||||
73
app/views/posts/partials/index/_excerpt.html.erb
Normal file
73
app/views/posts/partials/index/_excerpt.html.erb
Normal file
@@ -0,0 +1,73 @@
|
||||
<!--
|
||||
- post_set
|
||||
-->
|
||||
|
||||
<div id="excerpt" style="display: none;">
|
||||
<% if post_set.has_artist? %>
|
||||
<% unless post_set.artist.notes.blank? %>
|
||||
<div class="prose">
|
||||
<%= format_text(post_set.artist.notes) %>
|
||||
</div>
|
||||
|
||||
<p><%= link_to "View wiki page", post_set.artist.wiki_page %></p>
|
||||
<% end %>
|
||||
|
||||
<div>
|
||||
<ul>
|
||||
<li><strong>Status</strong> <%= post_set.artist.status %></li>
|
||||
<% if post_set.artist.has_tag_alias? %>
|
||||
<li><strong>Tag Alias</strong> <%= post_set.artist.tag_alias_name %></li>
|
||||
<% end %>
|
||||
<% if post_set.artist.other_names.present? %>
|
||||
<li><strong>Other Names</strong> <%= link_to_artists(post_set.artist.other_names.split(/ /)) %></li>
|
||||
<% end %>
|
||||
<% if post_set.artist.group_name.present? %>
|
||||
<li><strong>Group</strong> <%= link_to_artist(post_set.artist.group_name) %></li>
|
||||
<% end %>
|
||||
<% if post_set.artist.members.any? %>
|
||||
<li><strong>Members</strong> <%= link_to_artists(post_set.artist.members.map(&:name)) %></li>
|
||||
<% end %>
|
||||
<% post_set.artist.urls.each do |url| %>
|
||||
<li>
|
||||
URL: <%= link_to h(url.to_s), h(url.to_s) %>
|
||||
<% if CurrentUser.user.is_moderator? %>
|
||||
(<%= link_to("mass edit", edit_moderator_tag_path(:antecedent => "-#{post_set.artist.name} source:#{ArtistUrl.normalize_for_search(url.to_s)}", :consequent => post_set.artist.name)) %>)
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<p><%= link_to "View artist", artist_path(post_set.artist.id) %></p>
|
||||
</div>
|
||||
<% elsif post_set.has_wiki? %>
|
||||
<div class="prose">
|
||||
<%= format_text(post_set.wiki_page.presenter.excerpt) %>
|
||||
|
||||
<% if post_set.wiki_page.artist %>
|
||||
<p><%= link_to "View artist", post_set.wiki_page.artist %></p>
|
||||
<% end %>
|
||||
|
||||
<%= wiki_page_alias_and_implication_list(post_set.wiki_page) %>
|
||||
|
||||
<p><%= link_to "View wiki page", wiki_page_path(post_set.wiki_page.id) %></p>
|
||||
</div>
|
||||
<% elsif post_set.has_pool? %>
|
||||
<h4>
|
||||
<%= post_set.pool.pretty_category %>:
|
||||
<%= link_to post_set.pool.pretty_name, pool_path(post_set.pool), :class => "pool-category-#{post_set.pool.category}" %>
|
||||
<% if post_set.pool.is_deleted? %>
|
||||
<span class="inactive">(deleted)</span>
|
||||
<% end %>
|
||||
</h4>
|
||||
|
||||
<div id="description" class="prose">
|
||||
<%= format_text(post_set.pool.description) %>
|
||||
</div>
|
||||
|
||||
<p><%= link_to "View pool", pool_path(post_set.pool.id) %></p>
|
||||
<% else %>
|
||||
<% if post_set.tag_string.present? %>
|
||||
<p>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}) %>.</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -1,23 +0,0 @@
|
||||
<!--
|
||||
- post_set
|
||||
-->
|
||||
|
||||
<div id="wiki-page-excerpt" style="display: none;">
|
||||
<% if post_set.wiki_page %>
|
||||
<div class="prose">
|
||||
<%= format_text(post_set.wiki_page.presenter.excerpt) %>
|
||||
|
||||
<% if post_set.wiki_page.artist %>
|
||||
<p><%= link_to "View artist", post_set.wiki_page.artist %></p>
|
||||
<% end %>
|
||||
|
||||
<%= wiki_page_alias_and_implication_list(post_set.wiki_page) %>
|
||||
|
||||
<p>Read the <%= link_to "full article", wiki_page_path(post_set.wiki_page.id) %>.</p>
|
||||
</div>
|
||||
<% else %>
|
||||
<% if post_set.tag_string.present? %>
|
||||
<p>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}) %>.</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
Reference in New Issue
Block a user