Add djhtml to pre-commit check (#382)

This commit is contained in:
TAKAHASHI Shuuji 2023-01-10 01:58:17 +09:00 committed by GitHub
parent 024d956e5e
commit 0c1e51322f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 780 additions and 767 deletions

View file

@ -55,3 +55,10 @@ repos:
types-cachetools, types-cachetools,
types-python-dateutil, types-python-dateutil,
] ]
- repo: https://github.com/rtts/djhtml
rev: v1.5.2
hooks:
- id: djhtml
- id: djcss
- id: djjs

View file

@ -12,7 +12,7 @@
</div> </div>
{%- endif %} {%- endif %}
{% endblock brand_content %} {% endblock brand_content %}
</a> </a>
<div class="sidebar-tree" style="margin-top:0"> <div class="sidebar-tree" style="margin-top:0">
<ul> <ul>
<li class="toctree-l1"><a class="reference" href="https://jointakahe.org">Homepage</a></li> <li class="toctree-l1"><a class="reference" href="https://jointakahe.org">Homepage</a></li>

View file

@ -9,11 +9,11 @@
</div> </div>
</div> </div>
{% if request.htmx %} {% if request.htmx %}
<button class="add-image" <button class="add-image"
hx-get='{% url "compose_image_upload" %}' hx-get='{% url "compose_image_upload" %}'
hx-target="this" hx-target="this"
hx-swap="outerHTML" hx-swap="outerHTML"
_="on load if length of <.uploaded-image/> > 3 then hide me"> _="on load if length of <.uploaded-image/> > 3 then hide me">
Add Image Add Image
</button> </button>
{% endif %} {% endif %}

View file

@ -1,4 +1,5 @@
<script type="text/hyperscript"> <script type="text/hyperscript">
{# fmt:off #}
def imageviewer.show(source) def imageviewer.show(source)
set source_url to (<img /> in source) @data-original-url set source_url to (<img /> in source) @data-original-url
set source_alt to (<img /> in source) @alt set source_alt to (<img /> in source) @alt
@ -22,6 +23,7 @@
set <#image-viewer img /> @alt to '' set <#image-viewer img /> @alt to ''
set <#image-viewer figcaption />'s textContent to '' set <#image-viewer figcaption />'s textContent to ''
end end
{# fmt:on #}
</script> </script>
<figure id="image-viewer" _="on click imageviewer.close()"> <figure id="image-viewer" _="on click imageviewer.close()">
<picture> <picture>

View file

@ -4,15 +4,15 @@
<div class="poll"> <div class="poll">
<h3 style="display: none;">Options: {% if post.type_data.mode == "oneOf" %}<small>(choose one)</small>{% endif %}</h3> <h3 style="display: none;">Options: {% if post.type_data.mode == "oneOf" %}<small>(choose one)</small>{% endif %}</h3>
{% for item in post.type_data.options %} {% for item in post.type_data.options %}
{% if forloop.first %}<ul>{% endif %}{% widthratio item.votes post.type_data.voter_count 100 as item_percent %} {% if forloop.first %}<ul>{% endif %}{% widthratio item.votes post.type_data.voter_count 100 as item_percent %}
<li><label class="poll-option"> <li><label class="poll-option">
<input style="display:none" name="vote-options" type="{% if post.type_data.mode == "oneOf" %}radio{% else %}checkbox{% endif %}" value="0"> <input style="display:none" name="vote-options" type="{% if post.type_data.mode == "oneOf" %}radio{% else %}checkbox{% endif %}" value="0">
<span class="poll-number" title="{{ item.votes }} votes">{{ item_percent }}%</span> <span class="poll-number" title="{{ item.votes }} votes">{{ item_percent }}%</span>
<span class="poll-option-text">{{ item.name }}</span> <span class="poll-option-text">{{ item.name }}</span>
</label> </label>
{% if forloop.last %}</ul>{% endif %} {% if forloop.last %}</ul>{% endif %}
{% endfor %} {% endfor %}
<div class="poll-footer"> <div class="poll-footer">
<span class="vote-total">{{ post.type_data.voter_count }} people</span> <span class="vote-total">{{ post.type_data.voter_count }} people</span>
&mdash; &mdash;

View file

@ -60,7 +60,7 @@
</div> </div>
<div id="raw_response" class="hidden"> <div id="raw_response" class="hidden">
{{ raw_result|escape }} {{ raw_result|escape }}
</div> </div>
<div class="field payload"> <div class="field payload">

View file

@ -3,14 +3,14 @@
{% block title %}#{{ hashtag.display_name }} Timeline{% endblock %} {% block title %}#{{ hashtag.display_name }} Timeline{% endblock %}
{% block content %} {% block content %}
<div class="timeline-name">Explore Trending Tags</div> <div class="timeline-name">Explore Trending Tags</div>
<section class="icon-menu"> <section class="icon-menu">
{% for hashtag in page_obj %} {% for hashtag in page_obj %}
{% include "activities/_hashtag.html" %} {% include "activities/_hashtag.html" %}
{% empty %} {% empty %}
No tags are trending yet. No tags are trending yet.
{% endfor %} {% endfor %}
</section> </section>
{% endblock %} {% endblock %}

View file

@ -1,6 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<title>{% block title %}{% endblock %} - {{ config.site_name }}</title> <title>{% block title %}{% endblock %} - {{ config.site_name }}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
@ -31,8 +31,8 @@
{% endblock %} {% endblock %}
{% block extra_head %}{% endblock %} {% block extra_head %}{% endblock %}
{% block custom_head %}{% if config.custom_head %}{{ config.custom_head|safe }}{% endif %}{% endblock %} {% block custom_head %}{% if config.custom_head %}{{ config.custom_head|safe }}{% endif %}{% endblock %}
</head> </head>
<body class="{% block body_class %}{% endblock %}" hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'> <body class="{% block body_class %}{% endblock %}" hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'>
<a id='skip-to-main' class='screenreader-text' href='#main-content'>Skip to Content</a> <a id='skip-to-main' class='screenreader-text' href='#main-content'>Skip to Content</a>
<a id='skip-to-nav' class='screenreader-text' href='#side-navigation'>Skip to Navigation</a> <a id='skip-to-nav' class='screenreader-text' href='#side-navigation'>Skip to Navigation</a>
<main> <main>
@ -95,5 +95,5 @@
{% block footer %} {% block footer %}
{% endblock %} {% endblock %}
</body> </body>
</html> </html>

View file

@ -1,3 +1,3 @@
{% autoescape off %} {% autoescape off %}
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; margin-bottom: 15px;">{{ content }}</p> <p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; margin-bottom: 15px;">{{ content }}</p>
{% endautoescape %} {% endautoescape %}

View file

@ -1,5 +1,5 @@
{% autoescape off %} {% autoescape off %}
<table role="presentation" border="0" cellpadding="0" cellspacing="0" class="btn btn-primary" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; box-sizing: border-box; width: 100%;" width="100%"> <table role="presentation" border="0" cellpadding="0" cellspacing="0" class="btn btn-primary" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; box-sizing: border-box; width: 100%;" width="100%">
<tbody> <tbody>
<tr> <tr>
<td align="left" style="font-family: sans-serif; font-size: 14px; vertical-align: top; padding-bottom: 15px;" valign="top"> <td align="left" style="font-family: sans-serif; font-size: 14px; vertical-align: top; padding-bottom: 15px;" valign="top">
@ -13,5 +13,5 @@
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
{% endautoescape %} {% endautoescape %}

View file

@ -1,7 +1,7 @@
{% autoescape off %} {% autoescape off %}
<tr> <tr>
<td class="content-block" style="font-family: sans-serif; vertical-align: top; padding-bottom: 10px; padding-top: 10px; color: #999999; font-size: 12px; text-align: center;" valign="top" align="center"> <td class="content-block" style="font-family: sans-serif; vertical-align: top; padding-bottom: 10px; padding-top: 10px; color: #999999; font-size: 12px; text-align: center;" valign="top" align="center">
{{ content }} {{ content }}
</td> </td>
</tr> </tr>
{% endautoescape %} {% endautoescape %}

View file

@ -1,27 +1,27 @@
{% extends "emails/base.html" %} {% extends "emails/base.html" %}
{% load mail_tags %} {% load mail_tags %}
{% autoescape off %} {% autoescape off %}
{% block title %}{{settings.MAIN_DOMAIN}} - New Account Created{% endblock title %} {% block title %}{{settings.MAIN_DOMAIN}} - New Account Created{% endblock title %}
{% block subtitle %}{{settings.MAIN_DOMAIN}} - New Account Created{% endblock subtitle %} {% block subtitle %}{{settings.MAIN_DOMAIN}} - New Account Created{% endblock subtitle %}
{% block body_greeting %} {% block body_greeting %}
{% email_body_content "Hi there," %} {% email_body_content "Hi there," %}
{% endblock body_greeting %} {% endblock body_greeting %}
{% block body_content %} {% block body_content %}
{% email_body_content "Your email address was used to create a new account at {{config.site_name}} (https://{{settings.MAIN_DOMAIN}})." %} {% email_body_content "Your email address was used to create a new account at {{config.site_name}} (https://{{settings.MAIN_DOMAIN}})." %}
{% email_body_content "To confirm your new account, go to this link:" %} {% email_body_content "To confirm your new account, go to this link:" %}
{% endblock body_content %} {% endblock body_content %}
{% block body_button %} {% block body_button %}
{% email_button button_text="Confirm New Account" button_link="https://{{settings.MAIN_DOMAIN}}/auth/reset/{{reset.token}}/" %} {% email_button button_text="Confirm New Account" button_link="https://{{settings.MAIN_DOMAIN}}/auth/reset/{{reset.token}}/" %}
{% endblock body_button %} {% endblock body_button %}
{% block body_signature %} {% block body_signature %}
{% email_body_content "Thanks, Admins @{{settings.MAIN_DOMAIN}}" %} {% email_body_content "Thanks, Admins @{{settings.MAIN_DOMAIN}}" %}
{% endblock body_signature %} {% endblock body_signature %}
{% block extra_footer %} {% block extra_footer %}
{% email_footer "If this was not you, then please ignore this message - your email will not be used to make an account if this link is not visited." %} {% email_footer "If this was not you, then please ignore this message - your email will not be used to make an account if this link is not visited." %}
{% endblock extra_footer %} {% endblock extra_footer %}
{% endautoescape %} {% endautoescape %}

View file

@ -1,12 +1,12 @@
{% autoescape off %} {% autoescape off %}
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>{% block title %}{% endblock title %}</title> <title>{% block title %}{% endblock title %}</title>
<style> <style>
@media only screen and (max-width: 620px) { @media only screen and (max-width: 620px) {
table.body h1 { table.body h1 {
font-size: 28px !important; font-size: 28px !important;
margin-bottom: 10px !important; margin-bottom: 10px !important;
@ -54,8 +54,8 @@
max-width: 100% !important; max-width: 100% !important;
width: auto !important; width: auto !important;
} }
} }
@media all { @media all {
.ExternalClass { .ExternalClass {
width: 100%; width: 100%;
} }
@ -95,8 +95,8 @@
background-color: #34495e !important; background-color: #34495e !important;
border-color: #34495e !important; border-color: #34495e !important;
} }
} }
</style> </style>
</head> </head>
<body style="background-color: #f6f6f6; font-family: sans-serif; -webkit-font-smoothing: antialiased; font-size: 14px; line-height: 1.4; margin: 0; padding: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;"> <body style="background-color: #f6f6f6; font-family: sans-serif; -webkit-font-smoothing: antialiased; font-size: 14px; line-height: 1.4; margin: 0; padding: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;">
<span class="preheader" style="color: transparent; display: none; height: 0; max-height: 0; max-width: 0; opacity: 0; overflow: hidden; mso-hide: all; visibility: hidden; width: 0;">{% block subtitle %}{% endblock subtitle %}</span> <span class="preheader" style="color: transparent; display: none; height: 0; max-height: 0; max-width: 0; opacity: 0; overflow: hidden; mso-hide: all; visibility: hidden; width: 0;">{% block subtitle %}{% endblock subtitle %}</span>
@ -159,5 +159,5 @@
</tr> </tr>
</table> </table>
</body> </body>
</html> </html>
{% endautoescape %} {% endautoescape %}

View file

@ -1,27 +1,27 @@
{% extends "emails/base.html" %} {% extends "emails/base.html" %}
{% load mail_tags %} {% load mail_tags %}
{% autoescape off %} {% autoescape off %}
{% block title %}{{settings.MAIN_DOMAIN}} - Password Reset Requested{% endblock title %} {% block title %}{{settings.MAIN_DOMAIN}} - Password Reset Requested{% endblock title %}
{% block subtitle %}{{settings.MAIN_DOMAIN}} - Password Reset Requested{% endblock subtitle %} {% block subtitle %}{{settings.MAIN_DOMAIN}} - Password Reset Requested{% endblock subtitle %}
{% block body_greeting %} {% block body_greeting %}
{% email_body_content "Hi there," %} {% email_body_content "Hi there," %}
{% endblock body_greeting %} {% endblock body_greeting %}
{% block body_content %} {% block body_content %}
{% email_body_content "A password reset was requested for your account ({{reset.user.email}}) at {{Config.system.site_name}} (https://{{settings.MAIN_DOMAIN}})." %} {% email_body_content "A password reset was requested for your account ({{reset.user.email}}) at {{Config.system.site_name}} (https://{{settings.MAIN_DOMAIN}})." %}
{% email_body_content "To reset your password, go to this link:" %} {% email_body_content "To reset your password, go to this link:" %}
{% endblock body_content %} {% endblock body_content %}
{% block body_button %} {% block body_button %}
{% email_button button_text="Reset Password" button_link="https://{{settings.MAIN_DOMAIN}}/auth/reset/{{reset.token}}/" %} {% email_button button_text="Reset Password" button_link="https://{{settings.MAIN_DOMAIN}}/auth/reset/{{reset.token}}/" %}
{% endblock body_button %} {% endblock body_button %}
{% block body_signature %} {% block body_signature %}
{% email_body_content "Thanks, Admins @{{settings.MAIN_DOMAIN}}" %} {% email_body_content "Thanks, Admins @{{settings.MAIN_DOMAIN}}" %}
{% endblock body_signature %} {% endblock body_signature %}
{% block extra_footer %} {% block extra_footer %}
{% email_footer "If this was not you, then please ignore this message - your password will not be reset if this link is not visited." %} {% email_footer "If this was not you, then please ignore this message - your password will not be reset if this link is not visited." %}
{% endblock extra_footer %} {% endblock extra_footer %}
{% endautoescape %} {% endautoescape %}

View file

@ -1,15 +1,15 @@
{% extends "emails/base.html" %} {% extends "emails/base.html" %}
{% load mail_tags %} {% load mail_tags %}
{% autoescape off %} {% autoescape off %}
{% block title %}{{config.site_name}} - New Moderation Report{% endblock title %} {% block title %}{{config.site_name}} - New Moderation Report{% endblock title %}
{% block subtitle %}{{config.site_name}} - New Moderation Report{% endblock subtitle %} {% block subtitle %}{{config.site_name}} - New Moderation Report{% endblock subtitle %}
{% block body_greeting %} {% block body_greeting %}
{% email_body_content "Moderation Team," %} {% email_body_content "Moderation Team," %}
{% email_body_content "A new report has been recieved for {{config.site_name}}." %} {% email_body_content "A new report has been recieved for {{config.site_name}}." %}
{% endblock body_greeting %} {% endblock body_greeting %}
{% block body_content %} {% block body_content %}
{% email_body_content "=============== Report Summary ===============" %} {% email_body_content "=============== Report Summary ===============" %}
{% if report.source_identity %} {% if report.source_identity %}
@ -21,13 +21,13 @@
{% email_body_content "Reported Identity: {{report.subject_identity}}" %} {% email_body_content "Reported Identity: {{report.subject_identity}}" %}
{% email_body_content "Complaint Type: {{report.type}}" %} {% email_body_content "Complaint Type: {{report.type}}" %}
{% email_body_content "Complaint Notes: {{report.complaint}}" %} {% email_body_content "Complaint Notes: {{report.complaint}}" %}
{% endblock body_content %} {% endblock body_content %}
{% block body_button %} {% block body_button %}
{% email_button button_text="View Report" button_link="https://{{settings.MAIN_DOMAIN}}/admin/reports/{{report.id}}/" %} {% email_button button_text="View Report" button_link="https://{{settings.MAIN_DOMAIN}}/admin/reports/{{report.id}}/" %}
{% endblock body_button %} {% endblock body_button %}
{% block extra_footer %} {% block extra_footer %}
{% email_footer "You are recieving this email because you are a moderator on the Takahe instance https://{{settings.MAIN_DOMAIN}}" %} {% email_footer "You are recieving this email because you are a moderator on the Takahe instance https://{{settings.MAIN_DOMAIN}}" %}
{% endblock extra_footer %} {% endblock extra_footer %}
{% endautoescape %} {% endautoescape %}

View file

@ -1,6 +1,7 @@
{% with name_one=field_name_one|default:"name" name_two=field_name_two|default:"value" %} {% with name_one=field_name_one|default:"name" name_two=field_name_two|default:"value" %}
<script type="text/hyperscript"> <script type="text/hyperscript">
{# fmt:off #}
def {{ field.name }}.collect{{ field.name|title }}Fields() def {{ field.name }}.collect{{ field.name|title }}Fields()
set newdata to [] set newdata to []
for item in <div.{{ field.name }}-row/> for item in <div.{{ field.name }}-row/>
@ -24,12 +25,14 @@
add .{{ field.name }}-row to foo add .{{ field.name }}-row to foo
return foo return foo
end end
</script> {# fmt:on #}
</script>
{% include "forms/_field.html" %} {% include "forms/_field.html" %}
<div class="field multi-option"> <div class="field multi-option">
<section class="icon-menu"> <section class="icon-menu">
{# fmt:off #}
<span id="new_{{ field.name }}" stlye="display: none" <span id="new_{{ field.name }}" stlye="display: none"
_="on load _="on load
get the (value of #id_{{ field.name }}) as Object get the (value of #id_{{ field.name }}) as Object
@ -49,6 +52,7 @@
call {{ field.name }}.addEmptyField() call {{ field.name }}.addEmptyField()
end end
"></span> "></span>
{# fmt:on #}
<div class="option"> <div class="option">
<span class="option-field"> <span class="option-field">
@ -73,6 +77,6 @@
</section> </section>
</div> </div>
{% endwith %} {% endwith %}

View file

@ -11,7 +11,7 @@
</fieldset> </fieldset>
<fieldset> <fieldset>
<legend>Password</legend> <legend>Password</legend>
<p>To change your password, please trigger a <a href="{% url "trigger_reset" %}">password reset</a>. <p>To change your password, please trigger a <a href="{% url "trigger_reset" %}">password reset</a>.</p>
</fieldset> </fieldset>
</form> </form>
{% endblock %} {% endblock %}