8 __docformat__ = "restructuredtext en" |
8 __docformat__ = "restructuredtext en" |
9 _ = unicode |
9 _ = unicode |
10 |
10 |
11 from rql.nodes import VariableRef, Constant |
11 from rql.nodes import VariableRef, Constant |
12 |
12 |
13 from logilab.mtconverter import html_escape |
13 from logilab.mtconverter import xml_escape |
14 from logilab.common.deprecation import obsolete |
14 from logilab.common.deprecation import obsolete |
15 |
15 |
16 from cubicweb.interfaces import IPrevNext |
16 from cubicweb.interfaces import IPrevNext |
17 from cubicweb.selectors import (paginated_rset, sorted_rset, |
17 from cubicweb.selectors import (paginated_rset, sorted_rset, |
18 primary_view, match_context_prop, |
18 primary_view, match_context_prop, |
134 self.write_links(params, blocklist) |
134 self.write_links(params, blocklist) |
135 |
135 |
136 def format_link_content(self, startstr, stopstr): |
136 def format_link_content(self, startstr, stopstr): |
137 text = u'%s - %s' % (startstr.lower()[:self.nb_chars], |
137 text = u'%s - %s' % (startstr.lower()[:self.nb_chars], |
138 stopstr.lower()[:self.nb_chars]) |
138 stopstr.lower()[:self.nb_chars]) |
139 return html_escape(text) |
139 return xml_escape(text) |
140 |
140 |
141 def write_links(self, params, blocklist): |
141 def write_links(self, params, blocklist): |
142 self.w(u'<div class="pagination">') |
142 self.w(u'<div class="pagination">') |
143 self.w(u'%s ' % self.previous_link(params)) |
143 self.w(u'%s ' % self.previous_link(params)) |
144 self.w(u'[ %s ]' % u' | '.join(blocklist)) |
144 self.w(u'[ %s ]' % u' | '.join(blocklist)) |
157 nav.render(w=w) |
157 nav.render(w=w) |
158 params = dict(req.form) |
158 params = dict(req.form) |
159 nav.clean_params(params) |
159 nav.clean_params(params) |
160 # make a link to see them all |
160 # make a link to see them all |
161 if show_all_option: |
161 if show_all_option: |
162 url = html_escape(self.build_url(__force_display=1, **params)) |
162 url = xml_escape(self.build_url(__force_display=1, **params)) |
163 w(u'<p><a href="%s">%s</a></p>\n' |
163 w(u'<p><a href="%s">%s</a></p>\n' |
164 % (url, req._('show %s results') % len(rset))) |
164 % (url, req._('show %s results') % len(rset))) |
165 rset.limit(offset=start, limit=stop-start, inplace=True) |
165 rset.limit(offset=start, limit=stop-start, inplace=True) |
166 |
166 |
167 |
167 |
196 if previous: |
196 if previous: |
197 self.w(u'<div class="previousEntity left">') |
197 self.w(u'<div class="previousEntity left">') |
198 self.w(self.previous_link(previous, textsize)) |
198 self.w(self.previous_link(previous, textsize)) |
199 self.w(u'</div>') |
199 self.w(u'</div>') |
200 self.req.html_headers.add_raw('<link rel="prev" href="%s" />' |
200 self.req.html_headers.add_raw('<link rel="prev" href="%s" />' |
201 % html_escape(previous.absolute_url())) |
201 % xml_escape(previous.absolute_url())) |
202 if next: |
202 if next: |
203 self.w(u'<div class="nextEntity right">') |
203 self.w(u'<div class="nextEntity right">') |
204 self.w(self.next_link(next, textsize)) |
204 self.w(self.next_link(next, textsize)) |
205 self.w(u'</div>') |
205 self.w(u'</div>') |
206 self.req.html_headers.add_raw('<link rel="next" href="%s" />' |
206 self.req.html_headers.add_raw('<link rel="next" href="%s" />' |
207 % html_escape(next.absolute_url())) |
207 % xml_escape(next.absolute_url())) |
208 self.w(u'</div>') |
208 self.w(u'</div>') |
209 self.w(u'<div class="clear"></div>') |
209 self.w(u'<div class="clear"></div>') |
210 |
210 |
211 def previous_link(self, previous, textsize): |
211 def previous_link(self, previous, textsize): |
212 return u'<a href="%s" title="%s"><< %s</a>' % ( |
212 return u'<a href="%s" title="%s"><< %s</a>' % ( |
213 html_escape(previous.absolute_url()), |
213 xml_escape(previous.absolute_url()), |
214 self.req._('i18nprevnext_previous'), |
214 self.req._('i18nprevnext_previous'), |
215 html_escape(cut(previous.dc_title(), textsize))) |
215 xml_escape(cut(previous.dc_title(), textsize))) |
216 |
216 |
217 def next_link(self, next, textsize): |
217 def next_link(self, next, textsize): |
218 return u'<a href="%s" title="%s">%s >></a>' % ( |
218 return u'<a href="%s" title="%s">%s >></a>' % ( |
219 html_escape(next.absolute_url()), |
219 xml_escape(next.absolute_url()), |
220 self.req._('i18nprevnext_next'), |
220 self.req._('i18nprevnext_next'), |
221 html_escape(cut(next.dc_title(), textsize))) |
221 xml_escape(cut(next.dc_title(), textsize))) |