+ if len(objects) > 3:
+ best = random.sample(objects, 3)
+ else:
+ best = objects
+
+ result = {
+ 'object_list': objects,
+ 'categories': categories,
+ 'list_type': list_type,
+ 'tags': tags,
+
+ 'formats_form': forms.DownloadFormatsForm(),
+ 'best': best,
+ 'active_menu_item': list_type,
+ }
+ if extra:
+ result.update(extra)
+ return render_to_response(
+ 'catalogue/tagged_object_list.html', result,
+ context_instance=RequestContext(request))
+
+
+def literature(request):
+ books = Book.objects.filter(parent=None)
+
+ # last_published = Book.objects.exclude(cover_thumb='').filter(parent=None).order_by('-created_at')[:20]
+ # most_popular = Book.objects.exclude(cover_thumb='')\
+ # .order_by('-popularity__count', 'sort_key_author', 'sort_key')[:20]
+ return object_list(request, books, related_tags=get_top_level_related_tags([]))
+ # extra={
+ # 'last_published': last_published,
+ # 'most_popular': most_popular,
+ # })
+
+
+def gallery(request):
+ return object_list(request, Picture.objects.all(), list_type='gallery')
+
+
+def audiobooks(request):
+ audiobooks = Book.objects.filter(media__type__in=('mp3', 'ogg')).distinct()
+ return object_list(request, audiobooks, list_type='audiobooks', extra={
+ 'daisy': Book.objects.filter(media__type='daisy').distinct(),
+ })
+
+
+class ResponseInstead(Exception):
+ def __init__(self, response):
+ super(ResponseInstead, self).__init__()
+ self.response = response
+
+
+def analyse_tags(request, tag_str):