Moving forward.
[wolnelektury.git] / src / catalogue / 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 django.db.models import Max
6 from django.views.generic import ListView, RedirectView
7 from catalogue.feeds import AudiobookFeed
8 from catalogue.models import Book
9 from catalogue import views
10 import picture.views
11 import search.views
12
13
14 urlpatterns = [
15     path('obraz/strona/', picture.views.picture_page, name='picture_page'),
16     # pictures - currently pictures are coupled with catalogue, hence the url is here
17     path('obraz/', picture.views.picture_list_thumb, name='picture_list_thumb'), # TODO: catalogue view
18     path('obraz/<slug:slug>.html', picture.views.picture_viewer, name='picture_viewer'),
19     path('obraz/<slug:slug>/', picture.views.picture_detail, name='picture_detail'),
20
21     # old search page - redirected
22     path('szukaj/', RedirectView.as_view(
23         url='/szukaj/', query_string=True, permanent=True)),
24
25     path('', views.catalogue, name='catalogue'), # TODO catalogue
26
27     # TODO: catalogue
28     path('autor/', views.tag_catalogue, {'category': 'author'}, name='author_catalogue'),
29     path('epoka/', views.tag_catalogue, {'category': 'epoch'}, name='epoch_catalogue'),
30     path('gatunek/', views.tag_catalogue, {'category': 'genre'}, name='genre_catalogue'),
31     path('rodzaj/', views.tag_catalogue, {'category': 'kind'}, name='kind_catalogue'),
32     path('motyw/', views.tag_catalogue, {'category': 'theme'}, name='theme_catalogue'),
33
34     path('galeria/', views.gallery, name='gallery'),
35     path('kolekcje/', views.collections, name='catalogue_collections'),
36
37     path('lektury/', views.literature, name='book_list'),
38     path('lektury/<slug:slug>/', views.collection, name='collection'),
39     path('audiobooki/', views.audiobooks, name='audiobook_list'),
40     path('daisy/', views.daisy_list, name='daisy_list'), # TODO: catalogue
41     path('jtags/', search.views.hint, {'param': 'q', 'mozhint': True}, name='jhint'),
42     path('nowe/', ListView.as_view( # TODO
43         queryset=Book.objects.filter(parent=None, findable=True).order_by('-created_at'),
44         template_name='catalogue/recent_list.html'), name='recent_list'),
45     path('nowe/audiobooki/', ListView.as_view( # TODO
46         queryset=Book.objects.filter(media__type='ogg').annotate(m=Max('media__uploaded_at')).order_by('-m'),
47         template_name='catalogue/recent_audiobooks_list.html'), name='recent_audiobooks_list'),
48     path('nowe/daisy/', ListView.as_view( # TODO
49         queryset=Book.objects.filter(media__type='daisy').annotate(m=Max('media__uploaded_at')).order_by('-m'),
50         template_name='catalogue/recent_daisy_list.html'), name='recent_daisy_list'),
51
52     path('custompdf/<slug:slug>/', views.CustomPDFFormView(), name='custom_pdf_form'),
53
54     re_path(r'^audiobooki/(?P<type>mp3|ogg|daisy|all).xml$', AudiobookFeed(), name='audiobook_feed'),
55
56     path('pobierz/<key>/<slug:slug>.<slug:format_>', views.embargo_link, name='embargo_link'),
57
58     # zip
59     path('zip/pdf.zip', views.download_zip, {'file_format': 'pdf', 'slug': None}, 'download_zip_pdf'),
60     path('zip/epub.zip', views.download_zip, {'file_format': 'epub', 'slug': None}, 'download_zip_epub'),
61     path('zip/mobi.zip', views.download_zip, {'file_format': 'mobi', 'slug': None}, 'download_zip_mobi'),
62     path('zip/mp3/<slug:slug>.zip', views.download_zip, {'media_format': 'mp3'}, 'download_zip_mp3'),
63     path('zip/ogg/<slug:slug>.zip', views.download_zip, {'media_format': 'ogg'}, 'download_zip_ogg'),
64
65     # Public interface. Do not change this URLs.
66     path('lektura/<slug:slug>.html', views.book_text, name='book_text'),
67     path('lektura/<slug:slug>/audiobook/', views.player, name='book_player'),
68     path('lektura/<slug:slug>/', views.book_detail, name='book_detail'),
69     path('lektura/<slug:slug>/motyw/<slug:theme_slug>/',
70          views.book_fragments, name='book_fragments'),
71
72     path('okladka-ridero/<slug:slug>.png', views.ridero_cover),
73     path('isbn/<slug:book_format>/<slug:slug>/', views.get_isbn),
74
75     # This should be the last pattern.
76     re_path(r'^galeria/(?P<tags>[a-zA-Z0-9-/]*)/$', views.tagged_object_list, {'list_type': 'gallery'},
77         name='tagged_object_list_gallery'),
78     re_path(r'^audiobooki/(?P<tags>[a-zA-Z0-9-/]*)/$', views.tagged_object_list, {'list_type': 'audiobooks'},
79         name='tagged_object_list_audiobooks'),
80     re_path(r'^(?P<tags>[a-zA-Z0-9-/]*)/$', views.tagged_object_list, {'list_type': 'books'},
81         name='tagged_object_list'),
82
83 ]