<%def name="navlinks(view, curr, last)">
+% if curr != last:
+ % if curr != 1:
+ <a class="pagination" href="${request.route_url(view, page=curr-1)}" name="Previous Page">previous</a>
+ % endif
-% if curr != 1:
-<a class="pagination" href="${request.route_url(view, page=curr-1)}" name="Previous Page">previous</a>
-% endif
-
-% if last < 8:
- % for i in range(1, last+1):
- ${link_page(view, i, curr)}
- % endfor
-% else:
- % if curr < 5:
- % for i in range(1,7):
- ${link_page(view, i, curr)}
- % endfor
- <span class="pagination">...</span>
- <a class="pagination" href="${request.route_url(view, page=last)}" name="Last Page">${last}</a>
- % elif last-curr < 6:
- <a class="pagination" href="${request.route_url(view, page=1)}" name="First Page">1</a>
- <span class="pagination">...</span>
- % for i in range(last-5, last+1):
+ % if last < 8:
+ % for i in range(1, last+1):
${link_page(view, i, curr)}
% endfor
% else:
- <a class="pagination" href="${request.route_url(view, page=1)}" name="First Page">1</a>
- <span class="pagination">...</span>
- % for i in range(curr-2, curr+3):
- ${link_page(view, i, curr)}
- % endfor
- <span class="pagination">...</span>
- <a class="pagination" href="${request.route_url(view, page=last)}" name="Last Page">${last}</a>
+ % if curr < 5:
+ % for i in range(1,7):
+ ${link_page(view, i, curr)}
+ % endfor
+ <span class="pagination">...</span>
+ <a class="pagination" href="${request.route_url(view, page=last)}" name="Last Page">${last}</a>
+ % elif last-curr < 6:
+ <a class="pagination" href="${request.route_url(view, page=1)}" name="First Page">1</a>
+ <span class="pagination">...</span>
+ % for i in range(last-5, last+1):
+ ${link_page(view, i, curr)}
+ % endfor
+ % else:
+ <a class="pagination" href="${request.route_url(view, page=1)}" name="First Page">1</a>
+ <span class="pagination">...</span>
+ % for i in range(curr-2, curr+3):
+ ${link_page(view, i, curr)}
+ % endfor
+ <span class="pagination">...</span>
+ <a class="pagination" href="${request.route_url(view, page=last)}" name="Last Page">${last}</a>
+ % endif
% endif
-% endif
-% if curr != last:
-<a class="pagination" href="${request.route_url(view, page=curr+1)}" name="Next Page">next</a>
+ % if curr != last:
+ <a class="pagination" href="${request.route_url(view, page=curr+1)}" name="Next Page">next</a>
+ % endif
% endif
-
</%def>
<%def name="link_page(view, page_num, curr_page)">
<%inherit file="base.mako"/>
+<%namespace file="navlinks.mako" import="navlinks" />
% if results == None:
<form action="${request.route_url("search")}" method="get">
- <input type="hidden" name="form_submitted" />
+ <input type="hidden" name="fs" />
<table id="search_form" border="0">
<tr>
<td style="text-align:right;">Nick:</td>
</tr>
</table>
</form>
-% endif
+% elif len(results) == 0:
+ <h1>Sorry, nothing found!</h1>
+% else:
##### player-only results #####
% if result_type == "player":
% endfor
</table>
% endif
+
+<!-- navigation links -->
+<p>Work in progress (these won't work :P):</p>
+${navlinks("search", results.page, results.last_page)}
+% endif
return (result_type, q)
def search(request):
- form_submitted = None
+ fs = None
nick = None
server_name = None
map_name = None
result_type = None
results = None
- if request.params.has_key('form_submitted'):
- nick = request.params['nick']
- server_name = request.params['server_name']
- map_name = request.params['map_name']
+ current_page = 1
+
+ if request.params.has_key('fs'):
+ if request.params.has_key('nick'):
+ nick = request.params['nick']
+ if request.params.has_key('server_name'):
+ server_name = request.params['server_name']
+ if request.params.has_key('map_name'):
+ map_name = request.params['map_name']
(result_type, q) = search_q(nick=nick, server_name=server_name,
map_name=map_name)
log.debug(q)
try:
if q != None:
- results = q.all()
+ results = Page(q, current_page, url=page_url)
+ log.debug(len(results))
except Exception as e:
raise e
result_type = None