diff -r 058bb3dc685f -r 0b59724cb3f2 web/views/basetemplates.py
--- a/web/views/basetemplates.py Mon Jan 04 18:40:30 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,530 +0,0 @@
-# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
-# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
-#
-# This file is part of CubicWeb.
-#
-# CubicWeb is free software: you can redistribute it and/or modify it under the
-# terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 2.1 of the License, or (at your option)
-# any later version.
-#
-# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License along
-# with CubicWeb. If not, see
\n') - components = self._cw.vreg['components'] - rqlcomp = components.select_or_none('rqlinput', self._cw, rset=self.cw_rset) - if rqlcomp: - rqlcomp.render(w=self.w, view=view) - msgcomp = components.select_or_none('applmessages', self._cw, rset=self.cw_rset) - if msgcomp: - msgcomp.render(w=self.w) - self.content_header(view) - - def template_footer(self, view=None): - self.content_footer(view) - self.w(u' | \n') - self.nav_column(view, 'right') - self.w(u'
\n') - self.topleft_header() - boxes = list(self._cw.vreg['ctxcomponents'].poss_visible_objects( - self._cw, rset=self.cw_rset, view=view, context='left')) - if boxes: - w(u' | ') - w(u' \n') - w(u'')
-
- def topleft_header(self):
- logo = self._cw.vreg['components'].select_or_none('logo', self._cw,
- rset=self.cw_rset)
- if logo and logo.cw_propval('visible'):
- w = self.w
- w(u'
')
- self.state_header()
- self.w(u' ')
-
- def main_header(self, view):
- """build the top menu with authentification info and the rql box"""
- w = self.w
- w(u'
%s ' % msg)
-
-
-class HTMLPageFooter(View):
- """default html page footer: include footer actions"""
- __regid__ = 'footer'
-
- def call(self, **kwargs):
- self.w(u' ')
-
- def footer_content(self):
- actions = self._cw.vreg['actions'].possible_actions(self._cw,
- rset=self.cw_rset)
- footeractions = actions.get('footer', ())
- for i, action in enumerate(footeractions):
- self.w(u'%s' % (action.url(),
- self._cw._(action.title)))
- if i < (len(footeractions) - 1):
- self.w(u' | ')
-
-class HTMLContentHeader(View):
- """default html page content header:
- * include message component if selectable for this request
- * include selectable content navigation components
- """
- __regid__ = 'contentheader'
-
- def call(self, view, **kwargs):
- """by default, display informal messages in content header"""
- components = self._cw.vreg['ctxcomponents'].poss_visible_objects(
- self._cw, rset=self.cw_rset, view=view, context='navtop')
- if components:
- self.w(u'')
- for comp in components:
- comp.render(w=self.w, view=view)
- self.w(u' ')
-
-
-class HTMLContentFooter(View):
- """default html page content footer: include selectable content navigation
- components
- """
- __regid__ = 'contentfooter'
-
- def call(self, view, **kwargs):
- components = self._cw.vreg['ctxcomponents'].poss_visible_objects(
- self._cw, rset=self.cw_rset, view=view, context='navbottom')
- if components:
- self.w(u' ')
-
-class BaseLogForm(forms.FieldsForm):
- """Abstract Base login form to be used by any login form
- """
- __abstract__ = True
-
- __regid__ = 'logform'
- domid = 'loginForm'
- needs_css = ('cubicweb.login.css',)
-
- onclick_base = "javascript: cw.htmlhelpers.popupLoginBox('%s', '%s');"
- onclick_args = (None, None)
-
- @classproperty
- def form_buttons(cls):
- # we use a property because sub class will need to define their own onclick_args.
- # Therefor we can't juste make the string formating when instanciating this class
- onclick = cls.onclick_base % cls.onclick_args
- form_buttons = [fw.SubmitButton(label=_('log in'),
- attrs={'class': 'loginButton'}),
- fw.ResetButton(label=_('cancel'),
- attrs={'class': 'loginButton',
- 'onclick': onclick}),]
- ## Can't shortcut next access because __dict__ is a "dictproxy" which
- ## does not support items assignement.
- # cls.__dict__['form_buttons'] = form_buttons
- return form_buttons
-
- def form_action(self):
- if self.action is None:
- # reuse existing redirection if it exists
- target = self._cw.form.get('postlogin_path',
- self._cw.relative_path())
- url_args = {}
- if target and target != '/':
- url_args['postlogin_path'] = target
- return self._cw.build_url('login', __secure__=True, **url_args)
- return super(BaseLogForm, self).form_action()
-
-class LogForm(BaseLogForm):
- """Simple login form that send username and password
- """
- __regid__ = 'logform'
- domid = 'loginForm'
- needs_css = ('cubicweb.login.css',)
- # XXX have to recall fields name since python is mangling __login/__password
- __login = ff.StringField('__login', widget=fw.TextInput({'class': 'data'}))
- __password = ff.StringField('__password', label=_('password'),
- widget=fw.PasswordSingleInput({'class': 'data'}))
-
- onclick_args = ('popupLoginBox', '__login')
-
-
-class LogFormView(View):
- # XXX an awful lot of hardcoded assumptions there
- # makes it unobvious to reuse/specialize
- __regid__ = 'logform'
- __select__ = match_kwargs('id', 'klass')
-
- title = 'log in'
-
- def call(self, id, klass, title=True, showmessage=True):
- w = self.w
- w(u'' % (id, klass))
- if title:
- stitle = self._cw.property_value('ui.site-title')
- if stitle:
- stitle = xml_escape(stitle)
- else:
- stitle = u' '
- w(u' \n')
-
- def login_form(self, id):
- cw = self._cw
- form = cw.vreg['forms'].select('logform', cw)
- if cw.vreg.config['allow-email-login']:
- label = cw._('login or email')
- else:
- label = cw.pgettext('CWUser', 'login')
- form.field_by_name('__login').label = label
- form.render(w=self.w, table_class='', display_progress_div=False)
- cw.html_headers.add_onload('jQuery("#__login:visible").focus()')
-
-LogFormTemplate = class_renamed('LogFormTemplate', LogFormView)
%s ' % stitle)
- w(u'\n')
- if showmessage and self._cw.message:
- w(u' ')
- w(u'%s \n' % self._cw.message)
- config = self._cw.vreg.config
- if config['auth-mode'] != 'http':
- self.login_form(id) # Cookie authentication
- w(u' |