--- /dev/null
+<%def name="navlinks(view, curr, last)">
+
+<%
+if (curr+4) > last:
+ last_linked_page = last
+else:
+ last_linked_page = curr+4
+
+pages_to_link = range(curr+1, last_linked_page+1)
+%>
+
+<a class="pagination" href="${request.route_url(view, page=1)}" name="First Page"><<</a>
+
+% if curr != 1:
+<a class="pagination" href="${request.route_url(view, page=curr-1)}" name="Previous Page"><</a>
+% endif
+
+% for page_num in pages_to_link:
+<a class="pagination" href="${request.route_url(view, page=page_num)}" name="Go to page ${page_num}">${page_num}</a>
+% endfor
+
+% if curr != last:
+<a class="pagination" href="${request.route_url(view, page=curr+1)}" name="Next Page">></a>
+% endif
+
+<a class="pagination" href="${request.route_url(view, page=last)}" name="Last Page">>></a>
+
+(Page <a href="${request.route_url(view, page=curr)}" name="Go to page ${curr}">${curr}</a> of <a href="${request.route_url(view, page=last)}" name="Last Page">${last}</a>)
+</%def>
<%inherit file="base.mako"/>\r
+<%namespace file="navlinks.mako" import="navlinks" />\r
\r
<%block name="title">\r
Player Index - ${parent.title()}\r
</table>\r
% endif\r
\r
-<!-- pagination -->\r
-<a class="pagination" href="${request.route_url("player_index_paged", page=1)}" name="First Page"><<</a>\r
-\r
-% if players.previous_page:\r
-<a class="pagination" href="${request.route_url("player_index_paged", page=players.previous_page)}" name="Previous Page"><</a>\r
-% endif\r
-\r
-% for page in pages_to_link:\r
-<a class="pagination" href="${request.route_url("player_index_paged", page=page)}" name="Go to page ${page}">${page}</a>\r
-% endfor\r
-\r
-% if players.next_page:\r
-<a class="pagination" href="${request.route_url("player_index_paged", page=players.next_page)}" name="Next Page">></a>\r
-% endif\r
-\r
-<a class="pagination" href="${request.route_url("player_index_paged", page=players.last_page)}" name="Last Page">>></a>\r
-\r
-(Page <a href="${request.route_url("player_index_paged", page=players.page)}" name="Go to page ${players.page}">${players.page}</a> of <a href="${request.route_url("player_index_paged", page=players.last_page)}" name="Last Page">${players.last_page}</a>)\r
+<!-- navigation links -->\r
+${navlinks("player_index_paged", players.page, players.last_page)}\r