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.
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
15 urlpatterns = patterns('picture.views',
16 # pictures - currently pictures are coupled with catalogue, hence the url is here
17 url(r'^obraz/$', 'picture_list_thumb', name='picture_list_thumb'),
18 url(r'^obraz/(?P<slug>%s).html$' % SLUG, 'picture_viewer', name='picture_viewer'),
19 url(r'^obraz/(?P<slug>%s)/$' % SLUG, 'picture_detail'),
21 url(r'^p/(?P<pk>\d+)/short\.(?P<lang>.+)\.html', 'picture_short', name='picture_short'),
22 url(r'^pa/(?P<pk>\d+)/short\.(?P<lang>.+)\.html', 'picturearea_short', name='picture_area_short'),
25 urlpatterns += patterns('',
26 # old search page - redirected
27 url(r'^szukaj/$', RedirectView.as_view(
28 url='/szukaj/', query_string=True)),
31 urlpatterns += patterns('catalogue.views',
32 url(r'^$', 'catalogue', name='catalogue'),
34 url(r'^lektury/$', 'book_list', name='book_list'),
35 url(r'^lektury/(?P<slug>[a-zA-Z0-9-]+)/$', 'collection', name='collection'),
36 url(r'^audiobooki/$', 'audiobook_list', name='audiobook_list'),
37 url(r'^daisy/$', 'daisy_list', name='daisy_list'),
38 url(r'^tags/$', 'tags_starting_with', name='hint'),
39 url(r'^jtags/?$', 'json_tags_starting_with', name='jhint'),
40 url(r'^nowe/$', ListView.as_view(
41 queryset=Book.objects.filter(parent=None).order_by('-created_at'),
42 template_name='catalogue/recent_list.html'), name='recent_list'),
43 url(r'^nowe/audiobooki/$', ListView.as_view(
44 queryset=Book.objects.filter(media__type='ogg').annotate(m=Max('media__uploaded_at')).order_by('-m'),
45 template_name='catalogue/recent_audiobooks_list.html'), name='recent_audiobooks_list'),
46 url(r'^nowe/daisy/$', ListView.as_view(
47 queryset=Book.objects.filter(media__type='daisy').annotate(m=Max('media__uploaded_at')).order_by('-m'),
48 template_name='catalogue/recent_daisy_list.html'), name='recent_daisy_list'),
50 url(r'^custompdf/(?P<slug>%s)/$' % SLUG, CustomPDFFormView(), name='custom_pdf_form'),
52 url(r'^audiobooki/(?P<type>mp3|ogg|daisy|all).xml$', AudiobookFeed(), name='audiobook_feed'),
56 url(r'^zip/pdf\.zip$', 'download_zip', {'format': 'pdf', 'slug': None}, 'download_zip_pdf'),
57 url(r'^zip/epub\.zip$', 'download_zip', {'format': 'epub', 'slug': None}, 'download_zip_epub'),
58 url(r'^zip/mobi\.zip$', 'download_zip', {'format': 'mobi', 'slug': None}, 'download_zip_mobi'),
59 url(r'^zip/mp3/(?P<slug>%s)\.zip' % SLUG, 'download_zip', {'format': 'mp3'}, 'download_zip_mp3'),
60 url(r'^zip/ogg/(?P<slug>%s)\.zip' % SLUG, 'download_zip', {'format': 'ogg'}, 'download_zip_ogg'),
62 # Public interface. Do not change this URLs.
63 url(r'^lektura/(?P<slug>%s)\.html$' % SLUG, 'book_text', name='book_text'),
64 url(r'^lektura/(?P<slug>%s)/audiobook/$' % SLUG, 'player', name='book_player'),
65 url(r'^lektura/(?P<slug>%s)/$' % SLUG, 'book_detail', name='book_detail'),
66 url(r'^lektura/(?P<slug>%s)/motyw/(?P<theme_slug>[a-zA-Z0-9-]+)/$' % SLUG,
67 'book_fragments', name='book_fragments'),
70 url(r'^(?P<lang>[^/]+)\.json$', 'catalogue_json'),
71 url(r'^b/(?P<pk>\d+)/mini\.(?P<lang>.+)\.html', 'book_mini', name='catalogue_book_mini'),
72 url(r'^b/(?P<pk>\d+)/mini_nolink\.(?P<lang>.+)\.html', 'book_mini', {'with_link': False}, name='catalogue_book_mini_nolink'),
73 url(r'^b/(?P<pk>\d+)/short\.(?P<lang>.+)\.html', 'book_short', name='catalogue_book_short'),
74 url(r'^b/(?P<pk>\d+)/wide\.(?P<lang>.+)\.html', 'book_wide', name='catalogue_book_wide'),
75 url(r'^f/(?P<pk>\d+)/promo\.(?P<lang>.+)\.html', 'fragment_promo', name='catalogue_fragment_promo'),
76 url(r'^f/(?P<pk>\d+)/short\.(?P<lang>.+)\.html', 'fragment_short', name='catalogue_fragment_short'),
78 # This should be the last pattern.
79 url(r'^(?P<tags>[a-zA-Z0-9-/]*)/$', 'tagged_object_list', name='tagged_object_list'),