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

@ -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,33 +1,44 @@
{% 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>

View file

@ -8,15 +8,14 @@
{% 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"
type="application/json+oembed"
href="{{ oembed_absolute_uri }}?url={{ quoted_absolute_uri }}&format=json" href="{{ oembed_absolute_uri }}?url={{ quoted_absolute_uri }}&format=json"
title="{{ map.name }} oEmbed URL" /> title="{{ map.name }} oEmbed URL" />
{% endblock extra_head %} {% endblock extra_head %}

View file

@ -21,7 +21,8 @@
</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"
data-map-id="{{ unique_id }}"
title="{% translate "Open preview" %}"> 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>
@ -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"
class="icon-link"
title="{% translate "Share" %}"> 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"
class="icon-link"
title="{% translate "Edit" %}"> 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 %}"
class="icon-link"
title="{% translate "Download" %}"> 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>

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"'