From 0c1e51322f25a1074c30dc29a5e24e1878e65c0a Mon Sep 17 00:00:00 2001 From: TAKAHASHI Shuuji Date: Tue, 10 Jan 2023 01:58:17 +0900 Subject: [PATCH] Add djhtml to pre-commit check (#382) --- .pre-commit-config.yaml | 7 + docs/_templates/sidebar/brand.html | 24 +- templates/activities/_event.html | 6 +- templates/activities/_hashtag.html | 6 +- templates/activities/_identity.html | 6 +- templates/activities/_image_upload.html | 12 +- templates/activities/_image_uploaded.html | 14 +- templates/activities/_image_viewer.html | 2 + templates/activities/_menu.html | 6 +- templates/activities/_post.html | 150 +++++------ templates/activities/_type_question.html | 18 +- templates/activities/debug_json.html | 110 ++++---- templates/activities/explore_tag.html | 16 +- templates/activities/follows.html | 48 ++-- templates/activities/search.html | 12 +- templates/admin/domain_delete.html | 2 +- templates/admin/hashtag_edit.html | 22 +- templates/admin/hashtags.html | 52 ++-- templates/admin/identities.html | 16 +- templates/admin/identity_edit.html | 16 +- templates/admin/user_edit.html | 6 +- templates/base.html | 176 ++++++------- templates/emails/_body_content.html | 2 +- templates/emails/_button.html | 26 +- templates/emails/_footer.html | 10 +- templates/emails/account_new.html | 36 +-- templates/emails/base.html | 288 ++++++++++----------- templates/emails/password_reset.html | 36 +-- templates/emails/report_new.html | 46 ++-- templates/forms/_field.html | 6 +- templates/forms/_json_name_value_list.html | 132 +++++----- templates/identity/_identity_banner.html | 56 ++-- templates/identity/_menu.html | 8 +- templates/identity/_view_menu.html | 68 ++--- templates/identity/create.html | 2 +- templates/identity/view.html | 24 +- templates/settings/_menu.html | 70 ++--- templates/settings/login_security.html | 2 +- 38 files changed, 776 insertions(+), 763 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 400f20c1..f01c0006 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -55,3 +55,10 @@ repos: types-cachetools, types-python-dateutil, ] + + - repo: https://github.com/rtts/djhtml + rev: v1.5.2 + hooks: + - id: djhtml + - id: djcss + - id: djjs diff --git a/docs/_templates/sidebar/brand.html b/docs/_templates/sidebar/brand.html index 38fd75fc..9869d523 100644 --- a/docs/_templates/sidebar/brand.html +++ b/docs/_templates/sidebar/brand.html @@ -1,18 +1,18 @@ + {% if not event.collapsed %} - {% include "activities/_post.html" with post=event.subject_post %} + {% include "activities/_post.html" with post=event.subject_post %} {% endif %} {% elif event.type == "mentioned" %}
@@ -23,7 +23,7 @@ mentioned you
{% if not event.collapsed %} - {% include "activities/_post.html" with post=event.subject_post %} + {% include "activities/_post.html" with post=event.subject_post %} {% endif %} {% elif event.type == "boosted" %}
@@ -32,7 +32,7 @@ boosted your post
{% if not event.collapsed %} - {% include "activities/_post.html" with post=event.subject_post event=event %} + {% include "activities/_post.html" with post=event.subject_post event=event %} {% endif %} {% else %} Unknown event type {{event.type}} diff --git a/templates/activities/_hashtag.html b/templates/activities/_hashtag.html index 19233e56..02d107af 100644 --- a/templates/activities/_hashtag.html +++ b/templates/activities/_hashtag.html @@ -4,8 +4,8 @@ {{ hashtag.display_name }} {% if not hide_stats %} - - Post count: {{ hashtag.stats.total }} - + + Post count: {{ hashtag.stats.total }} + {% endif %} diff --git a/templates/activities/_identity.html b/templates/activities/_identity.html index 386d5ee0..38a6f7ac 100644 --- a/templates/activities/_identity.html +++ b/templates/activities/_identity.html @@ -4,9 +4,9 @@
{% include "identity/_identity_banner.html" with identity=identity %} {% if created %} - + {% endif %}
diff --git a/templates/activities/_image_upload.html b/templates/activities/_image_upload.html index 974884a3..c812c447 100644 --- a/templates/activities/_image_upload.html +++ b/templates/activities/_image_upload.html @@ -1,10 +1,10 @@
+ hx-encoding='multipart/form-data' + hx-post='{% url "compose_image_upload" %}' + hx-target="this" + hx-swap="outerHTML" + _="on htmx:xhr:progress(loaded, total) + set #attachmentProgress.value to (loaded/total)*100"> {% csrf_token %} {% include "forms/_field.html" with field=form.image %} {% include "forms/_field.html" with field=form.description %} diff --git a/templates/activities/_image_uploaded.html b/templates/activities/_image_uploaded.html index 2d9e5553..e2424ce1 100644 --- a/templates/activities/_image_uploaded.html +++ b/templates/activities/_image_uploaded.html @@ -9,11 +9,11 @@ {% if request.htmx %} - + {% endif %} diff --git a/templates/activities/_image_viewer.html b/templates/activities/_image_viewer.html index 14d9c737..2edbf06b 100644 --- a/templates/activities/_image_viewer.html +++ b/templates/activities/_image_viewer.html @@ -1,4 +1,5 @@
diff --git a/templates/activities/_menu.html b/templates/activities/_menu.html index 9961999e..517ae0da 100644 --- a/templates/activities/_menu.html +++ b/templates/activities/_menu.html @@ -29,9 +29,9 @@

Search {% if current_page == "tag" %} - - {{ hashtag.display_name }} - + + {{ hashtag.display_name }} + {% endif %} Settings diff --git a/templates/activities/_post.html b/templates/activities/_post.html index 4111d352..8848bf8c 100644 --- a/templates/activities/_post.html +++ b/templates/activities/_post.html @@ -3,36 +3,36 @@
- {% include "identity/_identity_banner.html" with identity=post.author %} - + {% include "identity/_identity_banner.html" with identity=post.author %} +
+ +
{% if post.summary %} {% if config_identity.expand_linked_cws %} -
+
{% else %} -
+
{% endif %} - {{ post.summary }} + {{ post.summary }}
{% endif %} @@ -40,65 +40,65 @@ {{ post.safe_content_local }} {% if post.attachments.exists %} -
- {% for attachment in post.attachments.all %} - {% if attachment.is_image %} - - {{ attachment.name|default:'(no description)' }} - - {% elif attachment.is_video %} - - - - {% endif %} - {% endfor %} -
+
+ {% for attachment in post.attachments.all %} + {% if attachment.is_image %} + + {{ attachment.name|default:'(no description)' }} + + {% elif attachment.is_video %} + + + + {% endif %} + {% endfor %} +
{% endif %}
{% if post.edited %} -
- Edited {{ post.edited | timedeltashort }} ago -
+
+ Edited {{ post.edited | timedeltashort }} ago +
{% endif %} {% if request.identity %} - + + + View Post & Replies + + + Report + + {% if post.author == request.identity %} + + Edit + + + Delete + + {% elif not post.local and post.url %} + + See Original + + {% endif %} + {% if request.user.admin %} + + View In Admin + + {% endif %} + +
{% endif %}
diff --git a/templates/activities/_type_question.html b/templates/activities/_type_question.html index 1b7211a7..5754e765 100644 --- a/templates/activities/_type_question.html +++ b/templates/activities/_type_question.html @@ -4,15 +4,15 @@

Options: {% if post.type_data.mode == "oneOf" %}(choose one){% endif %}

-{% for item in post.type_data.options %} -{% if forloop.first %}
    {% endif %}{% widthratio item.votes post.type_data.voter_count 100 as item_percent %} -
  • -{% if forloop.last %}
{% endif %} -{% endfor %} + {% for item in post.type_data.options %} + {% if forloop.first %}
    {% endif %}{% widthratio item.votes post.type_data.voter_count 100 as item_percent %} +
  • + {% if forloop.last %}
{% endif %} + {% endfor %} {% endwith %} diff --git a/templates/identity/_identity_banner.html b/templates/identity/_identity_banner.html index 24b1a4cb..71a69a4a 100644 --- a/templates/identity/_identity_banner.html +++ b/templates/identity/_identity_banner.html @@ -1,33 +1,33 @@ diff --git a/templates/identity/_menu.html b/templates/identity/_menu.html index 9b4854ca..4821b2f4 100644 --- a/templates/identity/_menu.html +++ b/templates/identity/_menu.html @@ -9,9 +9,9 @@ Logout {% if request.user.admin %} -

Administration

- - Domains - +

Administration

+ + Domains + {% endif %} diff --git a/templates/identity/_view_menu.html b/templates/identity/_view_menu.html index 2e0a1001..3edfcc3a 100644 --- a/templates/identity/_view_menu.html +++ b/templates/identity/_view_menu.html @@ -10,44 +10,44 @@ {% endif %}
{% csrf_token %} - {% if follow %} - - - {% else %} - - - {% endif %} + {% if follow %} + + + {% else %} + + + {% endif %}
{% endif %} {% if request.user.admin %} - - - - - {% if follow %} -
- {% csrf_token %} - {% if follow.boosts %} - - - {% else %} - - - {% endif %} -
- {% endif %} - {% if request.user.admin %} - - View in Admin - - - View in djadmin + + - {% endif %} -
- {% endif %} + + {% if follow %} +
+ {% csrf_token %} + {% if follow.boosts %} + + + {% else %} + + + {% endif %} +
+ {% endif %} + {% if request.user.admin %} + + View in Admin + + + View in djadmin + + {% endif %} +
+ {% endif %}
diff --git a/templates/identity/create.html b/templates/identity/create.html index 8afd1d9d..56cb4553 100644 --- a/templates/identity/create.html +++ b/templates/identity/create.html @@ -6,7 +6,7 @@

Create New Identity

You can have multiple identities - they are totally separate, and share - nothing apart from your login details. Use them for alternates, projects, and more.

+ nothing apart from your login details. Use them for alternates, projects, and more.

{% csrf_token %}
Identity Details diff --git a/templates/identity/view.html b/templates/identity/view.html index ed9fa838..3b4122a1 100644 --- a/templates/identity/view.html +++ b/templates/identity/view.html @@ -28,9 +28,9 @@

@{{ identity.handle }} {% if identity.metadata %} {% endif %} {% if identity.local and identity.config_identity.visible_follows %} - + {% endif %} {% if not identity.local %} diff --git a/templates/settings/_menu.html b/templates/settings/_menu.html index 478e5ae4..dfdce665 100644 --- a/templates/settings/_menu.html +++ b/templates/settings/_menu.html @@ -14,42 +14,42 @@

Account

Logout {% if request.user.moderator or request.user.admin %} -

Moderation

- - Identities - - - Invites - - - Hashtags - - - Reports - +

Moderation

+ + Identities + + + Invites + + + Hashtags + + + Reports + {% endif %} {% if request.user.admin %} -

Administration

- - Basic - - - Policies - - - Domains - - - Federation - - - Users - - - Stator - - - Django Admin - +

Administration

+ + Basic + + + Policies + + + Domains + + + Federation + + + Users + + + Stator + + + Django Admin + {% endif %} diff --git a/templates/settings/login_security.html b/templates/settings/login_security.html index 701b3258..9a3b22d8 100644 --- a/templates/settings/login_security.html +++ b/templates/settings/login_security.html @@ -11,7 +11,7 @@

Password -

To change your password, please trigger a password reset. +

To change your password, please trigger a password reset.

{% endblock %}