Club-related fixes.
[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.urls import path, re_path
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     path('collections/',
16          piwik_track_view(views.CollectionList.as_view()),
17          name="catalogue_api_collections"),
18     path('collections/<slug:slug>/',
19          piwik_track_view(views.CollectionDetail.as_view()),
20          name="collection-detail"),
21
22     re_path(tags_re + r'books/' + paginate_re,
23             piwik_track_view(views.BookList.as_view()),
24             name='catalogue_api_book_list'),
25     re_path(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     re_path(tags_re + r'audiobooks/' + paginate_re,
29             piwik_track_view(views.BookList.as_view()),
30             {"audiobooks": True}, name='catalogue_api_audiobook_list'),
31     re_path(tags_re + r'daisy/' + paginate_re,
32             piwik_track_view(views.BookList.as_view()),
33             {"daisy": True}, name='catalogue_api_daisy_list'),
34     re_path(r'^recommended/' + paginate_re,
35             piwik_track_view(views.BookList.as_view()),
36             {"recommended": True}, name='catalogue_api_recommended_list'),
37     path('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     path('books/<slug:slug>/',
43          piwik_track_view(views.BookDetail.as_view()),
44          name='catalogue_api_book'),
45
46     re_path(tags_re + r'ebooks/' + paginate_re,
47             piwik_track_view(views.EbookList.as_view()),
48             name='catalogue_api_ebook_list'),
49     re_path(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     path('filter-books/',
55          piwik_track_view(views.FilterBookList.as_view()),
56          name='catalogue_api_filter_books'),
57
58     path('epub/<slug:slug>/',
59          piwik_track_view(views.EpubView.as_view()),
60          name='catalogue_api_epub'),
61
62     path('preview/',
63          piwik_track_view(views.Preview.as_view()),
64          name='catalogue_api_preview'),
65
66     re_path(r'^(?P<tags>(?:(?:[a-z0-9-]+/){2}){1,6})fragments/$',
67             piwik_track_view(views.FragmentList.as_view())),
68     path('books/<slug:book>/fragments/<slug:anchor>/',
69          piwik_track_view(views.FragmentView.as_view()),
70          name="catalogue_api_fragment"),
71
72     path('<slug:category>s/',
73          piwik_track_view(views.TagCategoryView.as_view()),
74          name='catalogue_api_tag_list'),
75     path('<slug:category>s/<slug:slug>/',
76          piwik_track_view(views.TagView.as_view()),
77          name="catalogue_api_tag"),
78 ]