web/views/bookmark.py
branchstable
changeset 2312 af4d8f75c5db
parent 1977 606923dff11b
child 2476 1294a6bdf3bf
equal deleted inserted replaced
2311:f178182b1305 2312:af4d8f75c5db
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
     6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
     7 """
     7 """
     8 __docformat__ = "restructuredtext en"
     8 __docformat__ = "restructuredtext en"
     9 
     9 
    10 from logilab.mtconverter import html_escape
    10 from logilab.mtconverter import xml_escape
    11 
    11 
    12 from cubicweb import Unauthorized
    12 from cubicweb import Unauthorized
    13 from cubicweb.selectors import implements
    13 from cubicweb.selectors import implements
    14 from cubicweb.web.htmlwidgets import BoxWidget, BoxMenu, RawBoxItem
    14 from cubicweb.web.htmlwidgets import BoxWidget, BoxMenu, RawBoxItem
    15 from cubicweb.web import action, box
    15 from cubicweb.web import action, box
    33     def cell_call(self, row, col):
    33     def cell_call(self, row, col):
    34         """the primary view for bookmark entity"""
    34         """the primary view for bookmark entity"""
    35         entity = self.complete_entity(row, col)
    35         entity = self.complete_entity(row, col)
    36         self.w(u' ')
    36         self.w(u' ')
    37         self.w(u"<span class='title'><b>")
    37         self.w(u"<span class='title'><b>")
    38         self.w(u"%s : %s" % (self.req._('Bookmark'), html_escape(entity.title)))
    38         self.w(u"%s : %s" % (self.req._('Bookmark'), xml_escape(entity.title)))
    39         self.w(u"</b></span>")
    39         self.w(u"</b></span>")
    40         self.w(u'<br/><br/><div class="content"><a href="%s">' % (
    40         self.w(u'<br/><br/><div class="content"><a href="%s">' % (
    41             html_escape(entity.actual_url())))
    41             xml_escape(entity.actual_url())))
    42         self.w(u'</a>')
    42         self.w(u'</a>')
    43         self.w(u'<p>%s%s</p>' % (self.req._('Used by:'), ', '.join(html_escape(u.name())
    43         self.w(u'<p>%s%s</p>' % (self.req._('Used by:'), ', '.join(xml_escape(u.name())
    44                                                                    for u in entity.bookmarked_by)))
    44                                                                    for u in entity.bookmarked_by)))
    45         self.w(u'</div>')
    45         self.w(u'</div>')
    46 
    46 
    47 
    47 
    48 class BookmarksBox(box.UserRQLBoxTemplate):
    48 class BookmarksBox(box.UserRQLBoxTemplate):
    73         if candelete:
    73         if candelete:
    74             req.add_js( ('cubicweb.ajax.js', 'cubicweb.bookmarks.js') )
    74             req.add_js( ('cubicweb.ajax.js', 'cubicweb.bookmarks.js') )
    75         else:
    75         else:
    76             dlink = None
    76             dlink = None
    77         for bookmark in rset.entities():
    77         for bookmark in rset.entities():
    78             label = '<a href="%s">%s</a>' % (html_escape(bookmark.action_url()),
    78             label = '<a href="%s">%s</a>' % (xml_escape(bookmark.action_url()),
    79                                              html_escape(bookmark.title))
    79                                              xml_escape(bookmark.title))
    80             if candelete:
    80             if candelete:
    81                 dlink = u'[<a href="javascript:removeBookmark(%s)" title="%s">-</a>]' % (
    81                 dlink = u'[<a href="javascript:removeBookmark(%s)" title="%s">-</a>]' % (
    82                     bookmark.eid, _('delete this bookmark'))
    82                     bookmark.eid, _('delete this bookmark'))
    83                 label = '%s %s' % (dlink, label)
    83                 label = '%s %s' % (dlink, label)
    84             box.append(RawBoxItem(label))
    84             box.append(RawBoxItem(label))