1 # This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
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
14 # old search page - redirected
15 path('szukaj/', RedirectView.as_view(
16 url='/szukaj/', query_string=True, permanent=True)),
18 path('', views.catalogue, name='catalogue'),
20 path('autor/', views.tag_catalogue, {'category': 'author'}, name='author_catalogue'),
21 path('epoka/', views.tag_catalogue, {'category': 'epoch'}, name='epoch_catalogue'),
22 path('gatunek/', views.tag_catalogue, {'category': 'genre'}, name='genre_catalogue'),
23 path('rodzaj/', views.tag_catalogue, {'category': 'kind'}, name='kind_catalogue'),
24 path('motyw/', views.tag_catalogue, {'category': 'theme'}, name='theme_catalogue'),
26 path('galeria/', views.GalleryView.as_view(), name='gallery'),
27 path('kolekcje/', views.collections, name='catalogue_collections'),
29 path('lektury/', views.LiteratureView.as_view(), name='book_list'),
30 path('lektury/<slug:slug>/', views.collection, name='collection'),
31 path('audiobooki/', views.AudiobooksView.as_view(), name='audiobook_list'),
32 path('daisy/', views.daisy_list, name='daisy_list'),
33 path('jtags/', search.views.hint, {'param': 'q', 'mozhint': True}, name='jhint'),
34 path('nowe/', ListView.as_view(
35 queryset=Book.objects.filter(parent=None, findable=True).order_by('-created_at')[:100],
36 template_name='catalogue/recent_list.html'), name='recent_list'),
37 path('nowe/audiobooki/', ListView.as_view(
38 queryset=Book.objects.filter(media__type='ogg').annotate(m=Max('media__uploaded_at')).order_by('-m')[:100],
39 template_name='catalogue/recent_audiobooks_list.html'), name='recent_audiobooks_list'),
40 path('nowe/daisy/', ListView.as_view(
41 queryset=Book.objects.filter(media__type='daisy').annotate(m=Max('media__uploaded_at')).order_by('-m')[:100],
42 template_name='catalogue/recent_daisy_list.html'), name='recent_daisy_list'),
44 path('custompdf/<slug:slug>/', views.CustomPDFFormView(), name='custom_pdf_form'),
46 re_path(r'^audiobooki/(?P<type>mp3|ogg|daisy|all).xml$', AudiobookFeed(), name='audiobook_feed'),
48 path('pobierz/<key>/<slug:slug>.<slug:format_>', views.embargo_link, name='embargo_link'),
51 path('zip/pdf.zip', views.download_zip, {'file_format': 'pdf', 'slug': None}, 'download_zip_pdf'),
52 path('zip/epub.zip', views.download_zip, {'file_format': 'epub', 'slug': None}, 'download_zip_epub'),
53 path('zip/mobi.zip', views.download_zip, {'file_format': 'mobi', 'slug': None}, 'download_zip_mobi'),
54 path('zip/mp3/<slug:slug>.zip', views.download_zip, {'media_format': 'mp3'}, 'download_zip_mp3'),
55 path('zip/ogg/<slug:slug>.zip', views.download_zip, {'media_format': 'ogg'}, 'download_zip_ogg'),
57 # Public interface. Do not change this URLs.
58 path('lektura/<slug:slug>.html', views.book_text, name='book_text'),
59 path('lektura/<slug:slug>/', views.book_detail, name='book_detail'),
60 path('lektura/<slug:slug>/motyw/<slug:theme_slug>/',
61 views.book_fragments, name='book_fragments'),
63 path('okladka-ridero/<slug:slug>.png', views.ridero_cover),
64 path('isbn/<slug:book_format>/<slug:slug>/', views.get_isbn),
66 # This should be the last pattern.
67 re_path(r'^galeria/(?P<tags>[a-zA-Z0-9-/]*)/$', views.tagged_object_list, {'list_type': 'gallery'},
68 name='tagged_object_list_gallery'),
69 re_path(r'^audiobooki/(?P<tags>[a-zA-Z0-9-/]*)/$', views.tagged_object_list, {'list_type': 'audiobooks'},
70 name='tagged_object_list_audiobooks'),
71 re_path(r'^(?P<tags>[a-zA-Z0-9-/]*)/$', views.tagged_object_list, {'list_type': 'books'},
72 name='tagged_object_list'),