NO_BUILD_PDF option in settings
[wolnelektury.git] / apps / api / urls.py
1 # -*- coding: utf-8 -*-
2 from django.conf.urls.defaults import *
3 from piston.resource import Resource
4
5 from api import handlers
6
7
8 book_changes_resource = Resource(handler=handlers.BookChangesHandler)
9 tag_changes_resource = Resource(handler=handlers.TagChangesHandler)
10 changes_resource = Resource(handler=handlers.ChangesHandler)
11
12 book_list_resource = Resource(handler=handlers.BooksHandler)
13 book_resource = Resource(handler=handlers.BookDetailHandler)
14
15 tag_list_resource = Resource(handler=handlers.TagsHandler)
16 tag_resource = Resource(handler=handlers.TagDetailHandler)
17
18 fragment_resource = Resource(handler=handlers.FragmentDetailHandler)
19 fragment_list_resource = Resource(handler=handlers.FragmentsHandler)
20
21
22 urlpatterns = patterns('',
23     url(r'^$', 'django.views.generic.simple.direct_to_template',
24             {'template': 'api/main.html'}),
25
26
27     # changes handlers
28     url(r'^book_changes/(?P<since>\d*?)\.(?P<emitter_format>xml|json|yaml)$', book_changes_resource),
29     url(r'^tag_changes/(?P<since>\d*?)\.(?P<emitter_format>xml|json|yaml)$', tag_changes_resource),
30     # used by mobile app
31     url(r'^changes/(?P<since>\d*?)\.(?P<emitter_format>xml|json|yaml)$', changes_resource),
32
33     # info boxes (used by mobile app)
34     url(r'book/(?P<id>\d*?)/info\.html$', 'catalogue.views.book_info'),
35     url(r'tag/(?P<id>\d*?)/info\.html$', 'catalogue.views.tag_info'),
36
37
38     # objects details
39     url(r'^books/(?P<slug>[a-z0-9-]+)/$', book_resource, name="api_book"),
40     url(r'^(?P<category>[a-z0-9-]+)/(?P<slug>[a-z0-9-]+)/$',
41         tag_resource, name="api_tag"),
42     url(r'^books/(?P<slug>[a-z0-9-]+)/fragments/(?P<anchor>[a-z0-9-]+)/$',
43         fragment_resource, name="api_fragment"),
44
45     # books by tags
46     url(r'^(?P<tags>(?:(?:[a-z0-9-]+/){2}){0,6})books/$', book_list_resource),
47     url(r'^(?P<tags>(?:(?:[a-z0-9-]+/){2}){0,6})parent_books/$', book_list_resource, {"top_level": True}),
48
49     # fragments by book, tags, themes
50     # this should be paged
51     url(r'^(?P<tags>(?:(?:[a-z0-9-]+/){2}){1,6})fragments/$', fragment_list_resource),
52
53     # tags by category
54     url(r'^(?P<category>[a-z0-9-]+)/$', tag_list_resource),
55 )