feat: add favicon support with SVG response and update templates and tests
All checks were successful
Build and Push Docker Image / build (push) Successful in 26s
All checks were successful
Build and Push Docker Image / build (push) Successful in 26s
- Implemented a `favicon` view to serve a custom SVG favicon - Added `favicon.ico` route to `urls.py` - Updated `base.html` to include favicon link tag - Suppressed specific Django ASGI warnings in DEBUG mode - Added unit tests to verify favicon behavior and response
This commit is contained in:
@@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/5.2/ref/settings/
|
||||
"""
|
||||
|
||||
import os
|
||||
import warnings
|
||||
from pathlib import Path
|
||||
from urllib.parse import urlparse
|
||||
|
||||
@@ -151,6 +152,17 @@ SECRET_KEY = os.getenv("SECRET_KEY", "django-insecure-*%u*i415=%@ny05mbd-j3802bc
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = env_bool("DEBUG", True)
|
||||
|
||||
if DEBUG:
|
||||
warnings.filterwarnings(
|
||||
"ignore",
|
||||
message=(
|
||||
"StreamingHttpResponse must consume synchronous iterators in order to "
|
||||
"serve them asynchronously. Use an asynchronous iterator instead."
|
||||
),
|
||||
category=Warning,
|
||||
module=r"django\.core\.handlers\.asgi",
|
||||
)
|
||||
|
||||
ALLOWED_HOSTS = merge_unique(
|
||||
collect_hosts("COOLIFY_FQDN", "COOLIFY_URL", "ALLOWED_HOSTS"),
|
||||
["127.0.0.1", "localhost", "preview-1.azimkin.dev"],
|
||||
|
||||
@@ -17,10 +17,13 @@ Including another URLconf
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
|
||||
from santehray import views
|
||||
|
||||
urlpatterns = [
|
||||
path("favicon.ico", views.favicon, name="favicon"),
|
||||
path('', include('home.urls')),
|
||||
path('catalog/', include('items.urls')),
|
||||
path('orders/', include('orders.urls')),
|
||||
path('users/', include('users.urls')),
|
||||
path('admin/', admin.site.urls),
|
||||
]
|
||||
]
|
||||
|
||||
16
santehray/views.py
Normal file
16
santehray/views.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from django.http import HttpResponse
|
||||
|
||||
|
||||
_FAVICON_SVG = """<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="SantehRay">
|
||||
<rect width="64" height="64" rx="14" fill="#123b40"/>
|
||||
<rect x="14" y="29" width="36" height="6" rx="3" fill="#f2b544"/>
|
||||
<circle cx="18" cy="32" r="7" fill="#f5f1e8"/>
|
||||
<circle cx="46" cy="32" r="7" fill="#f5f1e8"/>
|
||||
<circle cx="18" cy="32" r="3" fill="#123b40"/>
|
||||
<circle cx="46" cy="32" r="3" fill="#123b40"/>
|
||||
</svg>
|
||||
"""
|
||||
|
||||
|
||||
def favicon(request):
|
||||
return HttpResponse(_FAVICON_SVG, content_type="image/svg+xml")
|
||||
Reference in New Issue
Block a user