fixes #1487
This commit is contained in:
@@ -144,6 +144,10 @@ class Pool < ActiveRecord::Base
|
||||
post_ids =~ /(?:\A| )#{post_id}(?:\Z| )/
|
||||
end
|
||||
|
||||
def page_number(post_id)
|
||||
post_id_array.find_index(post_id) + 1
|
||||
end
|
||||
|
||||
def deletable_by?(user)
|
||||
user.is_janitor?
|
||||
end
|
||||
|
||||
@@ -195,31 +195,31 @@ class PostPresenter < Presenter
|
||||
end
|
||||
|
||||
if @post.id != pool.post_id_array.first
|
||||
pool_html << template.link_to("«".html_safe, template.post_path(pool.post_id_array.first, :pool_id => pool.id), :class => "#{klass} first")
|
||||
pool_html << template.link_to("«".html_safe, template.post_path(pool.post_id_array.first, :pool_id => pool.id), :class => "#{klass} first", :title => "to page 1")
|
||||
else
|
||||
pool_html << '<span class="first">«</span>'
|
||||
end
|
||||
|
||||
if pool.neighbors(@post).previous
|
||||
pool_html << template.link_to("‹ prev".html_safe, template.post_path(pool.neighbors(@post).previous, :pool_id => pool.id), :rel => prev_rel, :class => "#{klass} prev")
|
||||
pool_html << template.link_to("‹ prev".html_safe, template.post_path(pool.neighbors(@post).previous, :pool_id => pool.id), :rel => prev_rel, :class => "#{klass} prev", :title => "to page #{pool.page_number(pool.neighbors(@post).previous)}")
|
||||
match_found = true
|
||||
else
|
||||
pool_html << '<span class="prev">‹ prev</span>'
|
||||
end
|
||||
|
||||
pool_html << ' <span class="pool-name ' + klass + '">'
|
||||
pool_html << template.link_to("Pool: #{pool.pretty_name}", template.pool_path(pool))
|
||||
pool_html << template.link_to("Pool: #{pool.pretty_name}", template.pool_path(pool), :title => "page #{pool.page_number(@post.id)}/#{pool.post_count}")
|
||||
pool_html << '</span> '
|
||||
|
||||
if pool.neighbors(@post).next
|
||||
pool_html << template.link_to("next ›".html_safe, template.post_path(pool.neighbors(@post).next, :pool_id => pool.id), :rel => next_rel, :class => "#{klass} next")
|
||||
pool_html << template.link_to("next ›".html_safe, template.post_path(pool.neighbors(@post).next, :pool_id => pool.id), :rel => next_rel, :class => "#{klass} next", :title => "to page #{pool.page_number(pool.neighbors(@post).next)}")
|
||||
match_found = true
|
||||
else
|
||||
pool_html << '<span class="next">next ›</span>'
|
||||
end
|
||||
|
||||
if @post.id != pool.post_id_array.last
|
||||
pool_html << template.link_to("»".html_safe, template.post_path(pool.post_id_array.last, :pool_id => pool.id), :class => "#{klass} last")
|
||||
pool_html << template.link_to("»".html_safe, template.post_path(pool.post_id_array.last, :pool_id => pool.id), :class => "#{klass} last", :title => "to page #{pool.post_count}")
|
||||
else
|
||||
pool_html << '<span class="last">»</span>'
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user