diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f251f3e..d0b56e0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,4 +15,6 @@ repos: rev: v1.34.0 hooks: - id: djlint-reformat-django + args: ["--ignore", "H011"] - id: djlint-django + args: ["--ignore", "H011"] diff --git a/common/utils.py b/common/utils.py index 098dc3a..6a5ec38 100644 --- a/common/utils.py +++ b/common/utils.py @@ -17,10 +17,10 @@ def Popover( result = mark_safe( str(content) + render_to_string( - "components/popover.html", + "cotton/popover.html", { "id": id, - "children": popover_content, + "slot": popover_content, }, ) ) diff --git a/games/templates/components.yml b/games/templates/components.yml deleted file mode 100644 index efe6bf9..0000000 --- a/games/templates/components.yml +++ /dev/null @@ -1,10 +0,0 @@ -components: - gamelink: "components/game_link.html" - popover: "components/popover.html" - table: "components/table.html" - table_row: "components/table_row.html" - table_td: "components/table_td.html" - simple_table: "components/simple_table.html" - button_group_sm: "components/button_group_sm.html" - button_group_button_sm: "components/button_group_button_sm.html" - h1: "components/h1.html" diff --git a/games/templates/components/button_group_sm.html b/games/templates/components/button_group_sm.html deleted file mode 100644 index 6bd902e..0000000 --- a/games/templates/components/button_group_sm.html +++ /dev/null @@ -1,5 +0,0 @@ -
- {% for button in buttons %} - {% button_group_button_sm href=button.href text=button.text color=button.color %} - {% endfor %} -
diff --git a/games/templates/components/edit_button.html b/games/templates/components/edit_button.html deleted file mode 100644 index 57997ee..0000000 --- a/games/templates/components/edit_button.html +++ /dev/null @@ -1,13 +0,0 @@ - - - diff --git a/games/templates/components/table_row.html b/games/templates/components/table_row.html deleted file mode 100644 index 4a12c09..0000000 --- a/games/templates/components/table_row.html +++ /dev/null @@ -1,15 +0,0 @@ -{% fragment as default_content %} -{% for td in data %} - {% if forloop.first %} - {{ td }} - {% else %} - {% #table_td %} - {{ td }} - {% /table_td %} - {% endif %} -{% endfor %} -{% endfragment %} - - {{ children|default:default_content }} - diff --git a/games/templates/components/table_td.html b/games/templates/components/table_td.html deleted file mode 100644 index 78cd369..0000000 --- a/games/templates/components/table_td.html +++ /dev/null @@ -1 +0,0 @@ -{{ children }} diff --git a/games/templates/cotton/button.html b/games/templates/cotton/button.html new file mode 100644 index 0000000..83f0695 --- /dev/null +++ b/games/templates/cotton/button.html @@ -0,0 +1,4 @@ + diff --git a/games/templates/components/button_group_button_sm.html b/games/templates/cotton/button_group_button_sm.html similarity index 97% rename from games/templates/components/button_group_button_sm.html rename to games/templates/cotton/button_group_button_sm.html index 2febc2d..2ea43a9 100644 --- a/games/templates/components/button_group_button_sm.html +++ b/games/templates/cotton/button_group_button_sm.html @@ -1,4 +1,4 @@ -{% var color=color|default:"gray" %} + {% if color == "gray" %} diff --git a/games/templates/cotton/button_group_sm.html b/games/templates/cotton/button_group_sm.html new file mode 100644 index 0000000..987db77 --- /dev/null +++ b/games/templates/cotton/button_group_sm.html @@ -0,0 +1,6 @@ + +
+ {% for button in buttons %} + + {% endfor %} +
diff --git a/games/templates/components/button.html b/games/templates/cotton/button_old.html similarity index 100% rename from games/templates/components/button.html rename to games/templates/cotton/button_old.html diff --git a/games/templates/components/button_start.html b/games/templates/cotton/button_start.html similarity index 100% rename from games/templates/components/button_start.html rename to games/templates/cotton/button_start.html diff --git a/games/templates/components/game_link.html b/games/templates/cotton/gamelink.html similarity index 80% rename from games/templates/components/game_link.html rename to games/templates/cotton/gamelink.html index bcb7cfe..5be4acd 100644 --- a/games/templates/components/game_link.html +++ b/games/templates/cotton/gamelink.html @@ -1,8 +1,8 @@
- {% if children %} - {{ children }} + {% if slot %} + {{ slot }} {% else %} {{ name }} {% endif %} diff --git a/games/templates/components/h1.html b/games/templates/cotton/h1.html similarity index 95% rename from games/templates/components/h1.html rename to games/templates/cotton/h1.html index a532283..3b7ad35 100644 --- a/games/templates/components/h1.html +++ b/games/templates/cotton/h1.html @@ -1,5 +1,5 @@

- {{ children }} + {{ slot }} {% if badge %} {{ badge }} diff --git a/games/templates/components/popover.html b/games/templates/cotton/popover.html similarity index 87% rename from games/templates/components/popover.html rename to games/templates/cotton/popover.html index a19d517..38b104c 100644 --- a/games/templates/components/popover.html +++ b/games/templates/cotton/popover.html @@ -2,6 +2,6 @@ id="{{ id }}" role="tooltip" class="absolute z-10 invisible inline-block text-sm text-white transition-opacity duration-300 bg-white border border-purple-200 rounded-lg shadow-sm opacity-0 dark:text-white dark:border-purple-600 dark:bg-purple-800"> -
{{ children }}
+
{{ slot }}
diff --git a/games/templates/components/simple_table.html b/games/templates/cotton/simple_table.html similarity index 91% rename from games/templates/components/simple_table.html rename to games/templates/cotton/simple_table.html index ab68ac2..62c413f 100644 --- a/games/templates/components/simple_table.html +++ b/games/templates/cotton/simple_table.html @@ -1,3 +1,4 @@ +{% load param_utils %}
diff --git a/games/templates/cotton/table_row.html b/games/templates/cotton/table_row.html new file mode 100644 index 0000000..4ca4622 --- /dev/null +++ b/games/templates/cotton/table_row.html @@ -0,0 +1,16 @@ + + {% if slot %} + {{ slot }} + {% else %} + {% for td in data %} + {% if forloop.first %} + {{ td }} + {% else %} + + {{ td }} + + {% endif %} + {% endfor %} + {% endif %} + diff --git a/games/templates/cotton/table_td.html b/games/templates/cotton/table_td.html new file mode 100644 index 0000000..47d2fca --- /dev/null +++ b/games/templates/cotton/table_td.html @@ -0,0 +1 @@ +{{ slot }} diff --git a/games/templates/list_purchases.html b/games/templates/list_purchases.html index 443e029..ac553d9 100644 --- a/games/templates/list_purchases.html +++ b/games/templates/list_purchases.html @@ -5,6 +5,6 @@ {% endblock title %} {% block content %}
- {% simple_table columns=data.columns rows=data.rows page_obj=page_obj elided_page_range=elided_page_range %} +
{% endblock content %} diff --git a/games/templates/stats.html b/games/templates/stats.html index f08ba1b..676b1c9 100644 --- a/games/templates/stats.html +++ b/games/templates/stats.html @@ -5,11 +5,11 @@ {% load static %} {% partialdef purchase-name %} {% if purchase.type != 'game' %} - {% #gamelink game_id=purchase.edition.game.id %} + {{ purchase.name }} ({{ purchase.edition.name }} {{ purchase.get_type_display }}) - {% /gamelink %} + {% else %} - {% gamelink game_id=purchase.edition.game.id name=purchase.edition.name %} + {% endif %} {% endpartialdef %} {% block content %} @@ -65,31 +65,31 @@ Longest session - {{ longest_session_time }} ({% gamelink game_id=longest_session_game.id name=longest_session_game.name %}) + {{ longest_session_time }} () Most sessions - {{ highest_session_count }} ({% gamelink game_id=highest_session_count_game.id name=highest_session_count_game.name %}) + {{ highest_session_count }} () Highest session average - {{ highest_session_average }} ({% gamelink game_id=highest_session_average_game.id name=highest_session_average_game.name %}) + {{ highest_session_average }} () First play - {% gamelink game_id=first_play_game.id name=first_play_game.name %} ({{ first_play_date }}) + ({{ first_play_date }}) Last play - {% gamelink game_id=last_play_game.id name=last_play_game.name %} ({{ last_play_date }}) + ({{ last_play_date }}) @@ -151,7 +151,9 @@ {% for game in top_10_games_by_playtime %} - {% gamelink game_id=game.id name=game.name %} + + + {{ game.formatted_playtime }} {% endfor %} diff --git a/games/templates/view_game.html b/games/templates/view_game.html index bc2d5a8..c0f647d 100644 --- a/games/templates/view_game.html +++ b/games/templates/view_game.html @@ -10,9 +10,9 @@
{{ game.name }} {{ game.year_released }} - {% #popover id="popover-year" %} + Original release year - {% /popover %} +
@@ -26,9 +26,9 @@ {{ hours_sum }} - {% #popover id="popover-hours" %} + Total hours played - {% /popover %} + @@ -41,9 +41,9 @@ {{ session_count }} - {% #popover id="popover-sessions" %} + Number of sessions - {% /popover %} + {{ session_average_without_manual }} - {% #popover id="popover-average" %} + Average playtime per session - {% /popover %} + @@ -70,9 +70,9 @@ {{ playrange }} - {% #popover id="popover-playrange" %} + Earliest and latest dates played - {% /popover %} +
- {% #h1 badge=edition_count %}Editions{% /h1 %} -
{% simple_table rows=edition_data.rows columns=edition_data.columns %}
+ Editions
- {% #h1 badge=purchase_count %}Purchases{% /h1 %} - {% simple_table rows=purchase_data.rows columns=purchase_data.columns %} +
- {% #h1 badge=session_count %}Sessions{% /h1 %} - {% simple_table rows=session_data.rows columns=session_data.columns page_obj=session_page_obj elided_page_range=session_elided_page_range %} + Purchases + +
+
+ Sessions +