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.
This commit is contained in:
parent
1804ddc93a
commit
0b9e9eb67c
5 changed files with 70 additions and 8 deletions
16
web/app.py
16
web/app.py
|
@ -32,6 +32,12 @@ def get_db_connection():
|
||||||
conn.row_factory = sqlite3.Row
|
conn.row_factory = sqlite3.Row
|
||||||
return conn
|
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)
|
@app.errorhandler(HTTPException)
|
||||||
def handle_exception(error):
|
def handle_exception(error):
|
||||||
return render_template("_error.html", error=error), error.code
|
return render_template("_error.html", error=error), error.code
|
||||||
|
@ -87,6 +93,16 @@ def about():
|
||||||
def submit_character():
|
def submit_character():
|
||||||
return render_template('submit.html')
|
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__':
|
if __name__ == '__main__':
|
||||||
app.run(host=config.BIND_ADDRESS, port=config.WEB_PORT, debug=True)
|
app.run(host=config.BIND_ADDRESS, port=config.WEB_PORT, debug=True)
|
||||||
|
|
|
@ -28,10 +28,20 @@ along with this program. If not, see https://www.gnu.org/licenses/.
|
||||||
{% endif %}
|
{% endif %}
|
||||||
| Kemoverse
|
| Kemoverse
|
||||||
</title>
|
</title>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
{% block header %}{% endblock %}
|
{% block header %}{% endblock %}
|
||||||
|
<h1>Kemoverse</h1>
|
||||||
|
<p>A gacha in the fediverse.</p>
|
||||||
|
<nav>
|
||||||
|
<a href="{{ url_for('index') }}">Home</a>
|
||||||
|
<a href="{{ url_for('about') }}">About</a>
|
||||||
|
<a href="{{ url_for('submit_character') }}">Submit a Character</a>
|
||||||
|
<a href="{{ url_for('player_list') }}">Player List</a>
|
||||||
|
</nav>
|
||||||
|
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
@ -39,8 +49,6 @@ along with this program. If not, see https://www.gnu.org/licenses/.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<a class="footer-link" href="{{ url_for('about') }}">About</a>
|
|
||||||
<a class="footer-link" href="{{ url_for('submit_character') }}">Submit a Character</a>
|
|
||||||
{% block footer_extra %}{% endblock %}
|
{% block footer_extra %}{% endblock %}
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -18,8 +18,8 @@ along with this program. If not, see https://www.gnu.org/licenses/.
|
||||||
{% extends "_base.html" %}
|
{% extends "_base.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>About This Gacha</h1>
|
<h1>About This Site</h1>
|
||||||
<p>This is a playful Misskey-themed gacha tracker made with Flask and SQLite.</p>
|
<p>Kemoverse is a simple web app designed to track gacha pulls and player stats in a fun, competitive way.</p>
|
||||||
<p>All rolls are stored, stats are tracked, and characters are added manually for now.</p>
|
<p>All rolls are stored, stats are tracked, and characters are added manually for now.</p>
|
||||||
<p>Built with love, chaos, and way too much caffeine ☕.</p>
|
<p>Built with love, chaos, and way too much caffeine ☕.</p>
|
||||||
<a href="{{ url_for('index') }}">← Back to Home</a>
|
<a href="{{ url_for('index') }}">← Back to Home</a>
|
||||||
|
|
|
@ -18,10 +18,7 @@ along with this program. If not, see https://www.gnu.org/licenses/.
|
||||||
|
|
||||||
{% extends "_base.html" %}
|
{% extends "_base.html" %}
|
||||||
|
|
||||||
{% block header %}
|
|
||||||
<h1>Kemoverse</h1>
|
|
||||||
<p>Track your luck. Compare your pulls. Compete with friends.</p>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
|
41
web/templates/player_list.html
Normal file
41
web/templates/player_list.html
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<!--
|
||||||
|
Kemoverse - a gacha-style bot for the Fediverse.
|
||||||
|
Copyright © 2025 Waifu
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see https://www.gnu.org/licenses/.
|
||||||
|
-->
|
||||||
|
{% extends "_base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Player List{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Player List</h1>
|
||||||
|
{% if players and players|length > 0 %}
|
||||||
|
<ul>
|
||||||
|
{% for player in players %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ url_for('player_profile', id=player['id']) }}">
|
||||||
|
{{ player['username'] }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
<p>No players found.</p>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block footer_extra %}
|
||||||
|
<p>Player list is dynamically generated from the database.</p>
|
||||||
|
{% endblock %}
|
Loading…
Add table
Reference in a new issue