diff --git a/app/__init__.py b/app/__init__.py index 8a53d17..01ca7d3 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -5,6 +5,7 @@ from flask_login import LoginManager from flask_mail import Mail from config import Config import time +import slugify app = Flask(__name__) app.config.from_object(Config) @@ -49,3 +50,8 @@ from app.routes.forum import index, topic from app.utils import pluralize # To use pluralize into the templates from app.utils import date from app.utils import is_title + +# Add slugify into the available functions in every template +app.jinja_env.globals.update( + slugify=slugify.slugify +) diff --git a/app/static/css/widgets.css b/app/static/css/widgets.css index 4b4ee68..8d06ef7 100644 --- a/app/static/css/widgets.css +++ b/app/static/css/widgets.css @@ -61,7 +61,7 @@ border-radius: 2px; } .trophy img { - height: 50px; margin-right: 5px; + height: 48px; margin-right: 8px; } .trophy div > * { display: block; diff --git a/app/static/images/trophies/actif.png b/app/static/images/trophies/actif.png new file mode 100644 index 0000000..aaebe3a Binary files /dev/null and b/app/static/images/trophies/actif.png differ diff --git a/app/static/images/trophies/aficionado.png b/app/static/images/trophies/aficionado.png new file mode 100644 index 0000000..a3160ed Binary files /dev/null and b/app/static/images/trophies/aficionado.png differ diff --git a/app/static/images/trophies/artiste.png b/app/static/images/trophies/artiste.png new file mode 100644 index 0000000..b17dcdd Binary files /dev/null and b/app/static/images/trophies/artiste.png differ diff --git a/app/static/images/trophies/beau-parleur.png b/app/static/images/trophies/beau-parleur.png new file mode 100644 index 0000000..7dcc133 Binary files /dev/null and b/app/static/images/trophies/beau-parleur.png differ diff --git a/app/static/images/trophies/bourreau-des-coeurs.png b/app/static/images/trophies/bourreau-des-coeurs.png new file mode 100644 index 0000000..e46dcb7 Binary files /dev/null and b/app/static/images/trophies/bourreau-des-coeurs.png differ diff --git a/app/static/images/trophies/codeur-invetere.png b/app/static/images/trophies/codeur-invetere.png new file mode 100644 index 0000000..c63c28d Binary files /dev/null and b/app/static/images/trophies/codeur-invetere.png differ diff --git a/app/static/images/trophies/concourant-encore.png b/app/static/images/trophies/concourant-encore.png new file mode 100644 index 0000000..78eccd2 Binary files /dev/null and b/app/static/images/trophies/concourant-encore.png differ diff --git a/app/static/images/trophies/concurrent-de-l-extreme.png b/app/static/images/trophies/concurrent-de-l-extreme.png new file mode 100644 index 0000000..0ffd2ce Binary files /dev/null and b/app/static/images/trophies/concurrent-de-l-extreme.png differ diff --git a/app/static/images/trophies/dessinateur-en-herbe.png b/app/static/images/trophies/dessinateur-en-herbe.png new file mode 100644 index 0000000..b24d5df Binary files /dev/null and b/app/static/images/trophies/dessinateur-en-herbe.png differ diff --git a/app/static/images/trophies/encyclopedie-vivante.png b/app/static/images/trophies/encyclopedie-vivante.png new file mode 100644 index 0000000..cb59edc Binary files /dev/null and b/app/static/images/trophies/encyclopedie-vivante.png differ diff --git a/app/static/images/trophies/gourou.png b/app/static/images/trophies/gourou.png new file mode 100644 index 0000000..94047d2 Binary files /dev/null and b/app/static/images/trophies/gourou.png differ diff --git a/app/static/images/trophies/grand-joueur.png b/app/static/images/trophies/grand-joueur.png new file mode 100644 index 0000000..4004b23 Binary files /dev/null and b/app/static/images/trophies/grand-joueur.png differ diff --git a/app/static/images/trophies/grand-maitre-des-traits-d-esprit.png b/app/static/images/trophies/grand-maitre-des-traits-d-esprit.png new file mode 100644 index 0000000..2bcb7c5 Binary files /dev/null and b/app/static/images/trophies/grand-maitre-des-traits-d-esprit.png differ diff --git a/app/static/images/trophies/grand-manitou.png b/app/static/images/trophies/grand-manitou.png new file mode 100644 index 0000000..f144704 Binary files /dev/null and b/app/static/images/trophies/grand-manitou.png differ diff --git a/app/static/images/trophies/guerrier-du-savoir.png b/app/static/images/trophies/guerrier-du-savoir.png new file mode 100644 index 0000000..9dc5c6e Binary files /dev/null and b/app/static/images/trophies/guerrier-du-savoir.png differ diff --git a/app/static/images/trophies/hard-tester.png b/app/static/images/trophies/hard-tester.png new file mode 100644 index 0000000..dec5542 Binary files /dev/null and b/app/static/images/trophies/hard-tester.png differ diff --git a/app/static/images/trophies/initie.png b/app/static/images/trophies/initie.png new file mode 100644 index 0000000..3838640 Binary files /dev/null and b/app/static/images/trophies/initie.png differ diff --git a/app/static/images/trophies/je-code-donc-je-suis.png b/app/static/images/trophies/je-code-donc-je-suis.png new file mode 100644 index 0000000..fde529e Binary files /dev/null and b/app/static/images/trophies/je-code-donc-je-suis.png differ diff --git a/app/static/images/trophies/maitre-du-code.png b/app/static/images/trophies/maitre-du-code.png new file mode 100644 index 0000000..b618680 Binary files /dev/null and b/app/static/images/trophies/maitre-du-code.png differ diff --git a/app/static/images/trophies/membre-d-honneur.png b/app/static/images/trophies/membre-d-honneur.png new file mode 100644 index 0000000..88c0bf3 Binary files /dev/null and b/app/static/images/trophies/membre-d-honneur.png differ diff --git a/app/static/images/trophies/membre-de-creativecalc.png b/app/static/images/trophies/membre-de-creativecalc.png new file mode 100644 index 0000000..ee9cbba Binary files /dev/null and b/app/static/images/trophies/membre-de-creativecalc.png differ diff --git a/app/static/images/trophies/open-pixel.png b/app/static/images/trophies/open-pixel.png new file mode 100644 index 0000000..fc7db4e Binary files /dev/null and b/app/static/images/trophies/open-pixel.png differ diff --git a/app/static/images/trophies/papy-casio.png b/app/static/images/trophies/papy-casio.png new file mode 100644 index 0000000..961eea5 Binary files /dev/null and b/app/static/images/trophies/papy-casio.png differ diff --git a/app/static/images/trophies/participant.png b/app/static/images/trophies/participant.png new file mode 100644 index 0000000..ebf3694 Binary files /dev/null and b/app/static/images/trophies/participant.png differ diff --git a/app/static/images/trophies/pedagogue.png b/app/static/images/trophies/pedagogue.png new file mode 100644 index 0000000..0bd30de Binary files /dev/null and b/app/static/images/trophies/pedagogue.png differ diff --git a/app/static/images/trophies/plume-infaillible.png b/app/static/images/trophies/plume-infaillible.png new file mode 100644 index 0000000..29e02aa Binary files /dev/null and b/app/static/images/trophies/plume-infaillible.png differ diff --git a/app/static/images/trophies/premiers-mots.png b/app/static/images/trophies/premiers-mots.png new file mode 100644 index 0000000..a6c82cf Binary files /dev/null and b/app/static/images/trophies/premiers-mots.png differ diff --git a/app/static/images/trophies/programmeur-du-dimanche.png b/app/static/images/trophies/programmeur-du-dimanche.png new file mode 100644 index 0000000..3fc9680 Binary files /dev/null and b/app/static/images/trophies/programmeur-du-dimanche.png differ diff --git a/app/static/images/trophies/roi-du-pixel.png b/app/static/images/trophies/roi-du-pixel.png new file mode 100644 index 0000000..875742e Binary files /dev/null and b/app/static/images/trophies/roi-du-pixel.png differ diff --git a/app/static/images/trophies/romancier-emerite.png b/app/static/images/trophies/romancier-emerite.png new file mode 100644 index 0000000..631e9e5 Binary files /dev/null and b/app/static/images/trophies/romancier-emerite.png differ diff --git a/app/static/images/trophies/survivant-de-la-v42.png b/app/static/images/trophies/survivant-de-la-v42.png new file mode 100644 index 0000000..8c6c41c Binary files /dev/null and b/app/static/images/trophies/survivant-de-la-v42.png differ diff --git a/app/static/images/trophies/testeur.png b/app/static/images/trophies/testeur.png new file mode 100644 index 0000000..22ecb26 Binary files /dev/null and b/app/static/images/trophies/testeur.png differ diff --git a/app/static/images/trophies/veni-vidi-casii.png b/app/static/images/trophies/veni-vidi-casii.png new file mode 100644 index 0000000..7695d11 Binary files /dev/null and b/app/static/images/trophies/veni-vidi-casii.png differ diff --git a/app/static/images/trophies/veteran-mythique.png b/app/static/images/trophies/veteran-mythique.png new file mode 100644 index 0000000..55d75c8 Binary files /dev/null and b/app/static/images/trophies/veteran-mythique.png differ diff --git a/app/templates/account/user.html b/app/templates/account/user.html index d2473bc..dc80ac9 100644 --- a/app/templates/account/user.html +++ b/app/templates/account/user.html @@ -46,7 +46,7 @@
{% for t in trophies if t in member.trophies or t.hidden == False %}
- +
{{ t.name }} {{ t.description }} diff --git a/assets/trophies-generate.py b/assets/trophies-generate.py new file mode 100755 index 0000000..af6bd2d --- /dev/null +++ b/assets/trophies-generate.py @@ -0,0 +1,35 @@ +#! /usr/bin/python3 + +from PIL import Image +import os +import sys +import slugify +import yaml + +if os.path.basename(os.getcwd()) != "assets": + print("This script should be started from the /assets folder of PCv5.") + sys.exit(1) + +# Read the list of trophies from /app/data/trophies.yaml +with open("../app/data/trophies.yaml") as fp: + trophies = yaml.safe_load(fp.read()) + names = [ slugify.slugify(t["name"]) for t in trophies ] + +# Write trophy images to /app/static/images/trophies +try: + os.mkdir("../app/static/images/trophies") +except FileExistsError: + pass + +# Skip blank squares in the source image +img = Image.open("trophies.png") + +def trophy_iterator(img): + for y in range(img.height // 26): + for x in range(img.width // 26): + icon = img.crop((26*x+1, 26*y+1, 26*x+25, 26*y+25)) + if len(icon.getcolors()) > 1: + yield icon.resize((48,48)) + +for (name, icon) in zip(names, trophy_iterator(img)): + icon.save(f"../app/static/images/trophies/{name}.png") diff --git a/assets/trophies.png b/assets/trophies.png new file mode 100644 index 0000000..c4a7c17 Binary files /dev/null and b/assets/trophies.png differ