b36cbe3052941dad3b147b55a2fabb6562a57a4d
[redakcja.git] / apps / api / urls.py
1 __author__="lreqc"
2 __date__ ="$2009-09-17 16:16:54$"
3
4 from django.conf.urls.defaults import *
5
6 from api.resources import *
7
8 FORMAT = r"\.(?P<emitter_format>xml|json|yaml)"
9 DOC = r'(?P<docid>[^/]+)'
10 REVISION = r'(?P<revision>latest|[0-9a-f]{40})'
11
12 def urlpath(*args, **kwargs):
13     format = kwargs.get('format', True)
14     return r'^' + (r'/'.join(args)) + (FORMAT if format else '') + '$'
15
16 urlpatterns = patterns('',
17 #    url(r'^hello$', hello_resource, {'emitter_format': 'json'}),
18 #    url(r'^hello\.(?P<emitter_format>.+)$', hello_resource),
19
20     # Toolbar
21     url(r'^toolbar/buttons$', toolbar_buttons, {'emitter_format': 'json'}),
22
23     # Toolbar
24     url(r'^toolbar/scriptlets$', scriptlets, {'emitter_format': 'json'}),
25     
26     # Documents
27     url(r'^documents$', library_resource,
28         {'emitter_format': 'json'}, name="document_list_view"),
29
30     url(urlpath(r'documents'), library_resource,
31         name="document_list_view_withformat"),
32         
33     url(urlpath(r'documents', DOC),
34         document_resource, name="document_view_withformat"),
35
36     url(urlpath(r'documents', DOC, format=False),
37         document_resource, {'emitter_format': 'json'},
38         name="document_view"),
39     
40     url(urlpath(r'documents', DOC, 'text', REVISION, format=False),
41         document_text_resource, {'emitter_format': 'rawxml'},
42         name="doctext_view"),
43
44     url(urlpath(r'documents', DOC, 'html', REVISION, format=False),
45         document_text_resource, {'emitter_format': 'rawhtml'},
46         name="dochtml_view"),
47
48     url(urlpath(r'documents', DOC, 'dc', REVISION),
49         document_dc_resource,
50         name="docdc_view_withformat"),
51
52     url(urlpath(r'documents', DOC, 'dc', REVISION, format=False),
53         document_dc_resource, {'emitter_format': 'json'},
54         name="docdc_view"),
55
56     url(urlpath(r'documents', DOC, 'revision'),
57         document_merge, {'emitter_format': 'json'}, name="docmerge_view")
58
59 #    url(r'^documents/(?P<docid>[^/]+)/parts$',
60 #        document_resource, {'emitter_format': 'json'},
61 #        name="docparts_view"),
62         
63   #  url(r'^posts/(?P<post_slug>[^/]+)/$', blogpost_resource),
64   #  url(r'^other/(?P<username>[^/]+)/(?P<data>.+)/$', arbitrary_resource),
65 )
66