6a95cf0cb60690780b44bbdfad997002bd9825f8
[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     url(r'^toolbar/scriptlets$', scriptlets, {'emitter_format': 'json'}),
23
24     # Pull requests
25     url(r"^pull-requests$", pullrequest_collection,
26         {'emitter_format': 'json'} ),
27         
28     url(r"^pull-requests/(?P<prq_id>\d+)$", pullrequest_rsrc,
29         {'emitter_format': 'json'}, name="pullrequest_view" ),    
30     
31     # Documents
32     url(r'^documents$', library_resource,
33         {'emitter_format': 'json'}, name="document_list_view"),
34
35     url(urlpath(r'documents'), library_resource,
36         name="document_list_view_withformat"),
37         
38     url(urlpath(r'documents', DOC),
39         document_resource, name="document_view_withformat"),
40
41     url(urlpath(r'documents', DOC, format=False),
42         document_resource, {'emitter_format': 'json'},
43         name="document_view"),
44     
45     url(urlpath(r'documents', DOC, 'text', REVISION, format=False),
46         document_text_resource, {'emitter_format': 'rawxml'},
47         name="doctext_view"),
48
49     url(urlpath(r'documents', DOC, 'html', REVISION, format=False),
50         document_html_resource, {'emitter_format': 'rawhtml'},
51         name="dochtml_view"),
52
53     url(urlpath(r'documents', DOC, 'dc', REVISION),
54         document_dc_resource,
55         name="docdc_view_withformat"),
56
57     url(urlpath(r'documents', DOC, 'dc', REVISION, format=False),
58         document_dc_resource, {'emitter_format': 'json'},
59         name="docdc_view"),
60
61     url(urlpath(r'documents', DOC, 'revision', format=False),
62         document_merge, {'emitter_format': 'json'}, name="docmerge_view")
63
64 #    url(r'^documents/(?P<docid>[^/]+)/parts$',
65 #        document_resource, {'emitter_format': 'json'},
66 #        name="docparts_view"),
67         
68   #  url(r'^posts/(?P<post_slug>[^/]+)/$', blogpost_resource),
69   #  url(r'^other/(?P<username>[^/]+)/(?P<data>.+)/$', arbitrary_resource),
70 )
71