# HG changeset patch # User Katia Saurfelt <katia.saurfelt@logilab.fr> # Date 1472634850 -7200 # Wed Aug 31 11:14:10 2016 +0200 # Node ID 08dc78d5c65837b8cfef91495bb9c5cb4ee9e7a4 # Parent b31c7fa7d65efccd944513d7ebc9c77e7b2c203f [html] refactor pagination links to ease overriding diff --git a/views.py b/views.py --- a/views.py +++ b/views.py @@ -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,10 +204,10 @@ 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: - 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,13 +217,13 @@ 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: - ul(t.li(t.a(u" · " * 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,9 +231,9 @@ url_params['page'] = current_page + 1 if current_page + 1 >= (total_pages): - ul(t.li(t.a(u' > ' * 3))) + ul(t.li(t.a(self.next_link))) else: - ul(t.li(t.a(u' > ' * 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):