Refactor handling of active user

This commit is contained in:
2024-02-16 17:59:43 +01:00
parent ab8def6b4f
commit ea34413b3c
5 changed files with 163 additions and 148 deletions

View File

@ -1,12 +1,6 @@
<!DOCTYPE html>
<html lang="en">
{# Easy nav-bar entries. When a page sets the active_page variable, the current entry will be underlined #}
{% macro nav_selector(page='', text='') %}
<a class="nav-link text-nowrap" href="{{ page }}">{% if active_page == page %}<u>{% endif %} {{ text }}
{% if active_page == page %}</u>{% endif %}</a>
{% endmacro %}
{# Simple driver dropdown. Requires list of drivers. #}
{% macro driver_select(name='', label='') %}
<div class="form-floating">
@ -83,6 +77,12 @@
</div>
{% endmacro %}
{# Easy nav-bar entries. When a page sets the active_page variable, the current entry will be underlined #}
{% macro nav_selector(page='', text='') %}
<a class="nav-link text-nowrap" href="{{ page }}">{% if active_page == page %}<u>{% endif %} {{ text }}
{% if active_page == page %}</u>{% endif %}</a>
{% endmacro %}
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@ -119,8 +119,8 @@
<div class="collapse navbar-collapse" id="navbarCollapse">
<div class="navbar-nav me-2">
{{ nav_selector("/race/" ~ active_user, "Race Picks") }}
{{ nav_selector("/season/" ~ active_user, "Season Picks") }}
{{ nav_selector("/race/" ~ active_user.name | default("Everyone"), "Race Picks") }}
{{ nav_selector("/season/" ~ active_user.name | default("Everyone"), "Season Picks") }}
{{ nav_selector("/graphs", "Statistics") }}
{{ nav_selector("/rules", "Rules") }}
</div>