API urls for OAuth and accessing catalogue
[wolnelektury.git] / apps / api / urls.py
1 # -*- coding: utf-8 -*-
2 from django.conf.urls.defaults import *
3 from piston.resource import Resource
4 from piston.authentication import OAuthAuthentication
5
6 from api.handlers import BookHandler, TagHandler
7
8
9 auth = OAuthAuthentication(realm='API')
10 book_resource = Resource(handler=BookHandler)
11 tag_resource = Resource(handler=TagHandler, authentication=auth)
12
13 urlpatterns = patterns('',
14     url(r'^books/(?P<slug>[^/]+)\.(?P<emitter_format>xml|json|yaml)$', book_resource),
15     url(r'^books\.(?P<emitter_format>xml|json|yaml)$', book_resource),
16     url(r'^tags/(?P<tags>[a-zA-Z0-9-/]*)\.(?P<emitter_format>xml|json|yaml)$', tag_resource),
17     url(r'^lektura/(?P<slug>[a-zA-Z0-9-]+)\.(?P<emitter_format>xml|json|yaml)$', book_resource), #detail
18     url(r'^lektura/(?P<book_slug>[a-zA-Z0-9-]+)/motyw/(?P<theme_slug>[a-zA-Z0-9-]+)\.(?P<emitter_format>xml|json|yaml)$', book_resource), #fragments
19     url(r'^oauth/callback/$','oauth_callback'),
20 )
21
22 urlpatterns += patterns(
23 'piston.authentication',
24     url(r'^oauth/request_token/$','oauth_request_token'),
25     url(r'^oauth/authorize/$','oauth_user_auth'),
26     url(r'^oauth/access_token/$','oauth_access_token'),
27 )