Skip to content

Commit

Permalink
feat: pre-commit djhtml (#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasvinclav authored Aug 20, 2024
1 parent 43ec771 commit fbb179e
Show file tree
Hide file tree
Showing 24 changed files with 159 additions and 154 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ repos:
- id: conventional-pre-commit
stages: [commit-msg]
args: []
- repo: https://github.com/rtts/djhtml
rev: 3.0.6
hooks:
- id: djhtml
files: .*/templates/.*\.html$
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{% load admin_urls i18n %}

{% block extrahead %}{{ block.super }}
{{ form.media }}
{{ form.media }}
{% endblock %}

{% block breadcrumbs %}{% if not is_popup %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% load admin_urls i18n %}

{% block extrahead %}{{ block.super }}
{{ form.media }}
{{ form.media }}
{% endblock %}

{% block breadcrumbs %}{% if not is_popup %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@
{% endblock %}

{% block content %}
{% if confirm_form %}
{% include "admin/import_export/import_confirm.html" %}
{% else %}
{% include "admin/import_export/import_form.html" %}
{% endif %}

{% if result %}
{% if result.has_errors %}
{% include "admin/import_export/import_errors.html" %}
{% elif result.has_validation_errors %}
{% include "admin/import_export/import_validation.html" %}
{% if confirm_form %}
{% include "admin/import_export/import_confirm.html" %}
{% else %}
{% include "admin/import_export/import_preview.html" %}
{% include "admin/import_export/import_form.html" %}
{% endif %}

{% if result %}
{% if result.has_errors %}
{% include "admin/import_export/import_errors.html" %}
{% elif result.has_validation_errors %}
{% include "admin/import_export/import_validation.html" %}
{% else %}
{% include "admin/import_export/import_preview.html" %}
{% endif %}
{% endif %}
{% endif %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<ul>
{% for error in result.base_errors %}
<li>
{{ error.error }}
{{ error.error }}

<div class="traceback">{{ error.traceback|linebreaks }}</div></li>
<div class="traceback">{{ error.traceback|linebreaks }}</div></li>
{% endfor %}

{% for line, errors in result.row_errors %}
Expand Down
2 changes: 1 addition & 1 deletion src/unfold/templates/admin/app_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h3 class="font-medium my-3 text-gray-900 text-sm dark:text-gray-200">
{% if model.admin_url %}
<a href="{{ model.admin_url }}" id="link-{{ app.app_label }}-{{ model.object_name|lower }}"
class="block -mx-3 px-3 py-3 rounded-md truncate {% if model.admin_url in request.path|urlencode %}bg-gray-100 font-semibold text-primary-600 dark:bg-white/[.06] dark:text-primary-500{% else %} hover:text-gray-700 dark:hover:text-gray-200{% endif %}">
{{ model.name }}
{{ model.name }}
</a>
{% else %}
{{ model.name }}
Expand Down
2 changes: 1 addition & 1 deletion src/unfold/templates/admin/auth/user/add_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
{% else %}
{% translate "Enter a username and password." %}x
{% endif %}
<p>
<p>
{% endblock %}
2 changes: 1 addition & 1 deletion src/unfold/templates/admin/base_site.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block title %}{% if subtitle %}{{ subtitle }} | {% endif %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %}

{% block branding %}
<h1 id="site-name"><a href="{% url 'admin:index' %}">{{ site_header|default:_('Django administration') }}</a></h1>
<h1 id="site-name"><a href="{% url 'admin:index' %}">{{ site_header|default:_('Django administration') }}</a></h1>
{% endblock %}

{% block nav-global %}{% endblock %}
2 changes: 1 addition & 1 deletion src/unfold/templates/admin/change_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
{% endif %}

{% block nav-global %}{% spaceless %}
{% if change and not is_popup %}
{% if change and not is_popup %}
{% block object-tools-items %}
{% change_form_object_tools %}
{% endblock %}
Expand Down
20 changes: 10 additions & 10 deletions src/unfold/templates/admin/change_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
{% load i18n admin_urls static admin_list unfold_list %}

{% block extrastyle %}
{{ block.super }}
{{ block.super }}

{% if cl.formset %}
<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}">
{% endif %}
{% if cl.formset %}
<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}">
{% endif %}


<script src="{% url 'admin:jsi18n' %}"></script>

{{ media.css }}
{{ media.css }}

{% if not actions_on_top and not actions_on_bottom %}
<style>
#changelist table thead th:first-child {width: inherit}
</style>
{% endif %}
{% if not actions_on_top and not actions_on_bottom %}
<style>
#changelist table thead th:first-child {width: inherit}
</style>
{% endif %}
{% endblock %}

{% block extrahead %}
Expand Down
2 changes: 1 addition & 1 deletion src/unfold/templates/admin/delete_confirmation.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h2 class="font-semibold mb-2 text-gray-900 dark:text-gray-100">
</h2>

<ul class="leading-relaxed text-sm">
{{ deleted_objects|unordered_list }}
{{ deleted_objects|unordered_list }}
</ul>
</div>

Expand Down
2 changes: 1 addition & 1 deletion src/unfold/templates/admin/nav_sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<div @click="sidebarMobileOpen = !sidebarMobileOpen"
class="fixed bottom-0 bg-gray-700 cursor-pointer flex items-center left-0 mb-2 ml-2 justify-center px-2 py-1 rounded-full shadow-sm text-xs text-white uppercase z-50 xl:hidden"
:class="{'ml-72 -translate-x-1/2': sidebarMobileOpen}">
:class="{'ml-72 -translate-x-1/2': sidebarMobileOpen}">
{% trans "Menu" %}
</div>

Expand Down
6 changes: 3 additions & 3 deletions src/unfold/templates/registration/password_change_done.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

{% block content %}
<div id="content-main">
<p class="bg-primary-100 mb-8 text-primary-600 px-3 py-3 rounded-md text-sm">
{% translate 'Your password was changed.' %}
</p>
<p class="bg-primary-100 mb-8 text-primary-600 px-3 py-3 rounded-md text-sm">
{% translate 'Your password was changed.' %}
</p>
</div>
{% endblock %}
22 changes: 11 additions & 11 deletions src/unfold/templates/unfold/change_list_filter.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ <h3 class="border-b flex font-semibold mb-6 px-6 py-4 text-gray-900 text-sm dark
{% if cl.model_admin.list_filter_submit %}
<form id="filter-form" method="get">

{% if request.GET.q %}
<input type="hidden" name="q" value="{{ request.GET.q }}">
{% endif %}
{% if request.GET.q %}
<input type="hidden" name="q" value="{{ request.GET.q }}">
{% endif %}

{% if request.GET.o %}
<input type="hidden" name="o" value="{{ request.GET.o }}">
{% endif %}
{% if request.GET.o %}
<input type="hidden" name="o" value="{{ request.GET.o }}">
{% endif %}
{% endif %}


Expand All @@ -38,11 +38,11 @@ <h3 class="border-b flex font-semibold mb-6 px-6 py-4 text-gray-900 text-sm dark
{% endfor %}

{% if cl.model_admin.list_filter_submit %}
<div class="bg-gray-50 border-gray-200 border-t bottom-4 fixed px-6 py-3 right-4 rounded-b w-96 dark:bg-gray-700 dark:border-gray-600">
<button type="submit" class="bg-primary-600 block border border-transparent font-medium px-3 py-2 rounded-md self-end text-sm text-white w-full">
{% trans "Apply Filters" %}
</button>
</div>
<div class="bg-gray-50 border-gray-200 border-t bottom-4 fixed px-6 py-3 right-4 rounded-b w-96 dark:bg-gray-700 dark:border-gray-600">
<button type="submit" class="bg-primary-600 block border border-transparent font-medium px-3 py-2 rounded-md self-end text-sm text-white w-full">
{% trans "Apply Filters" %}
</button>
</div>
</form>
{% endif %}
</div>
Expand Down
28 changes: 14 additions & 14 deletions src/unfold/templates/unfold/helpers/actions_row.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

{% if actions %}
<td data-label="{% trans "More actions" %}" class="field-actions_holder align-middle flex border-t border-gray-200 font-normal px-3 py-2 text-left text-sm before:block before:capitalize before:content-[attr(data-label)] before:mr-auto before:text-gray-500 dark:before:text-gray-300 lg:before:hidden lg:py-3 lg:table-cell dark:border-gray-800 lg:w-px">
{% with action_id=instance_pk|cut:"-" %}
<div class="group leading-none relative" x-data="{ openActionsId{{ action_id }}: false }">
<span x-ref="rowDropdown{{ action_id }}" class="cursor-pointer flex h-7 material-symbols-outlined md-18 -my-1 !leading-7 rounded text-center text-gray-400 w-7 group-hover:bg-gray-100 group-hover:text-gray-700 dark:text-gray-300 group-hover:dark:bg-gray-800 group-hover:dark:text-white" @click="openActionsId{{ action_id }} = !openActionsId{{ action_id }}">
more_horiz
</span>
{% with action_id=instance_pk|cut:"-" %}
<div class="group leading-none relative" x-data="{ openActionsId{{ action_id }}: false }">
<span x-ref="rowDropdown{{ action_id }}" class="cursor-pointer flex h-7 material-symbols-outlined md-18 -my-1 !leading-7 rounded text-center text-gray-400 w-7 group-hover:bg-gray-100 group-hover:text-gray-700 dark:text-gray-300 group-hover:dark:bg-gray-800 group-hover:dark:text-white" @click="openActionsId{{ action_id }} = !openActionsId{{ action_id }}">
more_horiz
</span>

<nav x-anchor.offset.4="$refs.rowDropdown{{ action_id }}" class="bg-white border flex flex-col leading-none py-1 rounded-md shadow-lg text-sm top-7 z-50 w-48 dark:bg-gray-800 dark:border-gray-700" x-cloak x-show="openActionsId{{ action_id }}" @click.outside="openActionsId{{ action_id }} = false">
{% for action in actions %}
<a href="{% url action.raw_path instance_pk %}" class="mx-1 px-3 py-2 rounded-md truncate hover:bg-gray-100 dark:hover:bg-gray-700 dark:hover:text-gray-200"{% for attr_name, attr_value in action.attrs.items %} {{ attr_name }}="{{ attr_value }}"{% endfor %}>
{{ action.title }}
</a>
{% endfor %}
</nav>
</div>
{% endwith %}
<nav x-anchor.offset.4="$refs.rowDropdown{{ action_id }}" class="bg-white border flex flex-col leading-none py-1 rounded-md shadow-lg text-sm top-7 z-50 w-48 dark:bg-gray-800 dark:border-gray-700" x-cloak x-show="openActionsId{{ action_id }}" @click.outside="openActionsId{{ action_id }} = false">
{% for action in actions %}
<a href="{% url action.raw_path instance_pk %}" class="mx-1 px-3 py-2 rounded-md truncate hover:bg-gray-100 dark:hover:bg-gray-700 dark:hover:text-gray-200"{% for attr_name, attr_value in action.attrs.items %} {{ attr_name }}="{{ attr_value }}"{% endfor %}>
{{ action.title }}
</a>
{% endfor %}
</nav>
</div>
{% endwith %}
</td>
{% endif %}
2 changes: 1 addition & 1 deletion src/unfold/templates/unfold/helpers/app_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h2 class="font-semibold flex flex-row items-center mb-1 mx-3 py-1.5 px-3 select
{% endif %}
{% endfor %}
</ol>
{% endif %}
{% endif %}
</div>
{% endfor %}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/unfold/templates/unfold/helpers/fieldset_row.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{% include "unfold/helpers/help_text.html" with help_text=field.field.help_text %}
</div>
{% endif %}
</div>
</div>

{% if field.errors %}
<div class="mt-1 text-red-600 text-sm dark:text-red-500">
Expand Down
6 changes: 3 additions & 3 deletions src/unfold/templates/unfold/helpers/fieldsets_tabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
{% for fieldset in tabs %}
<li>
<a class="cursor-pointer font-semibold hover:text-gray-700 dark:hover:text-white"
x-on:click="openTab = '{{ forloop.counter0 }}-{{ fieldset.name|slugify }}'"
x-bind:class="openTab == '{{ forloop.counter0 }}-{{ fieldset.name|slugify }}'{% if forloop.first %} || openTab == null{% endif %} ? 'text-gray-700 dark:text-white' : ''">
x-on:click="openTab = '{{ forloop.counter0 }}-{{ fieldset.name|slugify }}'"
x-bind:class="openTab == '{{ forloop.counter0 }}-{{ fieldset.name|slugify }}'{% if forloop.first %} || openTab == null{% endif %} ? 'text-gray-700 dark:text-white' : ''">
{{ fieldset.name }}
</a>
</li>
Expand All @@ -17,7 +17,7 @@

{% for fieldset in tabs %}
<div class="tab-wrapper{% if fieldset.name %} fieldset-{{ fieldset.name|slugify }} fieldset-{{ forloop.counter0 }}-{{ fieldset.name|slugify }}{% endif %}"
x-show="openTab == '{{ forloop.counter0 }}-{{ fieldset.name|slugify }}'{% if forloop.first %} || openTab == null{% endif %}">
x-show="openTab == '{{ forloop.counter0 }}-{{ fieldset.name|slugify }}'{% if forloop.first %} || openTab == null{% endif %}">
{% include 'admin/includes/fieldset.html' %}
</div>
{% endfor %}
Expand Down
26 changes: 13 additions & 13 deletions src/unfold/templates/unfold/helpers/label.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<span class="inline-block font-semibold leading-normal px-2 py-1 rounded text-xxs uppercase whitespace-nowrap
{% if type == 'info' %}
bg-blue-100 text-blue-700 dark:bg-blue-500/20 dark:text-blue-400
{% elif type == 'danger' %}
bg-red-100 text-red-700 dark:bg-red-500/20 dark:text-red-400
{% elif type == 'warning' %}
bg-orange-100 text-orange-700 dark:bg-orange-500/20 dark:text-orange-400
{% elif type == 'success' %}
bg-green-100 text-green-700 dark:bg-green-500/20 dark:text-green-400
{% elif type == 'primary' %}
bg-primary-100 text-primary-700 dark:bg-primary-500/20 dark:text-primary-400
{% else %}
bg-gray-100 text-gray-700 dark:bg-gray-500/20 dark:text-gray-400
{% endif %}">
{% if type == 'info' %}
bg-blue-100 text-blue-700 dark:bg-blue-500/20 dark:text-blue-400
{% elif type == 'danger' %}
bg-red-100 text-red-700 dark:bg-red-500/20 dark:text-red-400
{% elif type == 'warning' %}
bg-orange-100 text-orange-700 dark:bg-orange-500/20 dark:text-orange-400
{% elif type == 'success' %}
bg-green-100 text-green-700 dark:bg-green-500/20 dark:text-green-400
{% elif type == 'primary' %}
bg-primary-100 text-primary-700 dark:bg-primary-500/20 dark:text-primary-400
{% else %}
bg-gray-100 text-gray-700 dark:bg-gray-500/20 dark:text-gray-400
{% endif %}">
{{ text }}
</span>
22 changes: 11 additions & 11 deletions src/unfold/templates/unfold/helpers/messages.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
<ul>
{% for message in messages %}
<li class="mb-3 px-3 py-3 rounded-md text-sm last:mb-8
{% if message.tags == 'success' %}
bg-green-100 text-green-700 dark:bg-green-500/20 dark:text-green-400
{% elif message.tags == 'warning' %}
bg-orange-100 text-orange-700 dark:bg-orange-500/20 dark:text-orange-400
{% elif message.tags == 'error' %}
bg-red-100 text-red-700 dark:bg-red-500/20 dark:text-red-400
{% elif message.tags == 'info' %}
bg-blue-100 text-blue-700 dark:bg-blue-500/20 dark:text-blue-400
{% else %}
bg-gray-100 text-gray-700 dark:bg-gray-500/20 dark:text-gray-400
{% endif %}">
{% if message.tags == 'success' %}
bg-green-100 text-green-700 dark:bg-green-500/20 dark:text-green-400
{% elif message.tags == 'warning' %}
bg-orange-100 text-orange-700 dark:bg-orange-500/20 dark:text-orange-400
{% elif message.tags == 'error' %}
bg-red-100 text-red-700 dark:bg-red-500/20 dark:text-red-400
{% elif message.tags == 'info' %}
bg-blue-100 text-blue-700 dark:bg-blue-500/20 dark:text-blue-400
{% else %}
bg-gray-100 text-gray-700 dark:bg-gray-500/20 dark:text-gray-400
{% endif %}">
{{ message|capfirst }}
</li>
{% endfor %}
Expand Down
Loading

0 comments on commit fbb179e

Please sign in to comment.