prefix urls
This commit is contained in:
parent
4b5768d70b
commit
e8969ccc4a
1 changed files with 18 additions and 11 deletions
|
@ -8,32 +8,39 @@ from django.conf import settings
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
admin.autodiscover()
|
admin.autodiscover()
|
||||||
|
|
||||||
|
def p(url):
|
||||||
|
if settings.PREFIX:
|
||||||
|
url = r'^%s/%s' % (settings.PREFIX[1:], url)
|
||||||
|
else:
|
||||||
|
url = r'^' + url
|
||||||
|
return url
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
# Examples:
|
# Examples:
|
||||||
# url(r'^$', 'videopdf.views.home', name='home'),
|
# url(r'^$', 'videopdf.views.home', name='home'),
|
||||||
# url(r'^videopdf/', include('videopdf.foo.urls')),
|
# url(r'^videopdf/', include('videopdf.foo.urls')),
|
||||||
|
|
||||||
# Uncomment the admin/doc line below to enable admin documentation:
|
# Uncomment the admin/doc line below to enable admin documentation:
|
||||||
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
url(p('admin/doc/'), include('django.contrib.admindocs.urls')),
|
||||||
|
|
||||||
# Uncomment the next line to enable the admin:
|
# Uncomment the next line to enable the admin:
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(p('admin/'), include(admin.site.urls)),
|
||||||
)
|
)
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
urlpatterns += patterns('',
|
urlpatterns += patterns('',
|
||||||
(r'^data/(?P<path>.*)$', 'django.views.static.serve',
|
(p('data/(?P<path>.*)$'), 'django.views.static.serve',
|
||||||
{'document_root': settings.MEDIA_ROOT}),
|
{'document_root': settings.MEDIA_ROOT}),
|
||||||
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
|
(p('static/(?P<path>.*)$'), 'django.views.static.serve',
|
||||||
{'document_root': settings.STATIC_ROOT}),
|
{'document_root': settings.STATIC_ROOT}),
|
||||||
)
|
)
|
||||||
|
|
||||||
urlpatterns += patterns('item.views',
|
urlpatterns += patterns('item.views',
|
||||||
(r'^$', 'index'),
|
(p('$'), 'index'),
|
||||||
(r'^add$', 'add'),
|
(p('add$'), 'add'),
|
||||||
(r'^save$', 'save'),
|
(p('save$'), 'save'),
|
||||||
(r'^([A-Z0-9].*)/$', 'item'),
|
(p('([A-Z0-9].*)/$'), 'item'),
|
||||||
(r'^([A-Z0-9].*)/chunk$', 'chunk'),
|
(p('([A-Z0-9].*)/chunk$'), 'chunk'),
|
||||||
(r'^([A-Z0-9].*)/(.+.pdf)$', 'pdf'),
|
(p('([A-Z0-9].*)/(.+.pdf)$'), 'pdf'),
|
||||||
(r'^([A-Z0-9].*)$', 'item'),
|
(p('([A-Z0-9].*)$'), 'item'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue