update librarian
[wolnelektury.git] / src / search / views.py
index c6759ea..d105be6 100644 (file)
@@ -115,7 +115,7 @@ def hint(request):
                 break
             limit -= 1
             data.append({
-                'label': b.title,
+                'label': '<cite>%s</cite>, %s' % (b.title, b.author_unicode()),
                 'category': _('book'),
                 'id': b.id,
                 'url': b.get_absolute_url()
@@ -132,11 +132,18 @@ def hint(request):
 @cache.never_cache
 def main(request):
     query = request.GET.get('q', '')
+    query = ' '.join(query.split())
+    # filter out private use characters
+    import unicodedata
+    query = ''.join(ch for ch in query if unicodedata.category(ch) != 'Co')
 
     if len(query) < 2:
         return render_to_response(
             'catalogue/search_too_short.html', {'prefix': query},
             context_instance=RequestContext(request))
+    elif len(query) > 256:
+        return render_to_response(
+            'catalogue/search_too_long.html', {'prefix': query}, context_instance=RequestContext(request))
 
     query = remove_query_syntax_chars(query)