web/views/ibreadcrumbs.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 26 Mar 2010 08:32:32 +0100
branchstable
changeset 5032 e3fa27fc0d9a
parent 4802 fa2297d6542a
child 5291 593adaccd737
permissions -rw-r--r--
cleanup
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     1
"""navigation components definition for CubicWeb web client
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     2
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     3
:organization: Logilab
4212
ab6573088b4a update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3862
diff changeset
     4
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     5
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
1977
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1882
diff changeset
     6
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     7
"""
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     8
__docformat__ = "restructuredtext en"
1882
ce662160bb46 cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1802
diff changeset
     9
_ = unicode
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    10
2312
af4d8f75c5db use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    11
from logilab.mtconverter import xml_escape
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    12
3007
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    13
from cubicweb.interfaces import IBreadCrumbs
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    14
from cubicweb.selectors import (one_line_rset, implements, one_etype_rset,
4320
4efd4c306746 closes #345410: two_lines_rset, two_cols_rset, two_etypes_rset are badly named
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    15
                                multi_lines_rset, any_rset)
3007
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    16
from cubicweb.view import EntityView, Component
713
5adb6d8e5fa7 update imports of "cubicweb.common.entity" and use the new module path "cubicweb.entity"
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 692
diff changeset
    17
# don't use AnyEntity since this may cause bug with isinstance() due to reloading
984
536e421b082b import updates
sylvain.thenault@logilab.fr
parents: 742
diff changeset
    18
from cubicweb.entity import Entity
4023
eae23c40627a drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3890
diff changeset
    19
from cubicweb import tags, uilib
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    20
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    21
3007
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    22
class BreadCrumbEntityVComponent(Component):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3185
diff changeset
    23
    __regid__ = 'breadcrumbs'
3523
16880e7ee3fa don't accept None to avoid error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3184
diff changeset
    24
    __select__ = one_line_rset() & implements(IBreadCrumbs, accept_none=False)
3007
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    25
3407
da9cc8cc7c5f [api] use cw_property_defs instead of deprecated property_defs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
    26
    cw_property_defs = {
3007
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    27
        _('visible'):  dict(type='Boolean', default=True,
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    28
                            help=_('display the component or not')),
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    29
        }
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    30
    title = _('contentnavigation_breadcrumbs')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    31
    help = _('contentnavigation_breadcrumbs_description')
2996
866a2c135c33 B #345282 xhtml requires to use &#160; instead of &nbsp;
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2312
diff changeset
    32
    separator = u'&#160;&gt;&#160;'
3862
4908c7156eab [breadcrumbs] make it easier to redefine html structure of breadcrumbs component
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3523
diff changeset
    33
    link_template = u'<a href="%s">%s</a>'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    34
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    35
    def call(self, view=None, first_separator=True):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3407
diff changeset
    36
        entity = self.cw_rset.get_entity(0, 0)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    37
        path = entity.breadcrumbs(view)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    38
        if path:
3862
4908c7156eab [breadcrumbs] make it easier to redefine html structure of breadcrumbs component
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3523
diff changeset
    39
            self.open_breadcrumbs()
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    40
            if first_separator:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    41
                self.w(self.separator)
3007
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    42
            self.render_breadcrumbs(entity, path)
3862
4908c7156eab [breadcrumbs] make it easier to redefine html structure of breadcrumbs component
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3523
diff changeset
    43
            self.close_breadcrumbs()
4908c7156eab [breadcrumbs] make it easier to redefine html structure of breadcrumbs component
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3523
diff changeset
    44
4908c7156eab [breadcrumbs] make it easier to redefine html structure of breadcrumbs component
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3523
diff changeset
    45
    def open_breadcrumbs(self):
4908c7156eab [breadcrumbs] make it easier to redefine html structure of breadcrumbs component
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3523
diff changeset
    46
        self.w(u'<span id="breadcrumbs" class="pathbar">')
4908c7156eab [breadcrumbs] make it easier to redefine html structure of breadcrumbs component
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3523
diff changeset
    47
4908c7156eab [breadcrumbs] make it easier to redefine html structure of breadcrumbs component
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3523
diff changeset
    48
    def close_breadcrumbs(self):
4908c7156eab [breadcrumbs] make it easier to redefine html structure of breadcrumbs component
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3523
diff changeset
    49
        self.w(u'</span>')
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 984
diff changeset
    50
3007
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    51
    def render_breadcrumbs(self, contextentity, path):
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    52
        root = path.pop(0)
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    53
        if isinstance(root, Entity):
3890
d7a270f50f54 backport stable branch (one more time painfully)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3524 3862
diff changeset
    54
            self.w(self.link_template % (self._cw.build_url(root.__regid__),
3862
4908c7156eab [breadcrumbs] make it easier to redefine html structure of breadcrumbs component
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3523
diff changeset
    55
                                         root.dc_type('plural')))
3007
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    56
            self.w(self.separator)
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    57
        self.wpath_part(root, contextentity, not path)
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    58
        for i, parent in enumerate(path):
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    59
            self.w(self.separator)
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    60
            self.w(u"\n")
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    61
            self.wpath_part(parent, contextentity, i == len(path) - 1)
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    62
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    63
    def wpath_part(self, part, contextentity, last=False):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    64
        if isinstance(part, Entity):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    65
            if last and part.eid == contextentity.eid:
3179
0684544f6d0d from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3030
diff changeset
    66
                self.w(xml_escape(part.view('breadcrumbtext')))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    67
            else:
3179
0684544f6d0d from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3030
diff changeset
    68
                self.w(part.view('breadcrumbs'))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    69
        elif isinstance(part, tuple):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    70
            url, title = part
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3407
diff changeset
    71
            textsize = self._cw.property_value('navigation.short-line-size')
3862
4908c7156eab [breadcrumbs] make it easier to redefine html structure of breadcrumbs component
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3523
diff changeset
    72
            self.w(self.link_template % (
3179
0684544f6d0d from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3030
diff changeset
    73
                xml_escape(url), xml_escape(uilib.cut(title, textsize))))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    74
        else:
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3407
diff changeset
    75
            textsize = self._cw.property_value('navigation.short-line-size')
3179
0684544f6d0d from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3030
diff changeset
    76
            self.w(uilib.cut(unicode(part), textsize))
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 984
diff changeset
    77
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    78
3007
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    79
class BreadCrumbETypeVComponent(BreadCrumbEntityVComponent):
4320
4efd4c306746 closes #345410: two_lines_rset, two_cols_rset, two_etypes_rset are badly named
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    80
    __select__ = multi_lines_rset() & one_etype_rset() & \
3523
16880e7ee3fa don't accept None to avoid error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3184
diff changeset
    81
                 implements(IBreadCrumbs, accept_none=False)
3007
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    82
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    83
    def render_breadcrumbs(self, contextentity, path):
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    84
        # XXX hack: only display etype name or first non entity path part
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    85
        root = path.pop(0)
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    86
        if isinstance(root, Entity):
3460
e4843535db25 [api] some more _cw / __regid__, automatic tests now pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3451
diff changeset
    87
            self.w(u'<a href="%s">%s</a>' % (self._cw.build_url(root.__regid__),
3007
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    88
                                             root.dc_type('plural')))
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    89
        else:
3030
e086df78e267 B [views] fixing breadcrumbs
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 3015
diff changeset
    90
            self.wpath_part(root, contextentity, not path)
3007
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    91
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    92
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    93
class BreadCrumbAnyRSetVComponent(BreadCrumbEntityVComponent):
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    94
    __select__ = any_rset()
a15e982aa9a3 [breadcrumb] only provides a breadcrumbs component, no more as pluggable content nav comp; provides alternative implentation for rset with more than one entity
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2996
diff changeset
    95
3015
0588e39f6743 [breadcrumb] BreadCrumbAnyRSetVComponent should implements call()
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3007
diff changeset
    96
    def call(self, view=None, first_separator=True):
0588e39f6743 [breadcrumb] BreadCrumbAnyRSetVComponent should implements call()
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3007
diff changeset
    97
        self.w(u'<span id="breadcrumbs" class="pathbar">')
0588e39f6743 [breadcrumb] BreadCrumbAnyRSetVComponent should implements call()
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3007
diff changeset
    98
        if first_separator:
0588e39f6743 [breadcrumb] BreadCrumbAnyRSetVComponent should implements call()
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3007
diff changeset
    99
            self.w(self.separator)
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3407
diff changeset
   100
        self.w(self._cw._('search'))
3015
0588e39f6743 [breadcrumb] BreadCrumbAnyRSetVComponent should implements call()
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3007
diff changeset
   101
        self.w(u'</span>')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   102
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   103
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   104
class BreadCrumbView(EntityView):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3185
diff changeset
   105
    __regid__ = 'breadcrumbs'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   106
4802
fa2297d6542a [views/breadcrumbs] fix bad signature
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4320
diff changeset
   107
    def cell_call(self, row, col, **kwargs):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3407
diff changeset
   108
        entity = self.cw_rset.get_entity(row, col)
3179
0684544f6d0d from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3030
diff changeset
   109
        desc = xml_escape(uilib.cut(entity.dc_description(), 50))
0684544f6d0d from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3030
diff changeset
   110
        # XXX remember camember : tags.a autoescapes !
0684544f6d0d from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3030
diff changeset
   111
        self.w(tags.a(entity.view('breadcrumbtext'),
0684544f6d0d from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3030
diff changeset
   112
                      href=entity.absolute_url(), title=desc))
0684544f6d0d from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3030
diff changeset
   113
0684544f6d0d from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3030
diff changeset
   114
0684544f6d0d from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3030
diff changeset
   115
class BreadCrumbTextView(EntityView):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3185
diff changeset
   116
    __regid__ = 'breadcrumbtext'
3179
0684544f6d0d from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3030
diff changeset
   117
4802
fa2297d6542a [views/breadcrumbs] fix bad signature
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4320
diff changeset
   118
    def cell_call(self, row, col, **kwargs):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3407
diff changeset
   119
        entity = self.cw_rset.get_entity(row, col)
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3407
diff changeset
   120
        textsize = self._cw.property_value('navigation.short-line-size')
3179
0684544f6d0d from 3.5 branch; XXX the test depends on an eid value
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3030
diff changeset
   121
        self.w(uilib.cut(entity.dc_title(), textsize))