Add settings page skeleton

This commit is contained in:
Tim Van Baak 2021-09-04 13:34:24 -07:00
parent c5e68f1999
commit ba722562a8
5 changed files with 147 additions and 18 deletions

View File

@ -173,6 +173,36 @@ div.dashboard-lexicon-item p {
margin-block-start: 0.5em; margin-block-start: 0.5em;
margin-block-end: 0.5em; margin-block-end: 0.5em;
} }
ul.unordered-tabs {
list-style: none;
margin-block-start: 0;
margin-block-end: 0;
margin-inline-start: 0;
margin-inline-end: 0;
padding-block-start: 0;
padding-block-end: 0;
padding-inline-start: 0;
padding-inline-end: 0;
}
ul.unordered-tabs li {
display: inline-block;
margin: 3px;
}
ul.unordered-tabs li a {
background-color: var(--button-current);
display: flex;
border: 5px solid var(--button-current);
border-radius: 5px;
text-decoration: none;
}
ul.unordered-tabs li a[href] {
background-color: var(--button-default);
border-color: var(--button-default);
}
ul.unordered-tabs li a[href]:hover {
background-color: var(--button-hover);
border-color: var(--button-hover);
}
@media only screen and (max-width: 816px) { @media only screen and (max-width: 816px) {
div#wrapper { div#wrapper {
padding: 5px; padding: 5px;

View File

@ -19,31 +19,18 @@
{% if current_page == "rules" %}class="current-page" {% if current_page == "rules" %}class="current-page"
{% else %}href="{{ url_for('lexicon.rules', lexicon_name=g.lexicon.name) }}" {% else %}href="{{ url_for('lexicon.rules', lexicon_name=g.lexicon.name) }}"
{% endif %}>Rules</a>{% endblock %} {% endif %}>Rules</a>{% endblock %}
{% block sb_session %}<a {% block sb_settings %}<a
{% if current_page == "session" %}class="current-page" {% if current_page == "settings" %}class="current-page"
{% else %}href="#{#{ url_for('session.session', lexicon_name=g.lexicon.name) }}" {% else %}href="{{ url_for('lexicon.settings.page', lexicon_name=g.lexicon.name) }}"
{% endif %}>Session</a>{% endblock %} {% endif %}>Settings</a>{% endblock %}
{% block sb_stats %}<a {% block sb_stats %}<a
{% if current_page == "statistics" %}class="current-page" {% if current_page == "statistics" %}class="current-page"
{% else %}href="{{ url_for('lexicon.stats', lexicon_name=g.lexicon.name) }}" {% else %}href="{{ url_for('lexicon.stats', lexicon_name=g.lexicon.name) }}"
{% endif %}>Statistics</a>{% endblock %} {% endif %}>Statistics</a>{% endblock %}
{% if current_user.is_authenticated and (
current_user.is_site_admin
or memq.try_from_ids(g.db, current_user.id, g.lexicon.id)
) %}
{# self.sb_logo(), #}
{% set template_sidebar_rows = [ {% set template_sidebar_rows = [
self.sb_characters(), self.sb_characters(),
self.sb_contents(), self.sb_contents(),
self.sb_rules(), self.sb_rules(),
self.sb_session(), self.sb_settings(),
self.sb_stats()] %} self.sb_stats()] %}
{% else %}
{# self.sb_logo(), #}
{% set template_sidebar_rows = [
self.sb_characters(),
self.sb_contents(),
self.sb_rules(),
self.sb_stats()] %}
{% endif %}

View File

@ -8,12 +8,14 @@ from amanuensis.server.helpers import lexicon_param, player_required_if_not_publ
from .characters import bp as characters_bp from .characters import bp as characters_bp
from .forms import LexiconJoinForm from .forms import LexiconJoinForm
from .settings import bp as settings_bp
bp = Blueprint( bp = Blueprint(
"lexicon", __name__, url_prefix="/lexicon/<lexicon_name>", template_folder="." "lexicon", __name__, url_prefix="/lexicon/<lexicon_name>", template_folder="."
) )
bp.register_blueprint(characters_bp) bp.register_blueprint(characters_bp)
bp.register_blueprint(settings_bp)
@bp.route("/join/", methods=["GET", "POST"]) @bp.route("/join/", methods=["GET", "POST"])

View File

@ -0,0 +1,65 @@
from flask import Blueprint, render_template, url_for, redirect
from amanuensis.backend import *
from amanuensis.db import *
from amanuensis.server.helpers import editor_required, lexicon_param, player_required
bp = Blueprint("settings", __name__, url_prefix="/settings", template_folder=".")
@bp.get("/")
@lexicon_param
@player_required
def page(lexicon_name):
return redirect(url_for("lexicon.settings.player", lexicon_name=lexicon_name))
@bp.get("/player/")
@lexicon_param
@player_required
def player(lexicon_name):
return render_template("settings.jinja", lexicon_name=lexicon_name, page_name=player.__name__)
@bp.get("/general/")
@lexicon_param
@editor_required
def general(lexicon_name):
return render_template(
"settings.jinja", lexicon_name=lexicon_name, page_name=general.__name__
)
@bp.get("/join/")
@lexicon_param
@editor_required
def join(lexicon_name):
return render_template("settings.jinja", lexicon_name=lexicon_name, page_name=join.__name__)
@bp.get("/progress/")
@lexicon_param
@editor_required
def progress(lexicon_name):
return render_template(
"settings.jinja", lexicon_name=lexicon_name, page_name=progress.__name__
)
@bp.get("/publish/")
@lexicon_param
@editor_required
def publish(lexicon_name):
return render_template(
"settings.jinja", lexicon_name=lexicon_name, page_name=publish.__name__
)
@bp.get("/article/")
@lexicon_param
@editor_required
def article(lexicon_name):
return render_template(
"settings.jinja", lexicon_name=lexicon_name, page_name=article.__name__
)

View File

@ -0,0 +1,45 @@
{% extends "lexicon.jinja" %}
{% block title %}Edit | {{ lexicon_title }}{% endblock %}
{% macro settings_page_link(page, text) -%}
<a{% if page_name != page %} href="{{ url_for('lexicon.settings.' + page, lexicon_name=lexicon_name) }}"{% endif %}>{{ text }}</a>
{%- endmacro %}
{% block main %}
{% if current_membership.is_editor %}
<ul class="unordered-tabs">
<li>{{ settings_page_link("player", "Player") }}</li>
<li>{{ settings_page_link("general", "General") }}</li>
<li>{{ settings_page_link("join", "Visibility and Joining") }}</li>
<li>{{ settings_page_link("progress", "Game Progress") }}</li>
<li>{{ settings_page_link("publish", "Turn Publishing") }}</li>
<li>{{ settings_page_link("article", "Article Requirements") }}</li>
</ul>
{% endif %}
{% if page_name == "player" %}
<h3>Player Settings</h3>
{% endif %}
{% if page_name == "general" %}
<h3>General Settings</h3>
{% endif %}
{% if page_name == "join" %}
<h3>Visibility and Joining</h3>
{% endif %}
{% if page_name == "progress" %}
<h3>Game Progress</h3>
{% endif %}
{% if page_name == "publish" %}
<h3>Turn Publishing</h3>
{% endif %}
{% if page_name == "article" %}
<h3>Article Requirements</h3>
{% endif %}
{% endblock %}
{% set template_content_blocks = [self.main()] %}