Changeset View
Changeset View
Standalone View
Standalone View
swh/web/misc/urls.py
# Copyright (C) 2019-2022 The Software Heritage developers | # Copyright (C) 2019-2022 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU Affero General Public License version 3, or any later version | # License: GNU Affero General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import json | import json | ||||
import requests | import requests | ||||
from django.conf.urls import include, url | from django.conf.urls import include, url | ||||
from django.contrib.staticfiles import finders | from django.contrib.staticfiles import finders | ||||
from django.http import JsonResponse | from django.http import JsonResponse | ||||
from django.shortcuts import render | from django.shortcuts import render | ||||
from django.views.decorators.clickjacking import xframe_options_exempt | |||||
from swh.web.common import archive | from swh.web.common import archive | ||||
from swh.web.common.exc import sentry_capture_exception | from swh.web.common.exc import sentry_capture_exception | ||||
from swh.web.config import get_config | from swh.web.config import get_config | ||||
from swh.web.misc.metrics import prometheus_metrics | from swh.web.misc.metrics import prometheus_metrics | ||||
def _jslicenses(request): | def _jslicenses(request): | ||||
Show All 17 Lines | def _stat_counters(request): | ||||
counters = { | counters = { | ||||
"stat_counters": stat_counters, | "stat_counters": stat_counters, | ||||
"stat_counters_history": stat_counters_history, | "stat_counters_history": stat_counters_history, | ||||
} | } | ||||
return JsonResponse(counters) | return JsonResponse(counters) | ||||
@xframe_options_exempt | |||||
def hiring_banner(request): | |||||
lang = request.GET.get("lang") | |||||
return render( | |||||
request, | |||||
"misc/hiring-banner.html", | |||||
{ | |||||
"lang": lang if lang else "en", | |||||
}, | |||||
) | |||||
urlpatterns = [ | urlpatterns = [ | ||||
url(r"^", include("swh.web.misc.coverage")), | url(r"^", include("swh.web.misc.coverage")), | ||||
url(r"^jslicenses/$", _jslicenses, name="jslicenses"), | url(r"^jslicenses/$", _jslicenses, name="jslicenses"), | ||||
url(r"^", include("swh.web.misc.origin_save")), | url(r"^", include("swh.web.misc.origin_save")), | ||||
url(r"^stat_counters/$", _stat_counters, name="stat-counters"), | url(r"^stat_counters/$", _stat_counters, name="stat-counters"), | ||||
url(r"^", include("swh.web.misc.badges")), | url(r"^", include("swh.web.misc.badges")), | ||||
url(r"^metrics/prometheus/$", prometheus_metrics, name="metrics-prometheus"), | url(r"^metrics/prometheus/$", prometheus_metrics, name="metrics-prometheus"), | ||||
url(r"^", include("swh.web.misc.iframe")), | url(r"^", include("swh.web.misc.iframe")), | ||||
url(r"^", include("swh.web.misc.fundraising")), | url(r"^", include("swh.web.misc.fundraising")), | ||||
url(r"^hiring/banner/$", hiring_banner, name="swh-hiring-banner"), | |||||
] | ] | ||||
# when running end to end tests through cypress, declare some extra | # when running end to end tests through cypress, declare some extra | ||||
# endpoints to provide input data for some of those tests | # endpoints to provide input data for some of those tests | ||||
if get_config()["e2e_tests_mode"]: | if get_config()["e2e_tests_mode"]: | ||||
from swh.web.tests.views import ( | from swh.web.tests.views import ( | ||||
get_content_code_data_all_exts, | get_content_code_data_all_exts, | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |