author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Thu, 18 Feb 2010 15:42:29 +0100 | |
branch | stable |
changeset 4641 | 9d8903b04031 |
parent 4604 | 96cc3d296d75 |
child 4781 | d12cbd0b7574 |
permissions | -rw-r--r-- |
0 | 1 |
# -*- coding: utf-8 -*- |
2 |
"""default templates for CubicWeb web client |
|
3 |
||
4 |
:organization: Logilab |
|
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3818
diff
changeset
|
5 |
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
0 | 6 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1851
diff
changeset
|
7 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
0 | 8 |
""" |
9 |
__docformat__ = "restructuredtext en" |
|
10 |
||
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2119
diff
changeset
|
11 |
from logilab.mtconverter import xml_escape |
4599 | 12 |
from logilab.common.deprecation import class_renamed |
0 | 13 |
|
2657
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
14 |
from cubicweb.appobject import objectify_selector |
822 | 15 |
from cubicweb.selectors import match_kwargs |
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
|
16 |
from cubicweb.view import View, MainTemplate, NOINDEX, NOFOLLOW |
3816
37b376bb4088
[web] set pageid at request instanciation rather than in htmlheader template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3795
diff
changeset
|
17 |
from cubicweb.utils import UStringIO, can_do_pdf_conversion |
3242
390acf7594ed
missing import
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3184
diff
changeset
|
18 |
from cubicweb.schema import display_name |
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
|
19 |
from cubicweb.web import formfields as ff, formwidgets as fw |
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
|
20 |
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
|
21 |
|
0 | 22 |
# main templates ############################################################## |
23 |
||
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
24 |
class LogInOutTemplate(MainTemplate): |
0 | 25 |
|
26 |
def call(self): |
|
27 |
self.set_request_content_type() |
|
28 |
w = self.w |
|
29 |
self.write_doctype() |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
30 |
self.template_header('text/html', self._cw._('login_action')) |
0 | 31 |
w(u'<body>\n') |
32 |
self.content(w) |
|
33 |
w(u'</body>') |
|
34 |
||
35 |
def template_header(self, content_type, view=None, page_title='', additional_headers=()): |
|
36 |
w = self.whead |
|
37 |
# 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
|
38 |
w(u'<base href="%s"></base>' % xml_escape(self._cw.base_url())) |
0 | 39 |
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
|
40 |
% (content_type, self._cw.encoding)) |
0 | 41 |
w(NOINDEX) |
42 |
w(NOFOLLOW) |
|
43 |
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
|
44 |
self.wview('htmlheader', rset=self.cw_rset) |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2119
diff
changeset
|
45 |
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
|
46 |
|
0 | 47 |
|
48 |
class LogInTemplate(LogInOutTemplate): |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
49 |
__regid__ = 'login' |
0 | 50 |
title = 'log in' |
51 |
||
52 |
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
|
53 |
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
|
54 |
|
0 | 55 |
|
56 |
class LoggedOutTemplate(LogInOutTemplate): |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
57 |
__regid__ = 'loggedout' |
0 | 58 |
title = 'logged out' |
59 |
||
60 |
def content(self, w): |
|
852
105893288777
simplify css style
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
432
diff
changeset
|
61 |
# FIXME Deprecated code ? |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
62 |
msg = self._cw._('you have been logged out') |
852
105893288777
simplify css style
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
432
diff
changeset
|
63 |
w(u'<h2>%s</h2>\n' % msg) |
3659 | 64 |
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
|
65 |
indexurl = self._cw.build_url('view', vid='index', __message=msg) |
0 | 66 |
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
|
67 |
xml_escape(indexurl), |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
68 |
self._cw._('go back to the index page'))) |
0 | 69 |
|
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
70 |
@objectify_selector |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
71 |
def templatable_view(cls, req, rset, *args, **kwargs): |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
72 |
view = kwargs.pop('view', None) |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
73 |
if view is None: |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
74 |
return 1 |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
75 |
if view.binary: |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
76 |
return 0 |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
77 |
if req.form.has_key('__notemplate'): |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
78 |
return 0 |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
79 |
return view.templatable |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
80 |
|
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
81 |
|
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
82 |
class NonTemplatableViewTemplate(MainTemplate): |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
83 |
"""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
|
84 |
__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
|
85 |
__select__ = ~templatable_view() |
77ee26df178f
doc type handling refactoring: do the ext substitution at the module level
sylvain.thenault@logilab.fr
parents:
1149
diff
changeset
|
86 |
|
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
87 |
def call(self, view): |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
88 |
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
|
89 |
view.set_stream() |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
90 |
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
|
91 |
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
|
92 |
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
|
93 |
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
|
94 |
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
|
95 |
else: |
ca7b122f34fa
fix html headers for forced html content type : main template and json controller
Fabrice <fabrice@secondweb.fr>
parents:
2381
diff
changeset
|
96 |
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
|
97 |
# 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
|
98 |
# stream) |
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
99 |
self._stream = view._stream |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
100 |
|
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
101 |
|
0 | 102 |
class TheMainTemplate(MainTemplate): |
103 |
"""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
|
104 |
|
0 | 105 |
- call header / footer templates |
106 |
""" |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
107 |
__regid__ = 'main-template' |
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
108 |
__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
|
109 |
|
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
110 |
def call(self, view): |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
111 |
self.set_request_content_type() |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
112 |
self.template_header(self.content_type, view) |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
113 |
w = self.w |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
114 |
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
|
115 |
vtitle = self._cw.form.get('vtitle') |
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
116 |
if vtitle: |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2119
diff
changeset
|
117 |
w(u'<h1 class="vtitle">%s</h1>\n' % xml_escape(vtitle)) |
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
118 |
# 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
|
119 |
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
|
120 |
'etypenavigation', self._cw, rset=self.cw_rset) |
2818
326375561412
propagate some api changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2813
diff
changeset
|
121 |
if etypefilter and etypefilter.cw_propval('visible'): |
1723 | 122 |
etypefilter.render(w=w) |
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
123 |
self.nav_html = UStringIO() |
4244
2c3de1953d00
rename need_navigation into paginable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
124 |
if view: |
872 | 125 |
view.paginate(w=self.nav_html.write) |
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
126 |
w(_(self.nav_html.getvalue())) |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
127 |
w(u'<div id="contentmain">\n') |
1723 | 128 |
view.render(w=w) |
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
129 |
w(u'</div>\n') # close id=contentmain |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
130 |
w(_(self.nav_html.getvalue())) |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
131 |
w(u'</div>\n') # closes id=pageContent |
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
822
diff
changeset
|
132 |
self.template_footer(view) |
0 | 133 |
|
134 |
def template_header(self, content_type, view=None, page_title='', additional_headers=()): |
|
135 |
page_title = page_title or view.page_title() |
|
136 |
additional_headers = additional_headers or view.html_headers() |
|
137 |
self.template_html_header(content_type, page_title, additional_headers) |
|
138 |
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
|
139 |
|
0 | 140 |
def template_html_header(self, content_type, page_title, additional_headers=()): |
141 |
w = self.whead |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
142 |
lang = self._cw.lang |
0 | 143 |
self.write_doctype() |
2580
6e9453fd11ef
always explicitly close <base> tags because of an old IE6 bug
Florent <florent@secondweb.fr>
parents:
2559
diff
changeset
|
144 |
# 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
|
145 |
w(u'<base href="%s"></base>' % xml_escape(self._cw.base_url())) |
0 | 146 |
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
|
147 |
% (content_type, self._cw.encoding)) |
0 | 148 |
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
|
149 |
self.wview('htmlheader', rset=self.cw_rset) |
0 | 150 |
if page_title: |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2119
diff
changeset
|
151 |
w(u'<title>%s</title>\n' % xml_escape(page_title)) |
0 | 152 |
|
153 |
def template_body_header(self, view): |
|
154 |
w = self.w |
|
155 |
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
|
156 |
self.wview('header', rset=self.cw_rset, view=view) |
0 | 157 |
w(u'<div id="page"><table width="100%" border="0" id="mainLayout"><tr>\n') |
158 |
self.nav_column(view, 'left') |
|
159 |
w(u'<td id="contentcol">\n') |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
160 |
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
|
161 |
rqlcomp = components.select_or_none('rqlinput', self._cw, rset=self.cw_rset) |
0 | 162 |
if rqlcomp: |
1723 | 163 |
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
|
164 |
msgcomp = components.select_or_none('applmessages', self._cw, rset=self.cw_rset) |
0 | 165 |
if msgcomp: |
1723 | 166 |
msgcomp.render(w=self.w) |
0 | 167 |
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
|
168 |
|
0 | 169 |
def template_footer(self, view=None): |
170 |
self.content_footer(view) |
|
171 |
self.w(u'</td>\n') |
|
172 |
self.nav_column(view, 'right') |
|
173 |
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
|
174 |
self.wview('footer', rset=self.cw_rset) |
0 | 175 |
self.w(u'</body>') |
176 |
||
177 |
def nav_column(self, view, context): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
178 |
boxes = list(self._cw.vreg['boxes'].poss_visible_objects( |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
179 |
self._cw, rset=self.cw_rset, view=view, context=context)) |
0 | 180 |
if boxes: |
181 |
self.w(u'<td class="navcol"><div class="navboxes">\n') |
|
182 |
for box in boxes: |
|
1723 | 183 |
box.render(w=self.w, view=view) |
0 | 184 |
self.w(u'</div></td>\n') |
185 |
||
186 |
def content_header(self, view=None): |
|
187 |
"""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
|
188 |
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
|
189 |
|
0 | 190 |
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
|
191 |
self.wview('contentfooter', rset=self.cw_rset, view=view) |
0 | 192 |
|
193 |
||
194 |
class ErrorTemplate(TheMainTemplate): |
|
195 |
"""fallback template if an internal error occured during displaying the |
|
196 |
main template. This template may be called for authentication error, |
|
197 |
which means that req.cnx and req.user may not be set. |
|
198 |
""" |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
199 |
__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
|
200 |
|
0 | 201 |
def call(self): |
202 |
"""display an unexpected error""" |
|
203 |
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
|
204 |
self._cw.reset_headers() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
205 |
view = self._cw.vreg['views'].select('error', self._cw, rset=self.cw_rset) |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
206 |
self.template_header(self.content_type, view, self._cw._('an error occured'), |
0 | 207 |
[NOINDEX, NOFOLLOW]) |
1723 | 208 |
view.render(w=self.w) |
0 | 209 |
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
|
210 |
|
0 | 211 |
def template_header(self, content_type, view=None, page_title='', additional_headers=()): |
212 |
w = self.whead |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
213 |
lang = self._cw.lang |
0 | 214 |
self.write_doctype() |
215 |
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
|
216 |
% (content_type, self._cw.encoding)) |
0 | 217 |
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
|
218 |
self.wview('htmlheader', rset=self.cw_rset) |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2119
diff
changeset
|
219 |
w(u'<title>%s</title>\n' % xml_escape(page_title)) |
0 | 220 |
self.w(u'<body>\n') |
221 |
||
222 |
def template_footer(self, view=None): |
|
223 |
self.w(u'</body>') |
|
224 |
||
225 |
||
226 |
class SimpleMainTemplate(TheMainTemplate): |
|
227 |
||
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
228 |
__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
|
229 |
|
163
451a3e35dbcb
repairing error from preceding commit
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
158
diff
changeset
|
230 |
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
|
231 |
page_title = page_title or view.page_title() |
0 | 232 |
additional_headers = additional_headers or view.html_headers() |
233 |
whead = self.whead |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
234 |
lang = self._cw.lang |
0 | 235 |
self.write_doctype() |
236 |
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
|
237 |
% (content_type, self._cw.encoding)) |
0 | 238 |
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
|
239 |
self.wview('htmlheader', rset=self.cw_rset) |
0 | 240 |
w = self.w |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2119
diff
changeset
|
241 |
w(u'<title>%s</title>\n' % xml_escape(page_title)) |
0 | 242 |
w(u'<body>\n') |
243 |
w(u'<div id="page">') |
|
244 |
w(u'<table width="100%" height="100%" border="0"><tr>\n') |
|
245 |
w(u'<td class="navcol">\n') |
|
246 |
self.topleft_header() |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
247 |
boxes = list(self._cw.vreg['boxes'].poss_visible_objects( |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
248 |
self._cw, rset=self.cw_rset, view=view, context='left')) |
0 | 249 |
if boxes: |
250 |
w(u'<div class="navboxes">\n') |
|
251 |
for box in boxes: |
|
1723 | 252 |
box.render(w=w) |
0 | 253 |
self.w(u'</div>\n') |
254 |
w(u'</td>') |
|
255 |
w(u'<td id="contentcol" rowspan="2">') |
|
256 |
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
|
257 |
vtitle = self._cw.form.get('vtitle') |
0 | 258 |
if vtitle: |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2119
diff
changeset
|
259 |
w(u'<h1 class="vtitle">%s</h1>' % 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
|
260 |
|
0 | 261 |
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
|
262 |
logo = self._cw.vreg['components'].select_or_none('logo', self._cw, |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
263 |
rset=self.cw_rset) |
2818
326375561412
propagate some api changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2813
diff
changeset
|
264 |
if logo and logo.cw_propval('visible'): |
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
265 |
self.w(u'<table id="header"><tr>\n') |
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
266 |
self.w(u'<td>') |
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
267 |
logo.render(w=self.w) |
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
268 |
self.w(u'</td>\n') |
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
269 |
self.w(u'</tr></table>\n') |
0 | 270 |
|
2935
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
271 |
if can_do_pdf_conversion(): |
4254
966f62e97c72
Fix element tree import for python2.4
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4244
diff
changeset
|
272 |
try: |
966f62e97c72
Fix element tree import for python2.4
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4244
diff
changeset
|
273 |
from xml.etree.cElementTree import ElementTree |
966f62e97c72
Fix element tree import for python2.4
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4244
diff
changeset
|
274 |
except ImportError: #python2.4 |
966f62e97c72
Fix element tree import for python2.4
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4244
diff
changeset
|
275 |
from elementtree import ElementTree |
2935
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
276 |
from subprocess import Popen as sub |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
277 |
from StringIO import StringIO |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
278 |
from tempfile import NamedTemporaryFile |
3080
32c2b6a34ab2
move xhtml2fo to ext, allow to specify the section in url/get param
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3071
diff
changeset
|
279 |
from cubicweb.ext.xhtml2fo import ReportTransformer |
2935
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
280 |
|
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
281 |
class PdfMainTemplate(TheMainTemplate): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
282 |
__regid__ = 'pdf-main-template' |
2935
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
283 |
|
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
284 |
def call(self, view): |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
285 |
"""build the standard view, then when it's all done, convert xhtml to pdf |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
286 |
""" |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
287 |
super(PdfMainTemplate, self).call(view) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
288 |
section = self._cw.form.pop('section', 'contentmain') |
3080
32c2b6a34ab2
move xhtml2fo to ext, allow to specify the section in url/get param
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3071
diff
changeset
|
289 |
pdf = self.to_pdf(self._stream, section) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
290 |
self._cw.set_content_type('application/pdf', filename='report.pdf') |
2935
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
291 |
self.binary = True |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
292 |
self.w = None |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
293 |
self.set_stream() |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
294 |
# pylint needs help |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
295 |
self.w(pdf) |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
296 |
|
3080
32c2b6a34ab2
move xhtml2fo to ext, allow to specify the section in url/get param
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3071
diff
changeset
|
297 |
def to_pdf(self, stream, section): |
2935
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
298 |
# XXX see ticket/345282 |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
299 |
stream = stream.getvalue().replace(' ', ' ').encode('utf-8') |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
300 |
xmltree = ElementTree() |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
301 |
xmltree.parse(StringIO(stream)) |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
302 |
foptree = ReportTransformer(section).transform(xmltree) |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
303 |
foptmp = NamedTemporaryFile() |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
304 |
pdftmp = NamedTemporaryFile() |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
305 |
foptree.write(foptmp) |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
306 |
foptmp.flush() |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
307 |
fopproc = sub(['/usr/bin/fop', foptmp.name, pdftmp.name]) |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
308 |
fopproc.wait() |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
309 |
pdftmp.seek(0) |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
310 |
pdf = pdftmp.read() |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
311 |
return pdf |
e06b3eadef31
[views,pdf] minimal support for xhtml->pdf conversion
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2657
diff
changeset
|
312 |
|
0 | 313 |
# page parts templates ######################################################## |
314 |
||
816
9cd49a910fce
kill Template class and 'templates' registry
sylvain.thenault@logilab.fr
parents:
811
diff
changeset
|
315 |
class HTMLHeader(View): |
0 | 316 |
"""default html headers""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
317 |
__regid__ = 'htmlheader' |
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 call(self, **kwargs): |
320 |
self.favicon() |
|
321 |
self.stylesheets() |
|
322 |
self.javascripts() |
|
323 |
self.alternates() |
|
324 |
||
325 |
def favicon(self): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
326 |
favicon = self._cw.external_resource('FAVICON', None) |
0 | 327 |
if favicon: |
328 |
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
|
329 |
|
0 | 330 |
def stylesheets(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
331 |
req = self._cw |
0 | 332 |
add_css = req.add_css |
333 |
for css in req.external_resource('STYLESHEETS'): |
|
334 |
add_css(css, localfile=False) |
|
335 |
for css in req.external_resource('STYLESHEETS_PRINT'): |
|
336 |
add_css(css, u'print', localfile=False) |
|
337 |
for css in req.external_resource('IE_STYLESHEETS'): |
|
338 |
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
|
339 |
|
0 | 340 |
def javascripts(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
341 |
for jscript in self._cw.external_resource('JAVASCRIPTS'): |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
342 |
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
|
343 |
|
0 | 344 |
def alternates(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
345 |
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
|
346 |
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
|
347 |
if urlgetter is not None: |
0 | 348 |
self.whead(u'<link rel="alternate" type="application/rss+xml" title="RSS feed" href="%s"/>\n' |
2381 | 349 |
% xml_escape(urlgetter.feed_url())) |
0 | 350 |
|
351 |
||
816
9cd49a910fce
kill Template class and 'templates' registry
sylvain.thenault@logilab.fr
parents:
811
diff
changeset
|
352 |
class HTMLPageHeader(View): |
0 | 353 |
"""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
|
354 |
__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
|
355 |
main_cell_components = ('appliname', 'breadcrumbs') |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
356 |
|
0 | 357 |
def call(self, view, **kwargs): |
358 |
self.main_header(view) |
|
359 |
self.w(u''' |
|
360 |
<div id="stateheader">''') |
|
361 |
self.state_header() |
|
362 |
self.w(u''' |
|
363 |
</div> |
|
364 |
''') |
|
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
365 |
|
0 | 366 |
def main_header(self, view): |
367 |
"""build the top menu with authentification info and the rql box""" |
|
368 |
self.w(u'<table id="header"><tr>\n') |
|
369 |
self.w(u'<td id="firstcolumn">') |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
370 |
logo = 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
|
371 |
'logo', self._cw, rset=self.cw_rset) |
2818
326375561412
propagate some api changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2813
diff
changeset
|
372 |
if logo and logo.cw_propval('visible'): |
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
373 |
logo.render(w=self.w) |
0 | 374 |
self.w(u'</td>\n') |
375 |
# appliname and breadcrumbs |
|
376 |
self.w(u'<td id="headtext">') |
|
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
|
377 |
for cid in self.main_cell_components: |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
378 |
comp = 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
|
379 |
cid, self._cw, rset=self.cw_rset) |
2818
326375561412
propagate some api changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2813
diff
changeset
|
380 |
if comp and comp.cw_propval('visible'): |
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
381 |
comp.render(w=self.w) |
0 | 382 |
self.w(u'</td>') |
383 |
# logged user and help |
|
384 |
self.w(u'<td>\n') |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
385 |
comp = 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
|
386 |
'loggeduserlink', self._cw, rset=self.cw_rset) |
2818
326375561412
propagate some api changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2813
diff
changeset
|
387 |
if comp and comp.cw_propval('visible'): |
2058
7ef12c03447c
nicer vreg api, try to make rset an optional named argument in select and derivated (including selectors)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
388 |
comp.render(w=self.w) |
0 | 389 |
self.w(u'</td>') |
390 |
# lastcolumn |
|
391 |
self.w(u'<td id="lastcolumn">') |
|
392 |
self.w(u'</td>\n') |
|
393 |
self.w(u'</tr></table>\n') |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
394 |
self.wview('logform', rset=self.cw_rset, id='popupLoginBox', klass='hidden', |
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
|
395 |
title=False, showmessage=False) |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
396 |
|
0 | 397 |
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
|
398 |
state = self._cw.search_state |
0 | 399 |
if state[0] == 'normal': |
400 |
return |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
401 |
_ = self._cw._ |
4604
96cc3d296d75
remove 3.6 deprecation warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4603
diff
changeset
|
402 |
value = self._cw.view('oneline', self._cw.eid_rset(state[1][1])) |
0 | 403 |
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
|
404 |
display_name(self._cw, state[1][3]), |
0 | 405 |
_("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
|
406 |
_("by relation"), '"', |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
407 |
display_name(self._cw, state[1][2], state[1][0]), |
0 | 408 |
'"')) |
409 |
return self.w(u'<div class="stateMessage">%s</div>' % msg) |
|
410 |
||
411 |
||
412 |
||
816
9cd49a910fce
kill Template class and 'templates' registry
sylvain.thenault@logilab.fr
parents:
811
diff
changeset
|
413 |
class HTMLPageFooter(View): |
3795
ce6381416a12
[doc] fix inaccurate docstring
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
3498
diff
changeset
|
414 |
"""default html page footer: include footer actions |
0 | 415 |
""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
416 |
__regid__ = 'footer' |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
417 |
|
0 | 418 |
def call(self, **kwargs): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
419 |
req = self._cw |
0 | 420 |
self.w(u'<div class="footer">') |
3655
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3503
diff
changeset
|
421 |
actions = self._cw.vreg['actions'].possible_actions(self._cw, |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3503
diff
changeset
|
422 |
rset=self.cw_rset) |
3495
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3242
diff
changeset
|
423 |
footeractions = actions.get('footer', ()) |
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3242
diff
changeset
|
424 |
for i, action in enumerate(footeractions): |
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3242
diff
changeset
|
425 |
self.w(u'<a href="%s">%s</a>' % (action.url(), |
3655
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3503
diff
changeset
|
426 |
self._cw._(action.title))) |
3495
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3242
diff
changeset
|
427 |
if i < (len(footeractions) - 1): |
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3242
diff
changeset
|
428 |
self.w(u' | ') |
0 | 429 |
self.w(u'</div>') |
430 |
||
431 |
||
816
9cd49a910fce
kill Template class and 'templates' registry
sylvain.thenault@logilab.fr
parents:
811
diff
changeset
|
432 |
class HTMLContentHeader(View): |
0 | 433 |
"""default html page content header: |
434 |
* include message component if selectable for this request |
|
435 |
* include selectable content navigation components |
|
436 |
""" |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
437 |
__regid__ = 'contentheader' |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
438 |
|
0 | 439 |
def call(self, view, **kwargs): |
440 |
"""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
|
441 |
components = self._cw.vreg['contentnavigation'].poss_visible_objects( |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
442 |
self._cw, rset=self.cw_rset, view=view, context='navtop') |
0 | 443 |
if components: |
444 |
self.w(u'<div id="contentheader">') |
|
445 |
for comp in components: |
|
1723 | 446 |
comp.render(w=self.w, view=view) |
0 | 447 |
self.w(u'</div><div class="clear"></div>') |
448 |
||
449 |
||
816
9cd49a910fce
kill Template class and 'templates' registry
sylvain.thenault@logilab.fr
parents:
811
diff
changeset
|
450 |
class HTMLContentFooter(View): |
0 | 451 |
"""default html page content footer: include selectable content navigation |
452 |
components |
|
453 |
""" |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
454 |
__regid__ = 'contentfooter' |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
455 |
|
0 | 456 |
def call(self, view, **kwargs): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
457 |
components = self._cw.vreg['contentnavigation'].poss_visible_objects( |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
458 |
self._cw, rset=self.cw_rset, view=view, context='navbottom') |
0 | 459 |
if components: |
460 |
self.w(u'<div id="contentfooter">') |
|
461 |
for comp in components: |
|
1723 | 462 |
comp.render(w=self.w, view=view) |
0 | 463 |
self.w(u'</div>') |
464 |
||
465 |
||
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
|
466 |
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
|
467 |
__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
|
468 |
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
|
469 |
needs_css = ('cubicweb.login.css',) |
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
|
470 |
# 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
|
471 |
__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
|
472 |
__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
|
473 |
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
|
474 |
form_buttons = [fw.SubmitButton(label=_('log in'), |
4603
ce19b0a05db3
login form style fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4600
diff
changeset
|
475 |
attrs={'class': 'loginButton'})] |
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
|
476 |
|
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 |
@property |
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 |
def action(self): |
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 |
return xml_escape(login_form_url(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
|
480 |
|
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 |
|
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
|
482 |
class LogFormView(View): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
483 |
__regid__ = 'logform' |
826
51cb3d85c059
fix LogFormTemplate selector
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
823
diff
changeset
|
484 |
__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
|
485 |
|
0 | 486 |
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
|
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 call(self, id, klass, title=True, showmessage=True): |
0 | 489 |
self.w(u'<div id="%s" class="%s">' % (id, klass)) |
490 |
if title: |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
491 |
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
|
492 |
if stitle: |
2413e5291e8d
properly escape site-title
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3053
diff
changeset
|
493 |
stitle = xml_escape(stitle) |
2413e5291e8d
properly escape site-title
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3053
diff
changeset
|
494 |
else: |
2413e5291e8d
properly escape site-title
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3053
diff
changeset
|
495 |
stitle = u' ' |
2413e5291e8d
properly escape site-title
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3053
diff
changeset
|
496 |
self.w(u'<div id="loginTitle">%s</div>' % stitle) |
641
ed668804af37
split main template into main template + page-content template
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
609
diff
changeset
|
497 |
self.w(u'<div id="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
|
498 |
if showmessage and self._cw.message: |
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
|
499 |
self.w(u'<div class="simpleMessage">%s</div>\n' % self._cw.message) |
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
|
500 |
if self._cw.vreg.config['auth-mode'] != 'http': |
0 | 501 |
# Cookie authentication |
502 |
self.login_form(id) |
|
503 |
self.w(u'</div></div>\n') |
|
504 |
||
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
|
505 |
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
|
506 |
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
|
507 |
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
|
508 |
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
|
509 |
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
|
510 |
else: |
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
|
511 |
label = cw._('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
|
512 |
form.field_by_name('__login').label = label |
4596
13fd398916c2
specify login form dom id, don't render progress div
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4594
diff
changeset
|
513 |
self.w(form.render(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
|
514 |
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
|
515 |
|
4599 | 516 |
LogFormTemplate = class_renamed('LogFormTemplate', LogFormView) |
517 |
||
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
|
518 |
def login_form_url(req): |
0 | 519 |
if req.https: |
520 |
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
|
521 |
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
|
522 |
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
|
523 |
return req.url().replace(req.base_url(), httpsurl) |
0 | 524 |
return req.url() |