Set a default favicon
This commit is contained in:
parent
686ce1fe2d
commit
915d6b6db4
9 changed files with 40 additions and 4 deletions
BIN
umap/static/umap/favicons/apple-touch-icon.png
Normal file
BIN
umap/static/umap/favicons/apple-touch-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
BIN
umap/static/umap/favicons/favicon.ico
Normal file
BIN
umap/static/umap/favicons/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
BIN
umap/static/umap/favicons/icon-192.png
Normal file
BIN
umap/static/umap/favicons/icon-192.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
BIN
umap/static/umap/favicons/icon-512.png
Normal file
BIN
umap/static/umap/favicons/icon-512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 133 KiB |
5
umap/static/umap/favicons/icon.svg
Normal file
5
umap/static/umap/favicons/icon.svg
Normal file
|
@ -0,0 +1,5 @@
|
|||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="0.25" y="0.25" width="15.5" height="15.5" rx="7.75" fill="#F2F2F2" stroke="#F2F2F2" stroke-width="0.5"/>
|
||||
<path d="M5.85165 3.48438C4.82662 3.97171 3.99789 4.79329 3.50169 5.81407C3.00549 6.83484 2.87134 7.99406 3.12131 9.10118C3.37127 10.2083 3.99047 11.1974 4.87712 11.906C5.76377 12.6145 6.8651 13.0004 8.00009 13C4.1329 9.39063 3.24228 4.9375 5.85165 3.48438ZM8.00009 13C9.13508 13.0004 10.2364 12.6145 11.1231 11.906C12.0097 11.1974 12.6289 10.2083 12.8789 9.10118C13.1288 7.99406 12.9947 6.83484 12.4985 5.81407C12.0023 4.79329 11.1736 3.97171 10.1485 3.48438C12.7579 4.9375 11.8673 9.39063 8.00009 13Z" fill="#323E56"/>
|
||||
<path d="M9.85156 5.64062C9.85156 5.88378 9.80367 6.12455 9.71062 6.34919C9.61757 6.57383 9.48119 6.77794 9.30925 6.94988C9.13732 7.12181 8.9332 7.2582 8.70856 7.35125C8.48392 7.4443 8.24315 7.49219 8 7.49219C7.75685 7.49219 7.51608 7.4443 7.29144 7.35125C7.0668 7.2582 6.86268 7.12181 6.69075 6.94988C6.51881 6.77794 6.38243 6.57383 6.28938 6.34919C6.19633 6.12455 6.14844 5.88378 6.14844 5.64062C6.14844 5.14956 6.34351 4.67861 6.69075 4.33137C7.03798 3.98414 7.50894 3.78906 8 3.78906C8.49107 3.78906 8.96202 3.98414 9.30925 4.33137C9.65649 4.67861 9.85156 5.14956 9.85156 5.64062Z" fill="#323E56"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.3 KiB |
6
umap/static/umap/favicons/manifest.webmanifest
Normal file
6
umap/static/umap/favicons/manifest.webmanifest
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"icons": [
|
||||
{ "src": "/icon-192.png", "type": "image/png", "sizes": "192x192" },
|
||||
{ "src": "/icon-512.png", "type": "image/png", "sizes": "512x512" }
|
||||
]
|
||||
}
|
|
@ -15,6 +15,11 @@
|
|||
{% endblock extra_head %}
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||
{# See https://evilmartians.com/chronicles/how-to-favicon-in-2021-six-files-that-fit-most-needs #}
|
||||
<link rel="icon" href="/favicon.ico" sizes="32x32">
|
||||
<link rel="icon" href="/icon.svg" type="image/svg+xml">
|
||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png"><!-- 180×180 -->
|
||||
<link rel="manifest" href="/manifest.webmanifest">
|
||||
</head>
|
||||
<body class="{% block body_class %}{% endblock body_class %}">
|
||||
{% block header %}
|
||||
|
|
10
umap/urls.py
10
umap/urls.py
|
@ -183,7 +183,15 @@ urlpatterns += i18n_patterns(
|
|||
re_path(r"^user/(?P<identifier>.+)/$", views.user_maps, name="user_maps"),
|
||||
re_path(r"", include(i18n_urls)),
|
||||
)
|
||||
urlpatterns += (path("stats/", cache_page(60 * 60)(views.stats), name="stats"),)
|
||||
urlpatterns += (
|
||||
path("stats/", cache_page(60 * 60)(views.stats), name="stats"),
|
||||
path("favicon.ico", views.favicon_file),
|
||||
path("icon.svg", views.favicon_file),
|
||||
path("apple-touch-icon.png", views.favicon_file),
|
||||
path("manifest.webmanifest", views.favicon_file),
|
||||
path("icon-192.png", views.favicon_file),
|
||||
path("icon-512.png", views.favicon_file),
|
||||
)
|
||||
|
||||
if settings.DEBUG and settings.MEDIA_ROOT:
|
||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
|
|
@ -21,6 +21,7 @@ from django.core.signing import BadSignature, Signer
|
|||
from django.core.validators import URLValidator, ValidationError
|
||||
from django.db.models import Q
|
||||
from django.http import (
|
||||
FileResponse,
|
||||
HttpResponse,
|
||||
HttpResponseBadRequest,
|
||||
HttpResponseForbidden,
|
||||
|
@ -34,6 +35,8 @@ from django.utils.encoding import smart_bytes
|
|||
from django.utils.http import http_date
|
||||
from django.utils.translation import gettext as _
|
||||
from django.utils.translation import to_locale
|
||||
from django.views.decorators.cache import cache_control
|
||||
from django.views.decorators.http import require_GET
|
||||
from django.views.generic import DetailView, TemplateView, View
|
||||
from django.views.generic.base import RedirectView
|
||||
from django.views.generic.detail import BaseDetailView
|
||||
|
@ -469,9 +472,7 @@ class MapDetailMixin:
|
|||
else:
|
||||
map_statuses = AnonymousMapPermissionsForm.STATUS
|
||||
datalayer_statuses = AnonymousDataLayerPermissionsForm.STATUS
|
||||
properties["edit_statuses"] = [
|
||||
(i, str(label)) for i, label in map_statuses
|
||||
]
|
||||
properties["edit_statuses"] = [(i, str(label)) for i, label in map_statuses]
|
||||
properties["datalayer_edit_statuses"] = [
|
||||
(i, str(label)) for i, label in datalayer_statuses
|
||||
]
|
||||
|
@ -1016,6 +1017,17 @@ def stats(request):
|
|||
)
|
||||
|
||||
|
||||
@require_GET
|
||||
@cache_control(max_age=60 * 60 * 24, immutable=True, public=True) # one day
|
||||
def favicon_file(request):
|
||||
# See https://adamj.eu/tech/2022/01/18/how-to-add-a-favicon-to-your-django-site/
|
||||
name = request.path.lstrip("/")
|
||||
file = (Path(settings.PROJECT_DIR) / "static" / "umap" / "favicons" / name).open(
|
||||
"rb"
|
||||
)
|
||||
return FileResponse(file)
|
||||
|
||||
|
||||
def logout(request):
|
||||
do_logout(request)
|
||||
if is_ajax(request):
|
||||
|
|
Loading…
Reference in a new issue