Housekeeping.
[wolnelektury.git] / src / catalogue / api / urls.py
1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
3 #
4 from django.conf.urls import include, url
5 from stats.utils import piwik_track_view
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/$',
16         piwik_track_view(views.CollectionList.as_view()),
17         name="catalogue_api_collections"),
18     url(r'^collections/(?P<slug>[^/]+)/$',
19         piwik_track_view(views.CollectionDetail.as_view()),
20         name="collection-detail"),
21
22     url(tags_re + r'books/' + paginate_re,
23         piwik_track_view(views.BookList.as_view()),
24         name='catalogue_api_book_list'),
25     url(tags_re + r'parent_books/' + paginate_re,
26         piwik_track_view(views.BookList.as_view()),
27         {"top_level": True}, name='catalogue_api_parent_book_list'),
28     url(tags_re + r'audiobooks/' + paginate_re,
29         piwik_track_view(views.BookList.as_view()),
30         {"audiobooks": True}, name='catalogue_api_audiobook_list'),
31     url(tags_re + r'daisy/' + paginate_re,
32         piwik_track_view(views.BookList.as_view()),
33         {"daisy": True}, name='catalogue_api_daisy_list'),
34     url(r'^recommended/' + paginate_re,
35         piwik_track_view(views.BookList.as_view()),
36         {"recommended": True}, name='catalogue_api_recommended_list'),
37     url(r'^newest/$',
38         piwik_track_view(views.BookList.as_view()),
39         {"newest": True, "top_level": True, "count": 20},
40         name='catalogue_api_newest_list'),
41
42     url(r'^books/(?P<slug>[^/]+)/$',
43         piwik_track_view(views.BookDetail.as_view()),
44         name='catalogue_api_book'),
45
46     url(tags_re + r'ebooks/' + paginate_re,
47         piwik_track_view(views.EbookList.as_view()),
48         name='catalogue_api_ebook_list'),
49     url(tags_re + r'parent_ebooks/' + paginate_re,
50         piwik_track_view(views.EbookList.as_view()),
51         {"top_level": True},
52         name='catalogue_api_parent_ebook_list'),
53
54     url(r'^filter-books/$',
55         piwik_track_view(views.FilterBookList.as_view()),
56         name='catalogue_api_filter_books'),
57
58     url(r'^epub/(?P<slug>[a-z0-9-]+)/$',
59         piwik_track_view(views.EpubView.as_view()),
60         name='catalogue_api_epub'),
61
62     url(r'^preview/$',
63         piwik_track_view(views.Preview.as_view()),
64         name='catalogue_api_preview'),
65
66     url(r'^(?P<tags>(?:(?:[a-z0-9-]+/){2}){1,6})fragments/$',
67         piwik_track_view(views.FragmentList.as_view())),
68     url(r'^books/(?P<book>[a-z0-9-]+)/fragments/(?P<anchor>[a-z0-9-]+)/$',
69         piwik_track_view(views.FragmentView.as_view()),
70         name="catalogue_api_fragment"),
71
72     url(r'^(?P<category>[a-z]+)s/$',
73         piwik_track_view(views.TagCategoryView.as_view()),
74         name='catalogue_api_tag_list'),
75     url(r'^(?P<category>[a-z]+)s/(?P<slug>[a-z0-9-]+)/$',
76         piwik_track_view(views.TagView.as_view()),
77         name="catalogue_api_tag"),
78 ]