From f65a174089429d63bee1bba707a3c77150acb99f Mon Sep 17 00:00:00 2001 From: Kamil Date: Tue, 3 Jun 2025 23:26:30 +0200 Subject: [PATCH] skeleton to all sites (i hope) --- FlaskWebProject/FlaskWebProject/lewy.py | 15 +-- .../FlaskWebProject/lewy_routes.py | 71 +++++++++++++-- .../FlaskWebProject/static/style.css | 3 +- .../FlaskWebProject/templates/base.html | 8 +- .../FlaskWebProject/templates/club.html | 60 ++++++++++++ .../FlaskWebProject/templates/compare.html | 68 ++++++++++++++ .../FlaskWebProject/templates/history.html | 30 ------ .../FlaskWebProject/templates/index.html | 2 +- .../FlaskWebProject/templates/matches.html | 12 +++ .../templates/representation.html | 36 ++++++++ .../FlaskWebProject/templates/stats.html | 91 ++++++++++++++++--- .../FlaskWebProject/templates/trophies.html | 24 +++++ 12 files changed, 357 insertions(+), 63 deletions(-) create mode 100644 FlaskWebProject/FlaskWebProject/templates/club.html create mode 100644 FlaskWebProject/FlaskWebProject/templates/compare.html delete mode 100644 FlaskWebProject/FlaskWebProject/templates/history.html create mode 100644 FlaskWebProject/FlaskWebProject/templates/representation.html create mode 100644 FlaskWebProject/FlaskWebProject/templates/trophies.html diff --git a/FlaskWebProject/FlaskWebProject/lewy.py b/FlaskWebProject/FlaskWebProject/lewy.py index 948c550..9222251 100644 --- a/FlaskWebProject/FlaskWebProject/lewy.py +++ b/FlaskWebProject/FlaskWebProject/lewy.py @@ -62,12 +62,15 @@ def setup(): app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False # Widoki widoczne dla "normalnego" użytkownika: - app.add_url_rule('/', view_func=lewy_routes.index) - app.add_url_rule('/index.html', view_func=lewy_routes.index) - app.add_url_rule('/mecze', view_func=lewy_routes.mecze) - app.add_url_rule('/statystyki', view_func=lewy_routes.statystyki) - app.add_url_rule('/toggle_dark_mode', view_func=lewy_routes.toggle_dark_mode) - app.add_url_rule('/historia', view_func=lewy_routes.historia) + app.add_url_rule('/', view_func=lewy_routes.index) + app.add_url_rule('/index.html', view_func=lewy_routes.index) + app.add_url_rule('/mecze', view_func=lewy_routes.mecze) + app.add_url_rule('/statystyki', view_func=lewy_routes.statystyki) + app.add_url_rule('/toggle_dark_mode', view_func=lewy_routes.toggle_dark_mode) + app.add_url_rule('/club', view_func=lewy_routes.clubs) + app.add_url_rule('/representation', view_func=lewy_routes.representation) + app.add_url_rule('/compare', view_func=lewy_routes.compare) + app.add_url_rule('/trophies', view_func=lewy_routes.trophies) # API: app.add_url_rule('/api/', view_func=lewy_api.api_greeting) diff --git a/FlaskWebProject/FlaskWebProject/lewy_routes.py b/FlaskWebProject/FlaskWebProject/lewy_routes.py index f10eb3f..a2e73da 100644 --- a/FlaskWebProject/FlaskWebProject/lewy_routes.py +++ b/FlaskWebProject/FlaskWebProject/lewy_routes.py @@ -3,6 +3,39 @@ import lewy_api_v1 import lewy_db import lewy_globals +def get_lewy_stats(): + return { + 'all_time_stats': { + 'goals': 380, + 'assists': 120, + 'matches': 450, + }, + 'club_stats': { + 'goals': 132, + 'assists': 112, + 'matches': 245, + }, + 'nation_stats': { + 'goals': 86, + 'assists': 52, + 'matches': 158, + }, + 'worldcup': { + 'goals': 7, + 'assists': 2, + 'matches': 11, + }, + 'euro': { + 'goals': 6, + 'assists': 2, + 'matches': 18, + }, + 'cards': { + 'yellow': 24, + 'red': 4, + } + } + def index(): dark_mode = request.cookies.get('darkMode', 'disabled') # Przykładowe użycie endpointu last_goal_for(): @@ -32,20 +65,38 @@ def mecze(): return render_template('matches.html', matches=matches) def statystyki(): - stats = { - 'goals': 38, - 'assists': 12, - 'matches': 45, - } - return render_template('stats.html', stats=stats) + dane=get_lewy_stats() + return render_template('stats.html', **dane) -def historia(): +def clubs(): selected_club = request.args.get("club","FC Barcelona") - history = [ - {'club': 'FC Barcelona', 'goals': 22}, + clubs = [ + {'club': 'FC Barcelona', 'goals': 22,'assist':12}, {'club': 'Bayern Monachium', 'goals': 132}, + {'club': 'Borussia Dortmund', 'goals': 132}, + {'club': 'Lech Poznan', 'goals': 132}, ] - return render_template('history.html', history=history, selected_club=selected_club) + return render_template('club.html', clubs=clubs, selected_club=selected_club) + +def representation(): + nation_stats = { + 'goals': 86, + 'assists': 52, + 'matches': 158, + } + return render_template('representation.html', nation_stats=nation_stats) +def compare(): + selected_player = request.args.get("player","Leo Messi") + lewy=get_lewy_stats() + player2 = [ + {'name':'Leo Messi','goals': 34,'assists': 12}, + ] + return render_template('compare.html',player2=player2, selected_player=selected_player,**lewy, ) +def trophies(): + trophy = { + 'name': 'asdasd' + } + return render_template('trophies.html',trophy=trophy) def toggle_dark_mode(): # Przełącz tryb i zapisz w ciasteczku diff --git a/FlaskWebProject/FlaskWebProject/static/style.css b/FlaskWebProject/FlaskWebProject/static/style.css index 6850108..6daa72a 100644 --- a/FlaskWebProject/FlaskWebProject/static/style.css +++ b/FlaskWebProject/FlaskWebProject/static/style.css @@ -24,7 +24,7 @@ --polska-red: #E30B17; --polska-white: #FFFFFF; - --polska-section-color: #05204A; + --polska-section-color: #970000; --section-color: #051839; --pink-highlight: #E1317E; --blue-highlight: #00B9BF; @@ -82,6 +82,7 @@ body { width: 40%; padding: 20px; position: relative; + } .profile-image-cover { diff --git a/FlaskWebProject/FlaskWebProject/templates/base.html b/FlaskWebProject/FlaskWebProject/templates/base.html index f8f9858..f8a5b92 100644 --- a/FlaskWebProject/FlaskWebProject/templates/base.html +++ b/FlaskWebProject/FlaskWebProject/templates/base.html @@ -23,7 +23,13 @@
  • Strona główna
  • Mecze
  • Statystyki
  • -
  • Osiągnięcia
  • +
  • Kluby
  • +
  • Reprezentacja
  • +
  • Trofea
  • +
  • Porównaj
  • + + +
  • diff --git a/FlaskWebProject/FlaskWebProject/templates/club.html b/FlaskWebProject/FlaskWebProject/templates/club.html new file mode 100644 index 0000000..b059c9a --- /dev/null +++ b/FlaskWebProject/FlaskWebProject/templates/club.html @@ -0,0 +1,60 @@ +{% extends "base.html" %} + +{% block title %}Strona Główna{% endblock %} + +{% block content %} +
    + + + + + + + + + + + + +
    + + +{% for stats in clubs %} + {% if stats.club == selected_club %} +
    +

    Statystyki dla {{selected_club}}

    +
    + Gole: {{ stats.goals }} +
    +
    + Asysty: {{ stats.assist }} +
    +
    + Występy: {{ stats.goals }} +
    +
    + Łączny czas gry: {{ stats.goals }} +
    +
    + Hat-tricki: {{ stats.goals }} +
    +
    + Zwycięstwa: {{ stats.goals }} +
    +
    + Porażki: {{ stats.goals }} +
    +
    + Żółte kartki: {{ stats.goals }} +
    +
    + Czerwone kartki: {{ stats.goals }} +
    +
    + {% endif %} +{% endfor %} +{% endblock %} + +{% block footer %} +{{ commit_in_html | safe }} +{% endblock %} \ No newline at end of file diff --git a/FlaskWebProject/FlaskWebProject/templates/compare.html b/FlaskWebProject/FlaskWebProject/templates/compare.html new file mode 100644 index 0000000..e3b06be --- /dev/null +++ b/FlaskWebProject/FlaskWebProject/templates/compare.html @@ -0,0 +1,68 @@ +{% extends "base.html" %} + +{% block title %}Statystyki{% endblock %} + +{% block content %} + + +{%for player in player2 %} +{% if player.name == selected_player %} +
    +

    Gole

    +
    +
    +

    {{ all_time_stats.goals }}

    + +
    +
    +

    {{ player.goals}}

    + +
    +
    + + +

    Asysty

    +
    +
    +

    {{ all_time_stats.assists }}

    + +
    +
    +

    {{ player.assists}}

    + +
    +
    + +

    Wystąpienia

    +
    +
    +

    {{ all_time_stats.assists }}

    + +
    +
    +

    {{ player.assists}}

    + +
    +
    + +

    Minuty zagrane

    +
    +
    +

    {{ all_time_stats.assists }}

    + +
    +
    +

    {{ player.assists}}

    + +
    +
    +
    +{% endif %} +{% endfor%} + +{% endblock %} \ No newline at end of file diff --git a/FlaskWebProject/FlaskWebProject/templates/history.html b/FlaskWebProject/FlaskWebProject/templates/history.html deleted file mode 100644 index 75c8048..0000000 --- a/FlaskWebProject/FlaskWebProject/templates/history.html +++ /dev/null @@ -1,30 +0,0 @@ -{% extends "base.html" %} - -{% block title %}Strona Główna{% endblock %} - -{% block content %} -
    - - - - - - -
    - - -{% for stats in history %} - {% if stats.club == selected_club %} -
    -

    {{ stats.club }} - All time stats

    -
    - Gole: {{ stats.goals }} -
    -
    - {% endif %} -{% endfor %} -{% endblock %} - -{% block footer %} -{{ commit_in_html | safe }} -{% endblock %} \ No newline at end of file diff --git a/FlaskWebProject/FlaskWebProject/templates/index.html b/FlaskWebProject/FlaskWebProject/templates/index.html index f17801e..0ef03cf 100644 --- a/FlaskWebProject/FlaskWebProject/templates/index.html +++ b/FlaskWebProject/FlaskWebProject/templates/index.html @@ -30,7 +30,7 @@

    Osiągnięcia

    Lorem ipsum dolor sit amet consectetur adipisicing elit. Quod dicta veritatis quibusdam eligendi corrupti. Expedita delectus assumenda ipsum illum molestias a voluptates, voluptas quia reprehenderit, quod non, eum veritatis tenetur!

    - Zobacz osiągnięcia + Zobacz osiągnięcia
    diff --git a/FlaskWebProject/FlaskWebProject/templates/matches.html b/FlaskWebProject/FlaskWebProject/templates/matches.html index 46544ef..57a9573 100644 --- a/FlaskWebProject/FlaskWebProject/templates/matches.html +++ b/FlaskWebProject/FlaskWebProject/templates/matches.html @@ -3,6 +3,18 @@ {% block title %}Lista meczów{% endblock %} {% block content %} +

    📅 Mecze Roberta

    diff --git a/FlaskWebProject/FlaskWebProject/templates/representation.html b/FlaskWebProject/FlaskWebProject/templates/representation.html new file mode 100644 index 0000000..82a75c1 --- /dev/null +++ b/FlaskWebProject/FlaskWebProject/templates/representation.html @@ -0,0 +1,36 @@ +{% extends "base.html" %} + +{% block title %}Statystyki{% endblock %} + +{% block content %} +
    +

    Statystyki w reprezentacji Polski

    +
    + Gole: {{ nation_stats.goals }} +
    +
    + Asysty: {{ nation_stats.assist }} +
    +
    + Występy: {{ nation_stats.goals }} +
    +
    + Łączny czas gry: {{ nation_stats.goals }} +
    +
    + Hat-tricki: {{ nation_stats.goals }} +
    +
    + Zwycięstwa: {{ nation_stats.goals }} +
    +
    + Porażki: {{ nation_stats.goals }} +
    +
    + Żółte kartki: {{ nation_stats.goals }} +
    +
    + Czerwone kartki: {{ nation_stats.goals }} +
    +
    +{% endblock %} \ No newline at end of file diff --git a/FlaskWebProject/FlaskWebProject/templates/stats.html b/FlaskWebProject/FlaskWebProject/templates/stats.html index 666225b..52f713e 100644 --- a/FlaskWebProject/FlaskWebProject/templates/stats.html +++ b/FlaskWebProject/FlaskWebProject/templates/stats.html @@ -4,36 +4,99 @@ {% block content %}
    -

    All time stats

    +

    Ogólne statystyki

    -

    {{ stats.goals }}

    -

    Goals

    +

    {{ all_time_stats.goals }}

    +

    Gole

    -

    {{ stats.assists }}

    -

    Assists

    +

    {{ all_time_stats.assists }}

    +

    Asysty

    -

    {{ stats.matches }}

    -

    Apps

    +

    {{ all_time_stats.matches }}

    +

    Występy

    -

    All time stats

    +

    Klubowe statystyki

    -

    {{ stats.goals }}

    -

    Goals

    +

    {{ club_stats.goals }}

    +

    Gole

    -

    {{ stats.assists }}

    -

    Assists

    +

    {{ club_stats.assists }}

    +

    Asysty

    -

    {{ stats.matches }}

    -

    Apps

    +

    {{ club_stats.matches }}

    +

    Występy

    +
    +
    +
    +
    +

    Reprezentacja statystyki

    +
    +
    +

    {{ nation_stats.goals }}

    +

    Gole

    +
    +
    +

    {{ nation_stats.assists }}

    +

    Asysty

    +
    +
    +

    {{ nation_stats.matches }}

    +

    Występy

    +
    +
    +
    +

    Mistrzostwa świata

    +
    +
    +

    {{ worldcup.goals }}

    +

    Gole

    +
    +
    +

    {{ worldcup.assists }}

    +

    Asysty

    +
    +
    +

    {{ worldcup.matches }}

    +

    Występy

    +
    +
    +
    +
    +

    EURO

    +
    +
    +

    {{ euro.goals }}

    +

    Gole

    +
    +
    +

    {{ euro.assists }}

    +

    Asysty

    +
    +
    +

    {{ euro.matches }}

    +

    Występy

    +
    +
    +
    +
    +

    Kartki

    +
    +
    +

    {{ cards.yellow }}

    +

    Żółte

    +
    +
    +

    {{ cards.red }}

    +

    Czerwone

    diff --git a/FlaskWebProject/FlaskWebProject/templates/trophies.html b/FlaskWebProject/FlaskWebProject/templates/trophies.html new file mode 100644 index 0000000..7a4cf15 --- /dev/null +++ b/FlaskWebProject/FlaskWebProject/templates/trophies.html @@ -0,0 +1,24 @@ +{% extends "base.html" %} + +{% block title %}Statystyki{% endblock %} + +{% block content %} +
    +

    Ogólne statystyki

    +
    +
    +

    {{ trophy.name}}

    +

    Gole

    +
    +
    +

    {{ trophy.name }}

    +

    Asysty

    +
    +
    +

    {{ trophy.name }}

    +

    Występy

    +
    +
    +
    + +{% endblock %}