web/views/ibreadcrumbs.py
changeset 1889 874a055c373b
parent 1882 ce662160bb46
child 1977 606923dff11b
equal deleted inserted replaced
1888:f36d43f00f32 1889:874a055c373b
     3 :organization: Logilab
     3 :organization: Logilab
     4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     6 """
     6 """
     7 __docformat__ = "restructuredtext en"
     7 __docformat__ = "restructuredtext en"
       
     8 _ = unicode
     8 
     9 
     9 from logilab.mtconverter import html_escape
    10 from logilab.mtconverter import html_escape
    10 
    11 
    11 # don't use AnyEntity since this may cause bug with isinstance() due to reloading
    12 # don't use AnyEntity since this may cause bug with isinstance() due to reloading
    12 from cubicweb.interfaces import IBreadCrumbs
    13 from cubicweb.interfaces import IBreadCrumbs
    14 from cubicweb.entity import Entity
    15 from cubicweb.entity import Entity
    15 from cubicweb.view import EntityView
    16 from cubicweb.view import EntityView
    16 from cubicweb.common.uilib import cut
    17 from cubicweb.common.uilib import cut
    17 from cubicweb.web.component import EntityVComponent
    18 from cubicweb.web.component import EntityVComponent
    18 
    19 
    19 _ = unicode
       
    20 
    20 
    21 def bc_title(entity):
    21 def bc_title(entity):
    22     textsize = entity.req.property_value('navigation.short-line-size')
    22     textsize = entity.req.property_value('navigation.short-line-size')
    23     return html_escape(cut(entity.dc_title(), textsize))
    23     return html_escape(cut(entity.dc_title(), textsize))
    24 
    24 
    78 class BreadCrumbView(EntityView):
    78 class BreadCrumbView(EntityView):
    79     id = 'breadcrumbs'
    79     id = 'breadcrumbs'
    80 
    80 
    81     def cell_call(self, row, col):
    81     def cell_call(self, row, col):
    82         entity = self.entity(row, col)
    82         entity = self.entity(row, col)
    83         desc = cut(entity.dc_description(), 50)
    83         desc = html_escape(cut(entity.dc_description(), 50))
    84         self.w(u'<a href="%s" title="%s">%s</a>' % (html_escape(entity.absolute_url()),
    84         self.w(u'<a href="%s" title="%s">%s</a>' % (
    85                                                     html_escape(desc),
    85             html_escape(entity.absolute_url()), desc, bc_title(entity)))
    86                                                     bc_title(entity)))