refactor pool nav html
This commit is contained in:
17
app/views/posts/partials/show/_embedded.html.erb
Normal file
17
app/views/posts/partials/show/_embedded.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
<% if post.banblocked? -%>
|
||||
<p>The artist requested removal of this image.</p>
|
||||
<% elsif post.levelblocked? -%>
|
||||
<p><%= link_to("You need a gold account to see this image", new_user_upgrade_path) %>.</p>
|
||||
<% elsif post.safeblocked? -%>
|
||||
<p>This image is unavailable on safe mode (<%= Danbooru.config.app_name %>). Go to <%= link_to("Danbooru", "https://danbooru.donmai.us") %> or disable safe mode to view (<%= link_to("learn more", template.wiki_pages_path(title: "help:user_settings")) -%>).</p>
|
||||
<% elsif post.is_flash? -%>
|
||||
<%= render("posts/partials/show/flash", post: post) -%>
|
||||
<% elsif post.is_video? -%>
|
||||
<%= render("posts/partials/show/video", post: post) -%>
|
||||
<% elsif post.is_ugoira? -%>
|
||||
<%= render("posts/partials/show/ugoira", post: post) -%>
|
||||
<% elsif !post.is_image? -%>
|
||||
<%= render("posts/partials/show/download", post: post) -%>
|
||||
<% elsif post.is_image? -%>
|
||||
<%= render("posts/partials/show/image", post: post) -%>
|
||||
<% end %>
|
||||
@@ -5,7 +5,7 @@
|
||||
<% end %>
|
||||
|
||||
<% if post.pools.undeleted.any? %>
|
||||
<%= render "posts/partials/show/pools", :post => post %>
|
||||
<%= render "posts/partials/show/pool_list", post: post, pools: post.pools.undeleted.selected_first(params[:pool_id]) %>
|
||||
<% end %>
|
||||
|
||||
<% if post.favorite_groups(active_id=params[:favgroup_id]).any? %>
|
||||
|
||||
7
app/views/posts/partials/show/_pool_list.html.erb
Normal file
7
app/views/posts/partials/show/_pool_list.html.erb
Normal file
@@ -0,0 +1,7 @@
|
||||
<div id="pool-nav">
|
||||
<ul>
|
||||
<% pools.each do |pool| -%>
|
||||
<%= render "posts/partials/show/pool_list_item", pool: pool, post: post, selected: is_pool_selected?(pool) -%>
|
||||
<% end -%>
|
||||
</ul>
|
||||
</div>
|
||||
33
app/views/posts/partials/show/_pool_list_item.html.erb
Normal file
33
app/views/posts/partials/show/_pool_list_item.html.erb
Normal file
@@ -0,0 +1,33 @@
|
||||
<%= content_tag :li, id: "nav-link-for-pool-#{pool.id}", class: "pool-category-#{pool.category} pool-selected-#{selected}" do -%>
|
||||
<% if !pool.first_post?(post.id) -%>
|
||||
<%= link_to("«".html_safe, post_path(pool.first_post_id, pool_id: pool.id), class: "first", title: "to page 1") %>
|
||||
<% else -%>
|
||||
<span class="first">«</span>
|
||||
<% end -%>
|
||||
|
||||
<% pool.neighbors(post, :previous).tap do |previous_post_id| -%>
|
||||
<% if previous_post_id %>
|
||||
<%= link_to "‹ prev".html_safe, post_path(previous_post_id, pool_id: pool.id), rel: selected ? "prev" : nil, class: "prev", title: "to page #{pool.page_number(previous_post_id)}" -%>
|
||||
<% else -%>
|
||||
<span class="prev">‹ prev</span>
|
||||
<% end %>
|
||||
<% end -%>
|
||||
|
||||
<span class="pool-name">
|
||||
<%= link_to("Pool: #{pool.pretty_name}", pool_path(pool), title: "page #{pool.page_number(post.id)}/#{pool.post_count}") -%>
|
||||
</span>
|
||||
|
||||
<% if pool.neighbors(post, :next).tap do |previous_post_id| -%>
|
||||
<% if previous_post_id %>
|
||||
<%= link_to("next ›".html_safe, post_path(next_post_in_pool, pool_id: pool.id), rel: selected ? "next" : nil, class: "next", title: "to page #{pool.page_number(previous_post_id)}") -%>
|
||||
<% else -%>
|
||||
<span class="next">next ›</span>
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
|
||||
<% if post.id != pool.post_id_array.last -%>
|
||||
<%= link_to("»".html_safe, post_path(pool.post_id_array.last, pool_id: pool.id), class: "last", title: "to page #{pool.post_count}") -%>
|
||||
<% else -%>
|
||||
<span class="last">»</span>
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
@@ -1,3 +0,0 @@
|
||||
<div id="pool-nav">
|
||||
<%= @post.presenter.pool_html(self) %>
|
||||
</div>
|
||||
@@ -50,7 +50,7 @@
|
||||
<%= content_tag(:section, PostPresenter.data_attributes(@post).merge(id: "image-container")) do -%>
|
||||
<div id="note-container"></div>
|
||||
<div id="note-preview"></div>
|
||||
<%= @post.presenter.image_html(self) %>
|
||||
<%= render "posts/partials/show/embedded", post: @post %>
|
||||
<% end -%>
|
||||
|
||||
<% if CurrentUser.is_member? %>
|
||||
|
||||
Reference in New Issue
Block a user