author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Mon, 10 Jan 2011 12:28:09 +0100 | |
branch | stable |
changeset 6796 | e70ca9abfc51 |
parent 6786 | ce35c6f2f219 |
child 7069 | 8bf2337a6f3b |
child 7071 | db7608cb32bc |
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:
4952
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:
4952
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:
4952
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:
4952
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:
4952
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:
4952
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:
4952
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:
4952
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:
4952
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:
4952
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:
4952
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:
4952
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:
4952
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:
4952
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:
4952
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:
4952
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
5584
c1823448f81d
[web] disallow authenticated users to access to the login form (closes #914873)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
18 |
"""default templates for CubicWeb web client""" |
0 | 19 |
|
20 |
__docformat__ = "restructuredtext en" |
|
6582
8eb7883b4223
[pylint] fix a bug of pylint detected errors and i18n pb (calling builtins._ instead of req._)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6453
diff
changeset
|
21 |
_ = unicode |
0 | 22 |
|
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2119
diff
changeset
|
23 |
from logilab.mtconverter import xml_escape |
4599 | 24 |
from logilab.common.deprecation import class_renamed |
0 | 25 |
|
2657
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
26 |
from cubicweb.appobject import objectify_selector |
5584
c1823448f81d
[web] disallow authenticated users to access to the login form (closes #914873)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
27 |
from cubicweb.selectors import match_kwargs, no_cnx, anonymous_user |
2061
6a5044f15cb9
[basetemplates] do not use STRICT_DOCTYPE directly, use self.doctype to deal with non xhtml browser
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
28 |
from cubicweb.view import View, MainTemplate, NOINDEX, NOFOLLOW |
5195
e8235b2789fc
le patch move-pdf-export-to-cubes a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4952
diff
changeset
|
29 |
from cubicweb.utils import UStringIO |
3242
390acf7594ed
missing import
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3184
diff
changeset
|
30 |
from cubicweb.schema import display_name |
4935
f710770e6e90
move pdf icon component with it's template so we don't see it when the template isn't available due to missing dependancies
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4781
diff
changeset
|
31 |
from cubicweb.web import component, formfields as ff, formwidgets as fw |
4594
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
32 |
from cubicweb.web.views import forms |
2555
ca7b122f34fa
fix html headers for forced html content type : main template and json controller
Fabrice <fabrice@secondweb.fr>
parents:
2381
diff
changeset
|
33 |
|
0 | 34 |
# main templates ############################################################## |
35 |
||
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
36 |
class LogInOutTemplate(MainTemplate): |
0 | 37 |
|
38 |
def call(self): |
|
39 |
self.set_request_content_type() |
|
40 |
w = self.w |
|
41 |
self.write_doctype() |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
42 |
self.template_header('text/html', self._cw._('login_action')) |
0 | 43 |
w(u'<body>\n') |
44 |
self.content(w) |
|
45 |
w(u'</body>') |
|
46 |
||
47 |
def template_header(self, content_type, view=None, page_title='', additional_headers=()): |
|
48 |
w = self.whead |
|
49 |
# explictly close the <base> tag to avoid IE 6 bugs while browsing DOM |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
50 |
w(u'<base href="%s"></base>' % xml_escape(self._cw.base_url())) |
0 | 51 |
w(u'<meta http-equiv="content-type" content="%s; charset=%s"/>\n' |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
52 |
% (content_type, self._cw.encoding)) |
0 | 53 |
w(NOINDEX) |
54 |
w(NOFOLLOW) |
|
55 |
w(u'\n'.join(additional_headers) + u'\n') |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
56 |
self.wview('htmlheader', rset=self.cw_rset) |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2119
diff
changeset
|
57 |
w(u'<title>%s</title>\n' % xml_escape(page_title)) |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
58 |
|
0 | 59 |
|
60 |
class LogInTemplate(LogInOutTemplate): |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
61 |
__regid__ = 'login' |
5584
c1823448f81d
[web] disallow authenticated users to access to the login form (closes #914873)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
62 |
__select__ = anonymous_user() |
0 | 63 |
title = 'log in' |
64 |
||
65 |
def content(self, w): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
66 |
self.wview('logform', rset=self.cw_rset, id='loginBox', klass='') |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
67 |
|
0 | 68 |
|
69 |
class LoggedOutTemplate(LogInOutTemplate): |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
70 |
__regid__ = 'loggedout' |
0 | 71 |
title = 'logged out' |
72 |
||
73 |
def content(self, w): |
|
852
105893288777
simplify css style
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
432
diff
changeset
|
74 |
# FIXME Deprecated code ? |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
75 |
msg = self._cw._('you have been logged out') |
852
105893288777
simplify css style
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
432
diff
changeset
|
76 |
w(u'<h2>%s</h2>\n' % msg) |
3659 | 77 |
if self._cw.vreg.config['anonymous-user']: |
3460
e4843535db25
[api] some more _cw / __regid__, automatic tests now pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
78 |
indexurl = self._cw.build_url('view', vid='index', __message=msg) |
0 | 79 |
w(u'<p><a href="%s">%s</a><p>' % ( |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2119
diff
changeset
|
80 |
xml_escape(indexurl), |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
81 |
self._cw._('go back to the index page'))) |
0 | 82 |
|
5584
c1823448f81d
[web] disallow authenticated users to access to the login form (closes #914873)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
83 |
|
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
84 |
@objectify_selector |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
85 |
def templatable_view(cls, req, rset, *args, **kwargs): |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
86 |
view = kwargs.pop('view', None) |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
87 |
if view is None: |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
88 |
return 1 |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
89 |
if view.binary: |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
90 |
return 0 |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
91 |
if req.form.has_key('__notemplate'): |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
92 |
return 0 |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
93 |
return view.templatable |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
94 |
|
6005
0300fae1f7cb
[views] link to public url when trying https without an account
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5988
diff
changeset
|
95 |
|
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
96 |
class NonTemplatableViewTemplate(MainTemplate): |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
97 |
"""main template for any non templatable views (xml, binaries, etc.)""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
98 |
__regid__ = 'main-template' |
1421
77ee26df178f
doc type handling refactoring: do the ext substitution at the module level
sylvain.thenault@logilab.fr
parents:
1149
diff
changeset
|
99 |
__select__ = ~templatable_view() |
77ee26df178f
doc type handling refactoring: do the ext substitution at the module level
sylvain.thenault@logilab.fr
parents:
1149
diff
changeset
|
100 |
|
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
101 |
def call(self, view): |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
102 |
view.set_request_content_type() |
1421
77ee26df178f
doc type handling refactoring: do the ext substitution at the module level
sylvain.thenault@logilab.fr
parents:
1149
diff
changeset
|
103 |
view.set_stream() |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
104 |
if (self._cw.form.has_key('__notemplate') and view.templatable |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
105 |
and view.content_type == self._cw.html_content_type()): |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
106 |
view.w(self._cw.document_surrounding_div()) |
2555
ca7b122f34fa
fix html headers for forced html content type : main template and json controller
Fabrice <fabrice@secondweb.fr>
parents:
2381
diff
changeset
|
107 |
view.render() |
2559
46859078c866
[R xhtml] remove xhtml_wrap* function, use instead a single req.document_surrounding_div method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2555
diff
changeset
|
108 |
view.w(u'</div>') |
2555
ca7b122f34fa
fix html headers for forced html content type : main template and json controller
Fabrice <fabrice@secondweb.fr>
parents:
2381
diff
changeset
|
109 |
else: |
ca7b122f34fa
fix html headers for forced html content type : main template and json controller
Fabrice <fabrice@secondweb.fr>
parents:
2381
diff
changeset
|
110 |
view.render() |
2559
46859078c866
[R xhtml] remove xhtml_wrap* function, use instead a single req.document_surrounding_div method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2555
diff
changeset
|
111 |
# have to replace our stream by view's stream (which may be a binary |
46859078c866
[R xhtml] remove xhtml_wrap* function, use instead a single req.document_surrounding_div method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2555
diff
changeset
|
112 |
# stream) |
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
113 |
self._stream = view._stream |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
114 |
|
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
115 |
|
0 | 116 |
class TheMainTemplate(MainTemplate): |
117 |
"""default main template : |
|
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
118 |
|
0 | 119 |
- call header / footer templates |
120 |
""" |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
121 |
__regid__ = 'main-template' |
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
122 |
__select__ = templatable_view() |
1421
77ee26df178f
doc type handling refactoring: do the ext substitution at the module level
sylvain.thenault@logilab.fr
parents:
1149
diff
changeset
|
123 |
|
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
124 |
def call(self, view): |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
125 |
self.set_request_content_type() |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
126 |
self.template_header(self.content_type, view) |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
127 |
w = self.w |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
128 |
w(u'<div id="pageContent">\n') |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
129 |
vtitle = self._cw.form.get('vtitle') |
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
130 |
if vtitle: |
6140
65a619eb31c4
[boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6109
diff
changeset
|
131 |
w(u'<div class="vtitle">%s</div>\n' % xml_escape(vtitle)) |
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
132 |
# display entity type restriction component |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
133 |
etypefilter = self._cw.vreg['components'].select_or_none( |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
134 |
'etypenavigation', self._cw, rset=self.cw_rset) |
2818
326375561412
propagate some api changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2813
diff
changeset
|
135 |
if etypefilter and etypefilter.cw_propval('visible'): |
1723 | 136 |
etypefilter.render(w=w) |
5988
d8ac8acd27f9
[basetemplate nav] no need for an attribute here
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5854
diff
changeset
|
137 |
nav_html = UStringIO() |
4244
2c3de1953d00
rename need_navigation into paginable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
138 |
if view: |
5988
d8ac8acd27f9
[basetemplate nav] no need for an attribute here
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5854
diff
changeset
|
139 |
view.paginate(w=nav_html.write) |
6178
9b596b11e375
remove buggy call to builtins._ on navigation content
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6109
diff
changeset
|
140 |
w(nav_html.getvalue()) |
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
141 |
w(u'<div id="contentmain">\n') |
1723 | 142 |
view.render(w=w) |
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
143 |
w(u'</div>\n') # close id=contentmain |
6178
9b596b11e375
remove buggy call to builtins._ on navigation content
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6109
diff
changeset
|
144 |
w(nav_html.getvalue()) |
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
145 |
w(u'</div>\n') # closes id=pageContent |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
146 |
self.template_footer(view) |
0 | 147 |
|
148 |
def template_header(self, content_type, view=None, page_title='', additional_headers=()): |
|
149 |
page_title = page_title or view.page_title() |
|
150 |
additional_headers = additional_headers or view.html_headers() |
|
151 |
self.template_html_header(content_type, page_title, additional_headers) |
|
152 |
self.template_body_header(view) |
|
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
153 |
|
0 | 154 |
def template_html_header(self, content_type, page_title, additional_headers=()): |
155 |
w = self.whead |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
156 |
lang = self._cw.lang |
0 | 157 |
self.write_doctype() |
2580
6e9453fd11ef
always explicitly close <base> tags because of an old IE6 bug
Florent <florent@secondweb.fr>
parents:
2559
diff
changeset
|
158 |
# explictly close the <base> tag to avoid IE 6 bugs while browsing DOM |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
159 |
w(u'<base href="%s"></base>' % xml_escape(self._cw.base_url())) |
0 | 160 |
w(u'<meta http-equiv="content-type" content="%s; charset=%s"/>\n' |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
161 |
% (content_type, self._cw.encoding)) |
0 | 162 |
w(u'\n'.join(additional_headers) + u'\n') |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
163 |
self.wview('htmlheader', rset=self.cw_rset) |
0 | 164 |
if page_title: |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2119
diff
changeset
|
165 |
w(u'<title>%s</title>\n' % xml_escape(page_title)) |
0 | 166 |
|
167 |
def template_body_header(self, view): |
|
168 |
w = self.w |
|
169 |
w(u'<body>\n') |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
170 |
self.wview('header', rset=self.cw_rset, view=view) |
0 | 171 |
w(u'<div id="page"><table width="100%" border="0" id="mainLayout"><tr>\n') |
172 |
self.nav_column(view, 'left') |
|
5478
c52124b7a00e
[css] progressively fixing rhythm
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5477
diff
changeset
|
173 |
w(u'<td id="contentColumn">\n') |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
174 |
components = self._cw.vreg['components'] |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
175 |
rqlcomp = components.select_or_none('rqlinput', self._cw, rset=self.cw_rset) |
0 | 176 |
if rqlcomp: |
1723 | 177 |
rqlcomp.render(w=self.w, view=view) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
178 |
msgcomp = components.select_or_none('applmessages', self._cw, rset=self.cw_rset) |
0 | 179 |
if msgcomp: |
1723 | 180 |
msgcomp.render(w=self.w) |
0 | 181 |
self.content_header(view) |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
182 |
|
0 | 183 |
def template_footer(self, view=None): |
184 |
self.content_footer(view) |
|
185 |
self.w(u'</td>\n') |
|
186 |
self.nav_column(view, 'right') |
|
187 |
self.w(u'</tr></table></div>\n') |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
188 |
self.wview('footer', rset=self.cw_rset) |
0 | 189 |
self.w(u'</body>') |
190 |
||
191 |
def nav_column(self, view, context): |
|
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
192 |
boxes = list(self._cw.vreg['ctxcomponents'].poss_visible_objects( |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
193 |
self._cw, rset=self.cw_rset, view=view, context=context)) |
0 | 194 |
if boxes: |
6140
65a619eb31c4
[boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6109
diff
changeset
|
195 |
getlayout = self._cw.vreg['components'].select |
5478
c52124b7a00e
[css] progressively fixing rhythm
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5477
diff
changeset
|
196 |
self.w(u'<td id="navColumn%s"><div class="navboxes">\n' % context.capitalize()) |
0 | 197 |
for box in boxes: |
1723 | 198 |
box.render(w=self.w, view=view) |
0 | 199 |
self.w(u'</div></td>\n') |
200 |
||
201 |
def content_header(self, view=None): |
|
202 |
"""by default, display informal messages in content header""" |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
203 |
self.wview('contentheader', rset=self.cw_rset, view=view) |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
204 |
|
0 | 205 |
def content_footer(self, view=None): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
206 |
self.wview('contentfooter', rset=self.cw_rset, view=view) |
0 | 207 |
|
208 |
||
209 |
class ErrorTemplate(TheMainTemplate): |
|
6109
47d9c0e0f7b7
integrate Celso's work on translation file: proper/complete spanish translation, fixed some typos in french translation, occured -> occurred fix in various places
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6091
diff
changeset
|
210 |
"""fallback template if an internal error occurred during displaying the main |
5223
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5195
diff
changeset
|
211 |
template. This template may be called for authentication error, which means |
6abd6e3599f4
#773448: refactor session and 'no connection' handling, by introducing proper web session. We should now be able to see page even when no anon is configured, and be redirected to the login form as soon as one tries to do a query.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5195
diff
changeset
|
212 |
that req.cnx and req.user may not be set. |
0 | 213 |
""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
214 |
__regid__ = 'error-template' |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
215 |
|
0 | 216 |
def call(self): |
217 |
"""display an unexpected error""" |
|
218 |
self.set_request_content_type() |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
219 |
self._cw.reset_headers() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
220 |
view = self._cw.vreg['views'].select('error', self._cw, rset=self.cw_rset) |
6109
47d9c0e0f7b7
integrate Celso's work on translation file: proper/complete spanish translation, fixed some typos in french translation, occured -> occurred fix in various places
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6091
diff
changeset
|
221 |
self.template_header(self.content_type, view, self._cw._('an error occurred'), |
0 | 222 |
[NOINDEX, NOFOLLOW]) |
1723 | 223 |
view.render(w=self.w) |
0 | 224 |
self.template_footer(view) |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
225 |
|
0 | 226 |
def template_header(self, content_type, view=None, page_title='', additional_headers=()): |
227 |
w = self.whead |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
228 |
lang = self._cw.lang |
0 | 229 |
self.write_doctype() |
230 |
w(u'<meta http-equiv="content-type" content="%s; charset=%s"/>\n' |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
231 |
% (content_type, self._cw.encoding)) |
0 | 232 |
w(u'\n'.join(additional_headers)) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
233 |
self.wview('htmlheader', rset=self.cw_rset) |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2119
diff
changeset
|
234 |
w(u'<title>%s</title>\n' % xml_escape(page_title)) |
0 | 235 |
self.w(u'<body>\n') |
236 |
||
237 |
def template_footer(self, view=None): |
|
238 |
self.w(u'</body>') |
|
239 |
||
240 |
||
241 |
class SimpleMainTemplate(TheMainTemplate): |
|
242 |
||
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
243 |
__regid__ = 'main-no-top' |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
244 |
|
163
451a3e35dbcb
repairing error from preceding commit
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
158
diff
changeset
|
245 |
def template_header(self, content_type, view=None, page_title='', additional_headers=()): |
451a3e35dbcb
repairing error from preceding commit
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
158
diff
changeset
|
246 |
page_title = page_title or view.page_title() |
0 | 247 |
additional_headers = additional_headers or view.html_headers() |
248 |
whead = self.whead |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
249 |
lang = self._cw.lang |
0 | 250 |
self.write_doctype() |
251 |
whead(u'<meta http-equiv="content-type" content="%s; charset=%s"/>\n' |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
252 |
% (content_type, self._cw.encoding)) |
0 | 253 |
whead(u'\n'.join(additional_headers) + u'\n') |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
254 |
self.wview('htmlheader', rset=self.cw_rset) |
0 | 255 |
w = self.w |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2119
diff
changeset
|
256 |
w(u'<title>%s</title>\n' % xml_escape(page_title)) |
0 | 257 |
w(u'<body>\n') |
258 |
w(u'<div id="page">') |
|
259 |
w(u'<table width="100%" height="100%" border="0"><tr>\n') |
|
5478
c52124b7a00e
[css] progressively fixing rhythm
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5477
diff
changeset
|
260 |
w(u'<td id="navColumnLeft">\n') |
0 | 261 |
self.topleft_header() |
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
262 |
boxes = list(self._cw.vreg['ctxcomponents'].poss_visible_objects( |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
263 |
self._cw, rset=self.cw_rset, view=view, context='left')) |
0 | 264 |
if boxes: |
265 |
w(u'<div class="navboxes">\n') |
|
266 |
for box in boxes: |
|
1723 | 267 |
box.render(w=w) |
0 | 268 |
self.w(u'</div>\n') |
269 |
w(u'</td>') |
|
270 |
w(u'<td id="contentcol" rowspan="2">') |
|
271 |
w(u'<div id="pageContent">\n') |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
272 |
vtitle = self._cw.form.get('vtitle') |
0 | 273 |
if vtitle: |
6140
65a619eb31c4
[boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6109
diff
changeset
|
274 |
w(u'<div class="vtitle">%s</div>' % xml_escape(vtitle)) |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
275 |
|
0 | 276 |
def topleft_header(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
277 |
logo = self._cw.vreg['components'].select_or_none('logo', self._cw, |
5854 | 278 |
rset=self.cw_rset) |
2818
326375561412
propagate some api changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2813
diff
changeset
|
279 |
if logo and logo.cw_propval('visible'): |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
280 |
w = self.w |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
281 |
w(u'<table id="header"><tr>\n') |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
282 |
w(u'<td>') |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
283 |
logo.render(w=w) |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
284 |
w(u'</td>\n') |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
285 |
w(u'</tr></table>\n') |
0 | 286 |
|
2935
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
287 |
|
0 | 288 |
# page parts templates ######################################################## |
289 |
||
816
9cd49a910fce
kill Template class and 'templates' registry
sylvain.thenault@logilab.fr
parents:
811
diff
changeset
|
290 |
class HTMLHeader(View): |
0 | 291 |
"""default html headers""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
292 |
__regid__ = 'htmlheader' |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
293 |
|
0 | 294 |
def call(self, **kwargs): |
295 |
self.favicon() |
|
296 |
self.stylesheets() |
|
297 |
self.javascripts() |
|
298 |
self.alternates() |
|
299 |
||
300 |
def favicon(self): |
|
5467
57372dbfd114
[https] fix resource urls in https version of a site: should use the https version as well to avoid warnings from the nrowser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5444
diff
changeset
|
301 |
favicon = self._cw.uiprops.get('FAVICON', None) |
0 | 302 |
if favicon: |
303 |
self.whead(u'<link rel="shortcut icon" href="%s"/>\n' % favicon) |
|
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
304 |
|
0 | 305 |
def stylesheets(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
306 |
req = self._cw |
0 | 307 |
add_css = req.add_css |
5467
57372dbfd114
[https] fix resource urls in https version of a site: should use the https version as well to avoid warnings from the nrowser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5444
diff
changeset
|
308 |
for css in req.uiprops['STYLESHEETS']: |
0 | 309 |
add_css(css, localfile=False) |
5467
57372dbfd114
[https] fix resource urls in https version of a site: should use the https version as well to avoid warnings from the nrowser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5444
diff
changeset
|
310 |
for css in req.uiprops['STYLESHEETS_PRINT']: |
0 | 311 |
add_css(css, u'print', localfile=False) |
5467
57372dbfd114
[https] fix resource urls in https version of a site: should use the https version as well to avoid warnings from the nrowser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5444
diff
changeset
|
312 |
for css in req.uiprops['STYLESHEETS_IE']: |
0 | 313 |
add_css(css, localfile=False, ieonly=True) |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
314 |
|
0 | 315 |
def javascripts(self): |
5467
57372dbfd114
[https] fix resource urls in https version of a site: should use the https version as well to avoid warnings from the nrowser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5444
diff
changeset
|
316 |
for jscript in self._cw.uiprops['JAVASCRIPTS']: |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
317 |
self._cw.add_js(jscript, localfile=False) |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
318 |
|
0 | 319 |
def alternates(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
320 |
urlgetter = self._cw.vreg['components'].select_or_none('rss_feed_url', |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
321 |
self._cw, rset=self.cw_rset) |
142
0425ee84cfa6
add selector to test if result set is an object (for rss feed component)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
29
diff
changeset
|
322 |
if urlgetter is not None: |
0 | 323 |
self.whead(u'<link rel="alternate" type="application/rss+xml" title="RSS feed" href="%s"/>\n' |
2381 | 324 |
% xml_escape(urlgetter.feed_url())) |
0 | 325 |
|
326 |
||
816
9cd49a910fce
kill Template class and 'templates' registry
sylvain.thenault@logilab.fr
parents:
811
diff
changeset
|
327 |
class HTMLPageHeader(View): |
0 | 328 |
"""default html page header""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
329 |
__regid__ = 'header' |
3053
51f196c212d9
provide facility to override main header components without having to override the whole methode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3020
diff
changeset
|
330 |
main_cell_components = ('appliname', 'breadcrumbs') |
6697
ffc644fafcb4
[basetemplates] define header ctx components categories as attribute to ease overriding
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6678
diff
changeset
|
331 |
headers = (('headtext', 'header-left'), |
ffc644fafcb4
[basetemplates] define header ctx components categories as attribute to ease overriding
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6678
diff
changeset
|
332 |
('header-right', 'header-right')) |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
333 |
|
0 | 334 |
def call(self, view, **kwargs): |
335 |
self.main_header(view) |
|
6091
560df423149a
[login template] missing xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6005
diff
changeset
|
336 |
self.w(u'<div id="stateheader">') |
0 | 337 |
self.state_header() |
6091
560df423149a
[login template] missing xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6005
diff
changeset
|
338 |
self.w(u'</div>') |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
339 |
|
0 | 340 |
def main_header(self, view): |
341 |
"""build the top menu with authentification info and the rql box""" |
|
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
342 |
w = self.w |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
343 |
w(u'<table id="header"><tr>\n') |
6697
ffc644fafcb4
[basetemplates] define header ctx components categories as attribute to ease overriding
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6678
diff
changeset
|
344 |
for colid, context in self.headers: |
6428
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6389
diff
changeset
|
345 |
w(u'<td id="%s">' % colid) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6389
diff
changeset
|
346 |
components = self._cw.vreg['ctxcomponents'].poss_visible_objects( |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6389
diff
changeset
|
347 |
self._cw, rset=self.cw_rset, view=view, context=context) |
de95bbed8781
[components] refactor main template header: make it much more flexible by using CtxComponent
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6389
diff
changeset
|
348 |
for comp in components: |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
349 |
comp.render(w=w) |
6764
b2c1b481f310
[web/views/basetemplates] nbsp breaks tests, use #160 instead
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6697
diff
changeset
|
350 |
w(u' ') |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
351 |
w(u'</td>') |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
352 |
w(u'</tr></table>\n') |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
353 |
|
0 | 354 |
def state_header(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
355 |
state = self._cw.search_state |
0 | 356 |
if state[0] == 'normal': |
357 |
return |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
358 |
_ = self._cw._ |
4604
96cc3d296d75
remove 3.6 deprecation warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4603
diff
changeset
|
359 |
value = self._cw.view('oneline', self._cw.eid_rset(state[1][1])) |
0 | 360 |
msg = ' '.join((_("searching for"), |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
361 |
display_name(self._cw, state[1][3]), |
0 | 362 |
_("to associate with"), value, |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
363 |
_("by relation"), '"', |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
364 |
display_name(self._cw, state[1][2], state[1][0]), |
0 | 365 |
'"')) |
366 |
return self.w(u'<div class="stateMessage">%s</div>' % msg) |
|
367 |
||
368 |
||
816
9cd49a910fce
kill Template class and 'templates' registry
sylvain.thenault@logilab.fr
parents:
811
diff
changeset
|
369 |
class HTMLPageFooter(View): |
6786
ce35c6f2f219
[footer template] refactor to ease addition of some content into the footer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6764
diff
changeset
|
370 |
"""default html page footer: include footer actions""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
371 |
__regid__ = 'footer' |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
372 |
|
0 | 373 |
def call(self, **kwargs): |
5478
c52124b7a00e
[css] progressively fixing rhythm
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5477
diff
changeset
|
374 |
self.w(u'<div id="footer">') |
6786
ce35c6f2f219
[footer template] refactor to ease addition of some content into the footer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6764
diff
changeset
|
375 |
self.footer_content() |
ce35c6f2f219
[footer template] refactor to ease addition of some content into the footer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6764
diff
changeset
|
376 |
self.w(u'</div>') |
ce35c6f2f219
[footer template] refactor to ease addition of some content into the footer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6764
diff
changeset
|
377 |
|
ce35c6f2f219
[footer template] refactor to ease addition of some content into the footer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6764
diff
changeset
|
378 |
def footer_content(self): |
3655
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3503
diff
changeset
|
379 |
actions = self._cw.vreg['actions'].possible_actions(self._cw, |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3503
diff
changeset
|
380 |
rset=self.cw_rset) |
3495
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3242
diff
changeset
|
381 |
footeractions = actions.get('footer', ()) |
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3242
diff
changeset
|
382 |
for i, action in enumerate(footeractions): |
6140
65a619eb31c4
[boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6109
diff
changeset
|
383 |
self.w(u'<a href="%s">%s</a>' % (action.url(), |
65a619eb31c4
[boxes] introduce new boxes system
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6109
diff
changeset
|
384 |
self._cw._(action.title))) |
3495
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3242
diff
changeset
|
385 |
if i < (len(footeractions) - 1): |
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3242
diff
changeset
|
386 |
self.w(u' | ') |
0 | 387 |
|
816
9cd49a910fce
kill Template class and 'templates' registry
sylvain.thenault@logilab.fr
parents:
811
diff
changeset
|
388 |
class HTMLContentHeader(View): |
0 | 389 |
"""default html page content header: |
390 |
* include message component if selectable for this request |
|
391 |
* include selectable content navigation components |
|
392 |
""" |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
393 |
__regid__ = 'contentheader' |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
394 |
|
0 | 395 |
def call(self, view, **kwargs): |
396 |
"""by default, display informal messages in content header""" |
|
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
397 |
components = self._cw.vreg['ctxcomponents'].poss_visible_objects( |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
398 |
self._cw, rset=self.cw_rset, view=view, context='navtop') |
0 | 399 |
if components: |
400 |
self.w(u'<div id="contentheader">') |
|
401 |
for comp in components: |
|
1723 | 402 |
comp.render(w=self.w, view=view) |
0 | 403 |
self.w(u'</div><div class="clear"></div>') |
404 |
||
405 |
||
816
9cd49a910fce
kill Template class and 'templates' registry
sylvain.thenault@logilab.fr
parents:
811
diff
changeset
|
406 |
class HTMLContentFooter(View): |
0 | 407 |
"""default html page content footer: include selectable content navigation |
408 |
components |
|
409 |
""" |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
410 |
__regid__ = 'contentfooter' |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
411 |
|
0 | 412 |
def call(self, view, **kwargs): |
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6140
diff
changeset
|
413 |
components = self._cw.vreg['ctxcomponents'].poss_visible_objects( |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
414 |
self._cw, rset=self.cw_rset, view=view, context='navbottom') |
0 | 415 |
if components: |
416 |
self.w(u'<div id="contentfooter">') |
|
417 |
for comp in components: |
|
1723 | 418 |
comp.render(w=self.w, view=view) |
0 | 419 |
self.w(u'</div>') |
420 |
||
421 |
||
4594
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
422 |
class LogForm(forms.FieldsForm): |
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
423 |
__regid__ = 'logform' |
4596
13fd398916c2
specify login form dom id, don't render progress div
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4594
diff
changeset
|
424 |
domid = 'loginForm' |
4600
ae95c3241226
use needs_css so you can change login form css without redefining LogFormView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4599
diff
changeset
|
425 |
needs_css = ('cubicweb.login.css',) |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
426 |
onclick = "javascript: cw.htmlhelpers.popupLoginBox('%s', '%s');" |
4594
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
427 |
# XXX have to recall fields name since python is mangling __login/__password |
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
428 |
__login = ff.StringField('__login', widget=fw.TextInput({'class': 'data'})) |
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
429 |
__password = ff.StringField('__password', label=_('password'), |
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
430 |
widget=fw.PasswordSingleInput({'class': 'data'})) |
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
431 |
form_buttons = [fw.SubmitButton(label=_('log in'), |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
432 |
attrs={'class': 'loginButton'}), |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
433 |
fw.ResetButton(label=_('cancel'), |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
434 |
attrs={'class': 'loginButton', |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
435 |
'onclick': onclick % ('popupLoginBox', '__login')}),] |
4594
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
436 |
|
5588
377c9adfe81e
[forms] refactor action handling to ease overriding while keeping action overrideable by instance (closes #969167)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5584
diff
changeset
|
437 |
def form_action(self): |
377c9adfe81e
[forms] refactor action handling to ease overriding while keeping action overrideable by instance (closes #969167)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5584
diff
changeset
|
438 |
if self.action is None: |
377c9adfe81e
[forms] refactor action handling to ease overriding while keeping action overrideable by instance (closes #969167)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5584
diff
changeset
|
439 |
return login_form_url(self._cw) |
377c9adfe81e
[forms] refactor action handling to ease overriding while keeping action overrideable by instance (closes #969167)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5584
diff
changeset
|
440 |
return super(LogForm, self).form_action() |
4594
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
441 |
|
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
442 |
|
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
443 |
class LogFormView(View): |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
444 |
# XXX an awfull lot of hardcoded assumptions there |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
445 |
# makes it unobvious to reuse/specialize |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
446 |
__regid__ = 'logform' |
826
51cb3d85c059
fix LogFormTemplate selector
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
823
diff
changeset
|
447 |
__select__ = match_kwargs('id', 'klass') |
1421
77ee26df178f
doc type handling refactoring: do the ext substitution at the module level
sylvain.thenault@logilab.fr
parents:
1149
diff
changeset
|
448 |
|
0 | 449 |
title = 'log in' |
1421
77ee26df178f
doc type handling refactoring: do the ext substitution at the module level
sylvain.thenault@logilab.fr
parents:
1149
diff
changeset
|
450 |
|
4594
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
451 |
def call(self, id, klass, title=True, showmessage=True): |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
452 |
w = self.w |
6429
72669e7950c1
[login] fix some previously introduced login box css breakage
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6428
diff
changeset
|
453 |
w(u'<div id="%s" class="%s">' % (id, klass)) |
0 | 454 |
if title: |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
455 |
stitle = self._cw.property_value('ui.site-title') |
3166
2413e5291e8d
properly escape site-title
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3053
diff
changeset
|
456 |
if stitle: |
2413e5291e8d
properly escape site-title
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3053
diff
changeset
|
457 |
stitle = xml_escape(stitle) |
2413e5291e8d
properly escape site-title
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3053
diff
changeset
|
458 |
else: |
2413e5291e8d
properly escape site-title
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3053
diff
changeset
|
459 |
stitle = u' ' |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
460 |
w(u'<div class="loginTitle">%s</div>' % stitle) |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
461 |
w(u'<div class="loginContent">\n') |
4594
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
462 |
if showmessage and self._cw.message: |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
463 |
w(u'<div class="loginMessage">%s</div>\n' % self._cw.message) |
6005
0300fae1f7cb
[views] link to public url when trying https without an account
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5988
diff
changeset
|
464 |
config = self._cw.vreg.config |
0300fae1f7cb
[views] link to public url when trying https without an account
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5988
diff
changeset
|
465 |
if config['auth-mode'] != 'http': |
0300fae1f7cb
[views] link to public url when trying https without an account
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5988
diff
changeset
|
466 |
self.login_form(id) # Cookie authentication |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
467 |
w(u'</div>') |
6005
0300fae1f7cb
[views] link to public url when trying https without an account
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5988
diff
changeset
|
468 |
if self._cw.https and config.anonymous_user()[0]: |
6091
560df423149a
[login template] missing xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6005
diff
changeset
|
469 |
path = xml_escape(config['base-url'] + self._cw.relative_path()) |
6389
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
470 |
w(u'<div class="loginMessage"><a href="%s">%s</a></div>\n' |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
471 |
% (path, self._cw._('No account? Try public access at %s') % path)) |
72ba82a26e05
refactor login box & form to enable easy pluggability
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6225
diff
changeset
|
472 |
w(u'</div>\n') |
0 | 473 |
|
4594
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
474 |
def login_form(self, id): |
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
475 |
cw = self._cw |
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
476 |
form = cw.vreg['forms'].select('logform', cw) |
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
477 |
if cw.vreg.config['allow-email-login']: |
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
478 |
label = cw._('login or email') |
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
479 |
else: |
5838
68187d50968e
[login form] fix bad login field label by using pgettext
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5588
diff
changeset
|
480 |
label = cw.pgettext('CWUser', 'login') |
4594
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
481 |
form.field_by_name('__login').label = label |
6453
7fdd780d87e4
[form] unify form.render prototype to take a 'w' argument as other view/components render method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6429
diff
changeset
|
482 |
form.render(w=self.w, table_class='', display_progress_div=False) |
4594
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
483 |
cw.html_headers.add_onload('jQuery("#__login:visible").focus()') |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
484 |
|
4599 | 485 |
LogFormTemplate = class_renamed('LogFormTemplate', LogFormView) |
486 |
||
6005
0300fae1f7cb
[views] link to public url when trying https without an account
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5988
diff
changeset
|
487 |
|
4594
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
488 |
def login_form_url(req): |
0 | 489 |
if req.https: |
490 |
return req.url() |
|
4594
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
491 |
httpsurl = req.vreg.config.get('https-url') |
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
492 |
if httpsurl: |
7b9824d1b734
use an actual form for the login form ease customization from external cubes (eg rememberme)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4279
diff
changeset
|
493 |
return req.url().replace(req.base_url(), httpsurl) |
0 | 494 |
return req.url() |