From ba722562a8c0c33bd4c1b7b298120343018d4dbc Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Sat, 4 Sep 2021 13:34:24 -0700 Subject: [PATCH] Add settings page skeleton --- amanuensis/resources/page.css | 30 +++++++++ amanuensis/server/lexicon.jinja | 23 ++----- amanuensis/server/lexicon/__init__.py | 2 + .../server/lexicon/settings/__init__.py | 65 +++++++++++++++++++ .../server/lexicon/settings/settings.jinja | 45 +++++++++++++ 5 files changed, 147 insertions(+), 18 deletions(-) create mode 100644 amanuensis/server/lexicon/settings/__init__.py create mode 100644 amanuensis/server/lexicon/settings/settings.jinja diff --git a/amanuensis/resources/page.css b/amanuensis/resources/page.css index b2e3c6f..db95940 100644 --- a/amanuensis/resources/page.css +++ b/amanuensis/resources/page.css @@ -173,6 +173,36 @@ div.dashboard-lexicon-item p { margin-block-start: 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) { div#wrapper { padding: 5px; diff --git a/amanuensis/server/lexicon.jinja b/amanuensis/server/lexicon.jinja index 1d3e6c2..46f18c4 100644 --- a/amanuensis/server/lexicon.jinja +++ b/amanuensis/server/lexicon.jinja @@ -19,31 +19,18 @@ {% if current_page == "rules" %}class="current-page" {% else %}href="{{ url_for('lexicon.rules', lexicon_name=g.lexicon.name) }}" {% endif %}>Rules{% endblock %} -{% block sb_session %}Session{% endblock %} +{% block sb_settings %}Settings{% endblock %} {% block sb_stats %}Statistics{% 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 = [ self.sb_characters(), self.sb_contents(), self.sb_rules(), - self.sb_session(), + self.sb_settings(), self.sb_stats()] %} -{% else %} - {# self.sb_logo(), #} -{% set template_sidebar_rows = [ - self.sb_characters(), - self.sb_contents(), - self.sb_rules(), - self.sb_stats()] %} -{% endif %} diff --git a/amanuensis/server/lexicon/__init__.py b/amanuensis/server/lexicon/__init__.py index b2fc7a2..a75049e 100644 --- a/amanuensis/server/lexicon/__init__.py +++ b/amanuensis/server/lexicon/__init__.py @@ -8,12 +8,14 @@ from amanuensis.server.helpers import lexicon_param, player_required_if_not_publ from .characters import bp as characters_bp from .forms import LexiconJoinForm +from .settings import bp as settings_bp bp = Blueprint( "lexicon", __name__, url_prefix="/lexicon/", template_folder="." ) bp.register_blueprint(characters_bp) +bp.register_blueprint(settings_bp) @bp.route("/join/", methods=["GET", "POST"]) diff --git a/amanuensis/server/lexicon/settings/__init__.py b/amanuensis/server/lexicon/settings/__init__.py new file mode 100644 index 0000000..9705e58 --- /dev/null +++ b/amanuensis/server/lexicon/settings/__init__.py @@ -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__ + ) diff --git a/amanuensis/server/lexicon/settings/settings.jinja b/amanuensis/server/lexicon/settings/settings.jinja new file mode 100644 index 0000000..6cfa2ce --- /dev/null +++ b/amanuensis/server/lexicon/settings/settings.jinja @@ -0,0 +1,45 @@ +{% extends "lexicon.jinja" %} +{% block title %}Edit | {{ lexicon_title }}{% endblock %} + +{% macro settings_page_link(page, text) -%} +{{ text }} +{%- endmacro %} + +{% block main %} +{% if current_membership.is_editor %} +
    +
  • {{ settings_page_link("player", "Player") }}
  • +
  • {{ settings_page_link("general", "General") }}
  • +
  • {{ settings_page_link("join", "Visibility and Joining") }}
  • +
  • {{ settings_page_link("progress", "Game Progress") }}
  • +
  • {{ settings_page_link("publish", "Turn Publishing") }}
  • +
  • {{ settings_page_link("article", "Article Requirements") }}
  • +
+{% endif %} + +{% if page_name == "player" %} +

Player Settings

+{% endif %} + +{% if page_name == "general" %} +

General Settings

+{% endif %} + +{% if page_name == "join" %} +

Visibility and Joining

+{% endif %} + +{% if page_name == "progress" %} +

Game Progress

+{% endif %} + +{% if page_name == "publish" %} +

Turn Publishing

+{% endif %} + +{% if page_name == "article" %} +

Article Requirements

+{% endif %} +{% endblock %} + +{% set template_content_blocks = [self.main()] %}