|
a/views/pages.tpl |
|
b/views/pages.tpl |
|
|
1 |
%import sys
|
|
|
2 |
%py3k = sys.version_info >= (3, 0, 0)
|
|
|
3 |
%if py3k:
|
|
|
4 |
%from urllib.parse import urlencode
|
|
|
5 |
%else:
|
|
|
6 |
%from urllib.parse import urlencode
|
|
|
7 |
%end
|
|
|
8 |
%import math
|
|
|
9 |
|
1 |
%q = dict(query)
|
10 |
%q = dict(query)
|
2 |
%def page_href(page):
|
11 |
%def page_href(page):
|
3 |
%q['page'] = page
|
12 |
%q['page'] = page
|
4 |
%return './results?%s' % urllib.urlencode(q)
|
13 |
%return './results?%s' % urlencode(q)
|
5 |
%end
|
14 |
%end
|
6 |
%if nres > 0:
|
15 |
%if nres > 0:
|
7 |
%import math, urllib
|
|
|
8 |
%npages = int(math.ceil(nres/float(config['perpage'])))
|
16 |
%npages = int(math.ceil(nres/float(config['perpage'])))
|
9 |
%if npages > 1:
|
17 |
%if npages > 1:
|
10 |
<div id="pages">
|
18 |
<div id="pages">
|
11 |
<a title="First" class="page" href="{{page_href(1)}}">«</a>
|
19 |
<a title="First" class="page" href="{{page_href(1)}}">«</a>
|
12 |
<a title="Previous" class="page" href="{{page_href(max(1,query['page']-1))}}">‹</a>
|
20 |
<a title="Previous" class="page" href="{{page_href(max(1,query['page']-1))}}">‹</a>
|
13 |
%offset = ((query['page'])/10)*10
|
21 |
%offset = ((query['page'])//10)*10
|
14 |
%for p in range(max(1,offset), min(offset+10,npages+1)):
|
22 |
%for p in range(max(1,offset), min(offset+10,npages+1)):
|
15 |
%if p == query['page']:
|
23 |
%if p == query['page']:
|
16 |
%cls = "page current"
|
24 |
%cls = "page current"
|
17 |
%else:
|
25 |
%else:
|
18 |
%cls = "page"
|
26 |
%cls = "page"
|