From 45ee56d09b9cf6fa2db8de025c7fa31625998fb0 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Fri, 27 Aug 2021 11:53:37 -0700 Subject: [PATCH] Add character creation and signatures --- amanuensis/resources/page.css | 16 +++++-- amanuensis/server/lexicon.jinja | 2 +- .../server/lexicon/characters/__init__.py | 47 ++++++------------- .../lexicon/characters/characters.jinja | 10 ++++ 4 files changed, 37 insertions(+), 38 deletions(-) diff --git a/amanuensis/resources/page.css b/amanuensis/resources/page.css index d32161f..536b854 100644 --- a/amanuensis/resources/page.css +++ b/amanuensis/resources/page.css @@ -95,9 +95,6 @@ div.contentblock { border-radius: 5px; word-break: break-word; } -div.contentblock h3 { - margin: 0.3em 0; -} a.phantom { color: #cc2200; } @@ -139,10 +136,21 @@ ul.blockitem-list li { border-inline-start: 3px solid black; padding-inline-start: 0.5em; } -ul.blockitem-list p { +ul.blockitem-list * { margin-block-start: 0.5em; margin-block-end: 0.5em; } +ul.blockitem-list pre { + background-color: lightgray; + padding-block-start: 2px; + padding-block-end: 2px; + padding-inline-start: 2px; + padding-inline-end: 2px; + border: 1px solid gray; + border-radius: 2px; + font-size: smaller; + white-space: break-spaces; +} div.dashboard-lexicon-unstarted { border-left-color: blue; } diff --git a/amanuensis/server/lexicon.jinja b/amanuensis/server/lexicon.jinja index 41ea53c..70862b4 100644 --- a/amanuensis/server/lexicon.jinja +++ b/amanuensis/server/lexicon.jinja @@ -9,7 +9,7 @@ {% block sb_logo %}{% endblock %} {% block sb_characters %}Characters{% endblock %} {% block sb_contents %}', methods=['GET', 'POST']) @@ -29,11 +30,11 @@ def edit(name, character_id): char_uuid = uuid.UUID(character_id) except: flash("Character not found") - return redirect(url_for('lexicon.characters.characters', name=name)) + return redirect(url_for('lexicon.characters.list', name=name)) character: Optional[Character] = charq.try_from_public_id(g.db, char_uuid) if not character: flash("Character not found") - return redirect(url_for('lexicon.characters.characters', name=name)) + return redirect(url_for('lexicon.characters.list', name=name)) form = CharacterCreateForm() @@ -50,38 +51,18 @@ def edit(name, character_id): character.name = form.name.data character.signature = form.signature.data g.db.session.commit() - return redirect(url_for('lexicon.characters.characters', name=name)) + return redirect(url_for('lexicon.characters.list', name=name)) else: # POST submitted invalid data return render_template('characters.edit.jinja', character=character, form=form) -# def create_character(name: str, form: LexiconCharacterForm): -# # Characters can't be created if the game has already started -# if g.lexicon.status != LexiconModel.PREGAME: -# flash("Characters can't be added after the game has started") -# return redirect(url_for('session.session', name=name)) -# # Characters can't be created beyond the per-player limit -# player_characters = get_player_characters(g.lexicon, current_user.uid) -# if len(list(player_characters)) >= g.lexicon.cfg.join.chars_per_player: -# flash("Can't create more characters") -# return redirect(url_for('session.session', name=name)) - -# if not form.is_submitted(): -# # GET, populate with default values -# return render_template( -# 'session.character.jinja', form=form.for_new()) - -# if not form.validate(): -# # POST with invalid data, return unchanged -# return render_template('session.character.jinja', form=form) - -# # POST with valid data, create character -# char_name = form.characterName.data -# cid = create_character_in_lexicon(current_user, g.lexicon, char_name) -# with g.lexicon.ctx.edit_config() as cfg: -# cfg.character[cid].signature = form.defaultSignature.data -# flash('Character created') -# return redirect(url_for('session.session', name=name)) - +@bp.get('/new/') +@lexicon_param +@player_required +def new(name): + dummy_name = f"{current_user.username}'s new character" + dummy_signature = "~" + charq.create(g.db, g.lexicon.id, current_user.id, dummy_name, dummy_signature) + return redirect(url_for('lexicon.characters.list', name=name)) diff --git a/amanuensis/server/lexicon/characters/characters.jinja b/amanuensis/server/lexicon/characters/characters.jinja index f3f023e..2d0a31c 100644 --- a/amanuensis/server/lexicon/characters/characters.jinja +++ b/amanuensis/server/lexicon/characters/characters.jinja @@ -1,4 +1,5 @@ {% extends "lexicon.jinja" %} +{% set current_page = "characters" %} {% block title %}Character | {{ lexicon_title }}{% endblock %} {% block main %} @@ -10,9 +11,18 @@ {{ message }}
{% endfor %}