aboutsummaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorJoris2025-01-26 17:58:57 +0100
committerJoris2025-01-26 17:58:57 +0100
commit24eeb54a6b7159964e8887ade7fa5173b50feb3a (patch)
tree91af6253df784445db9b084b02b38b37a83224e8 /templates
parentc5759f348e70cf54b4bfa4cd17e1fe1828ead30a (diff)
Replace tera by minijinjamain
tera was doing the job all right, but minijinja has fewer dependencies.
Diffstat (limited to 'templates')
-rw-r--r--templates/balance.html14
-rw-r--r--templates/base.html6
-rw-r--r--templates/category/create.html4
-rw-r--r--templates/category/update.html4
-rw-r--r--templates/income/create.html12
-rw-r--r--templates/income/table.html6
-rw-r--r--templates/income/update.html10
-rw-r--r--templates/macros/paging.html16
-rw-r--r--templates/payment/create.html12
-rw-r--r--templates/payment/table.html8
-rw-r--r--templates/payment/table/search.html8
-rw-r--r--templates/payment/update.html10
-rw-r--r--templates/report/list.j26
-rw-r--r--templates/report/report.j226
-rw-r--r--templates/statistics.html2
15 files changed, 69 insertions, 75 deletions
diff --git a/templates/balance.html b/templates/balance.html
index b97ea40..c7f68e8 100644
--- a/templates/balance.html
+++ b/templates/balance.html
@@ -11,7 +11,7 @@
<ul class="g-Balance__ExceedingPayers">
{% for exceeding_payer in exceeding_payers %}
<li class="g-Balance__ExceedingPayer">
- {{ exceeding_payer.0 }} : +{{ exceeding_payer.1 | euros() }}
+ {{ exceeding_payer[0] }} : +{{ exceeding_payer[1] | euros() }}
</li>
{% endfor %}
</ul>
@@ -35,14 +35,14 @@
{% for user_income in user_incomes %}
<div class="g-Table__Row">
<span class="g-Table__Cell">
- {{ user_income.0 }}
+ {{ user_income[0] }}
</span>
<span class="g-Table__Cell g-Table__NumericCell">
- {{ user_income.1 | euros() }}
+ {{ user_income[1] | euros() }}
</span>
<span class="g-Table__Cell g-Table__NumericCell">
{% if total_income > 0 %}
- {{ user_income.1 / total_income * 100 | round() }} %
+ {{ (user_income[1] / total_income * 100) | round }} %
{% else %}
{% endif %}
@@ -76,14 +76,14 @@
{% for user_payment in user_payments %}
<div class="g-Table__Row">
<span class="g-Table__Cell">
- {{ user_payment.0 }}
+ {{ user_payment[0] }}
</span>
<span class="g-Table__Cell g-Table__NumericCell">
- {{ user_payment.1 | euros() }}
+ {{ user_payment[1] | euros() }}
</span>
<span class="g-Table__Cell g-Table__NumericCell">
{% if total_payments > 0 %}
- {{ user_payment.1 / total_payments * 100 | round() }} %
+ {{ (user_payment[1] / total_payments * 100) | round }} %
{% else %}
{% endif %}
diff --git a/templates/base.html b/templates/base.html
index c7dc9f0..9865e16 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -4,8 +4,8 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Budget — {% block title %}{% endblock title %}</title>
-<link rel="stylesheet" href="{{ assets | get(key="main.css") }}">
-<link rel="icon" href="{{ assets | get(key="icon.png") }}">
+<link rel="stylesheet" href="{{ assets["main.css"] }}">
+<link rel="icon" href="{{ assets["icon.png"] }}">
{% if connected_user %}
<header class="g-Header">
@@ -78,5 +78,5 @@
{% block main %}{% endblock main %}
</main>
-<script src="{{ assets | get(key="main.js") }}">
+<script src="{{ assets["main.js"] }}">
</script>
diff --git a/templates/category/create.html b/templates/category/create.html
index af95e16..f5395bf 100644
--- a/templates/category/create.html
+++ b/templates/category/create.html
@@ -27,7 +27,7 @@
<input
name="name"
class="g-Form__Input"
- value="{{ form.name | default(value="") }}"
+ value="{{ form.name or "" }}"
required
{% if not form %} autofocus {% endif %}
/>
@@ -39,7 +39,7 @@
name="color"
type="color"
class="g-Form__Input g-Form__InputColor"
- value="{{ form.color | default(value="") }}"
+ value="{{ form.color or "" }}"
required
/>
</label>
diff --git a/templates/category/update.html b/templates/category/update.html
index 48dda06..544c583 100644
--- a/templates/category/update.html
+++ b/templates/category/update.html
@@ -35,7 +35,7 @@
<input
name="name"
class="g-Form__Input"
- value="{{ form.name | default(value=category.name) }}"
+ value="{{ form.name or category.name }}"
required
/>
</label>
@@ -46,7 +46,7 @@
name="color"
type="color"
class="g-Form__Input g-Form__InputColor"
- value="{{ form.color | default(value=category.color) }}"
+ value="{{ form.color or category.color }}"
required
/>
</label>
diff --git a/templates/income/create.html b/templates/income/create.html
index 3c899ca..a7755db 100644
--- a/templates/income/create.html
+++ b/templates/income/create.html
@@ -10,7 +10,7 @@
<p class="g-Paragraph">
<a
class="g-Link g-Media__Large"
- href="/incomes?page={{ query.page | default(value=1) }}"
+ href="/incomes?page={{ query.page or 1 }}"
>
Retour aux revenus
</a>
@@ -18,7 +18,7 @@
<form
class="g-Form"
- action="/income/create?page={{ query.page | default(value=1) }}"
+ action="/income/create?page={{ query.page or 1 }}"
method="POST"
>
<h1 class="g-H1">
@@ -35,13 +35,13 @@
name="amount"
type="number"
class="g-Form__Input"
- value="{{ form.amount | default(value="") }}"
+ value="{{ form.amount or "" }}"
required
{% if not form %} autofocus {% endif %}
/>
</label>
- {% set user_id = form.user_id | default(value="" ~ connected_user.id) %}
+ {% set user_id = form.user_id or connected_user.id %}
<label class="g-Form__Label">
Personne
@@ -57,7 +57,7 @@
</select>
</label>
- {% set month_index = form.month | default(value="" ~ current_month) %}
+ {% set month_index = form.month or current_month %}
<label class="g-Form__Label">
Mois
@@ -81,7 +81,7 @@
name="year"
type="number"
class="g-Form__Input"
- value="{{ form.year | default(value=now() | date(format="%Y")) }}"
+ value="{{ form.year or now("%Y") }}"
required
/>
</label>
diff --git a/templates/income/table.html b/templates/income/table.html
index 60cd6e0..34ee096 100644
--- a/templates/income/table.html
+++ b/templates/income/table.html
@@ -18,7 +18,7 @@
<a
class="g-Paragraph g-Button__Validate"
- href="/income?page={{ page | default(value=1) }}"
+ href="/income?page={{ page or 1 }}"
>
Ajouter un revenu
</a>
@@ -33,7 +33,7 @@
{% for income in incomes %}
<a
class="g-Table__Row {% if highlight == income.id %} g-Table__Row--Highlight {% endif %}"
- href="/income/{{ income.id }}?page={{ page | default(value=1) }}"
+ href="/income/{{ income.id }}?page={{ page or 1 }}"
>
<span class="g-Table__Cell g-Table__NumericCell">
{{ income.amount | euros() }}
@@ -44,7 +44,7 @@
{% endfor %}
</div>
- {{ paging::paging(
+ {{ paging.view(
url="/incomes",
page=page,
max_page=max_page
diff --git a/templates/income/update.html b/templates/income/update.html
index 855d5c4..f5f976e 100644
--- a/templates/income/update.html
+++ b/templates/income/update.html
@@ -10,7 +10,7 @@
<p class="g-Paragraph">
<a
class="g-Link g-Media__Large"
- href="/incomes?page={{ query.page | default(value=1) }}"
+ href="/incomes?page={{ query.page or 1 }}"
>
Retour aux revenus
</a>
@@ -39,12 +39,12 @@
name="amount"
type="number"
class="g-Form__Input"
- value="{{ form.amount | default(value=income.amount) }}"
+ value="{{ form.amount or income.amount }}"
required
/>
</label>
- {% set user_id = form.user_id | default(value="" ~ income.user_id) %}
+ {% set user_id = form.user_id or income.user_id %}
<label class="g-Form__Label">
Personne
@@ -60,7 +60,7 @@
</select>
</label>
- {% set month_index = form.month | default(value="" ~ income.month) %}
+ {% set month_index = form.month or income.month %}
<label class="g-Form__Label">
Mois
@@ -82,7 +82,7 @@
name="year"
type="number"
class="g-Form__Input"
- value="{{ form.year | default(value=income.year) }}"
+ value="{{ form.year or income.year }}"
required
/>
</label>
diff --git a/templates/macros/paging.html b/templates/macros/paging.html
index 59ba617..840e8f4 100644
--- a/templates/macros/paging.html
+++ b/templates/macros/paging.html
@@ -1,10 +1,4 @@
-{% macro paging(url, page, max_page) %}
- {% if url is containing("?") %}
- {% set sign = "&" %}
- {% else %}
- {% set sign = "?" %}
- {% endif %}
-
+{% macro view(url, page, max_page) %}
<div class="g-Paging">
{% if page > 1 %}
<a
@@ -15,7 +9,7 @@
</a>
<a
class="g-Paging__Link g-Paging__Link--Active"
- href="{{ url }}{{ sign }}page={{ page - 1 }}"
+ href="{{ url | with_param("page", page - 1) }}"
>
</a>
@@ -33,13 +27,13 @@
{% if page < max_page %}
<a
class="g-Paging__Link g-Paging__Link--Active"
- href="{{ url }}{{ sign }}page={{ page + 1 }}"
+ href="{{ url | with_param("page", page + 1) }}"
>
</a>
<a
class="g-Paging__Link g-Paging__Link--Active"
- href="{{ url }}{{ sign }}page={{ max_page }}"
+ href="{{ url | with_param("page", max_page) }}"
>
❭❭
</a>
@@ -52,4 +46,4 @@
</span>
{% endif %}
</div>
-{% endmacro paging %}
+{% endmacro %}
diff --git a/templates/payment/create.html b/templates/payment/create.html
index 4ac73de..7bcc536 100644
--- a/templates/payment/create.html
+++ b/templates/payment/create.html
@@ -44,7 +44,7 @@
<input
name="name"
class="g-Form__Input"
- value="{{ form.name | default(value="") }}"
+ value="{{ form.name or "" }}"
required
{% if not form %} autofocus {% endif %}
/>
@@ -56,12 +56,12 @@
name="cost"
type="number"
class="g-Form__Input"
- value="{{ form.cost | default(value="") }}"
+ value="{{ form.cost or "" }}"
required
/>
</label>
- {% set user_id = form.user_id | default(value="" ~ connected_user.id) %}
+ {% set user_id = form.user_id or connected_user.id %}
<label class="g-Form__Label">
Personne
@@ -79,7 +79,7 @@
</select>
</label>
- {% set category_id = form.category_id | default(value="") %}
+ {% set category_id = form.category_id or "" %}
<label class="g-Form__Label">
Catégorie
@@ -96,7 +96,7 @@
</select>
</label>
- {% set date = form.date | default(value=now() | date(format="%Y-%m-%d")) %}
+ {% set date = form.date or now("%Y-%m-%d") %}
{% if query.frequency != "Monthly" %}
<label class="g-Form__Label">
@@ -120,7 +120,7 @@
<input
type="hidden"
name="frequency"
- value="{{ query.frequency | default(value="Punctual") }}"
+ value="{{ query.frequency or "Punctual" }}"
/>
<div>
diff --git a/templates/payment/table.html b/templates/payment/table.html
index 450d84b..71bfb0a 100644
--- a/templates/payment/table.html
+++ b/templates/payment/table.html
@@ -20,7 +20,7 @@
</div>
{% else %}
<div class="g-Paragraph">
- {{ count | numeric }} paiement{{ count | pluralize }} comptabilisant {{ total_cost | euros() }}.
+ {{ count | numeric }} paiement{{ pluralize(count, "paiement") }} comptabilisant {{ total_cost | euros() }}.
</div>
{% endif %}
@@ -81,9 +81,9 @@
{{ payment.cost | euros() }}
</span>
<span class="g-Table__Cell">{{ payment.user }}</span>
- <span
+ <span
class="g-Table__Cell g-Media__Large"
- is="colored-category"
+ is="colored-category"
data-color="{{ payment.category_color }}"
>
{{ payment.category_name }}
@@ -97,7 +97,7 @@
{% endfor %}
</div>
- {{ paging::paging(
+ {{ paging.view(
url="/" ~ payments_params(
frequency=query.frequency,
name=query.name,
diff --git a/templates/payment/table/search.html b/templates/payment/table/search.html
index 9fedb78..cb72282 100644
--- a/templates/payment/table/search.html
+++ b/templates/payment/table/search.html
@@ -17,7 +17,7 @@
type="search"
name="name"
class="g-Form__Input"
- value="{{ query.name }}"
+ value="{{ query.name or '' }}"
/>
</label>
@@ -27,7 +27,7 @@
type="number"
name="cost"
class="g-Form__Input"
- value="{{ query.cost }}"
+ value="{{ query.cost or '' }}"
/>
</label>
@@ -67,7 +67,7 @@
type="date"
name="start_date"
class="g-Form__Input"
- value="{{ query.start_date }}"
+ value="{{ query.start_date or '' }}"
/>
</label>
@@ -77,7 +77,7 @@
type="date"
name="end_date"
class="g-Form__Input"
- value="{{ query.end_date }}"
+ value="{{ query.end_date or '' }}"
/>
</label>
diff --git a/templates/payment/update.html b/templates/payment/update.html
index 22a4d01..dfa0892 100644
--- a/templates/payment/update.html
+++ b/templates/payment/update.html
@@ -57,7 +57,7 @@
<input
name="name"
class="g-Form__Input"
- value="{{ form.name | default(value=payment.name) }}"
+ value="{{ form.name or payment.name }}"
required
/>
</label>
@@ -68,12 +68,12 @@
name="cost"
type="number"
class="g-Form__Input"
- value="{{ form.cost | default(value=payment.cost) }}"
+ value="{{ form.cost or payment.cost }}"
required
/>
</label>
- {% set user_id = form.user_id | default(value="" ~ payment.user_id) %}
+ {% set user_id = form.user_id or payment.user_id %}
<label class="g-Form__Label">
Personne
@@ -89,7 +89,7 @@
</select>
</label>
- {% set category_id = form.category_id | default(value="" ~ payment.category_id) %}
+ {% set category_id = form.category_id or payment.category_id %}
<label class="g-Form__Label">
Catégorie
@@ -105,7 +105,7 @@
</select>
</label>
- {% set date = form.date | default(value=payment.date) %}
+ {% set date = form.date or payment.date %}
{% if payment.frequency == "Punctual" %}
<label class="g-Form__Label">
diff --git a/templates/report/list.j2 b/templates/report/list.j2
index ef53244..d683879 100644
--- a/templates/report/list.j2
+++ b/templates/report/list.j2
@@ -2,13 +2,13 @@
{% if xs -%}
- {% set s = xs | length | pluralize -%}
+ {% set l = xs | length %}
- {{ xs | length }} {{ resource }}{{ s }} {{ action }}{{ s }} :
+ {{ xs | length }} {{ pluralize(l, resource) }} {{ pluralize(l, action) }} :
{% for x in xs -%}
- {{ x.date }} {{ x.name }} {{ x.amount | euros() }}
{% endfor %}
{% endif -%}
-{% endmacro paging %}
+{% endmacro %}
diff --git a/templates/report/report.j2 b/templates/report/report.j2
index d36f3ce..8711184 100644
--- a/templates/report/report.j2
+++ b/templates/report/report.j2
@@ -5,7 +5,7 @@
Équilibre :
{% for exceeding_payer in exceeding_payers -%}
- - {{ exceeding_payer.0 }} : +{{ exceeding_payer.1 | euros() }}
+ - {{ exceeding_payer[0] }} : +{{ exceeding_payer[1] | euros() }}
{% endfor %}
{% else -%}
@@ -13,38 +13,38 @@
{% endif %}{#
-#}{{ list::list(
+#}{{ list.list(
resource="paiement",
action="créé",
- xs=payments | filter(attribute="action", value="Created")
+ xs=payments | filter("action", "Created")
) }}{#
-#}{{ list::list(
+#}{{ list.list(
resource="paiement",
action="modifié",
- xs=payments | filter(attribute="action", value="Updated")
+ xs=payments | filter("action", "Updated")
) }}{#
-#}{{ list::list(
+#}{{ list.list(
resource="paiement",
action="supprimé",
- xs=payments | filter(attribute="action", value="Deleted")
+ xs=payments | filter("action", "Deleted")
) }}{#
-#}{{ list::list(
+#}{{ list.list(
resource="revenu",
action="créé",
- xs=incomes | filter(attribute="action", value="Created")
+ xs=incomes | filter("action", "Created")
) }}{#
-#}{{ list::list(
+#}{{ list.list(
resource="revenu",
action="modifié",
- xs=incomes | filter(attribute="action", value="Updated")
+ xs=incomes | filter("action", "Updated")
) }}{#
-#}{{ list::list(
+#}{{ list.list(
resource="revenu",
action="supprimé",
- xs=incomes | filter(attribute="action", value="Deleted")
+ xs=incomes | filter("action", "Deleted")
) }}
diff --git a/templates/statistics.html b/templates/statistics.html
index 21e8fcd..8f9b673 100644
--- a/templates/statistics.html
+++ b/templates/statistics.html
@@ -25,7 +25,7 @@
{{ json_payments }}
</div>
- <script src="{{ assets | get(key="chart.js") }}">
+ <script src="{{ assets["chart.js"] }}">
</script>
{% endblock main %}