chore: format templates

This commit is contained in:
Alexis Métaireau 2024-02-22 15:31:32 +01:00
parent 76ed2200cf
commit d5b1821117
8 changed files with 100 additions and 91 deletions

View file

@ -8,45 +8,45 @@
login login
{% endblock body_class %} {% endblock body_class %}
{% block content %} {% block content %}
<section> <section>
<header class="umap-nav"> <header class="umap-nav">
{% include "umap/branding.html" %} {% include "umap/branding.html" %}
</header> </header>
{% if ENABLE_ACCOUNT_LOGIN %} {% if ENABLE_ACCOUNT_LOGIN %}
<h2>{% trans "Please log in with your account" %}</h2> <h2>{% trans "Please log in with your account" %}</h2>
<div> <div>
{% if form.non_field_errors %} {% if form.non_field_errors %}
<ul class="form-errors"> <ul class="form-errors">
{% for error in form.non_field_errors %}<li>{{ error }}</li>{% endfor %} {% for error in form.non_field_errors %}<li>{{ error }}</li>{% endfor %}
</ul>
{% endif %}
<form id="login_form" action="{% url "login" %}" method="post">
{% csrf_token %}
{{ form.username.errors }}
<input type="text"
name="username"
placeholder="{% trans "Username" %}"
autofocus />
{{ form.password.errors }}
<input type="password" name="password" placeholder="{% trans "Password" %}" />
<input type="submit" value="{% trans "Login" %}" />
</form>
</div>
{% endif %}
{% if backends.backends|length %}
<h2>{% trans "Please choose a provider" %}</h2>
<div>
<ul class="login-grid block-grid">
{% for name in backends.backends %}
<li>
<a rel="nofollow"
href="{% url "social:begin" name %}"
class="umap-login-popup login-{{ name }}"
title="{{ name|title }}"></a>
</li>
{% endfor %}
</ul> </ul>
{% endif %} </div>
<form id="login_form" action="{% url "login" %}" method="post"> {% endif %}
{% csrf_token %} </section>
{{ form.username.errors }}
<input type="text"
name="username"
placeholder="{% trans "Username" %}"
autofocus />
{{ form.password.errors }}
<input type="password" name="password" placeholder="{% trans "Password" %}" />
<input type="submit" value="{% trans "Login" %}" />
</form>
</div>
{% endif %}
{% if backends.backends|length %}
<h2>{% trans "Please choose a provider" %}</h2>
<div>
<ul class="login-grid block-grid">
{% for name in backends.backends %}
<li>
<a rel="nofollow"
href="{% url "social:begin" name %}"
class="umap-login-popup login-{{ name }}"
title="{{ name|title }}"></a>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
</section>
{% endblock content %} {% endblock content %}

View file

@ -1,5 +1,4 @@
{% load static %} {% load static %}
<link rel="stylesheet" <link rel="stylesheet"
href="{% static 'umap/vendors/leaflet/leaflet.css' %}" /> href="{% static 'umap/vendors/leaflet/leaflet.css' %}" />
<link rel="stylesheet" <link rel="stylesheet"

View file

@ -1,37 +1,48 @@
{% load static %} {% load static %}
<script type="module"
<script type="module" src="{% static 'umap/vendors/leaflet/leaflet-src.esm.js' %}" defer></script> src="{% static 'umap/vendors/leaflet/leaflet-src.esm.js' %}"
defer></script>
<script type="module" src="{% static 'umap/js/modules/global.js' %}" defer></script> <script type="module" src="{% static 'umap/js/modules/global.js' %}" defer></script>
<script src="{% static 'umap/vendors/editable/Path.Drag.js' %}" defer></script> <script src="{% static 'umap/vendors/editable/Path.Drag.js' %}" defer></script>
<script src="{% static 'umap/vendors/editable/Leaflet.Editable.js' %}" defer></script> <script src="{% static 'umap/vendors/editable/Leaflet.Editable.js' %}" defer></script>
<script src="{% static 'umap/vendors/hash/leaflet-hash.js' %}" defer></script> <script src="{% static 'umap/vendors/hash/leaflet-hash.js' %}" defer></script>
<script src="{% static 'umap/vendors/i18n/Leaflet.i18n.js' %}" defer></script> <script src="{% static 'umap/vendors/i18n/Leaflet.i18n.js' %}" defer></script>
<script src="{% static 'umap/vendors/editinosm/Leaflet.EditInOSM.js' %}" defer></script> <script src="{% static 'umap/vendors/editinosm/Leaflet.EditInOSM.js' %}"
<script src="{% static 'umap/vendors/minimap/Control.MiniMap.min.js' %}" defer></script> defer></script>
<script src="{% static 'umap/vendors/minimap/Control.MiniMap.min.js' %}"
defer></script>
<script src="{% static 'umap/vendors/csv2geojson/csv2geojson.js' %}" defer></script> <script src="{% static 'umap/vendors/csv2geojson/csv2geojson.js' %}" defer></script>
<script src="{% static 'umap/vendors/togeojson/togeojson.umd.js' %}" defer></script> <script src="{% static 'umap/vendors/togeojson/togeojson.umd.js' %}" defer></script>
<script src="{% static 'umap/vendors/osmtogeojson/osmtogeojson.js' %}" defer></script> <script src="{% static 'umap/vendors/osmtogeojson/osmtogeojson.js' %}" defer></script>
<script src="{% static 'umap/vendors/loading/Control.Loading.js' %}" defer></script> <script src="{% static 'umap/vendors/loading/Control.Loading.js' %}" defer></script>
<script src="{% static 'umap/vendors/markercluster/leaflet.markercluster.js' %}" defer></script> <script src="{% static 'umap/vendors/markercluster/leaflet.markercluster.js' %}"
<script src="{% static 'umap/vendors/contextmenu/leaflet.contextmenu.min.js' %}" defer></script> defer></script>
<script src="{% static 'umap/vendors/contextmenu/leaflet.contextmenu.min.js' %}"
defer></script>
<script src="{% static 'umap/vendors/photon/leaflet.photon.js' %}" defer></script> <script src="{% static 'umap/vendors/photon/leaflet.photon.js' %}" defer></script>
<script src="{% static 'umap/vendors/georsstogeojson/GeoRSSToGeoJSON.js' %}" defer></script> <script src="{% static 'umap/vendors/georsstogeojson/GeoRSSToGeoJSON.js' %}"
defer></script>
<script src="{% static 'umap/vendors/heat/leaflet-heat.js' %}" defer></script> <script src="{% static 'umap/vendors/heat/leaflet-heat.js' %}" defer></script>
<script src="{% static 'umap/vendors/fullscreen/Leaflet.fullscreen.min.js' %}" defer></script> <script src="{% static 'umap/vendors/fullscreen/Leaflet.fullscreen.min.js' %}"
defer></script>
<script src="{% static 'umap/vendors/toolbar/leaflet.toolbar.js' %}" defer></script> <script src="{% static 'umap/vendors/toolbar/leaflet.toolbar.js' %}" defer></script>
<script src="{% static 'umap/vendors/formbuilder/Leaflet.FormBuilder.js' %}" defer></script> <script src="{% static 'umap/vendors/formbuilder/Leaflet.FormBuilder.js' %}"
<script src="{% static 'umap/vendors/measurable/Leaflet.Measurable.js' %}" defer></script> defer></script>
<script src="{% static 'umap/vendors/measurable/Leaflet.Measurable.js' %}"
defer></script>
<script src="{% static 'umap/vendors/togpx/togpx.js' %}" defer></script> <script src="{% static 'umap/vendors/togpx/togpx.js' %}" defer></script>
<script src="{% static 'umap/vendors/iconlayers/iconLayers.js' %}" defer></script> <script src="{% static 'umap/vendors/iconlayers/iconLayers.js' %}" defer></script>
<script src="{% static 'umap/vendors/tokml/tokml.js' %}" defer></script> <script src="{% static 'umap/vendors/tokml/tokml.js' %}" defer></script>
<script src="{% static 'umap/vendors/locatecontrol/L.Control.Locate.min.js' %}" defer></script> <script src="{% static 'umap/vendors/locatecontrol/L.Control.Locate.min.js' %}"
defer></script>
<script src="{% static 'umap/vendors/dompurify/purify.min.js' %}" defer></script> <script src="{% static 'umap/vendors/dompurify/purify.min.js' %}" defer></script>
<script src="{% static 'umap/vendors/colorbrewer/colorbrewer.js' %}" defer></script> <script src="{% static 'umap/vendors/colorbrewer/colorbrewer.js' %}" defer></script>
<script src="{% static 'umap/vendors/simple-statistics/simple-statistics.min.js' %}" defer></script> <script src="{% static 'umap/vendors/simple-statistics/simple-statistics.min.js' %}"
defer></script>
{% if locale %} {% if locale %}
{% with "umap/locale/"|add:locale|add:".js" as path %} {% with "umap/locale/"|add:locale|add:".js" as path %}
<script src="{% static path %}" defer></script> <script src="{% static path %}" defer></script>
{% endwith %} {% endwith %}
{% endif %} {% endif %}
<script src="{% static 'umap/js/umap.core.js' %}" defer></script> <script src="{% static 'umap/js/umap.core.js' %}" defer></script>
<script src="{% static 'umap/js/umap.autocomplete.js' %}" defer></script> <script src="{% static 'umap/js/umap.autocomplete.js' %}" defer></script>

View file

@ -8,17 +8,16 @@
{% endblock body_class %} {% endblock body_class %}
{% block extra_head %} {% block extra_head %}
{% if preconnect_domains %} {% if preconnect_domains %}
{% for domain in preconnect_domains %} {% for domain in preconnect_domains %}<link rel="preconnect" href="{{ domain }}" />{% endfor %}
<link rel="preconnect" href="{{ domain }}" />
{% endfor %}
{% endif %} {% endif %}
{% umap_css %} {% umap_css %}
{{ block.super }} {{ block.super }}
{% umap_js locale=locale %} {% umap_js locale=locale %}
{% if object.share_status != object.PUBLIC %}<meta name="robots" content="noindex">{% endif %} {% if object.share_status != object.PUBLIC %}<meta name="robots" content="noindex">{% endif %}
<link rel="alternate" type="application/json+oembed" <link rel="alternate"
href="{{ oembed_absolute_uri }}?url={{ quoted_absolute_uri }}&format=json" type="application/json+oembed"
title="{{ map.name }} oEmbed URL" /> href="{{ oembed_absolute_uri }}?url={{ quoted_absolute_uri }}&format=json"
title="{{ map.name }} oEmbed URL" />
{% endblock extra_head %} {% endblock extra_head %}
{% block content %} {% block content %}
{% block map_init %} {% block map_init %}

View file

@ -1,4 +1,4 @@
{% load umap_tags %} {% load umap_tags %}
<umap-fragment data-settings='{{ map_settings|escape }}'> <umap-fragment data-settings='{{ map_settings|escape }}'>
<div id="{{ unique_id }}" class="map_fragment"></div> <div id="{{ unique_id }}" class="map_fragment"></div>
</umap-fragment> </umap-fragment>

View file

@ -21,8 +21,9 @@
</th> </th>
<td> <td>
{{ map_inst.preview_settings|json_script:unique_id }} {{ map_inst.preview_settings|json_script:unique_id }}
<button class="map-icon map-opener" data-map-id="{{ unique_id }}" <button class="map-icon map-opener"
title="{% translate "Open preview" %}"> data-map-id="{{ unique_id }}"
title="{% translate "Open preview" %}">
<span class="icon-dashboard icon-view"></span> <span class="icon-dashboard icon-view"></span>
<span class="sr-only">{% translate "Open preview" %}</span> <span class="sr-only">{% translate "Open preview" %}</span>
</button> </button>
@ -42,35 +43,37 @@
<a href="{{ map_inst.owner.get_url }}">{{ map_inst.owner }}</a> <a href="{{ map_inst.owner.get_url }}">{{ map_inst.owner }}</a>
</td> </td>
<td> <td>
<a href="{{ map_inst.get_absolute_url }}?share" class="icon-link" <a href="{{ map_inst.get_absolute_url }}?share"
title="{% translate "Share" %}"> class="icon-link"
title="{% translate "Share" %}">
<span class="icon-dashboard icon-share"></span> <span class="icon-dashboard icon-share"></span>
<span class="sr-only">{% translate "Share" %}</span> <span class="sr-only">{% translate "Share" %}</span>
</a> </a>
<a href="{{ map_inst.get_absolute_url }}?edit" class="icon-link" <a href="{{ map_inst.get_absolute_url }}?edit"
title="{% translate "Edit" %}"> class="icon-link"
title="{% translate "Edit" %}">
<span class="icon-dashboard icon-edit"></span> <span class="icon-dashboard icon-edit"></span>
<span class="sr-only">{% translate "Edit" %}</span> <span class="sr-only">{% translate "Edit" %}</span>
</a> </a>
<a href="{% url 'map_download' map_inst.pk %}" class="icon-link" <a href="{% url 'map_download' map_inst.pk %}"
title="{% translate "Download" %}"> class="icon-link"
title="{% translate "Download" %}">
<span class="icon-dashboard icon-download"></span> <span class="icon-dashboard icon-download"></span>
<span class="sr-only">{% translate "Download" %}</span> <span class="sr-only">{% translate "Download" %}</span>
</a> </a>
<form action="{% url 'map_clone' map_inst.pk %}" method="post"> <form action="{% url 'map_clone' map_inst.pk %}" method="post">
{% csrf_token %} {% csrf_token %}
<button class="map-icon" type="submit" <button class="map-icon" type="submit" title="{% translate "Clone" %}">
title="{% translate "Clone" %}">
<span class="icon-dashboard icon-duplicate"></span> <span class="icon-dashboard icon-duplicate"></span>
<span class="sr-only">{% translate "Clone" %}</span> <span class="sr-only">{% translate "Clone" %}</span>
</button> </button>
</form> </form>
<form action="{% url 'map_delete' map_inst.pk %}" <form action="{% url 'map_delete' map_inst.pk %}"
method="post" class="map-delete"> method="post"
class="map-delete">
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="next" value="{% url 'user_dashboard' %}"> <input type="hidden" name="next" value="{% url 'user_dashboard' %}">
<button class="map-icon" type="submit" <button class="map-icon" type="submit" title="{% translate "Delete" %}">
title="{% translate "Delete" %}">
<span class="icon-dashboard icon-delete"></span> <span class="icon-dashboard icon-delete"></span>
<span class="sr-only">{% translate "Delete" %}</span> <span class="sr-only">{% translate "Delete" %}</span>
</button> </button>
@ -93,13 +96,11 @@
<span></span> <span></span>
{# djlint:on #} {# djlint:on #}
{% endif %} {% endif %}
<span class="current"> <span class="current">
{% blocktranslate with maps_number=maps.number num_pages=maps.paginator.num_pages trimmed %} {% blocktranslate with maps_number=maps.number num_pages=maps.paginator.num_pages trimmed %}
Page {{ maps_number }} of {{ num_pages }} Page {{ maps_number }} of {{ num_pages }}
{% endblocktranslate %} {% endblocktranslate %}
</span> </span>
{% if maps.has_next %} {% if maps.has_next %}
<a href="?p={{ maps.next_page_number }}{% if q %}&q={{ q }}{% endif %}">{% translate "next" %} </a> <a href="?p={{ maps.next_page_number }}{% if q %}&q={{ q }}{% endif %}">{% translate "next" %} </a>
<a href="?p={{ maps.paginator.num_pages }}{% if q %}&q={{ q }}{% endif %}">{% translate "last" %} »</a> <a href="?p={{ maps.paginator.num_pages }}{% if q %}&q={{ q }}{% endif %}">{% translate "last" %} »</a>
@ -111,12 +112,12 @@
{% endif %} {% endif %}
<span> <span>
{% blocktranslate with per_page=maps.paginator.per_page trimmed %} {% blocktranslate with per_page=maps.paginator.per_page trimmed %}
Lines per page: {{ per_page }} Lines per page: {{ per_page }}
{% endblocktranslate %} {% endblocktranslate %}
</span> </span>
<span> <span>
{% blocktranslate with count=maps.paginator.count trimmed %} {% blocktranslate with count=maps.paginator.count trimmed %}
{{ count }} maps {{ count }} maps
{% endblocktranslate %} {% endblocktranslate %}
</span> </span>
{% endif %} {% endif %}

View file

@ -7,8 +7,7 @@
{% trans "Search my maps" as placeholder %} {% trans "Search my maps" as placeholder %}
<div class="row"> <div class="row">
<h2 class="section tabs"> <h2 class="section tabs">
<a class="selected" href="{% url 'user_dashboard' %}" <a class="selected" href="{% url 'user_dashboard' %}">{% blocktranslate with count=maps.paginator.count %}My Maps ({{ count }}){% endblocktranslate %}
>{% blocktranslate with count=maps.paginator.count %}My Maps ({{ count }}){% endblocktranslate %}
</a> </a>
<a href="{% url 'user_profile' %}">{% trans "My profile" %}</a> <a href="{% url 'user_profile' %}">{% trans "My profile" %}</a>
</h2> </h2>
@ -19,17 +18,18 @@
<form action="{{ request.get_full_path }}" method="get"> <form action="{{ request.get_full_path }}" method="get">
<span> <span>
<label class="sr-only" for="q">{% translate "Maps title" %}</label> <label class="sr-only" for="q">{% translate "Maps title" %}</label>
<input id="q" name="q" type="search" <input id="q"
name="q"
type="search"
placeholder="{% translate "Maps title" %}" placeholder="{% translate "Maps title" %}"
value="{{ request.GET.q|default:"" }}" /> value="{{ request.GET.q|default:"" }}" />
</span> </span>
<input type="submit" value="{% trans "Search my maps" %}" /> <input type="submit" value="{% trans "Search my maps" %}" />
</form> </form>
{% if maps.object_list|length > 1 %} {% if maps.object_list|length > 1 %}
<a href="{% url 'user_download' %}?{% spaceless %} <a href="{% url 'user_download' %}?{% spaceless %} {% for map_inst in maps %}map_id={{ map_inst.pk }}{% if not forloop.last %}&{% endif %}{% endfor %} {% endspaceless %}"
{% for map_inst in maps %}map_id={{ map_inst.pk }}{% if not forloop.last %}&{% endif %}{% endfor %} class="button button-download">
{% endspaceless %}" class="button button-download" {% blocktranslate with count=maps.object_list|length trimmed %}
>{% blocktranslate with count=maps.object_list|length trimmed %}
Download {{ count }} maps Download {{ count }} maps
{% endblocktranslate %} {% endblocktranslate %}
</a> </a>
@ -45,7 +45,6 @@
</div> </div>
</div> </div>
{% endblock maincontent %} {% endblock maincontent %}
{% block bottom_js %} {% block bottom_js %}
{{ block.super }} {{ block.super }}
<script type="text/javascript"> <script type="text/javascript">

View file

@ -818,10 +818,10 @@ def test_oembed_map(client, map, datalayer):
def test_oembed_link(client, map, datalayer): def test_oembed_link(client, map, datalayer):
response = client.get(map.get_absolute_url()) response = client.get(map.get_absolute_url())
assert response.status_code == 200 assert response.status_code == 200
assert ( assert (
'<link rel="alternate" type="application/json+oembed"' '<link rel="alternate"\n type="application/json+oembed"'
in response.content.decode() ) in response.content.decode()
)
assert ( assert (
'href="http://testserver/map/oembed/' 'href="http://testserver/map/oembed/'
f'?url=http%3A%2F%2Ftestserver%2Fen%2Fmap%2Ftest-map_{map.id}&format=json"' f'?url=http%3A%2F%2Ftestserver%2Fen%2Fmap%2Ftest-map_{map.id}&format=json"'