forked from readthedocs/readthedocs.org
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathurls.py
178 lines (153 loc) · 5.03 KB
/
urls.py
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# pylint: disable=missing-docstring
import os
from functools import reduce
from operator import add
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path, re_path
from django.views.generic.base import RedirectView, TemplateView
from readthedocs.core.views import (
HomepageView,
SupportView,
do_not_track,
server_error_404,
server_error_500,
)
from readthedocs.search.views import GlobalSearchView
admin.autodiscover()
handler404 = server_error_404
handler500 = server_error_500
basic_urls = [
path("", HomepageView.as_view(), name="homepage"),
re_path(r"^security/", TemplateView.as_view(template_name="security.html")),
re_path(
r'^\.well-known/security.txt$',
TemplateView
.as_view(template_name='security.txt', content_type='text/plain'),
),
path("support/", SupportView.as_view(), name="support"),
# These are redirected to from the support form
path(
"support/success/",
TemplateView.as_view(template_name="support/success.html"),
name="support_success",
),
path(
"support/error/",
TemplateView.as_view(template_name="support/error.html"),
name="support_error",
),
]
rtd_urls = [
path("search/", GlobalSearchView.as_view(), name="search"),
re_path(r"^dashboard/", include("readthedocs.projects.urls.private")),
re_path(r"^profiles/", include("readthedocs.profiles.urls.public")),
re_path(r"^accounts/", include("readthedocs.profiles.urls.private")),
re_path(r"^accounts/", include("allauth.urls")),
re_path(r"^notifications/", include("readthedocs.notifications.urls")),
re_path(r"^accounts/gold/", include("readthedocs.gold.urls")),
path("invitations/", include("readthedocs.invitations.urls")),
# For redirects
re_path(r'^builds/', include('readthedocs.builds.urls')),
# For testing the 500's with DEBUG on.
path("500/", handler500),
# Put this as a unique path for the webhook, so we don't clobber existing Stripe URL's
re_path(r"^djstripe/", include("djstripe.urls", namespace="djstripe")),
]
project_urls = [
re_path(r'^projects/', include('readthedocs.projects.urls.public')),
]
organization_urls = [
re_path(
r'^organizations/',
include('readthedocs.organizations.urls.private'),
),
re_path(
r'^organizations/',
include('readthedocs.organizations.urls.public'),
),
re_path(
r'^organizations/(?P<slug>[\w.-]+)/subscription/',
include('readthedocs.subscriptions.urls'),
),
# NOTE: This is overridden in .com to serve a real pricing page.
re_path(
r'^pricing/',
RedirectView.as_view(url='https://readthedocs.org/sustainability/'),
name='pricing',
),
]
api_urls = [
re_path(r'^api/v2/', include('readthedocs.api.v2.urls')),
# Keep `search_api` at root level, so the test does not fail for other API
re_path(r"^api/v2/search/$", include("readthedocs.search.api.v2.urls")),
# Deprecated
re_path(r'^api/v1/embed/', include('readthedocs.embed.urls')),
re_path(r'^api/v2/embed/', include('readthedocs.embed.urls')),
re_path(
r'^api-auth/',
include('rest_framework.urls', namespace='rest_framework')
),
re_path(r'^api/v3/', include('readthedocs.api.v3.urls')),
re_path(r'^api/v3/embed/', include('readthedocs.embed.v3.urls')),
]
i18n_urls = [
re_path(r'^i18n/', include('django.conf.urls.i18n')),
]
admin_urls = [
re_path(r'^admin/', admin.site.urls),
]
dnt_urls = [
re_path(r'^\.well-known/dnt/$', do_not_track),
# https://github.com/EFForg/dnt-guide#12-how-to-assert-dnt-compliance
re_path(
r'^\.well-known/dnt-policy.txt$',
TemplateView
.as_view(template_name='dnt-policy.txt', content_type='text/plain'),
),
]
debug_urls = []
for build_format in ('epub', 'htmlzip', 'json', 'pdf'):
debug_urls += static(
settings.MEDIA_URL + build_format,
document_root=os.path.join(settings.MEDIA_ROOT, build_format),
)
debug_urls += [
path("404/", server_error_404),
path(
"style-catalog/",
TemplateView.as_view(template_name="style_catalog.html"),
),
# This must come last after the build output files
path(
"media/<path:remainder>",
RedirectView.as_view(url=settings.STATIC_URL + "%(remainder)s"),
name="media-redirect",
),
]
# Export URLs
groups = [
basic_urls,
rtd_urls,
project_urls,
organization_urls,
api_urls,
i18n_urls,
]
if settings.DO_NOT_TRACK_ENABLED:
# Include Do Not Track URLs if DNT is supported
groups.append(dnt_urls)
if settings.READ_THE_DOCS_EXTENSIONS:
groups.append([
re_path(r'^', include('readthedocsext.urls'))
])
if settings.ALLOW_ADMIN:
groups.append(admin_urls)
if settings.SHOW_DEBUG_TOOLBAR:
import debug_toolbar
debug_urls += [
re_path(r'^__debug__/', include(debug_toolbar.urls)),
]
groups.append(debug_urls)
urlpatterns = reduce(add, groups)