prefix urls

This commit is contained in:
j 2013-02-12 16:01:17 +01:00
parent 4b5768d70b
commit e8969ccc4a

View file

@ -8,32 +8,39 @@ from django.conf import settings
from django.contrib import admin
admin.autodiscover()
def p(url):
if settings.PREFIX:
url = r'^%s/%s' % (settings.PREFIX[1:], url)
else:
url = r'^' + url
return url
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'videopdf.views.home', name='home'),
# url(r'^videopdf/', include('videopdf.foo.urls')),
# 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:
url(r'^admin/', include(admin.site.urls)),
url(p('admin/'), include(admin.site.urls)),
)
if settings.DEBUG:
urlpatterns += patterns('',
(r'^data/(?P<path>.*)$', 'django.views.static.serve',
(p('data/(?P<path>.*)$'), 'django.views.static.serve',
{'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}),
)
urlpatterns += patterns('item.views',
(r'^$', 'index'),
(r'^add$', 'add'),
(r'^save$', 'save'),
(r'^([A-Z0-9].*)/$', 'item'),
(r'^([A-Z0-9].*)/chunk$', 'chunk'),
(r'^([A-Z0-9].*)/(.+.pdf)$', 'pdf'),
(r'^([A-Z0-9].*)$', 'item'),
(p('$'), 'index'),
(p('add$'), 'add'),
(p('save$'), 'save'),
(p('([A-Z0-9].*)/$'), 'item'),
(p('([A-Z0-9].*)/chunk$'), 'chunk'),
(p('([A-Z0-9].*)/(.+.pdf)$'), 'pdf'),
(p('([A-Z0-9].*)$'), 'item'),
)