summaryrefslogtreecommitdiff
path: root/docs/urls.py
blob: 552a116fd9924ac2deb25ae64f101f9873b9a30a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from django.conf import settings
from django.urls import path, re_path
from django.views.generic import RedirectView

from . import views, views_debug

urlpatterns = [
    path("", views.index, name="homepage"),
    path("search/", views.redirect_search),
    path("<lang>/", views.language),
    re_path(
        r"^[a-z-]+/[\w.-]+/internals/team/$",
        RedirectView.as_view(
            url="https://www.djangoproject.com/foundation/teams/",
            permanent=True,
        ),
    ),
    re_path("^(?P<lang>[a-z-]+)/(?P<version>stable)/(?P<url>.*)$", views.stable),
    re_path(
        r"^(?P<lang>[a-z-]+)/(?P<version>[\w.-]+)/$",
        views.document,
        {"url": ""},
        name="document-index",
    ),
    re_path(
        r"^(?P<lang>[a-z-]+)/(?P<version>[\w.-]+)/_images/(?P<path>.*)$",
        views_debug.sphinx_static,
        {"subpath": "_images"},
    ),
    re_path("^(.*)/index/$", views.redirect_index),
    re_path(
        r"^(?P<lang>[a-z-]+)/(?P<version>[\w.-]+)/search/$",
        views.search_results,
        name="document-search",
    ),
    re_path(
        r"^(?P<lang>[a-z-]+)/(?P<version>[\w.-]+)/search/description/$",
        views.search_description,
        name="document-search-description",
    ),
    re_path(
        r"^(?P<lang>[a-z-]+)/(?P<version>[\w.-]+)/search/suggestions/$",
        views.search_suggestions,
        name="document-search-suggestions",
    ),
    re_path(
        r"^(?P<lang>[a-z-]+)/(?P<version>[\w.-]+)/(?P<url>[\w./-]*)/$",
        views.document,
        name="document-detail",
    ),
]

if settings.DEBUG:
    # Patterns for sphinx (in production they are served by nginx directly)
    # They need to be inserted at the beginning to take precedence over document-detail
    urlpatterns = [
        re_path(
            r"^(?P<lang>[a-z-]+)/(?P<version>[\w.-]+)/_objects/$",
            views_debug.objects_inventory,
        ),
        re_path(
            r"^(?P<lang>[a-z-]+)/(?P<version>[\w.-]+)/(?P<subpath>_downloads|_source)/(?P<path>.*)$",  # noqa: E501
            views_debug.sphinx_static,
        ),
        re_path(r"^pots/(?P<pot_name>\w+\.pot)$", views_debug.pot_file),
        *urlpatterns,
    ]