Summon the annoying banner.
[wolnelektury.git] / src / catalogue / api / urls.py
1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 #
5 from django.conf.urls import include, url
6 from . import views
7
8
9 tags_re = r'^(?P<tags>(?:(?:[a-z0-9-]+/){2}){0,6})'
10 paginate_re = r'(?:after/(?P<after>[a-z0-9-]+)/)?(?:count/(?P<count>[0-9]+)/)?$'
11
12
13 urlpatterns = [
14     # books by collections
15     url(r'^collections/$', views.CollectionList.as_view(), name="api_collections"),
16     url(r'^collections/(?P<slug>[^/]+)/$',
17         views.CollectionDetail.as_view(), name="collection-detail"),
18
19     url(tags_re + r'books/' + paginate_re,
20         views.BookList.as_view(), name='catalogue_api_book_list'),
21     url(tags_re + r'parent_books/' + paginate_re,
22         views.BookList.as_view(), {"top_level": True}, name='catalogue_api_parent_book_list'),
23     url(tags_re + r'audiobooks/' + paginate_re,
24         views.BookList.as_view(), {"audiobooks": True}, name='catalogue_api_audiobook_list'),
25     url(tags_re + r'daisy/' + paginate_re,
26         views.BookList.as_view(), {"daisy": True}, name='catalogue_api_daisy_list'),
27     url(r'^recommended/' + paginate_re,
28         views.BookList.as_view(),
29         {"recommended": True}, name='catalogue_api_recommended_list'),
30     url(r'^newest/$',
31         views.BookList.as_view(),
32         {"newest": True, "top_level": True, "count": 20}, name='catalogue_api_newest_list'),
33
34     url(r'^books/(?P<slug>[^/]+)/$', views.BookDetail.as_view(), name='catalogue_api_book'),
35
36     url(tags_re + r'ebooks/' + paginate_re,
37         views.EbookList.as_view(),
38         name='catalogue_api_ebook_list'),
39     url(tags_re + r'parent_ebooks/' + paginate_re,
40         views.EbookList.as_view(),
41         {"top_level": True},
42         name='catalogue_api_parent_ebook_list'),
43
44     url(r'^filter-books/$', views.FilterBookList.as_view(), name='catalogue_api_filter_books'),
45
46     url(r'^epub/(?P<slug>[a-z0-9-]+)/$', views.EpubView.as_view(), name='catalogue_api_epub'),
47
48     url(r'^preview/$', views.Preview.as_view(), name='catalogue_api_preview'),
49
50     url(r'^(?P<tags>(?:(?:[a-z0-9-]+/){2}){1,6})fragments/$', views.FragmentList.as_view()),
51     url(r'^books/(?P<book>[a-z0-9-]+)/fragments/(?P<anchor>[a-z0-9-]+)/$',
52         views.FragmentView.as_view(), name="catalogue_api_fragment"),
53
54     url(r'^(?P<category>[a-z]+)s/$', views.TagCategoryView.as_view(), name='catalogue_api_tag_list'),
55     url(r'^(?P<category>[a-z]+)s/(?P<slug>[a-z0-9-]+)/$', views.TagView.as_view(), name="catalogue_api_tag"),
56 ]