improved ui for browsing through pools
This commit is contained in:
@@ -42,4 +42,46 @@ class PostPresenter < Presenter
|
||||
@tag_set_presenter ||= TagSetPresenter.new(@post.tag_array)
|
||||
@tag_set_presenter.tag_list_html(template, options.merge(:show_extra_links => CurrentUser.user.is_privileged?))
|
||||
end
|
||||
|
||||
def pool_html(template)
|
||||
html = ["<ul>"]
|
||||
|
||||
if template.params[:pool_id]
|
||||
pool = Pool.where(:id => template.params[:pool_id]).first
|
||||
return if pool.nil?
|
||||
html = pool_link_html(html, template, pool)
|
||||
|
||||
@post.pools.active.where("id <> ?", template.params[:pool_id]).each do |other_pool|
|
||||
html = pool_link_html(html, template, other_pool)
|
||||
end
|
||||
else
|
||||
@post.pools.active.each do |pool|
|
||||
html = pool_link_html(html, template, pool)
|
||||
end
|
||||
end
|
||||
|
||||
html << "</ul>"
|
||||
html.join("\n").html_safe
|
||||
end
|
||||
|
||||
def pool_link_html(html, template, pool)
|
||||
html << "<li>"
|
||||
|
||||
if pool.neighbors(@post).previous
|
||||
html << template.link_to("«".html_safe, template.post_path(pool.neighbors(@post).previous, :pool_id => pool.id))
|
||||
else
|
||||
html << "«"
|
||||
end
|
||||
|
||||
if pool.neighbors(@post).next
|
||||
html << template.link_to("»".html_safe, template.post_path(pool.neighbors(@post).next, :pool_id => pool.id))
|
||||
else
|
||||
html << "»"
|
||||
end
|
||||
|
||||
html << " "
|
||||
html << template.link_to(pool.name, template.pool_path(pool))
|
||||
html << "</li>"
|
||||
html
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
<ul>
|
||||
<% post.pools.each do |pool| %>
|
||||
<li>
|
||||
<% if pool.neighbors(post).previous %>
|
||||
<%= link_to "«".html_safe, post_path(pool.neighbors(post).previous) %>
|
||||
<% else %>
|
||||
«
|
||||
<% end %>
|
||||
<% if pool.neighbors(post).next %>
|
||||
<%= link_to "»".html_safe, post_path(pool.neighbors(post).next) %>
|
||||
<% else %>
|
||||
»
|
||||
<% end %>
|
||||
<%= link_to pool.pretty_name, pool_path(pool) %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
@@ -6,7 +6,7 @@
|
||||
<% if @post.pools.any? %>
|
||||
<section id="pool-sidebar">
|
||||
<h1>Pools</h1>
|
||||
<%= render "posts/partials/show/pools", :post => @post %>
|
||||
<%= @post.presenter.pool_html(self) %>
|
||||
</section>
|
||||
<% end %>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user