reduce whitespaces in output html

This commit is contained in:
Hannaeko 2025-06-22 18:29:09 +01:00
parent e7fdecdacc
commit 7e8ea6affb
6 changed files with 95 additions and 98 deletions

View file

@ -1,15 +1,15 @@
{% macro rrset(record, zone, lang) %} {% macro rrset(record, zone, lang) %}
<li class="rrset"> <li class="rrset">
<div class="rtype"> <div class="rtype">
{% if record.record_type == "service" %} {%- if record.record_type == "service" -%}
{% if record.service.service_type.service_type == "other" %} {%- if record.service.service_type.service_type == "other" -%}
{{ record.service.service_type.name }}/{{ record.service.service_type.protocol }} {{ record.service.service_type.name }}/{{ record.service.service_type.protocol }}
{% else %} {%- else -%}
{{ record.srvice.service_type.service_type }} {{ record.srvice.service_type.service_type }}
{% endif %} {%- endif -%}
{% else %} {%- else -%}
{{ tr(msg="zone-content-record-type-" ~ record.record_type, attr="type-name", lang=lang) }} {{ tr(msg="zone-content-record-type-" ~ record.record_type, attr="type-name", lang=lang) }}
{% endif %} {%- endif -%}
<div class="action"> <div class="action">
<a class="button icon" href="#"> <a class="button icon" href="#">
{{ icons::pencil() }} {{ icons::pencil() }}
@ -18,8 +18,8 @@
</div> </div>
<ul> <ul>
{% if record.record_type == "addresses" %} {%- if record.record_type == "addresses" -%}
{% for address in record.addresses.addresses %} {%- for address in record.addresses.addresses -%}
<li> <li>
<div class="rdata"> <div class="rdata">
<div class="rdata-main"> <div class="rdata-main">
@ -29,9 +29,9 @@
</div> </div>
</div> </div>
</li> </li>
{% endfor %} {%- endfor -%}
{% elif record.record_type == "mailservers" %} {%- elif record.record_type == "mailservers" -%}
{% for mailserver in record.mailservers.mailservers %} {%- for mailserver in record.mailservers.mailservers -%}
<li> <li>
<div class="rdata-main"> <div class="rdata-main">
<span class="pill"> <span class="pill">
@ -48,9 +48,9 @@
</span> </span>
</div> </div>
</li> </li>
{% endfor %} {%- endfor -%}
{% elif record.record_type == "nameservers" %} {%- elif record.record_type == "nameservers" -%}
{% for nameserver in record.nameservers.nameservers %} {%- for nameserver in record.nameservers.nameservers -%}
<li> <li>
<div class="rdata-main"> <div class="rdata-main">
<span class="pill"> <span class="pill">
@ -58,9 +58,9 @@
</span> </span>
</div> </div>
</li> </li>
{% endfor %} {%- endfor -%}
{% elif record.record_type == "service" %} {%- elif record.record_type == "service" -%}
{% for service_target in record.service.service_targets %} {%- for service_target in record.service.service_targets -%}
<li> <li>
<div class="rdata-main"> <div class="rdata-main">
<span class="pill"> <span class="pill">
@ -84,8 +84,8 @@
</span> </span>
</div> </div>
</li> </li>
{% endfor %} {%- endfor -%}
{% endif %} {%- endif -%}
</ul> </ul>
</li> </li>
{% endmacro rrset %} {% endmacro rrset %}

View file

@ -1,52 +1,49 @@
{% macro input(id, name, value, type="text", description="", errors, errors_keys, error_msg_id, label, label_attributes, attributes) %} {% macro input(id, name, value, type="text", description="", errors, errors_keys, error_msg_id, label, label_attributes, attributes) -%}
{% set filtered_errors = [] %} {%- set filtered_errors = [] -%}
{% for error_key in errors_keys %} {%- for error_key in errors_keys -%}
{% set error = errors | get(key=error_key, default="") %} {%- set error = errors | get(key=error_key, default="") -%}
{% if error %} {%- if error -%}
{% set_global filtered_errors = filtered_errors | concat(with=error) %} {%- set_global filtered_errors = filtered_errors | concat(with=error) -%}
{% endif %} {%- endif -%}
{% endfor %} {%- endfor -%}
<label <label
for="{{ id }}" for="{{ id }}"
{% for i in range(start=0, end=label_attributes|length, step_by=2) %} {%- for i in range(start=0, end=label_attributes|length, step_by=2) %}
{{ label_attributes[i] }}="{{ label_attributes | nth(n=i+1) }}" {{ label_attributes[i] }}="{{ label_attributes | nth(n=i+1) }}"
{% endfor %} {%- endfor %}
> >
{{ label }} {{ label }}
</label> </label>
<div> <div>
<input <input
{% if type == "number" %} {%- if type == "number" %} type="text" inputmode="numeric"
type="text" {%- else %} type="{{ type }}"
inputmode="numeric" {%- endif %}
{% else %}
type="{{ type }}"
{% endif %}
name="{{ name }}" name="{{ name }}"
id="{{ id }}" id="{{ id }}"
{% for i in range(start=0, end=attributes|length, step_by=2) %} {%- for i in range(start=0, end=attributes|length, step_by=2) %}
{{ attributes[i] }}="{{ attributes | nth(n=i+1) }}" {{ attributes[i] }}="{{ attributes | nth(n=i+1) }}"
{% endfor %} {%- endfor %}
aria-describedby="{% for error in filtered_errors %} {{ id }}-error-{{ loop.index0 }}{% endfor %}{% if description %} {{ id }}-description{%endif %}" aria-describedby="{% for error in filtered_errors %} {{ id }}-error-{{ loop.index0 }}{% endfor %}{% if description %} {{ id }}-description{% endif %}"
{% if filtered_errors %}aria-invalid="true"{% endif %} {% if filtered_errors %}aria-invalid="true"{% endif %}
value="{{ value }}" value="{{ value }}"
> >
{% for error in filtered_errors %} {%- for error in filtered_errors -%}
<p class="error" id="{{ id }}-error-{{ loop.index0 }}" data-new-item-skip> <p class="error" id="{{ id }}-error-{{ loop.index0 }}" data-new-item-skip>
{{ tr( {{ tr(
msg=error_msg_id, msg=error_msg_id,
attr="error-" ~ error.code | replace(from=":", to="-"), attr="error-" ~ error.code | replace(from=":", to="-"),
lang=lang) }} lang=lang) }}
</p> </p>
{% endfor %} {%- endfor -%}
{% if description %} {%- if description -%}
<p class="help" id="{{ id }}-description"> <p class="help" id="{{ id }}-description">
{{ description }} {{ description }}
</p> </p>
{% endif %} {%- endif -%}
</div> </div>
{% endmacro %} {%- endmacro %}

View file

@ -1,11 +1,11 @@
{% macro plus_circle() %} {% macro plus_circle() -%}
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus-circle" viewBox="0 0 16 16" aria-hidden="true"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus-circle" viewBox="0 0 16 16" aria-hidden="true">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/> <path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/>
<path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4"/> <path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4"/>
</svg> </svg>
{% endmacro %} {%- endmacro %}
{% macro pencil() %} {% macro pencil() -%}
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil" viewBox="0 0 16 16"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil" viewBox="0 0 16 16">
<path d="M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325"/> <path d="M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325"/>
</svg> </svg>

View file

@ -1,23 +1,23 @@
{% extends "bases/app.html" %} {%- extends "bases/app.html" -%}
{% import "macros/icons.html" as icons %} {%- import "macros/icons.html" as icons -%}
{% import "macros/form.html" as form %} {%- import "macros/form.html" as form -%}
{% block title %}{{ tr(msg="new-record-title", lang=lang) }} {{ current_zone }} {% endblock title %} {%- block title -%}{{ tr(msg="new-record-title", lang=lang) }} {{ current_zone }} {%- endblock title -%}
{% block main %} {%- block main -%}
<h1>{{ tr(msg="record-creation-process-heading", zone=current_zone, lang=lang) }}</h1> <h1>{{ tr(msg="record-creation-process-heading", zone=current_zone, lang=lang) }}</h1>
{{ errors | json_encode(pretty=true) }} {{ errors | json_encode(pretty=true) }}
{% set domain_error = errors | get(key="/name", default="") %} {%- set domain_error = errors | get(key="/name", default="") -%}
{% if not new_record_name or (new_record_name and domain_error) %} {%- if not new_record_name or (new_record_name and domain_error) -%}
{% include "pages/new_record/choose_name.html" %} {%- include "pages/new_record/choose_name.html" -%}
{% elif not config and not rtype %} {%- elif not config and not rtype -%}
{% include "pages/new_record/choose_record.html" %} {%- include "pages/new_record/choose_record.html" -%}
{% else %} {%- else -%}
{% include "pages/new_record/configure_record.html" %} {%- include "pages/new_record/configure_record.html" -%}
{% endif %} {%- endif -%}
{% endblock %} {%- endblock -%}

View file

@ -1,4 +1,4 @@
{% if config == "web" %} {%- if config == "web" -%}
<h2>{{ tr(msg="record-config-web-heading", name=new_record_name, lang=lang) }}</h2> <h2>{{ tr(msg="record-config-web-heading", name=new_record_name, lang=lang) }}</h2>
@ -24,7 +24,7 @@
}} }}
</div> </div>
</div> </div>
{% for address in input_data.addresses.data.addresses | default(value=[""]) %} {%- for address in input_data.addresses.data.addresses | default(value=[""]) -%}
<div class="form-input" data-new-item-template="address"> <div class="form-input" data-new-item-template="address">
{{ {{
form::input( form::input(
@ -56,14 +56,14 @@
{{ icons::plus_circle() }} {{ icons::plus_circle() }}
{{ tr(msg="button-add-address", lang=lang) }} {{ tr(msg="button-add-address", lang=lang) }}
</button> </button>
{% endfor %} {%- endfor -%}
<div class="form-action"> <div class="form-action">
<button type="submit">{{ tr(msg="button-save-configuration", lang=lang) }}</button> <button type="submit">{{ tr(msg="button-save-configuration", lang=lang) }}</button>
</div> </div>
</form> </form>
{% elif config == "mail" %} {%- elif config == "mail" -%}
<h2>{{ tr(msg="record-config-mail-heading", name=new_record_name, lang=lang) }}</h2> <h2>{{ tr(msg="record-config-mail-heading", name=new_record_name, lang=lang) }}</h2>
@ -89,7 +89,7 @@
}} }}
</div> </div>
{% for mailserver in input_data.mailservers.data.mailservers | default(value=[""]) %} {%- for mailserver in input_data.mailservers.data.mailservers | default(value=[""]) -%}
<fieldset data-new-item-template="mailserver"> <fieldset data-new-item-template="mailserver">
<legend data-new-item-template-content="{{ tr(msg="record-input-mailservers", attr="legend", index="{i}", lang=lang) }}"> <legend data-new-item-template-content="{{ tr(msg="record-input-mailservers", attr="legend", index="{i}", lang=lang) }}">
{{ tr(msg="record-input-mailservers", attr="legend", index=loop.index, lang=lang) }} {{ tr(msg="record-input-mailservers", attr="legend", index=loop.index, lang=lang) }}
@ -146,7 +146,7 @@
}} }}
</div> </div>
</fieldset> </fieldset>
{% endfor %} {%- endfor -%}
<button class="form-new-item" type="button" data-new-item="mailserver"> <button class="form-new-item" type="button" data-new-item="mailserver">
{{ icons::plus_circle() }} {{ icons::plus_circle() }}
@ -260,4 +260,4 @@
<button type="submit">{{ tr(msg="button-save-configuration", lang=lang) }}</button> <button type="submit">{{ tr(msg="button-save-configuration", lang=lang) }}</button>
</div> </div>
</form> </form>
{% endif %} {%- endif -%}

View file

@ -1,11 +1,11 @@
{% import "macros/display_rrset.html" as rrset %} {%- import "macros/display_rrset.html" as rrset -%}
{% import "macros/icons.html" as icons %} {%- import "macros/icons.html" as icons -%}
{% extends "bases/app.html" %} {%- extends "bases/app.html" -%}
{% block title %}{{ tr(msg="zone-content-title", lang=lang) }} {{ current_zone }} {% endblock title %} {%- block title -%}{{ tr(msg="zone-content-title", lang=lang) }} {{ current_zone }} {%- endblock title -%}
{% block main %} {%- block main -%}
<h1>{{ tr(msg="zone-header", lang=lang, zone_name="<strong>" ~ current_zone ~ "</strong>") | safe }}</h1> <h1>{{ tr(msg="zone-header", lang=lang, zone_name="<strong>" ~ current_zone ~ "</strong>") | safe }}</h1>
<svg width="0" height="0" aria-hidden="true" style="position: absolute;"> <svg width="0" height="0" aria-hidden="true" style="position: absolute;">
<defs> <defs>
@ -17,7 +17,7 @@
<section> <section>
<h2>{{ tr(msg="zone-content-records-header", lang=lang) }}</h2> <h2>{{ tr(msg="zone-content-records-header", lang=lang) }}</h2>
{% for node in records.records %} {%- for node in records.records -%}
<article class="domain"> <article class="domain">
<header> <header>
<h3 class="folder-tab">{{ node.name }}</h3> <h3 class="folder-tab">{{ node.name }}</h3>
@ -27,75 +27,75 @@
{{ tr(msg="zone-content-new-record-button", lang=lang) }} {{ tr(msg="zone-content-new-record-button", lang=lang) }}
</a> </a>
</header> </header>
{% set sections = node.records | group_by(attribute="record_section") %} {%- set sections = node.records | group_by(attribute="record_section") -%}
<div class="records"> <div class="records">
{% if sections.web %} {%- if sections.web -%}
{% set records = sections.web | group_by(attribute="record_type") %} {%- set records = sections.web | group_by(attribute="record_type") -%}
<h4>{{ tr(msg="zone-content-section-web-header", lang=lang) }}</h4> <h4>{{ tr(msg="zone-content-section-web-header", lang=lang) }}</h4>
<ul> <ul>
{% if records.addresses %} {%- if records.addresses -%}
{{ rrset::rrset( {{ rrset::rrset(
record=records.addresses.0, record=records.addresses.0,
zone=current_zone, zone=current_zone,
lang=lang) }} lang=lang) }}
{% endif %} {%- endif -%}
</ul> </ul>
{% endif %} {%- endif -%}
{% if sections.mail %} {%- if sections.mail -%}
{% set records = sections.mail | group_by(attribute="record_type") %} {%- set records = sections.mail | group_by(attribute="record_type") -%}
<h4>{{ tr(msg="zone-content-section-mail-header", lang=lang) }}</h4> <h4>{{ tr(msg="zone-content-section-mail-header", lang=lang) }}</h4>
<ul> <ul>
{% if records.mailservers %} {%- if records.mailservers -%}
{{ rrset::rrset( {{ rrset::rrset(
record=records.mailservers.0, record=records.mailservers.0,
zone=current_zone, zone=current_zone,
lang=lang) }} lang=lang) }}
{% endif %} {%- endif -%}
{% if records.spf %} {%- if records.spf -%}
{{ rrset::rrset( {{ rrset::rrset(
record=records.spf.0, record=records.spf.0,
zone=current_zone, zone=current_zone,
lang=lang) }} lang=lang) }}
{% endif %} {%- endif -%}
</ul> </ul>
{% endif %} {%- endif -%}
{% if sections.services %} {%- if sections.services -%}
<h4>{{ tr(msg="zone-content-section-services-header", lang=lang) }}</h4> <h4>{{ tr(msg="zone-content-section-services-header", lang=lang) }}</h4>
<ul> <ul>
{% for service in sections.services %} {%- for service in sections.services -%}
{{ rrset::rrset( {{ rrset::rrset(
record=service, record=service,
zone=current_zone, zone=current_zone,
lang=lang) }} lang=lang) }}
{% endfor %} {%- endfor -%}
</ul> </ul>
{% endif %} {%- endif -%}
{% if sections.miscellaneous %} {%- if sections.miscellaneous -%}
<h4>{{ tr(msg="zone-content-section-general-header", lang=lang) }}</h4> <h4>{{ tr(msg="zone-content-section-general-header", lang=lang) }}</h4>
<ul> <ul>
{% for record in sections.miscellaneous %} {%- for record in sections.miscellaneous -%}
{{ rrset::rrset( {{ rrset::rrset(
record=record, record=record,
zone=current_zone, zone=current_zone,
lang=lang) }} lang=lang) }}
{% endfor %} {%- endfor -%}
</ul> </ul>
{% endif %} {%- endif -%}
</div> </div>
</article> </article>
{% endfor %} {%- endfor -%}
</section> </section>
<section> <section>
<h2>{{ tr(msg="zone-content-aliases-header", lang=lang) }}</h2> <h2>{{ tr(msg="zone-content-aliases-header", lang=lang) }}</h2>
<ul> <ul>
{% for alias in records.aliases %} {%- for alias in records.aliases -%}
<li>{{ alias.from }} → {{ alias.target }}</li> <li>{{ alias.from }} → {{ alias.target }}</li>
{% endfor %} {%- endfor -%}
</ul> </ul>
</section> </section>
{% endblock main %} {%- endblock main -%}