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 | 114 ++++---- 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 | 290 ++++++++++----------- templates/emails/password_reset.html | 36 +-- templates/emails/report_new.html | 46 ++-- templates/forms/_field.html | 6 +- templates/forms/_json_name_value_list.html | 134 +++++----- 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, 780 insertions(+), 767 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 400f20c..f01c000 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 38fd75f..9869d52 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 19233e5..02d107a 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 386d5ee..38a6f7a 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 974884a..c812c44 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 2d9e555..e2424ce 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 14d9c73..2edbf06 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 9961999..517ae0d 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 4111d35..8848bf8 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 1b7211a..5754e76 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 %}