Revision b3ae4dd1 snf-webproject/synnefo/webproject/urls.py
b/snf-webproject/synnefo/webproject/urls.py | ||
---|---|---|
31 | 31 |
# interpreted as representing official policies, either expressed |
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 |
import os |
|
35 |
|
|
34 | 36 |
from django.conf.urls.defaults import * |
35 | 37 |
from synnefo.util.entry_points import extend_urls |
38 |
from django.utils.importlib import import_module |
|
39 |
from django.conf import settings |
|
36 | 40 |
|
37 | 41 |
urlpatterns = patterns('', |
38 | 42 |
(r'^lang/$', 'synnefo.webproject.i18n.set_language') |
39 | 43 |
) |
40 | 44 |
|
45 |
if getattr(settings, 'WEBPROJECT_SERVE_STATIC', settings.DEBUG): |
|
46 |
for module, ns in settings.STATIC_FILES.iteritems(): |
|
47 |
module = import_module(module) |
|
48 |
static_root = os.path.join(os.path.dirname(module.__file__), 'static') |
|
49 |
if ns: |
|
50 |
# app contains static files in <appname>/static/ |
|
51 |
urlns = ns |
|
52 |
urlpatterns += patterns('', url(r'^%s%s/(?P<path>.*)$' % \ |
|
53 |
(settings.MEDIA_URL.lstrip("/"), urlns), |
|
54 |
'django.views.static.serve', |
|
55 |
{'document_root': static_root, |
|
56 |
'show_indexes': getattr(settings, |
|
57 |
'WEBPROJECT_STATIC_SHOW_INDEXES', True)})) |
|
58 |
else: |
|
59 |
# app contains static files in <appname>/static/<appname> |
|
60 |
for fpath in os.listdir(static_root): |
|
61 |
urlns = ns + fpath |
|
62 |
urlpatterns += patterns('', url(r'^%s%s/(?P<path>.*)$' % \ |
|
63 |
(settings.MEDIA_URL.lstrip("/"), urlns), |
|
64 |
'django.views.static.serve', |
|
65 |
{'document_root': os.path.join(static_root, urlns), |
|
66 |
'show_indexes': getattr(settings, |
|
67 |
'WEBPROJECT_STATIC_SHOW_INDEXES', True)})) |
|
68 |
|
|
41 | 69 |
urlpatterns = extend_urls(urlpatterns, 'synnefo') |
70 |
|
Also available in: Unified diff