From 22ca5be6085a253e6b636b01c85b100713bd009b Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Wed, 7 Dec 2011 20:50:00 -0500 Subject: [PATCH] Make a generic navlinks def in mako. --- xonstat/templates/navlinks.mako | 29 +++++++++++++++++++++++++++++ xonstat/templates/player_index.mako | 21 +++------------------ 2 files changed, 32 insertions(+), 18 deletions(-) create mode 100644 xonstat/templates/navlinks.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)} -- 2.39.2