From cd45116dcec442aa01c0e4db8c42662b25682e51 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Tue, 15 Jun 2021 02:35:40 +0200 Subject: [PATCH] dynamify games listing --- WebHostLib/__init__.py | 48 +++++++++---------- WebHostLib/templates/games.html | 34 ------------- .../{factorio => games}/factorio.html | 0 WebHostLib/templates/games/games.html | 17 +++++++ .../{minecraft => games}/minecraft.html | 0 .../templates/{zelda3 => games}/zelda3.html | 0 6 files changed, 40 insertions(+), 59 deletions(-) delete mode 100644 WebHostLib/templates/games.html rename WebHostLib/templates/{factorio => games}/factorio.html (100%) create mode 100644 WebHostLib/templates/games/games.html rename WebHostLib/templates/{minecraft => games}/minecraft.html (100%) rename WebHostLib/templates/{zelda3 => games}/zelda3.html (100%) diff --git a/WebHostLib/__init__.py b/WebHostLib/__init__.py index a502ce70..07ffa630 100644 --- a/WebHostLib/__init__.py +++ b/WebHostLib/__init__.py @@ -82,34 +82,36 @@ def page_not_found(err): return render_template('404.html'), 404 -base_page = Blueprint('base_page', __name__, template_folder='templates', url_prefix='/') -zelda_page = Blueprint('zelda_page', __name__, template_folder='templates/zelda3', url_prefix='/zelda3') -factorio_page = Blueprint('factorio_page', __name__, template_folder='templates/factorio', url_prefix='/factorio') -minecraft_page = Blueprint('minecraft_page', __name__, template_folder='templates/minecraft', url_prefix='/minecraft') - +games_list = { + "zelda3": ("The Legend of Zelda: A Link to the Past", + """ + The Legend of Zelda: A Link to the Past is an action/adventure game. Take on the role of Link, + a boy who is destined to save the land of Hyrule. Delve through three palaces and nine dungeons on + your quest to rescue the descendents of the seven wise men and defeat the evil Ganon!"""), + "factorio": ("Factorio", + """ + Factorio is a game about automation. You play as an engineer who has crash landed on the planet + Nauvis, an inhospitable world filled with dangerous creatures called biters. Build a factory, + research new technologies, and become more efficient in your quest to build a rocket and return home. + """), + "minecraft": ("Minecraft", + """ + Minecraft is a game about creativity. In a world made entirely of cubes, you explore, discover, mine, + craft, and try not to explode. Delve deep into the earth and discover abandoned mines, ancient + structures, and materials to create a portal to another world. Defeat the Ender Dragon, and claim + victory!""") +} @app.route('/games') def games(): - return render_template("games.html") + return render_template("games/games.html", games_list=games_list) -@zelda_page.route('/', defaults={'page': 'zelda3'}) -@zelda_page.route('/') -def zelda_pages(page): - return render_template(page+".html") +@app.route('/games/') +def game_page(game): + return render_template(f"/games/{game}"+".html") -@factorio_page.route('/', defaults={'page': 'factorio'}) -@factorio_page.route('/') -def factorio_pages(page): - return render_template(page+".html") - - -@minecraft_page.route('/', defaults={'page': 'minecraft'}) -@minecraft_page.route('/') -def minecraft_pages(page): - return render_template(page+".html") - @app.route('/tutorial///') def tutorial(game, file, lang): @@ -186,7 +188,3 @@ def favicon(): from WebHostLib.customserver import run_server_process from . import tracker, upload, landing, check, generate, downloads, api # to trigger app routing picking up on it app.register_blueprint(api.api_endpoints) -app.register_blueprint(base_page) -app.register_blueprint(zelda_page) -app.register_blueprint(factorio_page) -app.register_blueprint(minecraft_page) diff --git a/WebHostLib/templates/games.html b/WebHostLib/templates/games.html deleted file mode 100644 index 6458f6fe..00000000 --- a/WebHostLib/templates/games.html +++ /dev/null @@ -1,34 +0,0 @@ -{% extends 'pageWrapper.html' %} - -{% block head %} - Player Settings - -{% endblock %} - -{% block body %} - {% include 'header/grassHeader.html' %} -
-

Currently Supported Games

-

The Legend of Zelda: A Link to the Past

-

- The Legend of Zelda: A Link to the Past is an action/adventure game. Take on the role of Link, - a boy who is destined to save the land of Hyrule. Delve through three palaces and nine dungeons on - your quest to rescue the descendents of the seven wise men and defeat the evil Ganon! -

- -

Factorio

-

- Factorio is a game about automation. You play as an engineer who has crash landed on the planet - Nauvis, an inhospitable world filled with dangerous creatures called biters. Build a factory, - research new technologies, and become more efficient in your quest to build a rocket and return home. -

- -

Minecraft

-

- Minecraft is a game about creativity. In a world made entirely of cubes, you explore, discover, mine, - craft, and try not to explode. Delve deep into the earth and discover abandoned mines, ancient - structures, and materials to create a portal to another world. Defeat the Ender Dragon, and claim - victory! -

-
-{% endblock %} diff --git a/WebHostLib/templates/factorio/factorio.html b/WebHostLib/templates/games/factorio.html similarity index 100% rename from WebHostLib/templates/factorio/factorio.html rename to WebHostLib/templates/games/factorio.html diff --git a/WebHostLib/templates/games/games.html b/WebHostLib/templates/games/games.html new file mode 100644 index 00000000..9b5bec8d --- /dev/null +++ b/WebHostLib/templates/games/games.html @@ -0,0 +1,17 @@ +{% extends 'pageWrapper.html' %} + +{% block head %} + Player Settings + +{% endblock %} + +{% block body %} + {% include 'header/grassHeader.html' %} +
+

Currently Supported Games

+ {% for game, (display_name, description) in games_list.items() %} +

{{ display_name}}

+

{{ description}}

+ {% endfor %} +
+{% endblock %} diff --git a/WebHostLib/templates/minecraft/minecraft.html b/WebHostLib/templates/games/minecraft.html similarity index 100% rename from WebHostLib/templates/minecraft/minecraft.html rename to WebHostLib/templates/games/minecraft.html diff --git a/WebHostLib/templates/zelda3/zelda3.html b/WebHostLib/templates/games/zelda3.html similarity index 100% rename from WebHostLib/templates/zelda3/zelda3.html rename to WebHostLib/templates/games/zelda3.html