author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Mon, 11 Oct 2010 12:03:12 +0200 | |
changeset 6437 | d88be69179b8 |
parent 6429 | 72669e7950c1 |
child 6462 | 9586590060d4 |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5148
diff
changeset
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5148
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5148
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5148
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5148
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5148
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5148
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5148
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5148
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5148
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5148
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5148
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5148
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5148
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5148
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5148
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
0 | 18 |
"""Bases HTML components: |
19 |
||
20 |
* the rql input form |
|
21 |
* the logged user link |
|
5854 | 22 |
""" |
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
23 |
from __future__ import with_statement |
0 | 24 |
|
25 |
__docformat__ = "restructuredtext en" |
|
1937 | 26 |
_ = unicode |
0 | 27 |
|
2313 | 28 |
from logilab.mtconverter import xml_escape |
6396
a9e4c51fc1c1
[login ui] cleanup and somewhat bw compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6389
diff
changeset
|
29 |
from logilab.common.deprecation import class_renamed |
0 | 30 |
from rql import parse |
31 |
||
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6141
diff
changeset
|
32 |
from cubicweb.selectors import (yes, multi_etypes_rset, match_form_params, |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6141
diff
changeset
|
33 |
match_context, configuration_values, |
5148
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
34 |
anonymous_user, authenticated_user) |
1699 | 35 |
from cubicweb.schema import display_name |
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
36 |
from cubicweb.utils import wrap_on_write |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4004
diff
changeset
|
37 |
from cubicweb.uilib import toggle_action |
1739 | 38 |
from cubicweb.web import component |
1699 | 39 |
from cubicweb.web.htmlwidgets import (MenuWidget, PopupBoxMenu, BoxSeparator, |
40 |
BoxLink) |
|
0 | 41 |
|
1511
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
42 |
VISIBLE_PROP_DEF = { |
1968
d3de0f44b57b
components should be visible by default, applmessages components should not be hideable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1937
diff
changeset
|
43 |
_('visible'): dict(type='Boolean', default=True, |
1511
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
44 |
help=_('display the component or not')), |
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
45 |
} |
0 | 46 |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1514
diff
changeset
|
47 |
class RQLInputForm(component.Component): |
0 | 48 |
"""build the rql input form, usually displayed in the header""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3185
diff
changeset
|
49 |
__regid__ = 'rqlinput' |
2799
b703639614e7
refactor property handling to avoid name conflicts
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
50 |
cw_property_defs = VISIBLE_PROP_DEF |
2120
ed1cd652b343
rqlinput should have its default visible property to false
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2119
diff
changeset
|
51 |
visible = False |
2172
cf8f9180e63e
delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2120
diff
changeset
|
52 |
|
0 | 53 |
def call(self, view=None): |
54 |
if hasattr(view, 'filter_box_context_info'): |
|
55 |
rset = view.filter_box_context_info()[0] |
|
56 |
else: |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
57 |
rset = self.cw_rset |
0 | 58 |
# display multilines query as one line |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
59 |
rql = rset is not None and rset.printable_rql(encoded=False) or self._cw.form.get('rql', '') |
0 | 60 |
rql = rql.replace(u"\n", u" ") |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
61 |
req = self._cw |
0 | 62 |
self.w(u'''<div id="rqlinput" class="%s"> |
63 |
<form action="%s"> |
|
64 |
<fieldset> |
|
65 |
<input type="text" id="rql" name="rql" value="%s" title="%s" tabindex="%s" accesskey="q" class="searchField" /> |
|
66 |
</fieldset> |
|
2818
326375561412
propagate some api changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2799
diff
changeset
|
67 |
''' % (not self.cw_propval('visible') and 'hidden' or '', |
5819
1017163825c7
[css] more css rework, need visual test in compat/new modes
katia
parents:
5478
diff
changeset
|
68 |
self._cw.build_url('view'), xml_escape(rql), req._('full text or RQL query'), req.next_tabindex())) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
69 |
if self._cw.search_state[0] != 'normal': |
0 | 70 |
self.w(u'<input type="hidden" name="__mode" value="%s"/>' |
71 |
% ':'.join(req.search_state[1])) |
|
72 |
self.w(u'</form></div>') |
|
73 |
||
74 |
||
1511
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
75 |
|
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
76 |
class HeaderComponent(component.CtxComponent): # XXX rename properly along with related context |
5148
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
77 |
"""if the user is the anonymous user, build a link to login else display a menu |
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
78 |
with user'action (preference, logout, etc...) |
0 | 79 |
""" |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6141
diff
changeset
|
80 |
__abstract__ = True |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
81 |
cw_property_defs = component.override_ctx( |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
82 |
component.CtxComponent, |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
83 |
vocabulary=['header-left', 'header-center', 'header-right']) |
1511
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
84 |
# don't want user to hide this component using an cwproperty |
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
85 |
site_wide = True |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
86 |
context = _('header-center') |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
87 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
88 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
89 |
class ApplLogo(HeaderComponent): |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
90 |
"""build the instance logo, usually displayed in the header""" |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
91 |
__regid__ = 'logo' |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
92 |
order = -1 |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
93 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
94 |
def render(self, w): |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
95 |
w(u'<a href="%s"><img id="logo" src="%s" alt="logo"/></a>' |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
96 |
% (self._cw.base_url(), self._cw.uiprops['LOGO'])) |
0 | 97 |
|
5148
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
98 |
|
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
99 |
class ApplicationName(HeaderComponent): |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
100 |
"""display the instance name""" |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
101 |
__regid__ = 'appliname' |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
102 |
context = _('header-center') |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
103 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
104 |
def render(self, w): |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
105 |
title = self._cw.property_value('ui.site-title') |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
106 |
if title: |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
107 |
w(u'<span id="appliName"><a href="%s">%s</a></span>' % ( |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
108 |
self._cw.base_url(), xml_escape(title))) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
109 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
110 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
111 |
class CookieLoginComponent(HeaderComponent): |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
112 |
__regid__ = 'anonuserlink' |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
113 |
__select__ = (HeaderComponent.__select__ & anonymous_user() |
6396
a9e4c51fc1c1
[login ui] cleanup and somewhat bw compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6389
diff
changeset
|
114 |
& configuration_values('auth-mode', 'cookie')) |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
115 |
context = 'header-right' |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6141
diff
changeset
|
116 |
loginboxid = 'popupLoginBox' |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
117 |
_html = u"""[<a class="logout" title="%s" href="javascript: |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
118 |
cw.htmlhelpers.popupLoginBox('%s', '__login');">%s</a>]""" |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
119 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
120 |
def render(self, w): |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
121 |
# XXX bw compat, though should warn about subclasses redefining call |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
122 |
self.w = w |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
123 |
self.call() |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6141
diff
changeset
|
124 |
|
0 | 125 |
def call(self): |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
126 |
self.w(self._html % (self._cw._('login / password'), |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
127 |
self.loginboxid, self._cw._('i18n_login_popup'))) |
6437
d88be69179b8
CtxComponent don't have wview
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6429
diff
changeset
|
128 |
self.view('logform', rset=self.cw_rset, id=self.loginboxid, |
d88be69179b8
CtxComponent don't have wview
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6429
diff
changeset
|
129 |
klass='%s hidden' % self.loginboxid, title=False, showmessage=False, |
d88be69179b8
CtxComponent don't have wview
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6429
diff
changeset
|
130 |
w=self.w) |
0 | 131 |
|
6396
a9e4c51fc1c1
[login ui] cleanup and somewhat bw compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6389
diff
changeset
|
132 |
|
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
133 |
class HTTPLoginComponent(CookieLoginComponent): |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
134 |
__select__ = (HeaderComponent.__select__ & anonymous_user() |
6396
a9e4c51fc1c1
[login ui] cleanup and somewhat bw compat
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6389
diff
changeset
|
135 |
& configuration_values('auth-mode', 'http')) |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6141
diff
changeset
|
136 |
|
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
137 |
def render(self, w): |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6141
diff
changeset
|
138 |
# this redirects to the 'login' controller which in turn |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6141
diff
changeset
|
139 |
# will raise a 401/Unauthorized |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
140 |
req = self._cw |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
141 |
w(u'[<a class="logout" title="%s" href="%s">%s</a>]' |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
142 |
% (req._('login / password'), req.build_url('login'), req._('login'))) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
143 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
144 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
145 |
_UserLink = class_renamed('_UserLink', HeaderComponent) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
146 |
AnonUserLink = class_renamed('AnonUserLink', CookieLoginComponent) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
147 |
AnonUserLink.__abstract__ = True |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
148 |
AnonUserLink.__select__ &= yes(1) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
149 |
|
0 | 150 |
|
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
151 |
class AnonUserStatusLink(HeaderComponent): |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
152 |
__regid__ = 'userstatus' |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
153 |
__select__ = HeaderComponent.__select__ & anonymous_user() |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
154 |
context = _('header-right') |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
155 |
order = HeaderComponent.order - 10 |
5148
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
156 |
|
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
157 |
def render(self, w): |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
158 |
w(u'<span class="caption">%s</span>' % self._cw._('anonymous')) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
159 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
160 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
161 |
class AuthenticatedUserStatus(AnonUserStatusLink): |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
162 |
__select__ = HeaderComponent.__select__ & authenticated_user() |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
163 |
|
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
164 |
def render(self, w): |
5148
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
165 |
# display useractions and siteactions |
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
166 |
actions = self._cw.vreg['actions'].possible_actions(self._cw, rset=self.cw_rset) |
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
167 |
box = MenuWidget('', 'userActionsBox', _class='', islist=False) |
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
168 |
menu = PopupBoxMenu(self._cw.user.login, isitem=False) |
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
169 |
box.append(menu) |
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
170 |
for action in actions.get('useractions', ()): |
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
171 |
menu.append(BoxLink(action.url(), self._cw._(action.title), |
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
172 |
action.html_class())) |
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
173 |
if actions.get('useractions') and actions.get('siteactions'): |
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
174 |
menu.append(BoxSeparator()) |
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
175 |
for action in actions.get('siteactions', ()): |
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
176 |
menu.append(BoxLink(action.url(), self._cw._(action.title), |
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
177 |
action.html_class())) |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6396
diff
changeset
|
178 |
box.render(w=w) |
5148
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
179 |
|
ec0ea7366066
[web components] refactor as book recommends :$
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4935
diff
changeset
|
180 |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1514
diff
changeset
|
181 |
class ApplicationMessage(component.Component): |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2381
diff
changeset
|
182 |
"""display messages given using the __message parameter into a special div |
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2381
diff
changeset
|
183 |
section |
0 | 184 |
""" |
742
99115e029dca
replaced most of __selectors__ assignments with __select__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
692
diff
changeset
|
185 |
__select__ = yes() |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3185
diff
changeset
|
186 |
__regid__ = 'applmessages' |
1511
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
187 |
# don't want user to hide this component using an cwproperty |
2799
b703639614e7
refactor property handling to avoid name conflicts
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
188 |
cw_property_defs = {} |
0 | 189 |
|
190 |
def call(self): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
191 |
msgs = [msg for msg in (self._cw.get_shared_data('sources_error', pop=True), |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
192 |
self._cw.message) if msg] |
0 | 193 |
self.w(u'<div id="appMsg" onclick="%s" class="%s">\n' % |
194 |
(toggle_action('appMsg'), (msgs and ' ' or 'hidden'))) |
|
195 |
for msg in msgs: |
|
6140
65a619eb31c4
[boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5854
diff
changeset
|
196 |
self.w(u'<div class="message" id="%s">%s</div>' % (self.domid, msg)) |
0 | 197 |
self.w(u'</div>') |
198 |
||
199 |
||
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1514
diff
changeset
|
200 |
class EtypeRestrictionComponent(component.Component): |
0 | 201 |
"""displays the list of entity types contained in the resultset |
202 |
to be able to filter accordingly. |
|
203 |
""" |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3185
diff
changeset
|
204 |
__regid__ = 'etypenavigation' |
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
|
205 |
__select__ = multi_etypes_rset() | match_form_params('__restrtype', '__restrtypes', |
758
0c0dfd33a76d
instantiate selectors wherever needed
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
742
diff
changeset
|
206 |
'__restrrql') |
2799
b703639614e7
refactor property handling to avoid name conflicts
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
207 |
cw_property_defs = VISIBLE_PROP_DEF |
1511
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
208 |
# don't want user to hide this component using an cwproperty |
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
209 |
site_wide = True |
0 | 210 |
visible = False # disabled by default |
1511
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
211 |
|
0 | 212 |
def call(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
213 |
_ = self._cw._ |
0 | 214 |
self.w(u'<div id="etyperestriction">') |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
215 |
restrtype = self._cw.form.get('__restrtype') |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
216 |
restrtypes = self._cw.form.get('__restrtypes', '').split(',') |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
217 |
restrrql = self._cw.form.get('__restrrql') |
0 | 218 |
if not restrrql: |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
219 |
rqlst = self.cw_rset.syntax_tree() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
220 |
restrrql = rqlst.as_string(self._cw.encoding, self.cw_rset.args) |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
221 |
restrtypes = self.cw_rset.column_types(0) |
0 | 222 |
else: |
223 |
rqlst = parse(restrrql) |
|
224 |
html = [] |
|
225 |
on_etype = False |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
226 |
etypes = sorted((display_name(self._cw, etype).capitalize(), etype) |
0 | 227 |
for etype in restrtypes) |
228 |
for elabel, etype in etypes: |
|
229 |
if etype == restrtype: |
|
230 |
html.append(u'<span class="selected">%s</span>' % elabel) |
|
231 |
on_etype = True |
|
232 |
else: |
|
233 |
rqlst.save_state() |
|
234 |
for select in rqlst.children: |
|
235 |
select.add_type_restriction(select.selection[0], etype) |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
236 |
newrql = rqlst.as_string(self._cw.encoding, self.cw_rset.args) |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
237 |
url = self._cw.build_url(rql=newrql, __restrrql=restrrql, |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
238 |
__restrtype=etype, __restrtypes=','.join(restrtypes)) |
0 | 239 |
html.append(u'<span><a href="%s">%s</a></span>' % ( |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2218
diff
changeset
|
240 |
xml_escape(url), elabel)) |
0 | 241 |
rqlst.recover() |
242 |
if on_etype: |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3407
diff
changeset
|
243 |
url = self._cw.build_url(rql=restrrql) |
0 | 244 |
html.insert(0, u'<span><a href="%s">%s</a></span>' % ( |
245 |
url, _('Any'))) |
|
246 |
else: |
|
247 |
html.insert(0, u'<span class="selected">%s</span>' % _('Any')) |
|
2996
866a2c135c33
B #345282 xhtml requires to use   instead of
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2650
diff
changeset
|
248 |
self.w(u' | '.join(html)) |
0 | 249 |
self.w(u'</div>') |
1511
514e4e53a3c7
do not set visible property by default
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
250 |
|
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
251 |
# contextual components ######################################################## |
3840
2eff4348b1e4
prepare support for a 'context toolbar', used in tracker but will much probably be backported in default primary view. Turn pdfview component into a toolbar element
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3818
diff
changeset
|
252 |
|
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
253 |
# class SeeAlsoVComponent(component.RelatedObjectsVComponent): |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
254 |
# """display any entity's see also""" |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
255 |
# __regid__ = 'seealso' |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
256 |
# context = 'navcontentbottom' |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
257 |
# rtype = 'see_also' |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
258 |
# role = 'subject' |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
259 |
# order = 40 |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
260 |
# # register msg not generated since no entity use see_also in cubicweb itself |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
261 |
# title = _('ctxcomponents_seealso') |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
262 |
# help = _('ctxcomponents_seealso_description') |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
263 |
|
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
264 |
|
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
265 |
class MetaDataComponent(component.EntityCtxComponent): |
4004
c52619c738a5
api renaming update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
266 |
__regid__ = 'metadata' |
3844
c2625c512085
stop calling render_entity_metadata in primary view, provides a
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3840
diff
changeset
|
267 |
context = 'navbottom' |
c2625c512085
stop calling render_entity_metadata in primary view, provides a
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3840
diff
changeset
|
268 |
order = 1 |
c2625c512085
stop calling render_entity_metadata in primary view, provides a
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3840
diff
changeset
|
269 |
|
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
270 |
def render_body(self, w): |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
271 |
self.entity.view('metadata', w=w) |
3844
c2625c512085
stop calling render_entity_metadata in primary view, provides a
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3840
diff
changeset
|
272 |
|
3848 | 273 |
|
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
274 |
class SectionLayout(component.Layout): |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
275 |
__select__ = match_context('navtop', 'navbottom', |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
276 |
'navcontenttop', 'navcontentbottom') |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
277 |
cssclass = 'section' |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
278 |
|
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
279 |
def render(self, w): |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
280 |
if self.init_rendering(): |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
281 |
view = self.cw_extra_kwargs['view'] |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
282 |
w(u'<div class="%s %s" id="%s">' % (self.cssclass, view.cssclass, |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
283 |
view.domid)) |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
284 |
with wrap_on_write(w, '<h4>') as wow: |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
285 |
view.render_title(wow) |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
286 |
view.render_body(w) |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
287 |
w(u'</div>\n') |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
288 |
|
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
289 |
|
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
290 |
# def registration_callback(vreg): |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
291 |
# vreg.register_all(globals().values(), __name__, (SeeAlsoVComponent,)) |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
292 |
# if 'see_also' in vreg.schema: |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
293 |
# vreg.register(SeeAlsoVComponent) |