From: Ant Zucaro Date: Thu, 8 Dec 2011 01:50:00 +0000 (-0500) Subject: Make a generic navlinks def in mako. X-Git-Url: http://de.git.xonotic.org/?a=commitdiff_plain;h=22ca5be6085a253e6b636b01c85b100713bd009b;p=xonotic%2Fxonstat.git Make a generic navlinks def in mako. --- diff --git a/xonstat/templates/navlinks.mako b/xonstat/templates/navlinks.mako new file mode 100644 index 0000000..9fb0db8 --- /dev/null +++ b/xonstat/templates/navlinks.mako @@ -0,0 +1,29 @@ +<%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) +%> + + + +% if curr != 1: + +% endif + +% for page_num in pages_to_link: + +% endfor + +% if curr != last: + +% endif + + + +(Page ${curr} of ${last}) + diff --git a/xonstat/templates/player_index.mako b/xonstat/templates/player_index.mako index 15f3a05..9784a6c 100755 --- a/xonstat/templates/player_index.mako +++ b/xonstat/templates/player_index.mako @@ -1,4 +1,5 @@ <%inherit file="base.mako"/> +<%namespace file="navlinks.mako" import="navlinks" /> <%block name="title"> Player Index - ${parent.title()} @@ -23,21 +24,5 @@ Player Index - ${parent.title()} % endif - - - -% if players.previous_page: - -% endif - -% for page in pages_to_link: - -% endfor - -% if players.next_page: - -% endif - - - -(Page ${players.page} of ${players.last_page}) + +${navlinks("player_index_paged", players.page, players.last_page)}