Skip to content

Commit

Permalink
Add route for favicon to include pages that miss the location
Browse files Browse the repository at this point in the history
  • Loading branch information
pablodiegoss committed Oct 26, 2024
1 parent 5579ebe commit 79c5a24
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
6 changes: 4 additions & 2 deletions src/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
from core.views.static_views import (
community,
documentation,
favicon,
health_check,
home,
marker_generator,
robots_txt,
)
from core.views.views import (
artwork_preview,
Expand All @@ -16,7 +18,6 @@
exhibit_detail,
exhibit_select,
manifest,
robots_txt,
see_all,
service_worker,
upload_image,
Expand Down Expand Up @@ -46,7 +47,8 @@
path("upload", upload_image, name="upload-image"),
path("i18n/", include("django.conf.urls.i18n")),
path("see_all/", see_all, name="see_all"),
path("robots.txt/", robots_txt),
path("robots.txt", robots_txt),
path("favicon.ico", favicon),
path(settings.HEALTH_CHECK_URL, health_check),
path("<slug:slug>/", exhibit, name="exhibit"),
]
18 changes: 15 additions & 3 deletions src/core/views/static_views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.http import JsonResponse
from django.shortcuts import render

from django.http import JsonResponse, HttpResponse
from django.shortcuts import redirect, render
from django.templatetags.static import static

def home(request):
return render(request, "users/profile.jinja2", {})
Expand All @@ -24,3 +24,15 @@ def marker_generator(request):

def health_check(request):
return JsonResponse({"status": "ok"}, status=200)


def favicon(request):
return redirect(static("images/icons/favicon.ico"))


def robots_txt(request):
lines = [
"User-Agent: *",
"Disallow: ",
]
return HttpResponse("\n".join(lines), content_type="text/plain")
9 changes: 0 additions & 9 deletions src/core/views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,6 @@ def artwork_preview(request):
return render(request, "core/exhibit.jinja2", ctx)


@require_http_methods(["GET"])
def robots_txt(request):
lines = [
"User-Agent: *",
"Disallow: ",
]
return HttpResponse("\n".join(lines), content_type="text/plain")


@require_http_methods(["GET"])
def exhibit(request, slug):
exhibit = get_object_or_404(Exhibit.objects.prefetch_related("artworks"), slug=slug)
Expand Down

0 comments on commit 79c5a24

Please sign in to comment.