diff --git a/templates/bases/base.html b/templates/bases/base.html index e543cb6..f653f85 100644 --- a/templates/bases/base.html +++ b/templates/bases/base.html @@ -1,5 +1,5 @@ <!DOCTYPE html> -<html> +<html lang="fr"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> diff --git a/templates/macros.html b/templates/macros.html new file mode 100644 index 0000000..5316a26 --- /dev/null +++ b/templates/macros.html @@ -0,0 +1,74 @@ +{% macro rrset(rtype, ttl, data, zone) %} + <li class="rrset"> + <div class="rtype"> + {{ rtype }} + <div class="action"> + <button class="icon"> + <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash" viewBox="0 0 16 16"> + <path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0z"/> + <path d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4zM2.5 3h11V2h-11z"/> + </svg> + </button> + <a class="button icon" href="#"> + <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"/> + </svg> + </a> + </div> + </div> + + <ul> + {% for data in data %} + <li> + <div class="rdata"> + {% if rtype == "address" %} + <div class="rdata-main"> + <span class="pill"> + {{ data.address }} + </span> + </div> + {% elif rtype == "mailserver" %} + <div class="rdata-main"> + <span class="pill"> + {{ data.mail_exchanger }} + </span> + </div> + <div class="rdata-complementary"> + <span class="pill"> + Preference: {{ data.preference }} + </span> + </div> + {% elif rtype == "nameserver" %} + <div class="rdata-main"> + <span class="pill"> + {{ data.target }} + </span> + </div> + {% elif rtype == "service" %} + <div class="rdata-main"> + <span class="pill"> + {% if data.service_type == "other" %} + {{ data.service_name }}/{{ data.service_protocol }} + {% else %} + {{ data.service_type }} + {% endif %} + </span> + <span class="pill"> + Address: {{ data.server }}:{{ data.port }} + </span> + </div> + <div class="rdata-complementary"> + <span class="pill"> + Priority: {{ data.priority }} + </span> + <span class="pill"> + Weight: {{ data.weight }} + </span> + </div> + {% endif %} + </div> + </li> + {% endfor %} + </ul> + </li> +{% endmacro rrset %} diff --git a/templates/pages/new_record.html b/templates/pages/new_record.html new file mode 100644 index 0000000..6bab4a4 --- /dev/null +++ b/templates/pages/new_record.html @@ -0,0 +1,61 @@ +{% extends "bases/app.html" %} +{% block title %}New record - {{ current_zone }} - {% endblock title %} + +{% block main %} +<h1>Create a new record in zone {{ current_zone }}</h1> +{% if not new_record_name or (new_record_name and domain_error) %} +<h2>Choose the name of the new record</h2> +<form action="" method="GET"> + <label for="subdomain">Name of the new record</label> + <div class="input-group"> + <input + type="text" + name="subdomain" + id="subdomain" + {% if domain_error %}aria-invalid="true"{% endif %} + aria-describedby="subdomain-help{% if domain_error %} subdomain-error{% endif %}" + > + <span>.{{ current_zone }}</span> + </div> + {% if domain_error %} + <p class="error" id="subdomain-error">{{ domain_error.description }}</p> + {% endif %} + <p id="subdomain-help">Only the subdomain, without the main domain. For instance, "www" to create the subdomain "www.{{ current_zone }}".</p> + <button type="submit">Next step</button> +</form> +{% elif not config and not rtype %} + +<h2>Configure the domain {{ new_record_name }}...</h2> +<ul> + <li><a href="{{ url }}&config=web">Web</a></li> + <li><a href="{{ url }}&config=mail">E-mails</a></li> +</ul> +<h2>...or create a new record for the domain {{ new_record_name }}</h2> +<h3>General</h3> +<ul> + <li><a href="{{ url }}&rtype=address">Address (A or AAAA)</a></li> + <li><a href="{{ url }}&rtype=alias">Alias (CNAME)</a></li> + <li><a href="{{ url }}&rtype=text">Text (TXT)</a></li> + <li><a href="{{ url }}&rtype=service">Service (SRV)</a></li> +</ul> +<h3>E-mails</h3> +<ul> + <li><a href="{{ url }}&rtype=service">Mail servers (MX)</a></li> + <li><a href="{{ url }}&rtype=spf">Sender policy (SPF)</a></li> + <li><a href="{{ url }}&rtype=dkim">Cryptographic signatures (DKIM)</a></li> + <li><a href="{{ url }}&rtype=dmarc">Error reporting (DMARC)</a></li> +</ul> +<h3>Security</h3> +<ul> + <li><a href="{{ url }}&rtype=dane">Domain authentication (TLSA)</a></li> + <li><a href="{{ url }}&rtype=sshfp">SSH keys fingerprint (SSHFP)</a></li> +</ul> +<h3>DNS Delegation</h3> +<ul> + <li><a href="{{ url }}&rtype=nameserver">Nameserver (NS)</a></li> + <li><a href="{{ url }}&rtype=ds">Delegation signer (DS)</a></li> +</ul> +{% else %} +{% endif %} + +{% endblock %} diff --git a/templates/pages/records.html b/templates/pages/records.html index 5bc1407..7711904 100644 --- a/templates/pages/records.html +++ b/templates/pages/records.html @@ -1,9 +1,11 @@ +{% import "macros.html" as macros %} {% extends "bases/app.html" %} + {% block title %}Records - {{ current_zone }} - {% endblock title %} {% block main %} - <h1>Zone {{ current_zone }} records</h1> - <svg width="0" height="0" aria-hidden="true"> + <h1>Zone <strong>{{ current_zone }}</strong> records</h1> + <svg width="0" height="0" aria-hidden="true" style="position: absolute;"> <defs> <clipPath id="corner-folder-tab-right" clipPathUnits="objectBoundingBox"> <path d="m 0,0 c .25,0 0.75,1 1,1 l -1,0 z"/> @@ -12,26 +14,12 @@ </svg> <section> <h2>Records</h2> - - {% set current_domain = '' %} - {% set current_rtype = '' %} - - {% for record in records %} - {% if record.name != current_domain %} - {% if current_domain %} - </ul> - </li> - </ul> - </div> - </article> - {% endif %} - {% set_global current_domain = record.name %} - {% set_global current_rtype = '' %} + {% for group in records.records %} <article class="domain"> <header> - <h3 class="folder-tab">{{ record.name }}</h3> + <h3 class="folder-tab">{{ group.owner }}</h3> <span class="sep"></span> - <a href="#" class="button"> + <a href="{{ url }}/new?subdomain={{ group.owner | trim_end_matches(pat=current_zone) | trim_end_matches(pat=".") }}" class="button"> <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 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"/> @@ -40,64 +28,63 @@ </a> </header> <div class="records"> + {% if group.web %} + <h4>Web</h4> <ul> - {% endif %} - {% if record.type != current_rtype %} - {% if current_rtype %} - </ul> - </li> - {% endif %} - {% set_global current_rtype = record.type %} - <li class="rrset"> - <span class="rtype">{{ record.type }}</span> - <ul> - <li> + {% if group.web.addresses %} + {{ macros::rrset( + rtype=group.web.addresses.rtype, + ttl=group.web.addresses.ttl, + data=group.web.addresses.data, + zone=current_zone) }} {% endif %} - <div class="rdata"> - {% if record.type == "A" or record.type == "AAAA" %} - <div class="rdata-main"> - <span class="pill"> - {{ record.rdata.address }} - </span> - </div> - {% elif record.type == "MX" %} - <div class="rdata-main"> - <span class="pill"> - {{ record.rdata.mail_exchanger }} - </span> - </div> - <div class="rdata-complementary"> - <span class="pill"> - Preference: {{ record.rdata.mail_exchanger }} - </span> - </div> - {% elif record.type == "NS" %} - <div class="rdata-main"> - <span class="pill"> - {{ record.rdata.target }} - </span> - </div> - {% endif %} - </div> - <div class="action"> - <button class="icon"> - <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash" viewBox="0 0 16 16"> - <path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0z"/> - <path d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4zM2.5 3h11V2h-11z"/> - </svg> - </button> - <a class="button icon" href="#"> - <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"/> - </svg> - </a> - </div> - </li> + </ul> + {% endif %} + + {% if group.mail %} + <h4>E-mails</h4> + <ul> + {% if group.mail.servers %} + {{ macros::rrset( + rtype=group.mail.servers.rtype, + ttl=group.mail.servers.ttl, + data=group.mail.servers.data, + zone=current_zone) }} + {% endif %} + {% if group.mail.spf %} + {{ macros::rrset( + rtype=group.mail.spf.rtype, + ttl=group.mail.spf.ttl, + data=group.mail.spf.data, + zone=current_zone) }} + {% endif %} + </ul> + {% endif %} + + {% if group.general_records %} + <h4>General</h4> + <ul> + {% for rrset in group.general_records %} + {{ macros::rrset( + rtype=rrset.rtype, + ttl=rrset.ttl, + data=rrset.data, + zone=current_zone) }} + {% endfor %} + </ul> + {% endif %} + + </div> + </article> {% endfor %} - </ul> - </li> - </ul> - </div> - </article> + </section> + <section> + <h2>Aliases</h2> + + <ul> + {% for alias in records.aliases %} + <li>{{ alias.from }} → {{ alias.target }}</li> + {% endfor %} + </ul> </section> {% endblock main %}