Move login info to the header

This commit is contained in:
Tim Van Baak 2020-01-21 00:19:49 -08:00
parent 0c45af3a56
commit cace76ff0d
6 changed files with 36 additions and 18 deletions

View File

@ -16,9 +16,15 @@ div#header {
background-color: #ffffff; background-color: #ffffff;
box-shadow: 2px 2px 10px #888888; box-shadow: 2px 2px 10px #888888;
border-radius: 5px; border-radius: 5px;
overflow: auto;
} }
div#header p, div#header h2 { div#header p, div#header h2 {
margin: 5px; margin: 5px;
float: left;
}
div#login-status {
float: right;
text-align: right;
} }
div#sidebar { div#sidebar {
width: 200px; width: 200px;

View File

@ -40,6 +40,6 @@ def get_bp(login_manager):
@login_required @login_required
def logout(): def logout():
logout_user() logout_user()
return redirect(url_for('auth.login')) return redirect(url_for('home.home'))
return bp return bp

View File

@ -30,7 +30,6 @@ def get_bp():
bp = Blueprint('home', __name__, url_prefix='/home') bp = Blueprint('home', __name__, url_prefix='/home')
@bp.route('/', methods=['GET']) @bp.route('/', methods=['GET'])
@login_required
def home(): def home():
return render_template('home/home.html') return render_template('home/home.html')

View File

@ -1,6 +1,7 @@
{% extends "page_1col.html" %} {% extends "page_1col.html" %}
{% block title %}Login | Amanuensis{% endblock %} {% block title %}Login | Amanuensis{% endblock %}
{% block header %}<h2>Amanuensis - Login</h2>{% endblock %} {% block header %}<h2>Amanuensis - Login</h2>{% endblock %}
{% block login_status_attr %}style="display:none"{% endblock %}
{% block main %} {% block main %}
<form action="" method="post" novalidate> <form action="" method="post" novalidate>
{{ form.hidden_tag() }} {{ form.hidden_tag() }}

View File

@ -1,22 +1,16 @@
{% extends "page_2col.html" %} {% extends "page_1col.html" %}
{% block title %}Home | Amanuensis{% endblock %} {% block title %}Home | Amanuensis{% endblock %}
{% block header %}<h2>Amanuensis - Dashboard</h2>{% endblock %} {% block header %}<h2>Amanuensis - Home</h2>{% endblock %}
{% block sb_topline %}<b>{{ current_user.displayname }}</b>{% endblock %}
{% block sb_logout %}<a href="{{ url_for('auth.logout') }}">Log out</a>{% endblock %}
{% set template_sidebar_rows = [self.sb_topline(), self.sb_logout()] %}
{% if current_user.is_admin %}
{% block sb_admin %}<a href="{{ url_for('home.admin') }}">Admin</a>{% endblock %}
{% set template_sidebar_rows = template_sidebar_rows + [self.sb_admin()] %}
{% endif %}
{% block main %} {% block main %}
<h1>Welcome to Amanuensis!</h1>
<p>
Amanuensis is a hub for playing Lexicon, the encyclopedia RPG. Log in to access your Lexicon games. If you do not have an account, contact the administrator.
</p>
<h1>Open games</h1> {% if current_user.is_authenticated %}
{% set lexicons = current_user.lexicons_in() %} {% set lexicons = current_user.lexicons_in() %}
<h1>Your games</h1> <h2>Your games</h2>
{% if lexicons %} {% if lexicons %}
{% for lexicon in lexicons %} {% for lexicon in lexicons %}
@ -34,5 +28,13 @@
{% else %} {% else %}
<p>You haven't joined a game yet.</p> <p>You haven't joined a game yet.</p>
{% endif %} {% endif %}
{% endif %}
{% endblock %} {% endblock %}
{% set template_content_blocks = [self.main()] %} {% set template_content_blocks = [self.main()] %}
{% if current_user.is_admin %}
{% block admin_dash %}
<a href="{{ url_for('home.admin') }}" style="display:block; text-align:center;">Admin dashboard</a>
{% endblock %}
{% set template_content_blocks = [self.admin_dash()] + template_content_blocks %}
{% endif %}

View File

@ -8,7 +8,17 @@
</head> </head>
<body> <body>
<div id="wrapper"> <div id="wrapper">
<div id="header">{% block header %}{% endblock %}</div> <div id="header">
<div id="login-status" {% block login_status_attr %}{% endblock %}>
{% if current_user.is_authenticated %}
Logged in as <b>{{ current_user.username -}}</b>
<br><a href="{{ url_for('auth.logout') }}">Logout</a>
{% else %}
<a href="{{ url_for('auth.login') }}">Login</a>
{% endif %}
</div>
{% block header %}{% endblock %}
</div>
{% block sidebar %}{% endblock %} {% block sidebar %}{% endblock %}
<div id="content" class="{% block content_class %}{% endblock %}"> <div id="content" class="{% block content_class %}{% endblock %}">
{% if not template_content_blocks %}{% set template_content_blocks = [] %}{% endif %} {% if not template_content_blocks %}{% set template_content_blocks = [] %}{% endif %}