cf73c2cff69a95ac7039e6fd77e3467680f2ee85
[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 stats.utils import piwik_track_view
7 from . import views
8
9
10 tags_re = r'^(?P<tags>(?:(?:[a-z0-9-]+/){2}){0,6})'
11 paginate_re = r'(?:after/(?P<after>[a-z0-9-]+)/)?(?:count/(?P<count>[0-9]+)/)?$'
12
13
14 urlpatterns = [
15     # books by collections
16     url(r'^collections/$',
17         piwik_track_view(views.CollectionList.as_view()),
18         name="api_collections"),
19     url(r'^collections/(?P<slug>[^/]+)/$',
20         piwik_track_view(views.CollectionDetail.as_view()),
21         name="collection-detail"),
22
23     url(tags_re + r'books/' + paginate_re,
24         piwik_track_view(views.BookList.as_view()),
25         name='catalogue_api_book_list'),
26     url(tags_re + r'parent_books/' + paginate_re,
27         piwik_track_view(views.BookList.as_view()),
28         {"top_level": True}, name='catalogue_api_parent_book_list'),
29     url(tags_re + r'audiobooks/' + paginate_re,
30         piwik_track_view(views.BookList.as_view()),
31         {"audiobooks": True}, name='catalogue_api_audiobook_list'),
32     url(tags_re + r'daisy/' + paginate_re,
33         piwik_track_view(views.BookList.as_view()),
34         {"daisy": True}, name='catalogue_api_daisy_list'),
35     url(r'^recommended/' + paginate_re,
36         piwik_track_view(views.BookList.as_view()),
37         {"recommended": True}, name='catalogue_api_recommended_list'),
38     url(r'^newest/$',
39         piwik_track_view(views.BookList.as_view()),
40         {"newest": True, "top_level": True, "count": 20},
41         name='catalogue_api_newest_list'),
42
43     url(r'^books/(?P<slug>[^/]+)/$',
44         piwik_track_view(views.BookDetail.as_view()),
45         name='catalogue_api_book'),
46
47     url(tags_re + r'ebooks/' + paginate_re,
48         piwik_track_view(views.EbookList.as_view()),
49         name='catalogue_api_ebook_list'),
50     url(tags_re + r'parent_ebooks/' + paginate_re,
51         piwik_track_view(views.EbookList.as_view()),
52         {"top_level": True},
53         name='catalogue_api_parent_ebook_list'),
54
55     url(r'^filter-books/$',
56         piwik_track_view(views.FilterBookList.as_view()),
57         name='catalogue_api_filter_books'),
58
59     url(r'^epub/(?P<slug>[a-z0-9-]+)/$',
60         piwik_track_view(views.EpubView.as_view()),
61         name='catalogue_api_epub'),
62
63     url(r'^preview/$',
64         piwik_track_view(views.Preview.as_view()),
65         name='catalogue_api_preview'),
66
67     url(r'^(?P<tags>(?:(?:[a-z0-9-]+/){2}){1,6})fragments/$',
68         piwik_track_view(views.FragmentList.as_view())),
69     url(r'^books/(?P<book>[a-z0-9-]+)/fragments/(?P<anchor>[a-z0-9-]+)/$',
70         piwik_track_view(views.FragmentView.as_view()),
71         name="catalogue_api_fragment"),
72
73     url(r'^(?P<category>[a-z]+)s/$',
74         piwik_track_view(views.TagCategoryView.as_view()),
75         name='catalogue_api_tag_list'),
76     url(r'^(?P<category>[a-z]+)s/(?P<slug>[a-z0-9-]+)/$',
77         piwik_track_view(views.TagView.as_view()),
78         name="catalogue_api_tag"),
79 ]