From 0b9e9eb67cda8a7bb2d99ad81ae3c018d7735686 Mon Sep 17 00:00:00 2001 From: w Date: Sun, 29 Jun 2025 02:28:31 -0300 Subject: [PATCH] Add player list feature and enhance navigation - Implemented a new route to display a list of players fetched from the database. - Added a navigation menu in the header for better accessibility. - Updated the about page content for clarity and engagement. - Removed redundant header content from the index page. --- web/app.py | 16 +++++++++++++ web/templates/_base.html | 12 ++++++++-- web/templates/about.html | 4 ++-- web/templates/index.html | 5 +---- web/templates/player_list.html | 41 ++++++++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 web/templates/player_list.html diff --git a/web/app.py b/web/app.py index ab8d02e..225d812 100644 --- a/web/app.py +++ b/web/app.py @@ -32,6 +32,12 @@ def get_db_connection(): conn.row_factory = sqlite3.Row return conn +def get_db_cursor(): + """Get a database cursor.""" + if not hasattr(get_db_cursor, 'conn'): + get_db_cursor.conn = get_db_connection() + return get_db_cursor.conn.cursor() + @app.errorhandler(HTTPException) def handle_exception(error): return render_template("_error.html", error=error), error.code @@ -87,6 +93,16 @@ def about(): def submit_character(): return render_template('submit.html') +@app.route('/players') +def player_list(): + # Replace with your actual player fetching logic + + cursor = get_db_cursor() + cursor.execute('SELECT * FROM players') + players = cursor.fetchall() + if not players: + return render_template('player_list.html', players=[]) + return render_template('player_list.html', players=players) if __name__ == '__main__': app.run(host=config.BIND_ADDRESS, port=config.WEB_PORT, debug=True) diff --git a/web/templates/_base.html b/web/templates/_base.html index f025c75..68e15ee 100644 --- a/web/templates/_base.html +++ b/web/templates/_base.html @@ -28,10 +28,20 @@ along with this program. If not, see https://www.gnu.org/licenses/. {% endif %}  | Kemoverse +
{% block header %}{% endblock %} +

Kemoverse

+

A gacha in the fediverse.

+ +
@@ -39,8 +49,6 @@ along with this program. If not, see https://www.gnu.org/licenses/.
diff --git a/web/templates/about.html b/web/templates/about.html index b704664..7fc3f64 100644 --- a/web/templates/about.html +++ b/web/templates/about.html @@ -18,8 +18,8 @@ along with this program. If not, see https://www.gnu.org/licenses/. {% extends "_base.html" %} {% block content %} -

About This Gacha

-

This is a playful Misskey-themed gacha tracker made with Flask and SQLite.

+

About This Site

+

Kemoverse is a simple web app designed to track gacha pulls and player stats in a fun, competitive way.

All rolls are stored, stats are tracked, and characters are added manually for now.

Built with love, chaos, and way too much caffeine ☕.

← Back to Home diff --git a/web/templates/index.html b/web/templates/index.html index a39144d..a20cc2f 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -18,10 +18,7 @@ along with this program. If not, see https://www.gnu.org/licenses/. {% extends "_base.html" %} -{% block header %} -

Kemoverse

-

Track your luck. Compare your pulls. Compete with friends.

-{% endblock %} + {% block content %} diff --git a/web/templates/player_list.html b/web/templates/player_list.html new file mode 100644 index 0000000..7fe9145 --- /dev/null +++ b/web/templates/player_list.html @@ -0,0 +1,41 @@ + +{% extends "_base.html" %} + +{% block title %}Player List{% endblock %} + +{% block content %} +

Player List

+{% if players and players|length > 0 %} + +{% else %} +

No players found.

+{% endif %} +{% endblock %} + +{% block footer_extra %} +

Player list is dynamically generated from the database.

+{% endblock %} \ No newline at end of file