diff --git a/.gitignore b/.gitignore index b5993a7..93d2f8b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ __pycache__/ app/__pycache__/ app/static/avatars/ +app/static/images/trophies/ ## Devlopement files diff --git a/assets/trophies.png b/app/data/trophies.png similarity index 100% rename from assets/trophies.png rename to app/data/trophies.png diff --git a/app/static/images/trophies/actif.png b/app/static/images/trophies/actif.png deleted file mode 100644 index aaebe3a..0000000 Binary files a/app/static/images/trophies/actif.png and /dev/null differ diff --git a/app/static/images/trophies/aficionado.png b/app/static/images/trophies/aficionado.png deleted file mode 100644 index a3160ed..0000000 Binary files a/app/static/images/trophies/aficionado.png and /dev/null differ diff --git a/app/static/images/trophies/artiste.png b/app/static/images/trophies/artiste.png deleted file mode 100644 index b17dcdd..0000000 Binary files a/app/static/images/trophies/artiste.png and /dev/null differ diff --git a/app/static/images/trophies/beau-parleur.png b/app/static/images/trophies/beau-parleur.png deleted file mode 100644 index 7dcc133..0000000 Binary files a/app/static/images/trophies/beau-parleur.png and /dev/null differ diff --git a/app/static/images/trophies/bourreau-des-coeurs.png b/app/static/images/trophies/bourreau-des-coeurs.png deleted file mode 100644 index e46dcb7..0000000 Binary files a/app/static/images/trophies/bourreau-des-coeurs.png and /dev/null differ diff --git a/app/static/images/trophies/codeur-invetere.png b/app/static/images/trophies/codeur-invetere.png deleted file mode 100644 index c63c28d..0000000 Binary files a/app/static/images/trophies/codeur-invetere.png and /dev/null differ diff --git a/app/static/images/trophies/concourant-encore.png b/app/static/images/trophies/concourant-encore.png deleted file mode 100644 index 78eccd2..0000000 Binary files a/app/static/images/trophies/concourant-encore.png and /dev/null differ diff --git a/app/static/images/trophies/concurrent-de-l-extreme.png b/app/static/images/trophies/concurrent-de-l-extreme.png deleted file mode 100644 index 0ffd2ce..0000000 Binary files a/app/static/images/trophies/concurrent-de-l-extreme.png and /dev/null differ diff --git a/app/static/images/trophies/dessinateur-en-herbe.png b/app/static/images/trophies/dessinateur-en-herbe.png deleted file mode 100644 index b24d5df..0000000 Binary files a/app/static/images/trophies/dessinateur-en-herbe.png and /dev/null differ diff --git a/app/static/images/trophies/encyclopedie-vivante.png b/app/static/images/trophies/encyclopedie-vivante.png deleted file mode 100644 index cb59edc..0000000 Binary files a/app/static/images/trophies/encyclopedie-vivante.png and /dev/null differ diff --git a/app/static/images/trophies/gourou.png b/app/static/images/trophies/gourou.png deleted file mode 100644 index 94047d2..0000000 Binary files a/app/static/images/trophies/gourou.png and /dev/null differ diff --git a/app/static/images/trophies/grand-joueur.png b/app/static/images/trophies/grand-joueur.png deleted file mode 100644 index 4004b23..0000000 Binary files a/app/static/images/trophies/grand-joueur.png and /dev/null 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 deleted file mode 100644 index 2bcb7c5..0000000 Binary files a/app/static/images/trophies/grand-maitre-des-traits-d-esprit.png and /dev/null differ diff --git a/app/static/images/trophies/grand-manitou.png b/app/static/images/trophies/grand-manitou.png deleted file mode 100644 index f144704..0000000 Binary files a/app/static/images/trophies/grand-manitou.png and /dev/null differ diff --git a/app/static/images/trophies/guerrier-du-savoir.png b/app/static/images/trophies/guerrier-du-savoir.png deleted file mode 100644 index 9dc5c6e..0000000 Binary files a/app/static/images/trophies/guerrier-du-savoir.png and /dev/null differ diff --git a/app/static/images/trophies/hard-tester.png b/app/static/images/trophies/hard-tester.png deleted file mode 100644 index dec5542..0000000 Binary files a/app/static/images/trophies/hard-tester.png and /dev/null differ diff --git a/app/static/images/trophies/initie.png b/app/static/images/trophies/initie.png deleted file mode 100644 index 3838640..0000000 Binary files a/app/static/images/trophies/initie.png and /dev/null 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 deleted file mode 100644 index fde529e..0000000 Binary files a/app/static/images/trophies/je-code-donc-je-suis.png and /dev/null differ diff --git a/app/static/images/trophies/maitre-du-code.png b/app/static/images/trophies/maitre-du-code.png deleted file mode 100644 index b618680..0000000 Binary files a/app/static/images/trophies/maitre-du-code.png and /dev/null differ diff --git a/app/static/images/trophies/membre-d-honneur.png b/app/static/images/trophies/membre-d-honneur.png deleted file mode 100644 index 88c0bf3..0000000 Binary files a/app/static/images/trophies/membre-d-honneur.png and /dev/null differ diff --git a/app/static/images/trophies/membre-de-creativecalc.png b/app/static/images/trophies/membre-de-creativecalc.png deleted file mode 100644 index ee9cbba..0000000 Binary files a/app/static/images/trophies/membre-de-creativecalc.png and /dev/null differ diff --git a/app/static/images/trophies/open-pixel.png b/app/static/images/trophies/open-pixel.png deleted file mode 100644 index fc7db4e..0000000 Binary files a/app/static/images/trophies/open-pixel.png and /dev/null differ diff --git a/app/static/images/trophies/papy-casio.png b/app/static/images/trophies/papy-casio.png deleted file mode 100644 index 961eea5..0000000 Binary files a/app/static/images/trophies/papy-casio.png and /dev/null differ diff --git a/app/static/images/trophies/participant.png b/app/static/images/trophies/participant.png deleted file mode 100644 index ebf3694..0000000 Binary files a/app/static/images/trophies/participant.png and /dev/null differ diff --git a/app/static/images/trophies/pedagogue.png b/app/static/images/trophies/pedagogue.png deleted file mode 100644 index 0bd30de..0000000 Binary files a/app/static/images/trophies/pedagogue.png and /dev/null differ diff --git a/app/static/images/trophies/plume-infaillible.png b/app/static/images/trophies/plume-infaillible.png deleted file mode 100644 index 29e02aa..0000000 Binary files a/app/static/images/trophies/plume-infaillible.png and /dev/null differ diff --git a/app/static/images/trophies/premiers-mots.png b/app/static/images/trophies/premiers-mots.png deleted file mode 100644 index a6c82cf..0000000 Binary files a/app/static/images/trophies/premiers-mots.png and /dev/null differ diff --git a/app/static/images/trophies/programmeur-du-dimanche.png b/app/static/images/trophies/programmeur-du-dimanche.png deleted file mode 100644 index 3fc9680..0000000 Binary files a/app/static/images/trophies/programmeur-du-dimanche.png and /dev/null differ diff --git a/app/static/images/trophies/roi-du-pixel.png b/app/static/images/trophies/roi-du-pixel.png deleted file mode 100644 index 875742e..0000000 Binary files a/app/static/images/trophies/roi-du-pixel.png and /dev/null differ diff --git a/app/static/images/trophies/romancier-emerite.png b/app/static/images/trophies/romancier-emerite.png deleted file mode 100644 index 631e9e5..0000000 Binary files a/app/static/images/trophies/romancier-emerite.png and /dev/null differ diff --git a/app/static/images/trophies/survivant-de-la-v42.png b/app/static/images/trophies/survivant-de-la-v42.png deleted file mode 100644 index 8c6c41c..0000000 Binary files a/app/static/images/trophies/survivant-de-la-v42.png and /dev/null differ diff --git a/app/static/images/trophies/testeur.png b/app/static/images/trophies/testeur.png deleted file mode 100644 index 22ecb26..0000000 Binary files a/app/static/images/trophies/testeur.png and /dev/null differ diff --git a/app/static/images/trophies/veni-vidi-casii.png b/app/static/images/trophies/veni-vidi-casii.png deleted file mode 100644 index 7695d11..0000000 Binary files a/app/static/images/trophies/veni-vidi-casii.png and /dev/null differ diff --git a/app/static/images/trophies/veteran-mythique.png b/app/static/images/trophies/veteran-mythique.png deleted file mode 100644 index 55d75c8..0000000 Binary files a/app/static/images/trophies/veteran-mythique.png and /dev/null differ diff --git a/assets/trophies-generate.py b/assets/trophies-generate.py deleted file mode 100755 index af6bd2d..0000000 --- a/assets/trophies-generate.py +++ /dev/null @@ -1,35 +0,0 @@ -#! /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/master.py b/master.py index b19c2c3..5e617c8 100755 --- a/master.py +++ b/master.py @@ -10,6 +10,8 @@ import os import sys import yaml import readline +import slugify +from PIL import Image help_msg = """ This is the Planète Casio master shell. Type 'exit' or C-D to leave. @@ -37,7 +39,7 @@ the database. Type 'add-group #' to add a new member to a group. -Type 'create-trophies' to reset trophies and titles. +Type 'create-trophies' to reset trophies and titles and their icons. Type 'create-forums' to reset the forum tree. """ @@ -183,6 +185,29 @@ def create_trophies(): print(f"Created {len(tr)} trophies.") + # Create their icons in /app/static/images/trophies + names = [ slugify.slugify(t["name"]) for t in tr ] + src = os.path.join(app.root_path, "data", "trophies.png") + dst = os.path.join(app.root_path, "static", "images", "trophies") + + try: + os.mkdir(dst) + except FileExistsError: + pass + + img = Image.open(src) + + 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)) + # Skip blank squares in the source image + if len(icon.getcolors()) > 1: + yield icon.resize((48,48)) + + for (name, icon) in zip(names, trophy_iterator(img)): + icon.save(os.path.join(dst, f"{name}.png")) + def create_forums(): # Clean up forums forums("clear")