diff -r 1ab95857d584 -r c5ce145fdd70 templates/channel_search.tmpl
--- a/templates/channel_search.tmpl Tue Feb 10 00:04:15 2009 +0200
+++ b/templates/channel_search.tmpl Tue Feb 10 00:19:56 2009 +0200
@@ -1,39 +1,38 @@
<%inherit file="channel.tmpl" />
-<%def name="paginate(url, count, skip, max, _more=None, **args)">
- ## update max?
- % if more :
- <% max = h.max(max, skip) %>
- % else :
- <% max = skip %>
- % endif
- ## number of pages
- <% page_count = max / count + 1 %>
+<%def name="paginate(url, count, page_cur, page_max, _more=None, _last=False, **args)">
+ <%doc>
+ Pagination works using page numbers, with a specific number of maximum pages displayed. If _more is True,
+ then instead of a "Next" button, we have a "More" button, which goes to the max+1'th page, unless _last is
+ True, whereupon it's not displayed
+ %doc>
-
- % if skip :
- « Prev
+ % if page_cur > 1 :
+ « Prev
% else :
« Prev
%endif
- % for page in xrange(page_count) :
+ % for page in xrange(1, page_max + 1) :
-
- % if page == skip / count :
- ${page + 1}
+ % if page == page_cur :
+ ${page}
% else :
- ${page + 1}
+ ${page}
% endif
% endfor
-
- % if _more :
- More »
- % elif False :
- Next »
- % else : ## last page
+ % if _more and _last :
+ More »
+ % elif _more :
+ More »
+ % elif page_cur == page_max : ## last page
Next »
+ % else :
+ Next »
% endif
@@ -71,11 +70,11 @@
% else :
${channel.title} :: Search '${search_query}'
-${paginate(urls.channel_search, count, skip, max, channel=channel, q=search_query, _more=bool(lines))}
+${paginate(urls.channel_search, count, page, max, channel=channel, q=search_query, _more=True, _last=not(bool(lines)))}
% if lines :
<%include file="lines.tmpl" />
% else :
No results found
% endif
-${paginate(urls.channel_search, count, skip, max, channel=channel, q=search_query, _more=bool(lines))}
+${paginate(urls.channel_search, count, page, max, channel=channel, q=search_query, _more=True, _last=not(bool(lines)))}
% endif