a77169d83eafba1dcb43ae55013f597f59ee0265
[redakcja.git] / project / urls.py
1 # -*- coding: utf-8 -*-
2
3 from django.conf.urls.defaults import *
4 from django.contrib import admin
5 from django.conf import settings
6
7 admin.autodiscover()
8 PATH_SEC = r"(?P<path>[^/]+)"
9 PATH_END = PATH_SEC + "/$"
10
11 urlpatterns = patterns('',
12     # Explorer:
13     url(r'^$', 'explorer.views.file_list', name='file_list'),
14     
15     url(r'^file/'+PATH_SEC+'/text/$', 'explorer.views.file_xml', name='file_xml'),
16     url(r'^file/'+PATH_SEC+'/dc/$', 'explorer.views.file_dc', name='file_dc'),
17     url(r'^file/upload', 'explorer.views.file_upload', name='file_upload'),
18     url(r'^file/'+PATH_SEC+'/commit$', 'explorer.views.file_commit', name='file_commit'),
19     url(r'^file/'+PATH_SEC+'/update$', 'explorer.views.file_update_local', name='file_update'),
20
21     url(r'^images/(?P<folder>[^/]+)/$', 'explorer.views.folder_images', name='folder_image'),
22     url(r'^images/$', 'explorer.views.folder_images', {'folder': '.'}, name='folder_image_ajax'),
23     
24     # Editor panels
25     url(r'^editor/'+PATH_SEC+'/panel/(?P<name>[a-z]+)/$', 'explorer.views.panel_view', name='panel_view'),
26     url(r'^editor/'+PATH_END, 'explorer.views.display_editor', name='editor_view'),
27     url(r'^editor/$', 'explorer.views.file_list', name='editor_base'),
28
29     url(r'^editor/'+PATH_SEC+'/split$', 'explorer.views.split_text'),
30     url(r'^editor/'+PATH_SEC+'/split-success',
31         'explorer.views.split_success', name='split-success'),
32
33     url(r'^editor/'+PATH_SEC+'/print/html$', 'explorer.views.print_html'),
34     url(r'^editor/'+PATH_SEC+'/print/xml$', 'explorer.views.print_xml'),
35     
36     # Task managment
37     # url(r'^manager/pull-requests$', 'explorer.views.pull_requests'),
38
39     # Admin panel
40     url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
41     url(r'^admin/(.*)', admin.site.root),
42
43     # Prototypes
44     url(r'^wysiwyg-proto/', include('wysiwyg.urls')),
45
46     # Our über-restful api
47     url(r'^api/', include('api.urls') ),
48     
49 )
50
51 if 'cas_consumer' in settings.INSTALLED_APPS:
52     urlpatterns += patterns('',
53         # django-cas-consumer
54         url(r'^accounts/login/$', 'cas_consumer.views.login', name='login'),
55         url(r'^accounts/logout/$', 'cas_consumer.views.logout', name='logout'),
56     )
57 else:
58     urlpatterns += patterns('',
59         # Django auth
60         url(r'^accounts/login/$', 'django.contrib.auth.views.login', {'redirect_field_name': 'next'}, name='login'),
61         url(r'^accounts/logout/$', 'django.contrib.auth.views.logout', {'next_page': '/'}, name='logout'),    
62     )
63
64 # Static files
65 if settings.DEBUG and not hasattr(settings, 'DONT_SERVE_STATIC'):
66     urlpatterns += patterns('',
67         url(r'^%s(?P<path>.+)$' % settings.MEDIA_URL[1:], 'django.views.static.serve',
68             {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
69         url(r'^%s(?P<path>.+)$' % settings.STATIC_URL[1:], 'django.views.static.serve',
70             {'document_root': settings.STATIC_ROOT, 'show_indexes': True}),
71     )
72