e9f6383458bd181e13a1ab69ce0a3a0d702bfd44
[wolnelektury.git] / apps / catalogue / 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.defaults import *
6 from django.db.models import Max
7 from django.views.generic import ListView, RedirectView
8 from catalogue.feeds import AudiobookFeed
9 from catalogue.views import CustomPDFFormView
10 from catalogue.models import Book
11
12
13 SLUG = r'[a-z0-9-]*'
14
15 urlpatterns = patterns('picture.views',
16     # pictures - currently pictures are coupled with catalogue, hence the url is here
17     url(r'^obraz/?$', 'picture_list'),
18     url(r'^obraz/(?P<picture>%s)/?$' % SLUG, 'picture_detail')
19 )
20
21 urlpatterns += patterns('',
22     # old search page - redirected
23     url(r'^szukaj/$', RedirectView.as_view(
24             url='/szukaj/', query_string=True)),
25 )
26
27 urlpatterns += patterns('catalogue.views',
28     url(r'^$', 'catalogue', name='catalogue'),
29
30     url(r'^lektury/$', 'book_list', name='book_list'),
31     url(r'^lektury/(?P<slug>[a-zA-Z0-9-]+)/$', 'collection', name='collection'),
32     url(r'^audiobooki/$', 'audiobook_list', name='audiobook_list'),
33     url(r'^daisy/$', 'daisy_list', name='daisy_list'),
34     url(r'^tags/$', 'tags_starting_with', name='hint'),
35     url(r'^jtags/$', 'json_tags_starting_with', name='jhint'),
36     url(r'^nowe/$', ListView.as_view(
37         queryset=Book.objects.filter(parent=None).order_by('-created_at'),
38         template_name='catalogue/recent_list.html'), name='recent_list'),
39     url(r'^nowe/audiobooki/$', ListView.as_view(
40         queryset=Book.objects.filter(media__type='ogg').annotate(m=Max('media__uploaded_at')).order_by('-m'),
41             template_name='catalogue/recent_audiobooks_list.html'), name='recent_audiobooks_list'),
42     url(r'^nowe/daisy/$', ListView.as_view(
43         queryset=Book.objects.filter(media__type='daisy').annotate(m=Max('media__uploaded_at')).order_by('-m'),
44             template_name='catalogue/recent_daisy_list.html'), name='recent_daisy_list'),
45
46     url(r'^custompdf/(?P<slug>%s)/$' % SLUG, CustomPDFFormView(), name='custom_pdf_form'),
47
48     url(r'^audiobooki/(?P<type>mp3|ogg|daisy|all).xml$', AudiobookFeed(), name='audiobook_feed'),
49
50
51     # zip
52     url(r'^zip/pdf\.zip$', 'download_zip', {'format': 'pdf', 'slug': None}, 'download_zip_pdf'),
53     url(r'^zip/epub\.zip$', 'download_zip', {'format': 'epub', 'slug': None}, 'download_zip_epub'),
54     url(r'^zip/mobi\.zip$', 'download_zip', {'format': 'mobi', 'slug': None}, 'download_zip_mobi'),
55     url(r'^zip/mp3/(?P<slug>%s)\.zip' % SLUG, 'download_zip', {'format': 'mp3'}, 'download_zip_mp3'),
56     url(r'^zip/ogg/(?P<slug>%s)\.zip' % SLUG, 'download_zip', {'format': 'ogg'}, 'download_zip_ogg'),
57
58     # Public interface. Do not change this URLs.
59     url(r'^lektura/(?P<slug>%s)\.html$' % SLUG, 'book_text', name='book_text'),
60     url(r'^lektura/(?P<slug>%s)\.html2$' % SLUG, 'book_text2'),
61     url(r'^lektura/(?P<slug>%s)/audiobook/$' % SLUG, 'player', name='book_player'),
62     url(r'^lektura/(?P<slug>%s)/$' % SLUG, 'book_detail', name='book_detail'),
63     url(r'^lektura/(?P<slug>%s)/motyw/(?P<theme_slug>[a-zA-Z0-9-]+)/$' % SLUG,
64         'book_fragments', name='book_fragments'),
65
66     # This should be the last pattern.
67     url(r'^(?P<tags>[a-zA-Z0-9-/]*)/$', 'tagged_object_list', name='tagged_object_list'),
68 )