From 8bc86543252108b5491b4c4e060f437b0480ca66 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 10 Sep 2018 20:07:13 +0300 Subject: Change: move login form to a separate file --- qvisqve/auth_router.py | 26 ++------------------------ qvisqve/templates/login.tmpl | 19 +++++++++++++++++++ qvisqve/tmpl.py | 27 +++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 24 deletions(-) create mode 100644 qvisqve/templates/login.tmpl create mode 100644 qvisqve/tmpl.py diff --git a/qvisqve/auth_router.py b/qvisqve/auth_router.py index 9dfb582..0da34d3 100644 --- a/qvisqve/auth_router.py +++ b/qvisqve/auth_router.py @@ -23,29 +23,6 @@ import bottle import qvisqve -login_form = ''' - - - - - - - Qvisqve Login - - -
- - User name: -
- Password: -
- -
- - -''' - - class AuthRouter(qvisqve.Router): def __init__(self, apps, users, authz_attempts): @@ -103,7 +80,8 @@ class AuthRouter(qvisqve.Router): cleaned['redirect_uri'] = redirect_uri aa = self._attempts.create_attempt(cleaned) - form = bottle.template(login_form, attempt_id=aa.get_attempt_id()) + form = qvisqve.render_template( + 'login.tmpl', attempt_id=aa.get_attempt_id()) headers = { 'Content-Type': 'text/html; charset=utf-8', } diff --git a/qvisqve/templates/login.tmpl b/qvisqve/templates/login.tmpl new file mode 100644 index 0000000..3f71e23 --- /dev/null +++ b/qvisqve/templates/login.tmpl @@ -0,0 +1,19 @@ + + + + + + + Qvisqve Login + + +
+ + User name: +
+ Password: +
+ +
+ + diff --git a/qvisqve/tmpl.py b/qvisqve/tmpl.py new file mode 100644 index 0000000..3d91f02 --- /dev/null +++ b/qvisqve/tmpl.py @@ -0,0 +1,27 @@ +# Copyright (C) 2018 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + + +import os + +import bottle + +import qvisqve + + +def render_template(name, **values): + moduledir = os.path.dirname(qvisqve.__file__) + dirname = os.path.join(moduledir, 'templates') + return bottle.template(name, template_lookup=[dirname], **values) -- cgit v1.2.1