Fix #1883: Add <link> elements for all paginated pages.
Add <link rel="prev"> and <link rel="next"> elements to most pages with pagination. This should work on all index pages, but it won't work for things like pool or forum topic show pages. Also remove the <link rel="top"> element (wasn't useful, was just a link back to the root url).
This commit is contained in:
@@ -60,6 +60,30 @@ module PaginationExtension
|
||||
end
|
||||
end
|
||||
|
||||
def prev_page
|
||||
return nil if is_first_page?
|
||||
|
||||
if paginator_mode == :numbered
|
||||
current_page - 1
|
||||
elsif paginator_mode == :sequential_before
|
||||
"a#{records.first.id}"
|
||||
elsif paginator_mode == :sequential_after
|
||||
"b#{records.last.id}"
|
||||
end
|
||||
end
|
||||
|
||||
def next_page
|
||||
return nil if is_last_page?
|
||||
|
||||
if paginator_mode == :numbered
|
||||
current_page + 1
|
||||
elsif paginator_mode == :sequential_before
|
||||
"b#{records.last.id}"
|
||||
elsif paginator_mode == :sequential_after
|
||||
"a#{records.first.id}"
|
||||
end
|
||||
end
|
||||
|
||||
# XXX Hack: in sequential pagination we fetch one more record than we
|
||||
# need so that we can tell when we're on the first or last page. Here
|
||||
# we override a rails internal method to discard that extra record. See
|
||||
|
||||
Reference in New Issue
Block a user