update librarian
[wolnelektury.git] / src / 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 import patterns, url
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(
16     'picture.views',
17
18     url(r'^obraz/strona/$', 'picture_page', name='picture_page'),
19     # pictures - currently pictures are coupled with catalogue, hence the url is here
20     url(r'^obraz/$', 'picture_list_thumb', name='picture_list_thumb'),
21     url(r'^obraz/(?P<slug>%s).html$' % SLUG, 'picture_viewer', name='picture_viewer'),
22     url(r'^obraz/(?P<slug>%s)/$' % SLUG, 'picture_detail'),
23
24     url(r'^p/(?P<pk>\d+)/mini\.(?P<lang>.+)\.html', 'picture_mini', name='picture_mini'),
25     url(r'^p/(?P<pk>\d+)/short\.(?P<lang>.+)\.html', 'picture_short', name='picture_short'),
26     url(r'^pa/(?P<pk>\d+)/short\.(?P<lang>.+)\.html', 'picturearea_short', name='picture_area_short'),
27 )
28
29 urlpatterns += patterns(
30     '',
31     # old search page - redirected
32     url(r'^szukaj/$', RedirectView.as_view(
33             url='/szukaj/', query_string=True, permanent=True)),
34 )
35
36 urlpatterns += patterns(
37     'catalogue.views',
38     url(r'^$', 'catalogue', name='catalogue'),
39
40     url(r'^autor/$', 'tag_catalogue', {'category': 'author'}, name='author_catalogue'),
41     url(r'^epoka/$', 'tag_catalogue', {'category': 'epoch'}, name='epoch_catalogue'),
42     url(r'^gatunek/$', 'tag_catalogue', {'category': 'genre'}, name='genre_catalogue'),
43     url(r'^rodzaj/$', 'tag_catalogue', {'category': 'kind'}, name='kind_catalogue'),
44     url(r'^motyw/$', 'tag_catalogue', {'category': 'theme'}, name='theme_catalogue'),
45
46     url(r'^galeria/$', 'gallery', name='gallery'),
47     url(r'^kolekcje/$', 'collections', name='catalogue_collections'),
48
49     url(r'^lektury/$', 'literature', name='book_list'),
50     url(r'^lektury/(?P<slug>[a-zA-Z0-9-]+)/$', 'collection', name='collection'),
51     url(r'^audiobooki/$', 'audiobooks', name='audiobook_list'),
52     url(r'^daisy/$', 'daisy_list', name='daisy_list'),
53     url(r'^nowe/$', ListView.as_view(
54         queryset=Book.objects.filter(parent=None).order_by('-created_at'),
55         template_name='catalogue/recent_list.html'), name='recent_list'),
56     url(r'^nowe/audiobooki/$', ListView.as_view(
57         queryset=Book.objects.filter(media__type='ogg').annotate(m=Max('media__uploaded_at')).order_by('-m'),
58         template_name='catalogue/recent_audiobooks_list.html'), name='recent_audiobooks_list'),
59     url(r'^nowe/daisy/$', ListView.as_view(
60         queryset=Book.objects.filter(media__type='daisy').annotate(m=Max('media__uploaded_at')).order_by('-m'),
61         template_name='catalogue/recent_daisy_list.html'), name='recent_daisy_list'),
62
63     url(r'^custompdf/(?P<slug>%s)/$' % SLUG, CustomPDFFormView(), name='custom_pdf_form'),
64
65     url(r'^audiobooki/(?P<type>mp3|ogg|daisy|all).xml$', AudiobookFeed(), name='audiobook_feed'),
66
67     url(r'^pobierz/(?P<slug>%s).(?P<format_>[a-z0-9]*)$' % SLUG, 'embargo_link', name='embargo_link'),
68
69     # zip
70     url(r'^zip/pdf\.zip$', 'download_zip', {'format': 'pdf', 'slug': None}, 'download_zip_pdf'),
71     url(r'^zip/epub\.zip$', 'download_zip', {'format': 'epub', 'slug': None}, 'download_zip_epub'),
72     url(r'^zip/mobi\.zip$', 'download_zip', {'format': 'mobi', 'slug': None}, 'download_zip_mobi'),
73     url(r'^zip/mp3/(?P<slug>%s)\.zip' % SLUG, 'download_zip', {'format': 'mp3'}, 'download_zip_mp3'),
74     url(r'^zip/ogg/(?P<slug>%s)\.zip' % SLUG, 'download_zip', {'format': 'ogg'}, 'download_zip_ogg'),
75
76     # Public interface. Do not change this URLs.
77     url(r'^lektura/(?P<slug>%s)\.html$' % SLUG, 'book_text', name='book_text'),
78     url(r'^lektura/(?P<slug>%s)/audiobook/$' % SLUG, 'player', name='book_player'),
79     url(r'^lektura/(?P<slug>%s)/$' % SLUG, 'book_detail', name='book_detail'),
80     url(r'^lektura/(?P<slug>%s)/motyw/(?P<theme_slug>[a-zA-Z0-9-]+)/$' % SLUG,
81         'book_fragments', name='book_fragments'),
82
83     url(r'^okladka-ridero/(?P<slug>%s).png$' % SLUG, 'ridero_cover'),
84     url(r'^isbn/(?P<book_format>(pdf|epub|mobi|txt|html))/(?P<slug>%s)/' % SLUG, 'get_isbn'),
85
86     # Includes.
87     url(r'^b/(?P<pk>\d+)/mini\.(?P<lang>.+)\.html', 'book_mini', name='catalogue_book_mini'),
88     url(r'^b/(?P<pk>\d+)/mini_nolink\.(?P<lang>.+)\.html', 'book_mini', {'with_link': False},
89         name='catalogue_book_mini_nolink'),
90     url(r'^b/(?P<pk>\d+)/short\.(?P<lang>.+)\.html', 'book_short', name='catalogue_book_short'),
91     url(r'^b/(?P<pk>\d+)/wide\.(?P<lang>.+)\.html', 'book_wide', name='catalogue_book_wide'),
92     url(r'^f/(?P<pk>\d+)/promo\.(?P<lang>.+)\.html', 'fragment_promo', name='catalogue_fragment_promo'),
93     url(r'^f/(?P<pk>\d+)/short\.(?P<lang>.+)\.html', 'fragment_short', name='catalogue_fragment_short'),
94     url(r'^t/(?P<pk>\d+)/box\.(?P<lang>.+)\.html', 'tag_box', name='catalogue_tag_box'),
95     url(r'^c/(?P<pk>.+)/box\.(?P<lang>.+)\.html', 'collection_box', name='catalogue_collection_box'),
96
97     # This should be the last pattern.
98     url(r'^galeria/(?P<tags>[a-zA-Z0-9-/]*)/$', 'tagged_object_list', {'list_type': 'gallery'},
99         name='tagged_object_list_gallery'),
100     url(r'^audiobooki/(?P<tags>[a-zA-Z0-9-/]*)/$', 'tagged_object_list', {'list_type': 'audiobooks'},
101         name='tagged_object_list_audiobooks'),
102     url(r'^(?P<tags>[a-zA-Z0-9-/]*)/$', 'tagged_object_list', {'list_type': 'books'},
103         name='tagged_object_list'),
104 )