-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathurls.py
64 lines (56 loc) · 2.21 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
# Do not remove the 'import *', this is what allows this module to provide
# 'handler404' and 'handler500'. We provide django's default handlers. In a
# nutshell, this module inherits django.conf.urls.defaults and redefines
# whatever it wants. We could import the needed bit explicitely, but if newer
# django versions add other handlers, we'll get bit in the a** again. Django's
# API is retarded, but whatever.
# See http://docs.djangoproject.com/en/dev/topics/http/views/#the-404-page-not-found-view
from django.urls import path, re_path, include
from django.contrib import admin
from django.conf import settings
from django.views.i18n import JavaScriptCatalog
import django.views.static
import webengine
from webengine.utils import get_valid_plugins
# List of patterns to apply, default view is webengine.index
urlpatterns = [
path("", webengine.utils.default_view),
]
if hasattr(settings, "ENABLE_ADMIN") and settings.ENABLE_ADMIN:
admin.autodiscover()
urlpatterns.append(re_path(r"^admin/(.*)$", admin.site.root))
plugs = get_valid_plugins()
for name, mod in plugs:
# Append patterns of each plugins
# Let each plugin define their urlpatterns, just concat them here.
urlpatterns.append(path(name + "/", include(name + ".urls")))
# JS translations. We have to prepend 'webengine.' to the package
# name since it is the way it is spelled in
# settings.INSTALLED_APPS; see also #2306.
urlpatterns.append(
path(
"jsi18n/" + name + "/",
JavaScriptCatalog.as_view(packages=["webengine." + name]),
name=name + "javascript-catalog",
),
)
# JUST FOR DEBUG PURPOSE, STATIC PAGES WILL BE SERVED BY APACHE.
if settings.DEBUG:
urlpatterns.append(
re_path(
r"^medias/(?P<path>.*)$",
django.views.static.serve,
{"document_root": "/usr/share/webengine/medias/"},
),
)
if hasattr(settings, "ENABLE_ADMIN") and settings.ENABLE_ADMIN:
urlpatterns += patterns(
"",
(
r"^admin/(?P<path>.*)$",
"django.views.static.serve",
{
"document_root": "/usr/share/python-django-common/django/contrib/admin/static/admin/"
},
),
)