%import sys
%py3k = sys.version_info >= (3, 0, 0)
%if py3k:
%from urllib.parse import urlencode
%else:
%from urllib import urlencode
%end
%import math
%q = dict(query)
%def page_href(page):
%q['page'] = page
%return './results?%s' % urlencode(q)
%end
%if nres > 0:
%npages = int(math.ceil(nres/float(config['perpage'])))
%if npages > 1:
<div id="pages">
<a title="First" class="page" href="{{page_href(1)}}">«</a>
<a title="Previous" class="page" href="{{page_href(max(1,query['page']-1))}}">‹</a>
%offset = ((query['page'])//10)*10
%for p in range(max(1,offset), min(offset+10,npages+1)):
%if p == query['page']:
%cls = "page current"
%else:
%cls = "page"
%end
<a href="{{page_href(p)}}" class="{{cls}}">{{p}}</a>
%end
<a title="Next" class="page" href="{{page_href(min(npages, query['page']+1))}}">›</a>
<a title="Last" class="page" href="{{page_href(npages)}}">»</a>
</div>
%end
%end