From b9556f0f38587b4c5606de6dba08d9ffd604c984 Mon Sep 17 00:00:00 2001 From: Aidan Gerber Date: Tue, 10 May 2022 15:26:17 -0700 Subject: [PATCH 01/50] initial commit --- scripts/setup_database.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/setup_database.sh b/scripts/setup_database.sh index 82efebc..107a712 100755 --- a/scripts/setup_database.sh +++ b/scripts/setup_database.sh @@ -1,7 +1,7 @@ #!/bin/bash #TODO: This doesn't handle test databases correctly -RESULT=`psql -l | grep "sampleapp" | wc -l | awk '{print $1}'`; +RESULT=`psql -l | grep "sampleapp" | wc -l | awk '{print $1}' | -p 5433`; if test $RESULT -eq 0; then echo "Creating Database"; psql -c "create role sampleapp with createdb encrypted password 'sampleapp' login;" From 920125f57987d296fd46616511d175b2316495fd Mon Sep 17 00:00:00 2001 From: Aidan Gerber Date: Tue, 10 May 2022 15:27:26 -0700 Subject: [PATCH 02/50] initial commit --- scripts/setup_database.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/setup_database.sh b/scripts/setup_database.sh index 107a712..82efebc 100755 --- a/scripts/setup_database.sh +++ b/scripts/setup_database.sh @@ -1,7 +1,7 @@ #!/bin/bash #TODO: This doesn't handle test databases correctly -RESULT=`psql -l | grep "sampleapp" | wc -l | awk '{print $1}' | -p 5433`; +RESULT=`psql -l | grep "sampleapp" | wc -l | awk '{print $1}'`; if test $RESULT -eq 0; then echo "Creating Database"; psql -c "create role sampleapp with createdb encrypted password 'sampleapp' login;" From ff8cfadb6696d3831edee851281d596f6f5edb18 Mon Sep 17 00:00:00 2001 From: Aidan Gerber Date: Wed, 11 May 2022 10:58:08 -0700 Subject: [PATCH 03/50] config --- .gitignore | 3 +++ sampleapp/config/jinja2.py | 19 +++++++++++++++++++ sampleapp/config/settings/base.py | 11 ++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 sampleapp/config/jinja2.py diff --git a/.gitignore b/.gitignore index c6bcb56..75d0015 100644 --- a/.gitignore +++ b/.gitignore @@ -180,6 +180,9 @@ Temporary Items .directory +### VS Code ### +.vscode/ + ### PyCharm ### # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm diff --git a/sampleapp/config/jinja2.py b/sampleapp/config/jinja2.py new file mode 100644 index 0000000..300630c --- /dev/null +++ b/sampleapp/config/jinja2.py @@ -0,0 +1,19 @@ +# https://docs.djangoproject.com/en/4.0/topics/templates/#django.template.backends.jinja2.Jinja2 + +from django.templatetags.static import static +from django.urls import reverse +from jinja2 import Environment + + +def environment(**options): + options.pop( + "string_if_invalid", None + ) # https://github.com/pytest-dev/pytest-django/issues/327 + env = Environment(autoescape=True, **options) + env.globals.update( + { + "static": static, + "url": reverse, + } + ) + return env diff --git a/sampleapp/config/settings/base.py b/sampleapp/config/settings/base.py index 68f3f2c..78db993 100644 --- a/sampleapp/config/settings/base.py +++ b/sampleapp/config/settings/base.py @@ -190,6 +190,15 @@ # https://docs.djangoproject.com/en/dev/ref/settings/#templates TEMPLATES = [ + { + "BACKEND": "django.template.backends.jinja2.Jinja2", + "DIRS": [root("jinja2")], + "APP_DIRS": True, + "OPTIONS": { + "autoescape": True, + "environment": "sampleapp.config.jinja2.environment", + }, + }, { # https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND "BACKEND": "django.template.backends.django.DjangoTemplates", @@ -210,7 +219,7 @@ # https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors "context_processors": CONTEXT_PROCESSORS, }, - } + }, ] # components settings From 082ad59b41925639593b30c055ad036391ad96d9 Mon Sep 17 00:00:00 2001 From: Aidan Gerber Date: Wed, 11 May 2022 15:10:20 -0700 Subject: [PATCH 04/50] getting jinja set up, does not fully work --- sampleapp/config/jinja2.py | 10 ++- sampleapp/config/settings/base.py | 1 - sampleapp/home/urls.py | 2 + sampleapp/jinja2/403.html | 14 ++++ sampleapp/jinja2/404.html | 14 ++++ sampleapp/jinja2/500.html | 11 +++ sampleapp/jinja2/base.html | 54 ++++++++++++ sampleapp/jinja2/components/button.html | 6 ++ sampleapp/jinja2/components/menu.html | 35 ++++++++ sampleapp/jinja2/current_time.html | 1 + sampleapp/jinja2/footer.html | 82 +++++++++++++++++++ sampleapp/jinja2/forms/checkbox.html | 9 ++ sampleapp/jinja2/forms/default.html | 7 ++ .../jinja2/forms/errors/list/default.html | 9 ++ sampleapp/jinja2/forms/inputgroup.html | 27 ++++++ sampleapp/jinja2/forms/label.html | 7 ++ sampleapp/jinja2/forms/widgets/input.html | 4 + sampleapp/jinja2/forms/widgets/password.html | 41 ++++++++++ sampleapp/jinja2/header/base.html | 15 ++++ sampleapp/jinja2/header/desktop_center.html | 11 +++ sampleapp/jinja2/header/end.html | 55 +++++++++++++ sampleapp/jinja2/header/logo.html | 10 +++ sampleapp/jinja2/header/mobile_menu.html | 48 +++++++++++ .../jinja2/header/mobile_menu_button.html | 18 ++++ sampleapp/jinja2/index.html | 21 +++++ sampleapp/jinja2/jinja.html | 10 +++ sampleapp/jinja2/jinja2.html | 19 +++++ sampleapp/jinja2/util/messages.html | 27 ++++++ sampleapp/jinja2/util/social.html | 27 ++++++ 29 files changed, 593 insertions(+), 2 deletions(-) create mode 100644 sampleapp/jinja2/403.html create mode 100644 sampleapp/jinja2/404.html create mode 100644 sampleapp/jinja2/500.html create mode 100644 sampleapp/jinja2/base.html create mode 100644 sampleapp/jinja2/components/button.html create mode 100644 sampleapp/jinja2/components/menu.html create mode 100644 sampleapp/jinja2/current_time.html create mode 100644 sampleapp/jinja2/footer.html create mode 100644 sampleapp/jinja2/forms/checkbox.html create mode 100644 sampleapp/jinja2/forms/default.html create mode 100644 sampleapp/jinja2/forms/errors/list/default.html create mode 100644 sampleapp/jinja2/forms/inputgroup.html create mode 100644 sampleapp/jinja2/forms/label.html create mode 100644 sampleapp/jinja2/forms/widgets/input.html create mode 100644 sampleapp/jinja2/forms/widgets/password.html create mode 100644 sampleapp/jinja2/header/base.html create mode 100644 sampleapp/jinja2/header/desktop_center.html create mode 100644 sampleapp/jinja2/header/end.html create mode 100644 sampleapp/jinja2/header/logo.html create mode 100644 sampleapp/jinja2/header/mobile_menu.html create mode 100644 sampleapp/jinja2/header/mobile_menu_button.html create mode 100644 sampleapp/jinja2/index.html create mode 100644 sampleapp/jinja2/jinja.html create mode 100644 sampleapp/jinja2/jinja2.html create mode 100644 sampleapp/jinja2/util/messages.html create mode 100644 sampleapp/jinja2/util/social.html diff --git a/sampleapp/config/jinja2.py b/sampleapp/config/jinja2.py index 300630c..efd83c4 100644 --- a/sampleapp/config/jinja2.py +++ b/sampleapp/config/jinja2.py @@ -2,18 +2,26 @@ from django.templatetags.static import static from django.urls import reverse +from django_vite.templatetags.django_vite import vite_asset, vite_hmr_client from jinja2 import Environment +from sampleapp.config.settings.base import CSRF_COOKIE_NAME + def environment(**options): options.pop( "string_if_invalid", None ) # https://github.com/pytest-dev/pytest-django/issues/327 - env = Environment(autoescape=True, **options) + # This actually works, the below is necessary for + # flakeheaven env = Environment(**options) + env = Environment(**options, autoescape=True) env.globals.update( { "static": static, "url": reverse, + "csrf_cookie_name": CSRF_COOKIE_NAME, + "vite_asset": vite_asset, + "vite_hmr_client": vite_hmr_client, } ) return env diff --git a/sampleapp/config/settings/base.py b/sampleapp/config/settings/base.py index 78db993..2ac1745 100644 --- a/sampleapp/config/settings/base.py +++ b/sampleapp/config/settings/base.py @@ -193,7 +193,6 @@ { "BACKEND": "django.template.backends.jinja2.Jinja2", "DIRS": [root("jinja2")], - "APP_DIRS": True, "OPTIONS": { "autoescape": True, "environment": "sampleapp.config.jinja2.environment", diff --git a/sampleapp/home/urls.py b/sampleapp/home/urls.py index b5eb313..3ccb8ef 100644 --- a/sampleapp/home/urls.py +++ b/sampleapp/home/urls.py @@ -4,6 +4,8 @@ from .views import current_time, error urlpatterns = [ + path("jinja/", TemplateView.as_view(template_name="jinja.html"), name="jinja"), + path("jinja2/", TemplateView.as_view(template_name="jinja2.html"), name="jinja2"), path(r"current-time/", current_time, name="current_time"), path(r"error/", error, name="error"), path(r"", TemplateView.as_view(template_name="index.html"), name="home"), diff --git a/sampleapp/jinja2/403.html b/sampleapp/jinja2/403.html new file mode 100644 index 0000000..9e4f087 --- /dev/null +++ b/sampleapp/jinja2/403.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} +{% block title %} + Forbidden (403) +{% endblock title %} +{% block content %} +

Forbidden (403)

+

+ {% if exception %} + {{ exception }} + {% else %} + You're not allowed to access this page. + {% endif %} +

+{% endblock content %} diff --git a/sampleapp/jinja2/404.html b/sampleapp/jinja2/404.html new file mode 100644 index 0000000..3d58ae4 --- /dev/null +++ b/sampleapp/jinja2/404.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} +{% block title %} + Page not found +{% endblock title %} +{% block content %} +

Page not found

+

+ {% if exception %} + {{ exception }} + {% else %} + This is not the page you were looking for. + {% endif %} +

+{% endblock content %} diff --git a/sampleapp/jinja2/500.html b/sampleapp/jinja2/500.html new file mode 100644 index 0000000..986b837 --- /dev/null +++ b/sampleapp/jinja2/500.html @@ -0,0 +1,11 @@ +{% extends "base.html" %} +{% block title %} + Server Error +{% endblock title %} +{% block content %} +

Ooops!!! 500

+

Looks like something went wrong!

+

+ We track these errors automatically, but if the problem persists feel free to contact us. In the meantime, try refreshing. +

+{% endblock content %} diff --git a/sampleapp/jinja2/base.html b/sampleapp/jinja2/base.html new file mode 100644 index 0000000..13cc47f --- /dev/null +++ b/sampleapp/jinja2/base.html @@ -0,0 +1,54 @@ + + + + + + + + + + {{ vite_hmr_client() }} + {{ vite_asset('js/main.ts') }} + {# + {{ load(django_htmx) }} + {{ django_htmx_script }} + #} + {% block extra_head %} + Lightmatter + {% endblock extra_head %} + + + {% include "header/base.html" %} +
+ {% block content %} + {% endblock content %} +
    + {% include "util/messages.html" %} +
+
+ {% include "footer.html" %} + + + diff --git a/sampleapp/jinja2/components/button.html b/sampleapp/jinja2/components/button.html new file mode 100644 index 0000000..c4d3d72 --- /dev/null +++ b/sampleapp/jinja2/components/button.html @@ -0,0 +1,6 @@ +{% macro button() %} + +{% endmacro %} diff --git a/sampleapp/jinja2/components/menu.html b/sampleapp/jinja2/components/menu.html new file mode 100644 index 0000000..5bb5e1a --- /dev/null +++ b/sampleapp/jinja2/components/menu.html @@ -0,0 +1,35 @@ +{% from 'button.html' import button %} +{% macro menu(button) %} +
+ + + +
+{% endmacro %} diff --git a/sampleapp/jinja2/current_time.html b/sampleapp/jinja2/current_time.html new file mode 100644 index 0000000..a68238f --- /dev/null +++ b/sampleapp/jinja2/current_time.html @@ -0,0 +1 @@ +{% now "jS F Y H:i:s" %} diff --git a/sampleapp/jinja2/footer.html b/sampleapp/jinja2/footer.html new file mode 100644 index 0000000..d7b3f01 --- /dev/null +++ b/sampleapp/jinja2/footer.html @@ -0,0 +1,82 @@ + diff --git a/sampleapp/jinja2/forms/checkbox.html b/sampleapp/jinja2/forms/checkbox.html new file mode 100644 index 0000000..27bddcd --- /dev/null +++ b/sampleapp/jinja2/forms/checkbox.html @@ -0,0 +1,9 @@ +
+
{{ field }}
+
+ {% if field.label %}{{ field.label_tag }}{% endif %} +

+ {{ field.help_text|safe }} +

+
+
diff --git a/sampleapp/jinja2/forms/default.html b/sampleapp/jinja2/forms/default.html new file mode 100644 index 0000000..55cedbc --- /dev/null +++ b/sampleapp/jinja2/forms/default.html @@ -0,0 +1,7 @@ +
+ {{ errors }} + {% for field, errors in fields %} + {% include "django/forms/inputgroup.html" with field=field errors=errors %} + {% endfor %} + {% for field in hidden_fields %}{{ field }}{% endfor %} +
diff --git a/sampleapp/jinja2/forms/errors/list/default.html b/sampleapp/jinja2/forms/errors/list/default.html new file mode 100644 index 0000000..5fb21a6 --- /dev/null +++ b/sampleapp/jinja2/forms/errors/list/default.html @@ -0,0 +1,9 @@ +{% if errors %} + + {% for error in errors %} +

+ {{ error }} +

+ {% endfor %} +
+{% endif %} diff --git a/sampleapp/jinja2/forms/inputgroup.html b/sampleapp/jinja2/forms/inputgroup.html new file mode 100644 index 0000000..97fcd38 --- /dev/null +++ b/sampleapp/jinja2/forms/inputgroup.html @@ -0,0 +1,27 @@ +
+ {% if field.label %}{{ field.label_tag }}{% endif %} +
+ {{ field }} + {% if errors %} +
+ + +
+ {% endif %} +
+ {% if errors %} + {{ errors }} + {% elif field.help_text %} +

+ {{ field.help_text|safe }} +

+ {% endif %} +
diff --git a/sampleapp/jinja2/forms/label.html b/sampleapp/jinja2/forms/label.html new file mode 100644 index 0000000..b34e18d --- /dev/null +++ b/sampleapp/jinja2/forms/label.html @@ -0,0 +1,7 @@ +{% if use_tag %} + <{{ tag|default:'label' }} + {% include 'django/forms/attrs.html' %} + class="block text-sm font-medium text-gray-700">{{ field.label }} +{% else %} + {{ field.label }} +{% endif %} diff --git a/sampleapp/jinja2/forms/widgets/input.html b/sampleapp/jinja2/forms/widgets/input.html new file mode 100644 index 0000000..a55363a --- /dev/null +++ b/sampleapp/jinja2/forms/widgets/input.html @@ -0,0 +1,4 @@ + diff --git a/sampleapp/jinja2/forms/widgets/password.html b/sampleapp/jinja2/forms/widgets/password.html new file mode 100644 index 0000000..3448290 --- /dev/null +++ b/sampleapp/jinja2/forms/widgets/password.html @@ -0,0 +1,41 @@ + + +
+ + + + +
+
+ + + + + +
+
diff --git a/sampleapp/jinja2/header/base.html b/sampleapp/jinja2/header/base.html new file mode 100644 index 0000000..ef2b662 --- /dev/null +++ b/sampleapp/jinja2/header/base.html @@ -0,0 +1,15 @@ +
+ +
diff --git a/sampleapp/jinja2/header/desktop_center.html b/sampleapp/jinja2/header/desktop_center.html new file mode 100644 index 0000000..c938799 --- /dev/null +++ b/sampleapp/jinja2/header/desktop_center.html @@ -0,0 +1,11 @@ + diff --git a/sampleapp/jinja2/header/end.html b/sampleapp/jinja2/header/end.html new file mode 100644 index 0000000..ca00206 --- /dev/null +++ b/sampleapp/jinja2/header/end.html @@ -0,0 +1,55 @@ +{% if not request.user.is_authenticated %} + +{% else %} + +{% endif %} diff --git a/sampleapp/jinja2/header/logo.html b/sampleapp/jinja2/header/logo.html new file mode 100644 index 0000000..ea166b7 --- /dev/null +++ b/sampleapp/jinja2/header/logo.html @@ -0,0 +1,10 @@ + diff --git a/sampleapp/jinja2/header/mobile_menu.html b/sampleapp/jinja2/header/mobile_menu.html new file mode 100644 index 0000000..cecbec5 --- /dev/null +++ b/sampleapp/jinja2/header/mobile_menu.html @@ -0,0 +1,48 @@ + diff --git a/sampleapp/jinja2/header/mobile_menu_button.html b/sampleapp/jinja2/header/mobile_menu_button.html new file mode 100644 index 0000000..f14d3fa --- /dev/null +++ b/sampleapp/jinja2/header/mobile_menu_button.html @@ -0,0 +1,18 @@ +
+ + +
diff --git a/sampleapp/jinja2/index.html b/sampleapp/jinja2/index.html new file mode 100644 index 0000000..ec7bdba --- /dev/null +++ b/sampleapp/jinja2/index.html @@ -0,0 +1,21 @@ +{% extends "base.html" %} +{% block title %} + Lightmatter Base Install +{% endblock title %} +{% block content %} +
+ Hello - it is now +

+ {% include 'current_time.html' %} +

+ + test redirect + + +
+{% endblock content %} diff --git a/sampleapp/jinja2/jinja.html b/sampleapp/jinja2/jinja.html new file mode 100644 index 0000000..5009d36 --- /dev/null +++ b/sampleapp/jinja2/jinja.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} +{% block title %} + Jinja +{% endblock title %} +{% block content %} +

Jinja

+ {% set testing = 'it worked' %} +

{{ testing }}

+

Cookie Name: {{ csrf_cookie_name }}

+{% endblock content %} diff --git a/sampleapp/jinja2/jinja2.html b/sampleapp/jinja2/jinja2.html new file mode 100644 index 0000000..adbf595 --- /dev/null +++ b/sampleapp/jinja2/jinja2.html @@ -0,0 +1,19 @@ +{% from 'components/button.html' import button %} +

Jinja

+{% set testing = 'it worked' %} +

{{ testing }}

+

Cookie Name: {{ csrf_cookie_name }}

+{% call button() %} +Open user menu + + + +{% endcall %} diff --git a/sampleapp/jinja2/util/messages.html b/sampleapp/jinja2/util/messages.html new file mode 100644 index 0000000..7e50fbc --- /dev/null +++ b/sampleapp/jinja2/util/messages.html @@ -0,0 +1,27 @@ +{% for message in messages %} +
  • +
    +
    + +
    +
    +

    + {{ message }} +

    +
    +
    +
    + +
    +
    +
    +
  • +{% endfor %} diff --git a/sampleapp/jinja2/util/social.html b/sampleapp/jinja2/util/social.html new file mode 100644 index 0000000..2332bb3 --- /dev/null +++ b/sampleapp/jinja2/util/social.html @@ -0,0 +1,27 @@ + + {% if page.seo_title %} + {{ page.seo_title }} + {% else %} + {% endif %} + + + + +{% set img=image(page.social_image, "fill-1200x627") %} +{% set default_img=image(settings.wagtailapp.SocialMediaSettings.default_social_image, "fill-1200x627") %} + + + + + + + From 94992930acaf230c29adb623693e2e59c3cf14aa Mon Sep 17 00:00:00 2001 From: Aidan Gerber Date: Wed, 11 May 2022 17:22:59 -0700 Subject: [PATCH 05/50] progress --- sampleapp/config/jinja2.py | 4 +--- sampleapp/jinja2/components/button.html | 4 ++-- sampleapp/jinja2/components/menu.html | 25 +++++++++++++++++++------ sampleapp/jinja2/header/end.html | 18 +++++++++--------- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/sampleapp/config/jinja2.py b/sampleapp/config/jinja2.py index efd83c4..b6bdd61 100644 --- a/sampleapp/config/jinja2.py +++ b/sampleapp/config/jinja2.py @@ -12,9 +12,7 @@ def environment(**options): options.pop( "string_if_invalid", None ) # https://github.com/pytest-dev/pytest-django/issues/327 - # This actually works, the below is necessary for - # flakeheaven env = Environment(**options) - env = Environment(**options, autoescape=True) + env = Environment(**options) # noqa env.globals.update( { "static": static, diff --git a/sampleapp/jinja2/components/button.html b/sampleapp/jinja2/components/button.html index c4d3d72..aae2389 100644 --- a/sampleapp/jinja2/components/button.html +++ b/sampleapp/jinja2/components/button.html @@ -1,6 +1,6 @@ -{% macro button() %} +{% macro button(button_content='Button') %} {% endmacro %} diff --git a/sampleapp/jinja2/components/menu.html b/sampleapp/jinja2/components/menu.html index 5bb5e1a..ec63ae5 100644 --- a/sampleapp/jinja2/components/menu.html +++ b/sampleapp/jinja2/components/menu.html @@ -1,5 +1,18 @@ -{% from 'button.html' import button %} -{% macro menu(button) %} +{% from 'components/button.html' import button %} +{% set default_button %} +{{ button()}} +{% endset %} +{% set default_content %} +
    +{% endset %} +{% macro menu(button=default_button, content=default_content, button_style='text-gray-500 group bg-white rounded-md + inline-flex items-center text-base font-medium hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-offset-2 + focus:ring-indigo-500', menu_style='absolute z-10 left-1/2 transform -translate-x-1/2 mt-3 px-2 w-screen max-w-xs + sm:px-0') %}
    - {% slot "button" %}{% endslot %} + class="{{ button_style }}"> + {{ button }} -
    diff --git a/sampleapp/jinja2/header/end.html b/sampleapp/jinja2/header/end.html index ca00206..c7795fd 100644 --- a/sampleapp/jinja2/header/end.html +++ b/sampleapp/jinja2/header/end.html @@ -1,3 +1,5 @@ +{% from 'components/menu.html' import menu %} +{% from 'components/button.html' import button %} {% if not request.user.is_authenticated %}
    {% else %} {% endif %} From 5dabbcfdb4a39839a92fc4220b0105d126223efd Mon Sep 17 00:00:00 2001 From: Aidan Gerber Date: Thu, 12 May 2022 15:32:28 -0700 Subject: [PATCH 06/50] work on updating to jinja and django-jinja --- sampleapp/config/jinja2.py | 55 ++++++++------- sampleapp/config/settings/base.py | 16 +++-- sampleapp/config/settings/local.py | 4 +- sampleapp/{jinja2 => dtl}/403.html | 0 sampleapp/{jinja2 => dtl}/404.html | 0 sampleapp/{jinja2 => dtl}/500.html | 0 .../account/account_inactive.html | 0 .../account/components/account_box.html | 0 .../account/components/login_box.html | 0 .../account/components/signup_box.html | 0 .../account/components/welcome_box.html | 0 sampleapp/dtl/account/email/base_message.txt | 8 +++ .../email/email_confirmation_message.txt | 8 +++ .../email_confirmation_signup_message.txt | 2 + .../email_confirmation_signup_subject.txt | 2 + .../email/email_confirmation_subject.txt | 5 ++ .../email/password_reset_key_message.txt | 10 +++ .../email/password_reset_key_subject.txt | 5 ++ .../account/email/unknown_account_message.txt | 13 ++++ .../account/email/unknown_account_subject.txt | 5 ++ .../{templates => dtl}/account/login.html | 0 .../account/login_form.html | 0 .../{templates => dtl}/account/logout.html | 0 .../account/password_reset.html | 0 .../account/password_reset_done.html | 0 .../account/password_reset_from_key.html | 0 .../account/password_reset_from_key_done.html | 0 .../account/password_set.html | 0 .../{templates => dtl}/account/signup.html | 0 .../account/signup_form.html | 0 .../{templates => dtl}/account/welcome.html | 0 sampleapp/{templates => dtl}/base.html | 0 .../{templates => dtl}/components/button.html | 0 .../{templates => dtl}/components/menu.html | 0 sampleapp/{jinja2 => dtl}/current_time.html | 0 .../django}/forms/checkbox.html | 0 .../{jinja2 => dtl/django}/forms/default.html | 0 .../django}/forms/errors/list/default.html | 0 .../django}/forms/inputgroup.html | 0 .../{jinja2 => dtl/django}/forms/label.html | 0 .../django}/forms/widgets/input.html | 0 .../django}/forms/widgets/password.html | 0 sampleapp/{jinja2 => dtl}/footer.html | 0 sampleapp/{jinja2 => dtl}/header/base.html | 0 .../header/desktop_center.html | 0 sampleapp/{templates => dtl}/header/end.html | 0 sampleapp/{templates => dtl}/header/logo.html | 0 .../{jinja2 => dtl}/header/mobile_menu.html | 0 .../header/mobile_menu_button.html | 0 sampleapp/{jinja2 => dtl}/index.html | 0 sampleapp/{jinja2 => dtl}/util/messages.html | 0 sampleapp/{jinja2 => dtl}/util/social.html | 0 sampleapp/home/urls.py | 6 +- sampleapp/jinja2/header/end.html | 55 --------------- sampleapp/templates/{403.html => 403.jinja} | 2 +- sampleapp/templates/{404.html => 404.jinja} | 2 +- sampleapp/templates/{500.html => 500.jinja} | 2 +- .../templates/account/account_inactive.jinja | 11 +++ .../account/components/account_box.jinja | 28 ++++++++ .../account/components/login_box.jinja | 67 +++++++++++++++++++ .../account/components/signup_box.jinja | 67 +++++++++++++++++++ .../account/components/welcome_box.jinja | 67 +++++++++++++++++++ sampleapp/templates/account/login.jinja | 1 + sampleapp/templates/account/login_form.jinja | 12 ++++ sampleapp/templates/account/logout.jinja | 19 ++++++ .../templates/account/password_reset.jinja | 23 +++++++ .../account/password_reset_done.jinja | 13 ++++ .../account/password_reset_from_key.jinja | 25 +++++++ .../password_reset_from_key_done.jinja | 10 +++ .../templates/account/password_set.jinja | 14 ++++ sampleapp/templates/account/signup.jinja | 62 +++++++++++++++++ sampleapp/templates/account/signup_form.jinja | 11 +++ sampleapp/templates/account/welcome.jinja | 9 +++ .../base.html => templates/base.jinja} | 13 ++-- .../components/button.jinja} | 0 .../components/menu.jinja} | 2 +- sampleapp/templates/current_time.html | 1 - sampleapp/templates/current_time.jinja | 5 ++ .../forms/{checkbox.html => checkbox.jinja} | 0 .../forms/{default.html => default.jinja} | 2 +- .../list/{default.html => default.jinja} | 0 .../{inputgroup.html => inputgroup.jinja} | 0 .../django/forms/{label.html => label.jinja} | 2 +- .../forms/widgets/{input.html => input.jinja} | 2 +- .../widgets/{password.html => password.jinja} | 0 .../templates/{footer.html => footer.jinja} | 0 sampleapp/templates/forms/checkbox.jinja | 9 +++ sampleapp/templates/forms/default.jinja | 7 ++ .../templates/forms/errors/list/default.jinja | 9 +++ sampleapp/templates/forms/inputgroup.jinja | 27 ++++++++ sampleapp/templates/forms/label.jinja | 7 ++ sampleapp/templates/forms/widgets/input.jinja | 4 ++ .../templates/forms/widgets/password.jinja | 41 ++++++++++++ .../header/{base.html => base.jinja} | 10 +-- ...sktop_center.html => desktop_center.jinja} | 0 sampleapp/templates/header/end.jinja | 39 +++++++++++ .../logo.html => templates/header/logo.jinja} | 0 .../{mobile_menu.html => mobile_menu.jinja} | 0 ...u_button.html => mobile_menu_button.jinja} | 0 .../templates/{index.html => index.jinja} | 8 +-- .../jinja.html => templates/jinja.jinja} | 4 +- .../jinja2.html => templates/jinja2.jinja} | 0 sampleapp/templates/svg/twitter.svg | 6 ++ .../util/{messages.html => messages.jinja} | 0 .../util/{social.html => social.jinja} | 0 sampleapp/user/views.py | 6 +- tailwind.config.js | 1 + 107 files changed, 726 insertions(+), 118 deletions(-) rename sampleapp/{jinja2 => dtl}/403.html (100%) rename sampleapp/{jinja2 => dtl}/404.html (100%) rename sampleapp/{jinja2 => dtl}/500.html (100%) rename sampleapp/{templates => dtl}/account/account_inactive.html (100%) rename sampleapp/{templates => dtl}/account/components/account_box.html (100%) rename sampleapp/{templates => dtl}/account/components/login_box.html (100%) rename sampleapp/{templates => dtl}/account/components/signup_box.html (100%) rename sampleapp/{templates => dtl}/account/components/welcome_box.html (100%) create mode 100644 sampleapp/dtl/account/email/base_message.txt create mode 100644 sampleapp/dtl/account/email/email_confirmation_message.txt create mode 100644 sampleapp/dtl/account/email/email_confirmation_signup_message.txt create mode 100644 sampleapp/dtl/account/email/email_confirmation_signup_subject.txt create mode 100644 sampleapp/dtl/account/email/email_confirmation_subject.txt create mode 100644 sampleapp/dtl/account/email/password_reset_key_message.txt create mode 100644 sampleapp/dtl/account/email/password_reset_key_subject.txt create mode 100644 sampleapp/dtl/account/email/unknown_account_message.txt create mode 100644 sampleapp/dtl/account/email/unknown_account_subject.txt rename sampleapp/{templates => dtl}/account/login.html (100%) rename sampleapp/{templates => dtl}/account/login_form.html (100%) rename sampleapp/{templates => dtl}/account/logout.html (100%) rename sampleapp/{templates => dtl}/account/password_reset.html (100%) rename sampleapp/{templates => dtl}/account/password_reset_done.html (100%) rename sampleapp/{templates => dtl}/account/password_reset_from_key.html (100%) rename sampleapp/{templates => dtl}/account/password_reset_from_key_done.html (100%) rename sampleapp/{templates => dtl}/account/password_set.html (100%) rename sampleapp/{templates => dtl}/account/signup.html (100%) rename sampleapp/{templates => dtl}/account/signup_form.html (100%) rename sampleapp/{templates => dtl}/account/welcome.html (100%) rename sampleapp/{templates => dtl}/base.html (100%) rename sampleapp/{templates => dtl}/components/button.html (100%) rename sampleapp/{templates => dtl}/components/menu.html (100%) rename sampleapp/{jinja2 => dtl}/current_time.html (100%) rename sampleapp/{jinja2 => dtl/django}/forms/checkbox.html (100%) rename sampleapp/{jinja2 => dtl/django}/forms/default.html (100%) rename sampleapp/{jinja2 => dtl/django}/forms/errors/list/default.html (100%) rename sampleapp/{jinja2 => dtl/django}/forms/inputgroup.html (100%) rename sampleapp/{jinja2 => dtl/django}/forms/label.html (100%) rename sampleapp/{jinja2 => dtl/django}/forms/widgets/input.html (100%) rename sampleapp/{jinja2 => dtl/django}/forms/widgets/password.html (100%) rename sampleapp/{jinja2 => dtl}/footer.html (100%) rename sampleapp/{jinja2 => dtl}/header/base.html (100%) rename sampleapp/{jinja2 => dtl}/header/desktop_center.html (100%) rename sampleapp/{templates => dtl}/header/end.html (100%) rename sampleapp/{templates => dtl}/header/logo.html (100%) rename sampleapp/{jinja2 => dtl}/header/mobile_menu.html (100%) rename sampleapp/{jinja2 => dtl}/header/mobile_menu_button.html (100%) rename sampleapp/{jinja2 => dtl}/index.html (100%) rename sampleapp/{jinja2 => dtl}/util/messages.html (100%) rename sampleapp/{jinja2 => dtl}/util/social.html (100%) delete mode 100644 sampleapp/jinja2/header/end.html rename sampleapp/templates/{403.html => 403.jinja} (91%) rename sampleapp/templates/{404.html => 404.jinja} (91%) rename sampleapp/templates/{500.html => 500.jinja} (92%) create mode 100644 sampleapp/templates/account/account_inactive.jinja create mode 100644 sampleapp/templates/account/components/account_box.jinja create mode 100644 sampleapp/templates/account/components/login_box.jinja create mode 100644 sampleapp/templates/account/components/signup_box.jinja create mode 100644 sampleapp/templates/account/components/welcome_box.jinja create mode 100644 sampleapp/templates/account/login.jinja create mode 100644 sampleapp/templates/account/login_form.jinja create mode 100644 sampleapp/templates/account/logout.jinja create mode 100644 sampleapp/templates/account/password_reset.jinja create mode 100644 sampleapp/templates/account/password_reset_done.jinja create mode 100644 sampleapp/templates/account/password_reset_from_key.jinja create mode 100644 sampleapp/templates/account/password_reset_from_key_done.jinja create mode 100644 sampleapp/templates/account/password_set.jinja create mode 100644 sampleapp/templates/account/signup.jinja create mode 100644 sampleapp/templates/account/signup_form.jinja create mode 100644 sampleapp/templates/account/welcome.jinja rename sampleapp/{jinja2/base.html => templates/base.jinja} (85%) rename sampleapp/{jinja2/components/button.html => templates/components/button.jinja} (100%) rename sampleapp/{jinja2/components/menu.html => templates/components/menu.jinja} (97%) delete mode 100644 sampleapp/templates/current_time.html create mode 100644 sampleapp/templates/current_time.jinja rename sampleapp/templates/django/forms/{checkbox.html => checkbox.jinja} (100%) rename sampleapp/templates/django/forms/{default.html => default.jinja} (66%) rename sampleapp/templates/django/forms/errors/list/{default.html => default.jinja} (100%) rename sampleapp/templates/django/forms/{inputgroup.html => inputgroup.jinja} (100%) rename sampleapp/templates/django/forms/{label.html => label.jinja} (80%) rename sampleapp/templates/django/forms/widgets/{input.html => input.jinja} (73%) rename sampleapp/templates/django/forms/widgets/{password.html => password.jinja} (100%) rename sampleapp/templates/{footer.html => footer.jinja} (100%) create mode 100644 sampleapp/templates/forms/checkbox.jinja create mode 100644 sampleapp/templates/forms/default.jinja create mode 100644 sampleapp/templates/forms/errors/list/default.jinja create mode 100644 sampleapp/templates/forms/inputgroup.jinja create mode 100644 sampleapp/templates/forms/label.jinja create mode 100644 sampleapp/templates/forms/widgets/input.jinja create mode 100644 sampleapp/templates/forms/widgets/password.jinja rename sampleapp/templates/header/{base.html => base.jinja} (58%) rename sampleapp/templates/header/{desktop_center.html => desktop_center.jinja} (100%) create mode 100644 sampleapp/templates/header/end.jinja rename sampleapp/{jinja2/header/logo.html => templates/header/logo.jinja} (100%) rename sampleapp/templates/header/{mobile_menu.html => mobile_menu.jinja} (100%) rename sampleapp/templates/header/{mobile_menu_button.html => mobile_menu_button.jinja} (100%) rename sampleapp/templates/{index.html => index.jinja} (77%) rename sampleapp/{jinja2/jinja.html => templates/jinja.jinja} (72%) rename sampleapp/{jinja2/jinja2.html => templates/jinja2.jinja} (100%) create mode 100644 sampleapp/templates/svg/twitter.svg rename sampleapp/templates/util/{messages.html => messages.jinja} (100%) rename sampleapp/templates/util/{social.html => social.jinja} (100%) diff --git a/sampleapp/config/jinja2.py b/sampleapp/config/jinja2.py index b6bdd61..4494435 100644 --- a/sampleapp/config/jinja2.py +++ b/sampleapp/config/jinja2.py @@ -1,25 +1,32 @@ -# https://docs.djangoproject.com/en/4.0/topics/templates/#django.template.backends.jinja2.Jinja2 +""" +Example options from the docs +options = { + "tests": { + "mytest": "path.to.tests.mytestfn", + }, + "filters": { + "myfilter": "path.to.filters.myfilterfn", + }, + "constants": { + "hello": "hello world", + }, + "globals": { + "somefn": "path.to.functions.somefn", + }, +} +""" +import datetime -from django.templatetags.static import static -from django.urls import reverse -from django_vite.templatetags.django_vite import vite_asset, vite_hmr_client -from jinja2 import Environment - -from sampleapp.config.settings.base import CSRF_COOKIE_NAME - - -def environment(**options): - options.pop( - "string_if_invalid", None - ) # https://github.com/pytest-dev/pytest-django/issues/327 - env = Environment(**options) # noqa - env.globals.update( - { - "static": static, - "url": reverse, - "csrf_cookie_name": CSRF_COOKIE_NAME, - "vite_asset": vite_asset, - "vite_hmr_client": vite_hmr_client, - } - ) - return env +options = { + "constants": {"csrf_cookie_name": "sampleapp"}, + "filters": { + "template_localtime": "django.utils.timezone.template_localtime", + }, + "globals": { + "vite_asset": "django_vite.templatetags.django_vite.vite_asset", + "vite_hmr_client": "django_vite.templatetags.django_vite.vite_hmr_client", + "django_htmx_script": "django_htmx.templatetags.django_htmx.django_htmx_script", + "now": datetime.datetime.utcnow, + "template_localtime": "django.utils.timezone.template_localtime", + }, +} diff --git a/sampleapp/config/settings/base.py b/sampleapp/config/settings/base.py index 2ac1745..a082e5e 100644 --- a/sampleapp/config/settings/base.py +++ b/sampleapp/config/settings/base.py @@ -5,6 +5,8 @@ from django.core.exceptions import ImproperlyConfigured from environ import Env, Path +from ..jinja2 import options + root = Path(__file__) - 3 env = Env() @@ -71,6 +73,7 @@ "cachalot", "django_extensions", "django_htmx", + "django_jinja", "django_vite", "django_components", "model_utils", @@ -189,14 +192,14 @@ # https://docs.djangoproject.com/en/dev/ref/settings/#templates + TEMPLATES = [ { - "BACKEND": "django.template.backends.jinja2.Jinja2", - "DIRS": [root("jinja2")], - "OPTIONS": { - "autoescape": True, - "environment": "sampleapp.config.jinja2.environment", - }, + # https://niwi.nz/django-jinja/latest/ + "BACKEND": "django_jinja.backend.Jinja2", + "DIRS": [root("templates")], + "APP_DIRS": True, + "OPTIONS": options, }, { # https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND @@ -308,6 +311,7 @@ def prefixed_cookie(name): ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_EMAIL_VERIFICATION = "none" ACCOUNT_SIGNUP_EMAIL_ENTER_TWICE = True +ACCOUNT_TEMPLATE_EXTENSION = "jinja" # https://django-allauth.readthedocs.io/en/latest/forms.html#account-forms ACCOUNT_FORMS = { diff --git a/sampleapp/config/settings/local.py b/sampleapp/config/settings/local.py index a1fa964..f986f16 100644 --- a/sampleapp/config/settings/local.py +++ b/sampleapp/config/settings/local.py @@ -72,13 +72,15 @@ # https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#internal-ips INTERNAL_IPS = ["127.0.0.1", "10.0.2.2"] - +""" +Only use in some dev conditions class InvalidVariable(str): def __bool__(self): return False TEMPLATES[0]["OPTIONS"]["string_if_invalid"] = InvalidVariable("BAD TEMPLATE VARIABLE: %s") +""" import sys TESTING = sys.argv[1:2] == ["test"] diff --git a/sampleapp/jinja2/403.html b/sampleapp/dtl/403.html similarity index 100% rename from sampleapp/jinja2/403.html rename to sampleapp/dtl/403.html diff --git a/sampleapp/jinja2/404.html b/sampleapp/dtl/404.html similarity index 100% rename from sampleapp/jinja2/404.html rename to sampleapp/dtl/404.html diff --git a/sampleapp/jinja2/500.html b/sampleapp/dtl/500.html similarity index 100% rename from sampleapp/jinja2/500.html rename to sampleapp/dtl/500.html diff --git a/sampleapp/templates/account/account_inactive.html b/sampleapp/dtl/account/account_inactive.html similarity index 100% rename from sampleapp/templates/account/account_inactive.html rename to sampleapp/dtl/account/account_inactive.html diff --git a/sampleapp/templates/account/components/account_box.html b/sampleapp/dtl/account/components/account_box.html similarity index 100% rename from sampleapp/templates/account/components/account_box.html rename to sampleapp/dtl/account/components/account_box.html diff --git a/sampleapp/templates/account/components/login_box.html b/sampleapp/dtl/account/components/login_box.html similarity index 100% rename from sampleapp/templates/account/components/login_box.html rename to sampleapp/dtl/account/components/login_box.html diff --git a/sampleapp/templates/account/components/signup_box.html b/sampleapp/dtl/account/components/signup_box.html similarity index 100% rename from sampleapp/templates/account/components/signup_box.html rename to sampleapp/dtl/account/components/signup_box.html diff --git a/sampleapp/templates/account/components/welcome_box.html b/sampleapp/dtl/account/components/welcome_box.html similarity index 100% rename from sampleapp/templates/account/components/welcome_box.html rename to sampleapp/dtl/account/components/welcome_box.html diff --git a/sampleapp/dtl/account/email/base_message.txt b/sampleapp/dtl/account/email/base_message.txt new file mode 100644 index 0000000..9a5aa38 --- /dev/null +++ b/sampleapp/dtl/account/email/base_message.txt @@ -0,0 +1,8 @@ + +{% load i18n %}{% autoescape off %}{% blocktrans with site_name=current_site.name %}Hello from {{ site_name }}!{% endblocktrans %} + +{% block content %}{% endblock %} + +{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Thank you for using {{ site_name }}! +{{ site_domain }}{% endblocktrans %} +{% endautoescape %} \ No newline at end of file diff --git a/sampleapp/dtl/account/email/email_confirmation_message.txt b/sampleapp/dtl/account/email/email_confirmation_message.txt new file mode 100644 index 0000000..c1b0a25 --- /dev/null +++ b/sampleapp/dtl/account/email/email_confirmation_message.txt @@ -0,0 +1,8 @@ + +{% extends "account/email/base_message.txt" %} +{% load account %} +{% load i18n %} + +{% block content %}{% autoescape off %}{% user_display user as user_display %}{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}You're receiving this e-mail because user {{ user_display }} has given your e-mail address to register an account on {{ site_domain }}. + +To confirm this is correct, go to {{ activate_url }}{% endblocktrans %}{% endautoescape %}{% endblock %} \ No newline at end of file diff --git a/sampleapp/dtl/account/email/email_confirmation_signup_message.txt b/sampleapp/dtl/account/email/email_confirmation_signup_message.txt new file mode 100644 index 0000000..7dfb5da --- /dev/null +++ b/sampleapp/dtl/account/email/email_confirmation_signup_message.txt @@ -0,0 +1,2 @@ + +{% include "account/email/email_confirmation_message.txt" %} \ No newline at end of file diff --git a/sampleapp/dtl/account/email/email_confirmation_signup_subject.txt b/sampleapp/dtl/account/email/email_confirmation_signup_subject.txt new file mode 100644 index 0000000..2570bdd --- /dev/null +++ b/sampleapp/dtl/account/email/email_confirmation_signup_subject.txt @@ -0,0 +1,2 @@ + +{% include "account/email/email_confirmation_subject.txt" %} \ No newline at end of file diff --git a/sampleapp/dtl/account/email/email_confirmation_subject.txt b/sampleapp/dtl/account/email/email_confirmation_subject.txt new file mode 100644 index 0000000..165979c --- /dev/null +++ b/sampleapp/dtl/account/email/email_confirmation_subject.txt @@ -0,0 +1,5 @@ + +{% load i18n %} +{% autoescape off %} +{% blocktrans %}Please Confirm Your E-mail Address{% endblocktrans %} +{% endautoescape %} \ No newline at end of file diff --git a/sampleapp/dtl/account/email/password_reset_key_message.txt b/sampleapp/dtl/account/email/password_reset_key_message.txt new file mode 100644 index 0000000..7982dc2 --- /dev/null +++ b/sampleapp/dtl/account/email/password_reset_key_message.txt @@ -0,0 +1,10 @@ + +{% extends "account/email/base_message.txt" %} +{% load i18n %} + +{% block content %}{% autoescape off %}{% blocktrans %}You're receiving this e-mail because you or someone else has requested a password for your user account. +It can be safely ignored if you did not request a password reset. Click the link below to reset your password.{% endblocktrans %} + +{{ password_reset_url }}{% if username %} + +{% blocktrans %}In case you forgot, your username is {{ username }}.{% endblocktrans %}{% endif %}{% endautoescape %}{% endblock %} \ No newline at end of file diff --git a/sampleapp/dtl/account/email/password_reset_key_subject.txt b/sampleapp/dtl/account/email/password_reset_key_subject.txt new file mode 100644 index 0000000..c553733 --- /dev/null +++ b/sampleapp/dtl/account/email/password_reset_key_subject.txt @@ -0,0 +1,5 @@ + +{% load i18n %} +{% autoescape off %} +{% blocktrans %}Password Reset E-mail{% endblocktrans %} +{% endautoescape %} \ No newline at end of file diff --git a/sampleapp/dtl/account/email/unknown_account_message.txt b/sampleapp/dtl/account/email/unknown_account_message.txt new file mode 100644 index 0000000..f3d08be --- /dev/null +++ b/sampleapp/dtl/account/email/unknown_account_message.txt @@ -0,0 +1,13 @@ + +{% extends "account/email/base_message.txt" %} +{% load i18n %} + +{% block content %}{% autoescape off %}{% blocktrans %}You are receiving this e-mail because you or someone else has requested a +password for your user account. However, we do not have any record of a user +with email {{ email }} in our database. + +This mail can be safely ignored if you did not request a password reset. + +If it was you, you can sign up for an account using the link below.{% endblocktrans %} + +{{ signup_url }}{% endautoescape %}{% endblock %} \ No newline at end of file diff --git a/sampleapp/dtl/account/email/unknown_account_subject.txt b/sampleapp/dtl/account/email/unknown_account_subject.txt new file mode 100644 index 0000000..c553733 --- /dev/null +++ b/sampleapp/dtl/account/email/unknown_account_subject.txt @@ -0,0 +1,5 @@ + +{% load i18n %} +{% autoescape off %} +{% blocktrans %}Password Reset E-mail{% endblocktrans %} +{% endautoescape %} \ No newline at end of file diff --git a/sampleapp/templates/account/login.html b/sampleapp/dtl/account/login.html similarity index 100% rename from sampleapp/templates/account/login.html rename to sampleapp/dtl/account/login.html diff --git a/sampleapp/templates/account/login_form.html b/sampleapp/dtl/account/login_form.html similarity index 100% rename from sampleapp/templates/account/login_form.html rename to sampleapp/dtl/account/login_form.html diff --git a/sampleapp/templates/account/logout.html b/sampleapp/dtl/account/logout.html similarity index 100% rename from sampleapp/templates/account/logout.html rename to sampleapp/dtl/account/logout.html diff --git a/sampleapp/templates/account/password_reset.html b/sampleapp/dtl/account/password_reset.html similarity index 100% rename from sampleapp/templates/account/password_reset.html rename to sampleapp/dtl/account/password_reset.html diff --git a/sampleapp/templates/account/password_reset_done.html b/sampleapp/dtl/account/password_reset_done.html similarity index 100% rename from sampleapp/templates/account/password_reset_done.html rename to sampleapp/dtl/account/password_reset_done.html diff --git a/sampleapp/templates/account/password_reset_from_key.html b/sampleapp/dtl/account/password_reset_from_key.html similarity index 100% rename from sampleapp/templates/account/password_reset_from_key.html rename to sampleapp/dtl/account/password_reset_from_key.html diff --git a/sampleapp/templates/account/password_reset_from_key_done.html b/sampleapp/dtl/account/password_reset_from_key_done.html similarity index 100% rename from sampleapp/templates/account/password_reset_from_key_done.html rename to sampleapp/dtl/account/password_reset_from_key_done.html diff --git a/sampleapp/templates/account/password_set.html b/sampleapp/dtl/account/password_set.html similarity index 100% rename from sampleapp/templates/account/password_set.html rename to sampleapp/dtl/account/password_set.html diff --git a/sampleapp/templates/account/signup.html b/sampleapp/dtl/account/signup.html similarity index 100% rename from sampleapp/templates/account/signup.html rename to sampleapp/dtl/account/signup.html diff --git a/sampleapp/templates/account/signup_form.html b/sampleapp/dtl/account/signup_form.html similarity index 100% rename from sampleapp/templates/account/signup_form.html rename to sampleapp/dtl/account/signup_form.html diff --git a/sampleapp/templates/account/welcome.html b/sampleapp/dtl/account/welcome.html similarity index 100% rename from sampleapp/templates/account/welcome.html rename to sampleapp/dtl/account/welcome.html diff --git a/sampleapp/templates/base.html b/sampleapp/dtl/base.html similarity index 100% rename from sampleapp/templates/base.html rename to sampleapp/dtl/base.html diff --git a/sampleapp/templates/components/button.html b/sampleapp/dtl/components/button.html similarity index 100% rename from sampleapp/templates/components/button.html rename to sampleapp/dtl/components/button.html diff --git a/sampleapp/templates/components/menu.html b/sampleapp/dtl/components/menu.html similarity index 100% rename from sampleapp/templates/components/menu.html rename to sampleapp/dtl/components/menu.html diff --git a/sampleapp/jinja2/current_time.html b/sampleapp/dtl/current_time.html similarity index 100% rename from sampleapp/jinja2/current_time.html rename to sampleapp/dtl/current_time.html diff --git a/sampleapp/jinja2/forms/checkbox.html b/sampleapp/dtl/django/forms/checkbox.html similarity index 100% rename from sampleapp/jinja2/forms/checkbox.html rename to sampleapp/dtl/django/forms/checkbox.html diff --git a/sampleapp/jinja2/forms/default.html b/sampleapp/dtl/django/forms/default.html similarity index 100% rename from sampleapp/jinja2/forms/default.html rename to sampleapp/dtl/django/forms/default.html diff --git a/sampleapp/jinja2/forms/errors/list/default.html b/sampleapp/dtl/django/forms/errors/list/default.html similarity index 100% rename from sampleapp/jinja2/forms/errors/list/default.html rename to sampleapp/dtl/django/forms/errors/list/default.html diff --git a/sampleapp/jinja2/forms/inputgroup.html b/sampleapp/dtl/django/forms/inputgroup.html similarity index 100% rename from sampleapp/jinja2/forms/inputgroup.html rename to sampleapp/dtl/django/forms/inputgroup.html diff --git a/sampleapp/jinja2/forms/label.html b/sampleapp/dtl/django/forms/label.html similarity index 100% rename from sampleapp/jinja2/forms/label.html rename to sampleapp/dtl/django/forms/label.html diff --git a/sampleapp/jinja2/forms/widgets/input.html b/sampleapp/dtl/django/forms/widgets/input.html similarity index 100% rename from sampleapp/jinja2/forms/widgets/input.html rename to sampleapp/dtl/django/forms/widgets/input.html diff --git a/sampleapp/jinja2/forms/widgets/password.html b/sampleapp/dtl/django/forms/widgets/password.html similarity index 100% rename from sampleapp/jinja2/forms/widgets/password.html rename to sampleapp/dtl/django/forms/widgets/password.html diff --git a/sampleapp/jinja2/footer.html b/sampleapp/dtl/footer.html similarity index 100% rename from sampleapp/jinja2/footer.html rename to sampleapp/dtl/footer.html diff --git a/sampleapp/jinja2/header/base.html b/sampleapp/dtl/header/base.html similarity index 100% rename from sampleapp/jinja2/header/base.html rename to sampleapp/dtl/header/base.html diff --git a/sampleapp/jinja2/header/desktop_center.html b/sampleapp/dtl/header/desktop_center.html similarity index 100% rename from sampleapp/jinja2/header/desktop_center.html rename to sampleapp/dtl/header/desktop_center.html diff --git a/sampleapp/templates/header/end.html b/sampleapp/dtl/header/end.html similarity index 100% rename from sampleapp/templates/header/end.html rename to sampleapp/dtl/header/end.html diff --git a/sampleapp/templates/header/logo.html b/sampleapp/dtl/header/logo.html similarity index 100% rename from sampleapp/templates/header/logo.html rename to sampleapp/dtl/header/logo.html diff --git a/sampleapp/jinja2/header/mobile_menu.html b/sampleapp/dtl/header/mobile_menu.html similarity index 100% rename from sampleapp/jinja2/header/mobile_menu.html rename to sampleapp/dtl/header/mobile_menu.html diff --git a/sampleapp/jinja2/header/mobile_menu_button.html b/sampleapp/dtl/header/mobile_menu_button.html similarity index 100% rename from sampleapp/jinja2/header/mobile_menu_button.html rename to sampleapp/dtl/header/mobile_menu_button.html diff --git a/sampleapp/jinja2/index.html b/sampleapp/dtl/index.html similarity index 100% rename from sampleapp/jinja2/index.html rename to sampleapp/dtl/index.html diff --git a/sampleapp/jinja2/util/messages.html b/sampleapp/dtl/util/messages.html similarity index 100% rename from sampleapp/jinja2/util/messages.html rename to sampleapp/dtl/util/messages.html diff --git a/sampleapp/jinja2/util/social.html b/sampleapp/dtl/util/social.html similarity index 100% rename from sampleapp/jinja2/util/social.html rename to sampleapp/dtl/util/social.html diff --git a/sampleapp/home/urls.py b/sampleapp/home/urls.py index 3ccb8ef..1ed26ee 100644 --- a/sampleapp/home/urls.py +++ b/sampleapp/home/urls.py @@ -4,9 +4,9 @@ from .views import current_time, error urlpatterns = [ - path("jinja/", TemplateView.as_view(template_name="jinja.html"), name="jinja"), - path("jinja2/", TemplateView.as_view(template_name="jinja2.html"), name="jinja2"), + path("jinja/", TemplateView.as_view(template_name="jinja.jinja"), name="jinja"), + path("jinja2/", TemplateView.as_view(template_name="jinja2.jinja"), name="jinja2"), path(r"current-time/", current_time, name="current_time"), path(r"error/", error, name="error"), - path(r"", TemplateView.as_view(template_name="index.html"), name="home"), + path(r"", TemplateView.as_view(template_name="index.jinja"), name="home"), ] diff --git a/sampleapp/jinja2/header/end.html b/sampleapp/jinja2/header/end.html deleted file mode 100644 index c7795fd..0000000 --- a/sampleapp/jinja2/header/end.html +++ /dev/null @@ -1,55 +0,0 @@ -{% from 'components/menu.html' import menu %} -{% from 'components/button.html' import button %} -{% if not request.user.is_authenticated %} - -{% else %} - -{% endif %} diff --git a/sampleapp/templates/403.html b/sampleapp/templates/403.jinja similarity index 91% rename from sampleapp/templates/403.html rename to sampleapp/templates/403.jinja index 9e4f087..a3f001f 100644 --- a/sampleapp/templates/403.html +++ b/sampleapp/templates/403.jinja @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "base.jinja" %} {% block title %} Forbidden (403) {% endblock title %} diff --git a/sampleapp/templates/404.html b/sampleapp/templates/404.jinja similarity index 91% rename from sampleapp/templates/404.html rename to sampleapp/templates/404.jinja index 3d58ae4..cd02ab9 100644 --- a/sampleapp/templates/404.html +++ b/sampleapp/templates/404.jinja @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "base.jinja" %} {% block title %} Page not found {% endblock title %} diff --git a/sampleapp/templates/500.html b/sampleapp/templates/500.jinja similarity index 92% rename from sampleapp/templates/500.html rename to sampleapp/templates/500.jinja index 986b837..be36ba0 100644 --- a/sampleapp/templates/500.html +++ b/sampleapp/templates/500.jinja @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "base.jinja" %} {% block title %} Server Error {% endblock title %} diff --git a/sampleapp/templates/account/account_inactive.jinja b/sampleapp/templates/account/account_inactive.jinja new file mode 100644 index 0000000..98dd80f --- /dev/null +++ b/sampleapp/templates/account/account_inactive.jinja @@ -0,0 +1,11 @@ +{% extends "base.jinja" %} +{# {% load i18n %} #} +{% block head_title %} + {% trans "Account Inactive" %} +{% endblock head_title %} +{% block content %} +

    {% trans "Account Inactive" %}

    +

    + {% trans "This account is inactive." %} +

    +{% endblock content %} diff --git a/sampleapp/templates/account/components/account_box.jinja b/sampleapp/templates/account/components/account_box.jinja new file mode 100644 index 0000000..ca798b7 --- /dev/null +++ b/sampleapp/templates/account/components/account_box.jinja @@ -0,0 +1,28 @@ +
    +
    + {% slot "back" %} + + + + + + {% endslot %} + logo +

    {% slot "title" %}{% endslot %}

    + {% slot "content" %}{% endslot %} +
    +
    diff --git a/sampleapp/templates/account/components/login_box.jinja b/sampleapp/templates/account/components/login_box.jinja new file mode 100644 index 0000000..770fc30 --- /dev/null +++ b/sampleapp/templates/account/components/login_box.jinja @@ -0,0 +1,67 @@ +{% component_block "account_box" %} +{% slot title %} +Welcome back, {{ user.first_name }}! +{% endslot title %} +{% slot content %} +
    + {{ form }} + {% csrf_token %} + +
    +
    +
    +
    +
    +
    + Or +
    +
    + +{% endslot content %} +{% endcomponent_block %} diff --git a/sampleapp/templates/account/components/signup_box.jinja b/sampleapp/templates/account/components/signup_box.jinja new file mode 100644 index 0000000..8c88221 --- /dev/null +++ b/sampleapp/templates/account/components/signup_box.jinja @@ -0,0 +1,67 @@ +{% component_block "account_box" %} +{% slot title %} +Sign up +{% endslot title %} +{% slot content %} +
    +
    {{ form }}
    + + {% csrf_token %} +
    +
    +
    +
    +
    +
    + Or +
    +
    + +{% endslot content %} +{% endcomponent_block %} diff --git a/sampleapp/templates/account/components/welcome_box.jinja b/sampleapp/templates/account/components/welcome_box.jinja new file mode 100644 index 0000000..b621378 --- /dev/null +++ b/sampleapp/templates/account/components/welcome_box.jinja @@ -0,0 +1,67 @@ +{% component_block "account_box" %} +{% slot title %} +Log in/Sign up +{% endslot title %} +{% slot back %} {% endslot back %} +{% slot content %} +
    + {{ form }} + +
    +
    +
    +
    +
    +
    + Or +
    +
    + +{% endslot content %} +{% endcomponent_block %} diff --git a/sampleapp/templates/account/login.jinja b/sampleapp/templates/account/login.jinja new file mode 100644 index 0000000..5e38f6a --- /dev/null +++ b/sampleapp/templates/account/login.jinja @@ -0,0 +1 @@ +{% component "login_box" %} diff --git a/sampleapp/templates/account/login_form.jinja b/sampleapp/templates/account/login_form.jinja new file mode 100644 index 0000000..37b3f41 --- /dev/null +++ b/sampleapp/templates/account/login_form.jinja @@ -0,0 +1,12 @@ +
    + {{ errors }} + {% for field, errors in fields %} + {% if field.name == 'remember' %} + {% include "django/forms/checkbox.jinja" with field=field errors=errors %} + {% else %} + {% include "django/forms/inputgroup.jinja" with field=field errors=errors %} + {% endif %} + {% endfor %} + Forgot your password? + {% for field in hidden_fields %}{{ field }}{% endfor %} +
    diff --git a/sampleapp/templates/account/logout.jinja b/sampleapp/templates/account/logout.jinja new file mode 100644 index 0000000..70eea1d --- /dev/null +++ b/sampleapp/templates/account/logout.jinja @@ -0,0 +1,19 @@ +{% extends "base.jinja" %} +{% block head_title %} + {% trans "Sign Out" %} +{% endblock head_title %} +{% block content %} +

    {% trans "Sign Out" %}

    +

    + {% trans 'Are you sure you want to sign out?' %} +

    +
    + {% csrf_token %} + {% if redirect_field_value %} + + {% endif %} + +
    +{% endblock content %} diff --git a/sampleapp/templates/account/password_reset.jinja b/sampleapp/templates/account/password_reset.jinja new file mode 100644 index 0000000..0860dbe --- /dev/null +++ b/sampleapp/templates/account/password_reset.jinja @@ -0,0 +1,23 @@ +{% extends "base.jinja" %} +{% block head_title %} + {% trans "Password Reset" %} +{% endblock head_title %} +{% block content %} +

    {% trans "Password Reset" %}

    + {% if user.is_authenticated %} + {% include "account/snippets/already_logged_in.html" %} + {% endif %} +

    + {% trans "Forgotten your password? Enter your e-mail address below, and we'll send you an e-mail allowing you to reset it." %} +

    +
    + {% csrf_token %} + {{ form.as_p }} + +
    +

    + {% blocktrans %}Please contact us if you have any trouble resetting your password.{% endblocktrans %} +

    +{% endblock content %} diff --git a/sampleapp/templates/account/password_reset_done.jinja b/sampleapp/templates/account/password_reset_done.jinja new file mode 100644 index 0000000..955d66e --- /dev/null +++ b/sampleapp/templates/account/password_reset_done.jinja @@ -0,0 +1,13 @@ +{% extends "base.jinja" %} +{% block head_title %} + {% trans "Password Reset" %} +{% endblock head_title %} +{% block content %} +

    {% trans "Password Reset" %}

    + {% if user.is_authenticated %} + {% include "account/snippets/already_logged_in.html" %} + {% endif %} +

    + {% blocktrans %}We have sent you an e-mail. If you have not received it please check your spam folder. Otherwise contact us if you do not receive it in a few minutes.{% endblocktrans %} +

    +{% endblock content %} diff --git a/sampleapp/templates/account/password_reset_from_key.jinja b/sampleapp/templates/account/password_reset_from_key.jinja new file mode 100644 index 0000000..c69110d --- /dev/null +++ b/sampleapp/templates/account/password_reset_from_key.jinja @@ -0,0 +1,25 @@ +{% extends "base.jinja" %} +{% block head_title %} + {% trans "Change Password" %} +{% endblock head_title %} +{% block content %} +

    + {% if token_fail %} + {% trans "Bad Token" %} + {% else %} + {% trans "Change Password" %} + {% endif %} +

    + {% if token_fail %} + {% url 'account_reset_password' as passwd_reset_url %} +

    + {% blocktrans %}The password reset link was invalid, possibly because it has already been used. Please request a new password reset.{% endblocktrans %} +

    + {% else %} +
    + {% csrf_token %} + {{ form.as_p }} + +
    + {% endif %} +{% endblock content %} diff --git a/sampleapp/templates/account/password_reset_from_key_done.jinja b/sampleapp/templates/account/password_reset_from_key_done.jinja new file mode 100644 index 0000000..4a8410a --- /dev/null +++ b/sampleapp/templates/account/password_reset_from_key_done.jinja @@ -0,0 +1,10 @@ +{% extends "base.jinja" %} +{% block head_title %} + {% trans "Change Password" %} +{% endblock head_title %} +{% block content %} +

    {% trans "Change Password" %}

    +

    + {% trans 'Your password is now changed.' %} +

    +{% endblock content %} diff --git a/sampleapp/templates/account/password_set.jinja b/sampleapp/templates/account/password_set.jinja new file mode 100644 index 0000000..82a38b1 --- /dev/null +++ b/sampleapp/templates/account/password_set.jinja @@ -0,0 +1,14 @@ +{% extends "base.jinja" %} +{% block head_title %} + {% trans "Set Password" %} +{% endblock head_title %} +{% block content %} +

    {% trans "Set Password" %}

    +
    + {% csrf_token %} + {{ form.as_p }} + +
    +{% endblock content %} diff --git a/sampleapp/templates/account/signup.jinja b/sampleapp/templates/account/signup.jinja new file mode 100644 index 0000000..a7a4c96 --- /dev/null +++ b/sampleapp/templates/account/signup.jinja @@ -0,0 +1,62 @@ +{% component_block "account_box" %} +{% slot title %} +Sign up +{% endslot title %} +{% slot content %} +
    +
    {{ form }}
    + + {% csrf_token %} +
    +
    +
    +
    +
    +
    + Or +
    +
    + +{% endslot content %} +{% endcomponent_block %} diff --git a/sampleapp/templates/account/signup_form.jinja b/sampleapp/templates/account/signup_form.jinja new file mode 100644 index 0000000..fecc626 --- /dev/null +++ b/sampleapp/templates/account/signup_form.jinja @@ -0,0 +1,11 @@ +
    + {{ errors }} + {% for field, errors in fields %} + {% if field.name == 'first_name' or field.name == 'last_name' %} + {% include "django/forms/inputgroup.jinja" with field=field errors=errors layout_classes="w-5/12" %} + {% else %} + {% include "django/forms/inputgroup.jinja" with field=field errors=errors %} + {% endif %} + {% endfor %} + {% for field in hidden_fields %}{{ field }}{% endfor %} +
    diff --git a/sampleapp/templates/account/welcome.jinja b/sampleapp/templates/account/welcome.jinja new file mode 100644 index 0000000..c443efa --- /dev/null +++ b/sampleapp/templates/account/welcome.jinja @@ -0,0 +1,9 @@ +{% extends "base.jinja" %} +{% block head_title %} + {% trans %} + Sign In +{% endtrans %} +{% endblock head_title %} +{% block content %} +
    {% component "welcome_box" %}
    +{% endblock content %} diff --git a/sampleapp/jinja2/base.html b/sampleapp/templates/base.jinja similarity index 85% rename from sampleapp/jinja2/base.html rename to sampleapp/templates/base.jinja index 13cc47f..59881df 100644 --- a/sampleapp/jinja2/base.html +++ b/sampleapp/templates/base.jinja @@ -6,28 +6,25 @@ - + {{ vite_hmr_client() }} {{ vite_asset('js/main.ts') }} - {# - {{ load(django_htmx) }} - {{ django_htmx_script }} - #} + {{ django_htmx_script() }} {% block extra_head %} Lightmatter {% endblock extra_head %} - {% include "header/base.html" %} + {% include "header/base.jinja" %}
    {% block content %} {% endblock content %}
      - {% include "util/messages.html" %} + {% include "util/messages.jinja" %}
    - {% include "footer.html" %} + {% include "footer.jinja" %} + + From 880aa70025e3921dead686a07cc598fe3b62fe15 Mon Sep 17 00:00:00 2001 From: Aidan Gerber Date: Tue, 17 May 2022 11:01:53 -0700 Subject: [PATCH 18/50] work on consistent styling --- sampleapp/templates/account/logout.jinja | 14 ++++++++------ sampleapp/templates/account/password_reset.jinja | 3 ++- sampleapp/templates/components/button.jinja | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/sampleapp/templates/account/logout.jinja b/sampleapp/templates/account/logout.jinja index 3b9ce1f..1625326 100644 --- a/sampleapp/templates/account/logout.jinja +++ b/sampleapp/templates/account/logout.jinja @@ -1,3 +1,6 @@ +{% from 'account/components/account_box.jinja' import account_box %} +{% from 'django/forms/inputgroup.jinja' import inputgroup %} +{% from 'components/button.jinja' import button %} {% extends "base.jinja" %} {% block head_title %} {% trans %} @@ -5,8 +8,9 @@ {% endtrans %} {% endblock head_title %} {% block content %} + {% set title="Sign Out" %} + {% set content %} {% trans %} -

    Sign Out

    Are you sure you want to sign out?

    @@ -18,10 +22,8 @@ name="{{ redirect_field_name }}" value="{{ redirect_field_value }}"/> {% endif %} - + {{ button("Sign Out", 'submit') }} +{% endset %} +{{ account_box(title, content, back='') }} {% endblock content %} diff --git a/sampleapp/templates/account/password_reset.jinja b/sampleapp/templates/account/password_reset.jinja index aaf59f5..77b7d2b 100644 --- a/sampleapp/templates/account/password_reset.jinja +++ b/sampleapp/templates/account/password_reset.jinja @@ -1,5 +1,6 @@ {% from 'django/forms/inputgroup.jinja' import inputgroup %} {% from 'account/components/account_box.jinja' import account_box %} +{% from 'components/button.jinja' import button %} {% extends "base.jinja" %} {% block head_title %} {% trans %} @@ -22,7 +23,7 @@ class="password_reset"> {% csrf_token %} {{ inputgroup(form) }} - + {{ button("Reset My Password", 'submit') }}

    {% trans %} diff --git a/sampleapp/templates/components/button.jinja b/sampleapp/templates/components/button.jinja index aae2389..943c610 100644 --- a/sampleapp/templates/components/button.jinja +++ b/sampleapp/templates/components/button.jinja @@ -1,5 +1,5 @@ -{% macro button(button_content='Button') %} - From 4e350b03c3775e335140d38e9ed3abd329efe6d8 Mon Sep 17 00:00:00 2001 From: Aidan Gerber Date: Tue, 17 May 2022 11:08:31 -0700 Subject: [PATCH 19/50] reformat jinja files --- .pre-commit-config.yaml | 2 +- sampleapp/templates/account/login_form.jinja | 5 +- .../templates/account/password_reset.jinja | 46 +++++++++---------- .../account/password_reset_from_key.jinja | 1 - sampleapp/templates/components/menu.jinja | 12 ++--- .../templates/django/forms/inputgroup.jinja | 2 +- sampleapp/templates/django/forms/label.jinja | 16 +++---- sampleapp/templates/footer.jinja | 1 - sampleapp/templates/header/mobile_menu.jinja | 2 +- sampleapp/templates/index.jinja | 14 ++---- sampleapp/templates/random_chart.jinja | 5 +- sampleapp/templates/svg/svg.jinja | 3 +- 12 files changed, 49 insertions(+), 60 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d29d377..d19c859 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,7 +42,7 @@ repos: name: djlint entry: poetry run djlint --reformat language: system - types_or: [html] + types_or: [html,jinja] ## system - repo: https://github.com/asottile/pyupgrade diff --git a/sampleapp/templates/account/login_form.jinja b/sampleapp/templates/account/login_form.jinja index 031669c..361f3cf 100644 --- a/sampleapp/templates/account/login_form.jinja +++ b/sampleapp/templates/account/login_form.jinja @@ -1,6 +1,5 @@ {% from 'django/forms/inputgroup.jinja' import inputgroup %} {% from 'django/forms/checkbox.jinja' import checkbox %} -

    {{ errors }} {% for field, errors in fields %} @@ -10,6 +9,8 @@ {{ inputgroup(field, errors) }} {% endif %} {% endfor %} - Forgot your password? + Forgot your password? {% for field in hidden_fields %}{{ field }}{% endfor %}
    diff --git a/sampleapp/templates/account/password_reset.jinja b/sampleapp/templates/account/password_reset.jinja index 77b7d2b..dd4ce17 100644 --- a/sampleapp/templates/account/password_reset.jinja +++ b/sampleapp/templates/account/password_reset.jinja @@ -4,32 +4,32 @@ {% extends "base.jinja" %} {% block head_title %} {% trans %} - Reset Password - {% endtrans %} + Reset Password +{% endtrans %} {% endblock head_title %} {% block content %} {% set title="Reset Password" %} {% set content %} - {% if request.user.is_authenticated %} - {% include "account/snippets/already_logged_in.jinja" %} - {% endif %} -

    - {% trans %} - Forgotten your password? Enter your e-mail address below, and we'll send you an e-mail allowing you to reset it. - {% endtrans %} -

    -
    - {% csrf_token %} - {{ inputgroup(form) }} - {{ button("Reset My Password", 'submit') }} -
    -

    - {% trans %} - Please contact us if you have any trouble resetting your password. - {% endtrans %} -

    - {% endset %} + {% if request.user.is_authenticated %} + {% include "account/snippets/already_logged_in.jinja" %} + {% endif %} +

    + {% trans %} + Forgotten your password? Enter your e-mail address below, and we'll send you an e-mail allowing you to reset it. + {% endtrans %} +

    +
    + {% csrf_token %} + {{ inputgroup(form) }} + {{ button("Reset My Password", 'submit') }} +
    +

    + {% trans %} + Please contact us if you have any trouble resetting your password. +{% endtrans %} +

    +{% endset %} {{ account_box(title, content, back='') }} {% endblock content %} diff --git a/sampleapp/templates/account/password_reset_from_key.jinja b/sampleapp/templates/account/password_reset_from_key.jinja index 4f43ed8..c2f0e16 100644 --- a/sampleapp/templates/account/password_reset_from_key.jinja +++ b/sampleapp/templates/account/password_reset_from_key.jinja @@ -1,5 +1,4 @@ {% from 'django/forms/inputgroup.jinja' import inputgroup %} - {% extends "base.jinja" %} {% block head_title %} {% trans %} diff --git a/sampleapp/templates/components/menu.jinja b/sampleapp/templates/components/menu.jinja index 2cf6067..b14917d 100644 --- a/sampleapp/templates/components/menu.jinja +++ b/sampleapp/templates/components/menu.jinja @@ -19,12 +19,12 @@ class="relative"> + @click="toggle()" + :aria-expanded="open" + :aria-controls="$id('dropdown-button')" + type="button" + :class="open ? 'text-gray-900' : 'text-gray-500'" + class="{{ button_style }}"> {{ button }}