From 255e9a953d0394e6eb90742b6a566fadf423c03e Mon Sep 17 00:00:00 2001 From: w Date: Sat, 21 Jun 2025 21:36:49 -0300 Subject: [PATCH 1/2] Website fix, modified variable names to correctly refer the glossary --- web/app.py | 34 ++++++++++++------------ web/templates/index.html | 12 +++------ web/templates/{user.html => player.html} | 8 +++--- 3 files changed, 24 insertions(+), 30 deletions(-) rename web/templates/{user.html => player.html} (84%) diff --git a/web/app.py b/web/app.py index f125784..ab8d02e 100644 --- a/web/app.py +++ b/web/app.py @@ -43,41 +43,41 @@ def i404(): @app.route('/') def index(): conn = get_db_connection() - users = conn.execute('SELECT id, username FROM users').fetchall() - top_users = conn.execute(''' - SELECT users.id, users.username, COUNT(pulls.id) AS pull_count - FROM users - LEFT JOIN pulls ON users.id = pulls.user_id - GROUP BY users.id + players = conn.execute('SELECT id, username FROM players').fetchall() + top_players = conn.execute(''' + SELECT players.id, players.username, COUNT(pulls.id) AS pull_count + FROM players + LEFT JOIN pulls ON players.id = pulls.player_id + GROUP BY players.id ORDER BY pull_count DESC LIMIT 5 ''').fetchall() conn.close() - return render_template('index.html', users=users, top_users=top_users) + return render_template('index.html', players=players, top_players=top_players) -@app.route('/user/') -def user_profile(user_id): +@app.route('/player/') +def player_profile(id): conn = get_db_connection() conn.row_factory = sqlite3.Row cursor = conn.cursor() - cursor.execute('SELECT * FROM users WHERE id = ?', (user_id,)) - user = cursor.fetchone() - if user is None: + cursor.execute('SELECT * FROM players WHERE id = ?', (id,)) + player = cursor.fetchone() + if player is None: abort(404) cursor.execute(''' - SELECT pulls.timestamp, characters.name as character_name, characters.rarity + SELECT pulls.timestamp, cards.name as card_name, cards.rarity FROM pulls - JOIN characters ON pulls.character_id = characters.id - WHERE pulls.user_id = ? + JOIN cards ON pulls.card_id = cards.id + WHERE pulls.player_id = ? ORDER BY pulls.timestamp DESC - ''', (user_id,)) + ''', (id,)) pulls = cursor.fetchall() conn.close() - return render_template('user.html', user=user, pulls=pulls) + return render_template('player.html', player=player, pulls=pulls) @app.route('/about') def about(): diff --git a/web/templates/index.html b/web/templates/index.html index 6f2351d..a39144d 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -19,27 +19,21 @@ along with this program. If not, see https://www.gnu.org/licenses/. {% extends "_base.html" %} {% block header %} -

Misskey Gacha Center

+

Kemoverse

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

{% endblock %} {% block content %}

🎖️ Leaderboard: Most Rolls

- {% for user in top_users %} + {% for player in top_players %}
- {{ loop.index }}. {{ user['username'] }} — {{ user['pull_count'] }} rolls + {{ loop.index }}. {{ player['username'] }} — {{ player['pull_count'] }} rolls
{% else %}

No pulls yet. Be the first to roll!

{% endfor %} -

📋 All Registered Users

-
🚀 This is a fun little gacha tracker! More features coming soon. Want to help shape it? diff --git a/web/templates/user.html b/web/templates/player.html similarity index 84% rename from web/templates/user.html rename to web/templates/player.html index 1ccb447..b37971e 100644 --- a/web/templates/user.html +++ b/web/templates/player.html @@ -18,8 +18,8 @@ along with this program. If not, see https://www.gnu.org/licenses/. {% extends "_base.html" %} {% block content %}
-

{{ user['username'] }}'s Gacha Rolls

-

User ID: {{ user['id'] }}

+

{{ player['username'] }}'s Gacha Rolls

+

Player ID: {{ player['id'] }}

Total Rolls: {{ pulls | length }}

@@ -29,12 +29,12 @@ along with this program. If not, see https://www.gnu.org/licenses/. {% for pull in pulls %}
  • {{ pull['timestamp'] }}
    - {{ pull['character_name'] }} + {{ pull['card_name'] }} {{ '★' * pull['rarity'] }}
  • {% endfor %}
    - ← Back to Users + ← Back to Home {% endblock %} \ No newline at end of file From 0b9e9eb67cda8a7bb2d99ad81ae3c018d7735686 Mon Sep 17 00:00:00 2001 From: w Date: Sun, 29 Jun 2025 02:28:31 -0300 Subject: [PATCH 2/2] 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