Skip to content
Snippets Groups Projects
Commit 08dc78d5c658 authored by Katia Saurfelt's avatar Katia Saurfelt
Browse files

[html] refactor pagination links to ease overriding

parent b31c7fa7d65e
No related branches found
No related tags found
No related merge requests found
......@@ -78,6 +78,9 @@
class ElasticSearchView(StartupView):
__regid__ = "esearch"
previous_link = u' < '
next_link = u' > '
middle_link = u" · " * 3
def render_search_comp(self):
search_comp = self._cw.vreg['components'].select_or_none('search-comp',
......@@ -201,6 +204,6 @@
current_page = int(url_params.get('page', 1))
url_params['page'] = current_page - 1
if current_page - 1 >= 1:
ul(t.li(t.a(u' < ' * 3,
ul(t.li(t.a(self.previous_link,
href=xml_escape(self._cw.build_url(**url_params)))))
else:
......@@ -205,6 +208,6 @@
href=xml_escape(self._cw.build_url(**url_params)))))
else:
ul(t.li(t.a(u' < ' * 3)))
ul(t.li(t.a(self.previous_link)))
total_pages = (response.hits.total / 10) + 2
page_padding = 3
......@@ -214,9 +217,9 @@
current_page - page_padding)):
self.page_number(url_params, page, current_page, ul)
if current_page > (page_padding * 2) + 1:
ul(t.li(t.a(u" · " * 3)))
ul(t.li(t.a(self.middle_link)))
for page in range(max(1, current_page - page_padding),
min(current_page + page_padding, total_pages)):
self.page_number(url_params, page, current_page, ul)
if current_page < total_pages - page_padding:
if current_page < total_pages - page_padding * 2:
......@@ -218,9 +221,9 @@
for page in range(max(1, current_page - page_padding),
min(current_page + page_padding, total_pages)):
self.page_number(url_params, page, current_page, ul)
if current_page < total_pages - page_padding:
if current_page < total_pages - page_padding * 2:
ul(t.li(t.a(u" &middot; " * 3)))
ul(t.li(t.a(self.middle_link)))
for page in range(max(current_page + page_padding,
total_pages - page_padding),
total_pages):
......@@ -228,5 +231,5 @@
url_params['page'] = current_page + 1
if current_page + 1 >= (total_pages):
ul(t.li(t.a(u' &gt; ' * 3)))
ul(t.li(t.a(self.next_link)))
else:
......@@ -232,5 +235,5 @@
else:
ul(t.li(t.a(u' &gt; ' * 3,
ul(t.li(t.a(self.next_link,
href=xml_escape(self._cw.build_url(**url_params)))))
def page_number(self, url_params, page, current_page, ul):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment