This commit is contained in:
Toks
2013-05-18 09:36:20 -04:00
parent 5632f8c05c
commit a680555e72
2 changed files with 9 additions and 5 deletions

View File

@@ -144,6 +144,10 @@ class Pool < ActiveRecord::Base
post_ids =~ /(?:\A| )#{post_id}(?:\Z| )/ post_ids =~ /(?:\A| )#{post_id}(?:\Z| )/
end end
def page_number(post_id)
post_id_array.find_index(post_id) + 1
end
def deletable_by?(user) def deletable_by?(user)
user.is_janitor? user.is_janitor?
end end

View File

@@ -195,31 +195,31 @@ class PostPresenter < Presenter
end end
if @post.id != pool.post_id_array.first if @post.id != pool.post_id_array.first
pool_html << template.link_to("&laquo;".html_safe, template.post_path(pool.post_id_array.first, :pool_id => pool.id), :class => "#{klass} first") pool_html << template.link_to("&laquo;".html_safe, template.post_path(pool.post_id_array.first, :pool_id => pool.id), :class => "#{klass} first", :title => "to page 1")
else else
pool_html << '<span class="first">&laquo;</span>' pool_html << '<span class="first">&laquo;</span>'
end end
if pool.neighbors(@post).previous if pool.neighbors(@post).previous
pool_html << template.link_to("&lsaquo;&thinsp;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("&lsaquo;&thinsp;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 match_found = true
else else
pool_html << '<span class="prev">&lsaquo;&thinsp;prev</span>' pool_html << '<span class="prev">&lsaquo;&thinsp;prev</span>'
end end
pool_html << ' <span class="pool-name ' + klass + '">' 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> ' pool_html << '</span> '
if pool.neighbors(@post).next if pool.neighbors(@post).next
pool_html << template.link_to("next&thinsp;&rsaquo;".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&thinsp;&rsaquo;".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 match_found = true
else else
pool_html << '<span class="next">next&thinsp;&rsaquo;</span>' pool_html << '<span class="next">next&thinsp;&rsaquo;</span>'
end end
if @post.id != pool.post_id_array.last if @post.id != pool.post_id_array.last
pool_html << template.link_to("&raquo;".html_safe, template.post_path(pool.post_id_array.last, :pool_id => pool.id), :class => "#{klass} last") pool_html << template.link_to("&raquo;".html_safe, template.post_path(pool.post_id_array.last, :pool_id => pool.id), :class => "#{klass} last", :title => "to page #{pool.post_count}")
else else
pool_html << '<span class="last">&raquo;</span>' pool_html << '<span class="last">&raquo;</span>'
end end