diff --git a/default_config.py b/default_config.py index d13ae2e..36ee21c 100644 --- a/default_config.py +++ b/default_config.py @@ -29,4 +29,7 @@ INSTANCE_PATH="instance" ENABLED_LOGS=["NEW_GROUPE", "NEW_ALBUM", "NEW_PARTITION", "NEW_USER", "SERVER_RESTART", "FAILED_LOGIN"] # Available languages -LANGUAGES=['en', 'fr'] \ No newline at end of file +LANGUAGES=['en', 'fr'] + +# Show Launch page +LAUNCH_PAGE=True \ No newline at end of file diff --git a/partitioncloud/__init__.py b/partitioncloud/__init__.py index f52e80c..2eb3a38 100644 --- a/partitioncloud/__init__.py +++ b/partitioncloud/__init__.py @@ -8,11 +8,11 @@ import datetime import subprocess import importlib.util -from flask import Flask, g, redirect, render_template, request, send_file, flash, session, abort +from flask import Flask, g, redirect, render_template, request, send_file, flash, session, abort, url_for from werkzeug.security import generate_password_hash from flask_babel import Babel, _ -from .modules.utils import User, Album, get_all_albums +from .modules.utils import User, Album, get_all_albums, user_count, partition_count from .modules import albums, auth, partition, admin, groupe, thumbnails, logging from .modules.auth import admin_required, login_required from .modules.db import get_db @@ -101,8 +101,20 @@ logging.log([], logging.LogEntry.SERVER_RESTART) @app.route("/") def home(): - """Redirect to home""" - return redirect("/albums/") + """Show launch page if enabled""" + if g.user is None: + if app.config["LAUNCH_PAGE"]: + return redirect(url_for("launch_page")) + return redirect(url_for("auth.login")) + return redirect(url_for("albums.index")) + + +@app.route("/launch") +def launch_page(): + """Show launch page if enabled""" + if not app.config["LAUNCH_PAGE"]: + return home() + return render_template("launch.html", user_count=user_count(), partition_count=partition_count()) @app.route("/add-user", methods=["GET", "POST"]) @@ -133,10 +145,10 @@ def add_user(): if album_uuid != "": user.join_album(album_uuid) flash(_("Created user %(username)s", username=username)) - return redirect("/albums") + return redirect(url_for("albums.index")) except LookupError: flash(_("This album does not exists, but user %(username)s has been created", username=username)) - return redirect("/albums") + return redirect(url_for("albums.index")) flash(error) return render_template("auth/register.html", albums=get_all_albums(), user=current_user) diff --git a/partitioncloud/modules/auth.py b/partitioncloud/modules/auth.py index 21c5cf0..8acfbdc 100644 --- a/partitioncloud/modules/auth.py +++ b/partitioncloud/modules/auth.py @@ -130,6 +130,7 @@ def register(): [user.username, user.id, False], logging.LogEntry.NEW_USER ) + return redirect(url_for("auth.login")) return render_template("auth/register.html") @@ -169,4 +170,4 @@ def login(): def logout(): """Clear the current session, including the stored user id.""" session.clear() - return redirect(url_for("auth.login")) + return redirect("/") diff --git a/partitioncloud/modules/utils.py b/partitioncloud/modules/utils.py index 9b5ec53..6abdc07 100644 --- a/partitioncloud/modules/utils.py +++ b/partitioncloud/modules/utils.py @@ -72,3 +72,25 @@ def get_all_albums(): "uuid": a["uuid"] } for a in albums ] + + +def user_count(): + db = get_db() + count = db.execute( + """ + SELECT COUNT(*) as count FROM user + """ + ).fetchone() + + return count[0] + + +def partition_count(): + db = get_db() + count = db.execute( + """ + SELECT COUNT(*) FROM partition + """ + ).fetchone() + + return count[0] \ No newline at end of file diff --git a/partitioncloud/static/images/dark-preview.png b/partitioncloud/static/images/dark-preview.png new file mode 100644 index 0000000..34fec19 Binary files /dev/null and b/partitioncloud/static/images/dark-preview.png differ diff --git a/partitioncloud/static/images/light-preview.png b/partitioncloud/static/images/light-preview.png new file mode 100644 index 0000000..8d72d51 Binary files /dev/null and b/partitioncloud/static/images/light-preview.png differ diff --git a/partitioncloud/static/style/launch.css b/partitioncloud/static/style/launch.css new file mode 100644 index 0000000..d778a58 --- /dev/null +++ b/partitioncloud/static/style/launch.css @@ -0,0 +1,110 @@ +@import url('/static/style/colors.css'); + + +* { + font-family: var(--font-family); +} + +h2 { + color: var(--color-subtext1); +} + +a { + text-decoration: none; + color: var(--color-blue); +} + +body { + color: var(--color-text); + background-color: var(--color-base); +} + +.no-color-link { + color: var(--color-text); +} + +button { + padding: 10px 20px; + margin: 5px; + border-radius: 3px; + cursor: pointer; + + font-weight: bold; + font-size: 0.95em; + + border: var(--color-subtext0); + border-width: 2px; + border-style: solid; + + background-color: var(--color-subtext0); + color: var(--color-base); +} + +button.blue { + background-color: var(--color-blue); + border-color: var(--color-blue); +} + +button:hover { + background-color: var(--color-crust); + border-color: var(--color-blue); + color: var(--color-blue); +} + +header { + display: flex; +} + +#login { + position: absolute; + right: 15px; +} + +#logo-container { + margin: 25px; +} + +main { + margin: 5vw; + text-align: center; +} + +#instance-stats { + margin: 35px 0px; + color: var(--color-subtext1); +} + +img.preview { + max-width: 85vw; + border-style: solid; + border-radius: 5px; + border-color: var(--color-overlay1); + border-width: 3px; +} + +img#light-preview { + display: none; +} + +img#dark-preview { + display: initial; +} + +@media (prefers-color-scheme: light) { + img#light-preview { + display: initial; + } + + img#dark-preview { + display: none; + } +} + +footer { + color: var(--color-subtext1); + position: fixed; + bottom: 0; + width: 100%; + text-align: center; + margin-bottom: 10px; +} \ No newline at end of file diff --git a/partitioncloud/templates/launch.html b/partitioncloud/templates/launch.html new file mode 100644 index 0000000..eefa1e7 --- /dev/null +++ b/partitioncloud/templates/launch.html @@ -0,0 +1,62 @@ + + + + + + + + + PartitionCloud + + + + + + + + +
+ + Logo + +
+ + + +
+
+ +
+

{{ _("PartitionCloud is an open-source score library server, to help you in all your musical activities") }}

+
+ + + + + + +
+
+ {% set user_bold %} + {{ user_count }} + {% endset %} + {% set partition_bold %} + {{ partition_count }} + {% endset %} + {{ _("This instance is used by %(users)s users with a total of %(scores)s scores.", users=user_bold, scores=partition_bold) }} +
+ + +
+ + + \ No newline at end of file diff --git a/partitioncloud/translations/en/LC_MESSAGES/messages.po b/partitioncloud/translations/en/LC_MESSAGES/messages.po index 9a433a1..16573a8 100644 --- a/partitioncloud/translations/en/LC_MESSAGES/messages.po +++ b/partitioncloud/translations/en/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2024-01-25 16:19+0100\n" +"POT-Creation-Date: 2024-01-29 18:32+0100\n" "PO-Revision-Date: 2024-01-22 15:38+0100\n" "Last-Translator: FULL NAME \n" "Language: en\n" @@ -18,12 +18,12 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.14.0\n" -#: partitioncloud/__init__.py:135 +#: partitioncloud/__init__.py:147 #, python-format msgid "Created user %(username)s" msgstr "Created user %(username)s" -#: partitioncloud/__init__.py:138 +#: partitioncloud/__init__.py:150 #, python-format msgid "This album does not exists, but user %(username)s has been created" msgstr "This album does not exists, but user %(username)s has been created" @@ -141,7 +141,7 @@ msgstr "New users registration is disabled by owner." msgid "Successfully created new user. You can log in." msgstr "Successfully created new user. You can log in." -#: partitioncloud/modules/auth.py:152 +#: partitioncloud/modules/auth.py:153 msgid "Incorrect username or password" msgstr "Incorrect username or password" @@ -217,82 +217,108 @@ msgstr "You are not allowed to delete this score." msgid "Score deleted." msgstr "Score deleted." -#: partitioncloud/templates/base.html:23 +#: partitioncloud/templates/base.html:25 msgid "New Album" msgstr "New Album" -#: partitioncloud/templates/base.html:25 partitioncloud/templates/base.html:36 +#: partitioncloud/templates/base.html:27 partitioncloud/templates/base.html:38 #: partitioncloud/templates/groupe/index.html:10 #: partitioncloud/templates/partition/attachments.html:11 msgid "Name" msgstr "Name" -#: partitioncloud/templates/base.html:26 partitioncloud/templates/base.html:37 +#: partitioncloud/templates/base.html:28 partitioncloud/templates/base.html:39 msgid "Create" msgstr "Create" -#: partitioncloud/templates/base.html:30 +#: partitioncloud/templates/base.html:32 msgid "I want to create a collection of albums." msgstr "I want to create a collection of albums." -#: partitioncloud/templates/base.html:30 +#: partitioncloud/templates/base.html:32 msgid "Create group" msgstr "Create group" -#: partitioncloud/templates/base.html:34 +#: partitioncloud/templates/base.html:36 msgid "Create new group" msgstr "Create new group" -#: partitioncloud/templates/base.html:61 +#: partitioncloud/templates/base.html:63 msgid "Search" msgstr "Search" -#: partitioncloud/templates/base.html:63 +#: partitioncloud/templates/base.html:65 msgid "Number of online searches" msgstr "Number of online searches" #: partitioncloud/templates/admin/index.html:23 -#: partitioncloud/templates/base.html:71 +#: partitioncloud/templates/base.html:73 #: partitioncloud/templates/partition/details.html:41 msgid "Albums" msgstr "Albums" -#: partitioncloud/templates/base.html:75 +#: partitioncloud/templates/base.html:77 msgid "New album" msgstr "New album" -#: partitioncloud/templates/base.html:92 +#: partitioncloud/templates/base.html:94 msgid "No albums" msgstr "No albums" -#: partitioncloud/templates/base.html:111 +#: partitioncloud/templates/base.html:113 msgid "No album available" msgstr "No album available" -#: partitioncloud/templates/base.html:125 +#: partitioncloud/templates/base.html:127 msgid "Log in to see your albums" msgstr "Log in to see your albums" -#: partitioncloud/templates/base.html:139 +#: partitioncloud/templates/base.html:141 msgid "Log out" msgstr "Log out" -#: partitioncloud/templates/base.html:154 +#: partitioncloud/templates/base.html:156 msgid "Admin Panel" msgstr "Admin Panel" #: partitioncloud/templates/auth/register.html:5 #: partitioncloud/templates/auth/register.html:20 -#: partitioncloud/templates/base.html:166 +#: partitioncloud/templates/base.html:168 msgid "Create account" msgstr "Create account" #: partitioncloud/templates/auth/login.html:5 #: partitioncloud/templates/auth/login.html:10 -#: partitioncloud/templates/base.html:168 +#: partitioncloud/templates/base.html:170 +#: partitioncloud/templates/launch.html:26 msgid "Log in" msgstr "Log in" +#: partitioncloud/templates/launch.html:33 +msgid "" +"PartitionCloud is an open-source score library server, to help you in all" +" your musical activities" +msgstr "" +"PartitionCloud is an open-source score library server, to help you in all" +" your musical activities" + +#: partitioncloud/templates/launch.html:38 +msgid "Let's go !" +msgstr "Let's go !" + +#: partitioncloud/templates/launch.html:44 +msgid "Check code" +msgstr "Check code" + +#: partitioncloud/templates/launch.html:55 +#, python-format +msgid "" +"This instance is used by %(users)s users with a total of %(scores)s " +"scores." +msgstr "" +"This instance has %(users)s users with a total of %(scores)s " +"scores." + #: partitioncloud/templates/admin/index.html:5 msgid "Administration Panel" msgstr "Administration Panel" @@ -462,7 +488,7 @@ msgstr "author" msgid "lyrics" msgstr "lyrics" -#: partitioncloud/templates/components/add_partition.html:10 +#: partitioncloud/templates/components/add_partition.html:12 #: partitioncloud/templates/groupe/index.html:11 #: partitioncloud/templates/partition/attachments.html:13 msgid "Add" diff --git a/partitioncloud/translations/fr/LC_MESSAGES/messages.po b/partitioncloud/translations/fr/LC_MESSAGES/messages.po index f820305..5135b4b 100644 --- a/partitioncloud/translations/fr/LC_MESSAGES/messages.po +++ b/partitioncloud/translations/fr/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2024-01-25 16:19+0100\n" +"POT-Creation-Date: 2024-01-29 18:32+0100\n" "PO-Revision-Date: 2024-01-22 15:24+0100\n" "Last-Translator: FULL NAME \n" "Language: fr\n" @@ -18,12 +18,12 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.14.0\n" -#: partitioncloud/__init__.py:135 +#: partitioncloud/__init__.py:147 #, python-format msgid "Created user %(username)s" msgstr "Utilisateur %(username)s créé" -#: partitioncloud/__init__.py:138 +#: partitioncloud/__init__.py:150 #, python-format msgid "This album does not exists, but user %(username)s has been created" msgstr "Cet album n'existe pas. L'utilisateur %(username)s a été créé" @@ -143,7 +143,7 @@ msgstr "" msgid "Successfully created new user. You can log in." msgstr "Utilisateur créé avec succès. Vous pouvez vous connecter." -#: partitioncloud/modules/auth.py:152 +#: partitioncloud/modules/auth.py:153 msgid "Incorrect username or password" msgstr "Nom d'utilisateur ou mot de passe incorrect." @@ -219,84 +219,110 @@ msgstr "Vous n'êtes pas autorisé à supprimer cette partition." msgid "Score deleted." msgstr "Partition supprimée." -#: partitioncloud/templates/base.html:23 +#: partitioncloud/templates/base.html:25 msgid "New Album" msgstr "Créer un nouvel album" -#: partitioncloud/templates/base.html:25 partitioncloud/templates/base.html:36 +#: partitioncloud/templates/base.html:27 partitioncloud/templates/base.html:38 #: partitioncloud/templates/groupe/index.html:10 #: partitioncloud/templates/partition/attachments.html:11 msgid "Name" msgstr "Nom" -#: partitioncloud/templates/base.html:26 partitioncloud/templates/base.html:37 +#: partitioncloud/templates/base.html:28 partitioncloud/templates/base.html:39 msgid "Create" msgstr "Créer" -#: partitioncloud/templates/base.html:30 +#: partitioncloud/templates/base.html:32 msgid "I want to create a collection of albums." msgstr "" "Je souhaite créer plusieurs albums et pouvoir tous les partager avec un " "seul lien." -#: partitioncloud/templates/base.html:30 +#: partitioncloud/templates/base.html:32 msgid "Create group" msgstr "Créer un groupe" -#: partitioncloud/templates/base.html:34 +#: partitioncloud/templates/base.html:36 msgid "Create new group" msgstr "Créer un nouveau groupe" -#: partitioncloud/templates/base.html:61 +#: partitioncloud/templates/base.html:63 msgid "Search" msgstr "Rechercher" -#: partitioncloud/templates/base.html:63 +#: partitioncloud/templates/base.html:65 msgid "Number of online searches" msgstr "Nombre de recherches en ligne" #: partitioncloud/templates/admin/index.html:23 -#: partitioncloud/templates/base.html:71 +#: partitioncloud/templates/base.html:73 #: partitioncloud/templates/partition/details.html:41 msgid "Albums" msgstr "Albums" -#: partitioncloud/templates/base.html:75 +#: partitioncloud/templates/base.html:77 msgid "New album" msgstr "Créer un album" -#: partitioncloud/templates/base.html:92 +#: partitioncloud/templates/base.html:94 msgid "No albums" msgstr "Aucun album disponible" -#: partitioncloud/templates/base.html:111 +#: partitioncloud/templates/base.html:113 msgid "No album available" msgstr "Aucun album disponible" -#: partitioncloud/templates/base.html:125 +#: partitioncloud/templates/base.html:127 msgid "Log in to see your albums" msgstr "Connectez vous pour avoir accès à vos albums" -#: partitioncloud/templates/base.html:139 +#: partitioncloud/templates/base.html:141 msgid "Log out" msgstr "Déconnexion" -#: partitioncloud/templates/base.html:154 +#: partitioncloud/templates/base.html:156 msgid "Admin Panel" msgstr "Panneau admin" #: partitioncloud/templates/auth/register.html:5 #: partitioncloud/templates/auth/register.html:20 -#: partitioncloud/templates/base.html:166 +#: partitioncloud/templates/base.html:168 msgid "Create account" msgstr "Créer un compte" #: partitioncloud/templates/auth/login.html:5 #: partitioncloud/templates/auth/login.html:10 -#: partitioncloud/templates/base.html:168 +#: partitioncloud/templates/base.html:170 +#: partitioncloud/templates/launch.html:26 msgid "Log in" msgstr "Se connecter" +#: partitioncloud/templates/launch.html:33 +msgid "" +"PartitionCloud is an open-source score library server, to help you in all" +" your musical activities" +msgstr "" +"PartitionCloud est une bibliothèque de partitions open-source, pour vous " +"aider dans toutes vos activités musicales" + +#: partitioncloud/templates/launch.html:38 +msgid "Let's go !" +msgstr "C'est parti !" + +#: partitioncloud/templates/launch.html:44 +msgid "Check code" +msgstr "Voir le code" + +#: partitioncloud/templates/launch.html:55 +#, python-format +msgid "" +"This instance is used by %(users)s users with a total of %(scores)s " +"scores." +msgstr "" +"Cette instance est utilisée par %(users)s personnes avec un total de " +"%(scores)s partitions." + #: partitioncloud/templates/admin/index.html:5 msgid "Administration Panel" msgstr "Panneau d'administration" @@ -466,7 +492,7 @@ msgstr "auteur" msgid "lyrics" msgstr "paroles" -#: partitioncloud/templates/components/add_partition.html:10 +#: partitioncloud/templates/components/add_partition.html:12 #: partitioncloud/templates/groupe/index.html:11 #: partitioncloud/templates/partition/attachments.html:13 msgid "Add"