From f578d42dd50b2450c072ce8cbff1ebfe58d3143a Mon Sep 17 00:00:00 2001 From: Samuel ORTION Date: Fri, 27 May 2022 10:08:25 +0200 Subject: [PATCH] Update --- .gitignore | 3 +- README.md | 9 +--- app.py | 12 +++-- babel.cfg | 3 +- language/message.pot | 24 +++++++-- .../translations/fr/LC_MESSAGES/messages.mo | Bin 596 -> 760 bytes .../translations/fr/LC_MESSAGES/messages.po | 51 ++++++++++++++++-- static/scripts/app.js | 0 static/styles/style.css | 9 ++-- templates/base.html | 19 +++++-- templates/game/answer.html | 2 + templates/game/new.html | 2 +- templates/game/question.html | 1 + templates/lang.html | 11 ---- templates/language.html | 10 ++++ templates/menu.html | 25 +++++---- utils/make_migration.sh | 4 ++ utils/make_translations.sh | 4 ++ 18 files changed, 138 insertions(+), 51 deletions(-) create mode 100644 static/scripts/app.js delete mode 100644 templates/lang.html create mode 100644 templates/language.html create mode 100644 utils/make_migration.sh create mode 100644 utils/make_translations.sh diff --git a/.gitignore b/.gitignore index 800023a..4ce5e7f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ venv config.py __pycache__ -src_audio/ \ No newline at end of file +src_audio/ +node_modules \ No newline at end of file diff --git a/README.md b/README.md index be3d67c..c2dbbf8 100644 --- a/README.md +++ b/README.md @@ -33,11 +33,6 @@ cp config.py.example config.py ## Database migration ```bash -python3 -``` - -```python3 -from app import * -app.app_context().push() -db.create_all() +flask db migrate -m "Migration message." +flask db upgrade # Perform migration (after script verification in ./migrations/versions/) ``` \ No newline at end of file diff --git a/app.py b/app.py index f1eee14..3c912b1 100644 --- a/app.py +++ b/app.py @@ -42,14 +42,15 @@ def get_timezone(): if user is not None: return user.timezone +app.jinja_env.globals['get_locale'] = get_locale + @app.route('/lang') def get_lang(): return render_template('lang.html') -@app.route('/lang', methods=["POST"]) -def set_lang(): - lang = request.form["lang"] - session['lang'] = lang +@app.route('/lang/') +def set_lang(locale='en'): + session['lang'] = locale return redirect('/') @app.route("/") @@ -140,8 +141,9 @@ def game_answer(): message = "You are correct !" else: message = "You are not correct !" - return render_template("game/answer.html", message=message) + return render_template("game/answer.html", message=message, question=session["question"]) elif request.method == "GET": return render_template("game/new.html") + migrate = Migrate(app, db) \ No newline at end of file diff --git a/babel.cfg b/babel.cfg index 751ac40..3894803 100644 --- a/babel.cfg +++ b/babel.cfg @@ -1,4 +1,3 @@ [python: **.py] [jinja2: templates/**.html] -encoding = utf-8 -extensions=jinja2.ext.autoescape,jinja2.ext.with_ \ No newline at end of file +encoding = utf-8 \ No newline at end of file diff --git a/language/message.pot b/language/message.pot index 1133c9f..50b6440 100644 --- a/language/message.pot +++ b/language/message.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2022-05-26 12:11+0200\n" +"POT-Creation-Date: 2022-05-27 10:03+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,7 +17,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.10.1\n" -#: templates/base.html:15 +#: templates/base.html:17 msgid "Welcome" msgstr "" @@ -25,11 +25,27 @@ msgstr "" msgid "Welcome to BirdQuizz !" msgstr "" -#: templates/menu.html:3 +#: templates/menu.html:7 msgid "Home" msgstr "" -#: templates/menu.html:4 +#: templates/menu.html:8 msgid "Game" msgstr "" +#: templates/menu.html:9 +msgid "About" +msgstr "" + +#: templates/menu.html:11 +msgid "Logout" +msgstr "" + +#: templates/menu.html:13 +msgid "Login" +msgstr "" + +#: templates/menu.html:15 +msgid "Identify bird song" +msgstr "" + diff --git a/language/translations/fr/LC_MESSAGES/messages.mo b/language/translations/fr/LC_MESSAGES/messages.mo index a2432433bdedbef0b8e783cdd9f6fcf27407563a..833d0779e1636a8366b42c368f54a7aacaaa95ac 100644 GIT binary patch delta 320 zcmcb@@`JVho)F7a1|Z-BVi_P#0dbJP8X%h$h}Qx!3lMLH(mQ~(5D@PLVvzg=AZ7#N zYe38n#CL&M42YisaUUZC!yh0GvZI@cfq@xFPX*FIb+HUHfeetv3xPC9!9F0(1Efzt z`B#Co1dx9pNHaJl<(HN)xF_bOGI-SF)XW?P&pe1RnW+jnsl^~; k6jIdlGmBFbODhC!*7+emoOonkL8!)K=04WzlP5=M^ delta 164 zcmeytdWEI_o)F7a1|VPsVi_QI0dbH(4v@_P#JNzq2uQO7aXAo+0dYML_c1asOas!) zK&;9Hk=F#$oIt)Ikd^?_)\n" "Language: fr\n" @@ -18,7 +18,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.10.1\n" -#: templates/base.html:15 +#: templates/base.html:17 msgid "Welcome" msgstr "Bienvenue" @@ -26,11 +26,54 @@ msgstr "Bienvenue" msgid "Welcome to BirdQuizz !" msgstr "Bienvenue au BirdQuizz !" -#: templates/menu.html:3 +#: templates/menu.html:7 msgid "Home" msgstr "Accueil" -#: templates/menu.html:4 +#: templates/menu.html:8 msgid "Game" msgstr "Jeu" +#: templates/menu.html:9 +msgid "About" +msgstr "À propos" + +#: templates/menu.html:11 +msgid "Logout" +msgstr "Déconnexion" + +#: templates/menu.html:13 +msgid "Login" +msgstr "Connexion" + +#: templates/menu.html:15 +msgid "Identify bird song" +msgstr "Indentifie les son d'oiseaux" + +#~ msgid "Welcome" +#~ msgstr "Bienvenue" + +#~ msgid "Welcome to BirdQuizz !" +#~ msgstr "Bienvenue au BirdQuizz !" + +#~ msgid "Home" +#~ msgstr "Accueil" + +#~ msgid "Game" +#~ msgstr "Jeu" + +#~ msgid "Username empty. Try to find one." +#~ msgstr "Nom d'utilisateur vide. Essayez d'en trouver un." + +#~ msgid "Email empty. Please give me one." +#~ msgstr "Email non fourmi. Merci de m'en envoyez un." + +#~ msgid "You should not use an empty password" +#~ msgstr "Vous ne devriez pas utiliser un mot de passe vide." + +#~ msgid "Email already used by a user." +#~ msgstr "Cet email a déjà été utilisé par quelqu'un." + +#~ msgid "Username already used by a user." +#~ msgstr "Ce nom d'utilisateur a déjà été pris." + diff --git a/static/scripts/app.js b/static/scripts/app.js new file mode 100644 index 0000000..e69de29 diff --git a/static/styles/style.css b/static/styles/style.css index 79a3e7e..d10e314 100644 --- a/static/styles/style.css +++ b/static/styles/style.css @@ -1,4 +1,7 @@ -body { - background-color: black; - color: white; +main { + min-height: 100vh; +} + +footer { + padding: 1em; } \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index 1e211e7..4216bba 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,25 +1,36 @@ + {% block title %}BirdQuizz{% endblock %} + +
{% include 'menu.html' %} -

BirdQuizz

{% if username is defined %} -

{{ _('Welcome') }} {{ username }}

+

{{ _('Welcome') }} {{ username }}

{% endif %}
{% block content %}{% endblock %}
-