Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add djhtml to format HTML templates #164

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,10 @@ repos:
hooks:
- id: sync_with_poetry
args: []

- repo: https://github.com/rtts/djhtml
rev: "main" # replace with the latest tag on GitHub
hooks:
- id: djhtml
- id: djcss
- id: djjs
18 changes: 15 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pytest-cov = "^4.1.0"
faker = "^23.2.1"
isort = "^5.13.2"
pyproject-flake8 = "^6.1.0"
djhtml = "^3.0.6"

[build-system]
requires = ["poetry-core"]
Expand Down
96 changes: 48 additions & 48 deletions templates/base/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,61 @@
<!DOCTYPE html>
<html lang="en" class="govuk-template app-html-class">

{% include "base/head.html" %}
{% include "base/head.html" %}

<body class="govuk-template__body app-body-class" data-test="My value" data-other="report:details">
<script>
document.body.className += ' js-enabled' + ('noModule' in HTMLScriptElement.prototype ? ' govuk-frontend-supported' : '');
</script>
<a href="#main-content" class="govuk-skip-link" data-module="govuk-skip-link">Skip to main content</a>
<body class="govuk-template__body app-body-class" data-test="My value" data-other="report:details">
<script>
document.body.className += ' js-enabled' + ('noModule' in HTMLScriptElement.prototype ? ' govuk-frontend-supported' : '');
</script>
<a href="#main-content" class="govuk-skip-link" data-module="govuk-skip-link">Skip to main content</a>

{% include "base/navigation.html" %}
{% include "base/navigation.html" %}

<div class="govuk-width-container app-width-container">
<div class="govuk-phase-banner" role="region">
<p class="govuk-phase-banner__content">
<strong class="govuk-tag govuk-phase-banner__content__tag">Alpha</strong>
{% if env == "dev" %}
<strong class="govuk-tag govuk-tag--yellow govuk-phase-banner__content__tag">{{ env|title }}</strong>
{% endif %}
{% if env == "test" %}
<strong class="govuk-tag govuk-tag--green govuk-phase-banner__content__tag">{{ env|title }}</strong>
{% endif %}
{% if env == "preprod" %}
<strong class="govuk-tag govuk-tag--blue govuk-phase-banner__content__tag">{{ env|title }}</strong>
{% endif %}
<div class="govuk-width-container app-width-container">
<div class="govuk-phase-banner" role="region">
<p class="govuk-phase-banner__content">
<strong class="govuk-tag govuk-phase-banner__content__tag">Alpha</strong>
{% if env == "dev" %}
<strong class="govuk-tag govuk-tag--yellow govuk-phase-banner__content__tag">{{ env|title }}</strong>
{% endif %}
{% if env == "test" %}
<strong class="govuk-tag govuk-tag--green govuk-phase-banner__content__tag">{{ env|title }}</strong>
{% endif %}
{% if env == "preprod" %}
<strong class="govuk-tag govuk-tag--blue govuk-phase-banner__content__tag">{{ env|title }}</strong>
{% endif %}
<!--<span class="govuk-phase-banner__text">
This is a new service – your <a class="govuk-link" href="#">feedback</a> will help us to improve it.
</span>-->
<span class="govuk-phase-banner__text">
This service is currently in development and feedback is being gathered through user research.
</span>
</p>
</div>
<span class="govuk-phase-banner__text">
This service is currently in development and feedback is being gathered through user research.
</span>
</p>
</div>

{% block breadcrumbs %}
{% endblock breadcrumbs %}
{% block breadcrumbs %}
{% endblock breadcrumbs %}

<main class="govuk-main-wrapper" id="main-content" role="main">
{% block content %}
{% endblock content %}
</main>
<main class="govuk-main-wrapper" id="main-content" role="main">
{% block content %}
{% endblock content %}
</main>

</div>
{% include "base/footer.html" %}
<script type="module" href="{% static 'assets/js/govuk-frontend.min.js' %}"></script>
<script src="{% static 'assets/js/moj-frontend.js' %}"></script>
<script
src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous"
></script>
<script type="module">
import {initAll} from "{% static 'assets/js/govuk-frontend.min.js' %}"
initAll();
window.MOJFrontend.initAll();
</script>
{% block scripts %}
{% endblock scripts %}
</body>
</div>
{% include "base/footer.html" %}
<script type="module" href="{% static 'assets/js/govuk-frontend.min.js' %}"></script>
<script src="{% static 'assets/js/moj-frontend.js' %}"></script>
<script
src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous"
></script>
<script type="module">
import {initAll} from "{% static 'assets/js/govuk-frontend.min.js' %}"
initAll();
window.MOJFrontend.initAll();
</script>
{% block scripts %}
{% endblock scripts %}
</body>
</html>
24 changes: 12 additions & 12 deletions templates/base/error/page_not_found.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<div class="govuk-width-container">
<main class="govuk-main-wrapper govuk-main-wrapper--l" id="main-content" role="main">
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l">Page not found</h1>
<p class="govuk-body">
If you typed the web address, check it is correct.
</p>
<p class="govuk-body">
If you pasted the web address, check you copied the entire address.
</p>
<p class="govuk-body">
If the web address is correct or you selected a link or button, <a href="#" class="govuk-link">contact the Tax Credits Helpline</a> if you need to speak to someone about your tax credits.
</p>
</div>
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l">Page not found</h1>
<p class="govuk-body">
If you typed the web address, check it is correct.
</p>
<p class="govuk-body">
If you pasted the web address, check you copied the entire address.
</p>
<p class="govuk-body">
If the web address is correct or you selected a link or button, <a href="#" class="govuk-link">contact the Tax Credits Helpline</a> if you need to speak to someone about your tax credits.
</p>
</div>
</div>
</main>
</div>
18 changes: 9 additions & 9 deletions templates/base/navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<div class="govuk-header__logo">
<a href="#" class="govuk-header__link govuk-header__link--homepage">
<svg
focusable="false"
role="img"
class="govuk-header__logotype"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 148 30"
height="30"
width="148"
aria-label="GOV.UK"
>
focusable="false"
role="img"
class="govuk-header__logotype"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 148 30"
height="30"
width="148"
aria-label="GOV.UK"
>
<title>GOV.UK</title>
<path d="M22.6 10.4c-1 .4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 2 .1 2.4 1s-.1 2-1 2.4m-5.9 6.7c-.9.4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 2 .1 2.4 1s-.1 2-1 2.4m10.8-3.7c-1 .4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 2 .1 2.4 1s0 2-1 2.4m3.3 4.8c-1 .4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 2 .1 2.4 1s-.1 2-1 2.4M17 4.7l2.3 1.2V2.5l-2.3.7-.2-.2.9-3h-3.4l.9 3-.2.2c-.1.1-2.3-.7-2.3-.7v3.4L15 4.7c.1.1.1.2.2.2l-1.3 4c-.1.2-.1.4-.1.6 0 1.1.8 2 1.9 2.2h.7c1-.2 1.9-1.1 1.9-2.1 0-.2 0-.4-.1-.6l-1.3-4c-.1-.2 0-.2.1-.3m-7.6 5.7c.9.4 2-.1 2.4-1 .4-.9-.1-2-1-2.4-.9-.4-2 .1-2.4 1s0 2 1 2.4m-5 3c.9.4 2-.1 2.4-1 .4-.9-.1-2-1-2.4-.9-.4-2 .1-2.4 1s.1 2 1 2.4m-3.2 4.8c.9.4 2-.1 2.4-1 .4-.9-.1-2-1-2.4-.9-.4-2 .1-2.4 1s0 2 1 2.4m14.8 11c4.4 0 8.6.3 12.3.8 1.1-4.5 2.4-7 3.7-8.8l-2.5-.9c.2 1.3.3 1.9 0 2.7-.4-.4-.8-1.1-1.1-2.3l-1.2 4c.7-.5 1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.1s-1 1.7-1.8 2.4c-.7.7-1.6 1.2-2.7 1.5-1 .4-2.2.5-3.4.5-1.2 0-2.4-.2-3.4-.5-1-.4-1.9-.9-2.7-1.5-.8-.7-1.3-1.5-1.8-2.4-.4-.9-.6-2-.6-3.1V6.9h4.2v13c0 .8.1 1.4.3 2 .2.6.5 1 .9 1.4.4.4.8.6 1.4.8.6.2 1.1.3 1.8.3zm13-17.4h4.2v9.1l7.4-9.1h5.2l-7.2 8.4L148 28h-4.9l-5.5-9.4-2.7 3V28h-4.2V7zm-27.6 16.1c-1.5 0-2.7 1.2-2.7 2.7s1.2 2.7 2.7 2.7 2.7-1.2 2.7-2.7-1.2-2.7-2.7-2.7z"></path>
</svg>
Expand Down
106 changes: 53 additions & 53 deletions templates/details_chart.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,69 +4,69 @@
{% load humanize %}

{% block breadcrumbs %}
<div class="govuk-breadcrumbs">
<ol class="govuk-breadcrumbs__list">
<li class="govuk-breadcrumbs__list-item">
<a class="govuk-breadcrumbs__link" href="{%url 'home:search' %}?{{request.session.last_search|default:''}}">Search</a>
</li>
<li class="govuk-breadcrumbs__list-item">
<a class="govuk-breadcrumbs__link" href="{{request.path}}">{{chart.name}}</a>
</li>
</ol>
</div>
<div class="govuk-breadcrumbs">
<ol class="govuk-breadcrumbs__list">
<li class="govuk-breadcrumbs__list-item">
<a class="govuk-breadcrumbs__link" href="{%url 'home:search' %}?{{request.session.last_search|default:''}}">Search</a>
</li>
<li class="govuk-breadcrumbs__list-item">
<a class="govuk-breadcrumbs__link" href="{{request.path}}">{{chart.name}}</a>
</li>
</ol>
</div>
{% endblock breadcrumbs %}

{% block content %}

<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<span class="govuk-caption-m">Chart</span>
<h2 class="govuk-heading-l">{{chart.name}}</h2>
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<span class="govuk-caption-m">Chart</span>
<h2 class="govuk-heading-l">{{chart.name}}</h2>
</div>
</div>
</div>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<div class="summary-card">
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<div class="summary-card">
<h2 class="govuk-heading-s govuk-!-margin-top-3">
Description
</h2>
<div class="govuk-body">
{{chart.description|markdown:3}}
</div>
<ul class="govuk-list govuk-body" id="metadata-property-list">
<li>
<span class="govuk-!-font-weight-bold">Last updated date:</span>
</li>
<li>
<span class="govuk-!-font-weight-bold">Retention period:</span>
</li>
<li>
<span class="govuk-!-font-weight-bold">Refresh period:</span>
</li>
<li>
<span class="govuk-!-font-weight-bold">Domain:</span>
</li>
<li>
<span class="govuk-!-font-weight-bold">Tags:</span>
</li>
</ul>
</div>
</div>
<div class="govuk-grid-column-one-third">
{% include "partial/contact_info.html" with data_owner="chart owner" data_owner_email="chart owner email" %}
</div>
</div>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-s govuk-!-margin-top-3">
Description
URL
</h2>
<div class="govuk-body">
{{chart.description|markdown:3}}
<a href="{{chart.external_url}}" class="govuk-link">
{{chart.external_url}}
</a>
</div>
<ul class="govuk-list govuk-body" id="metadata-property-list">
<li>
<span class="govuk-!-font-weight-bold">Last updated date:</span>
</li>
<li>
<span class="govuk-!-font-weight-bold">Retention period:</span>
</li>
<li>
<span class="govuk-!-font-weight-bold">Refresh period:</span>
</li>
<li>
<span class="govuk-!-font-weight-bold">Domain:</span>
</li>
<li>
<span class="govuk-!-font-weight-bold">Tags:</span>
</li>
</ul>
</div>
</div>
<div class="govuk-grid-column-one-third">
{% include "partial/contact_info.html" with data_owner="chart owner" data_owner_email="chart owner email" %}
</div>
</div>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-s govuk-!-margin-top-3">
URL
</h2>
<div class="govuk-body">
<a href="{{chart.external_url}}" class="govuk-link">
{{chart.external_url}}
</a>
</div>
</div>
</div>

{% endblock content %}
Loading
Loading