+ tags = search.hint_tags(prefix, pdcounter=True)
+ tags = filter(lambda t: not is_dupe(t), tags)
+ for t in tags:
+ if not limit:
+ break
+ limit -= 1
+ data.append({
+ 'label': t.name,
+ 'category': category_name(t.category),
+ 'id': t.id,
+ 'url': t.get_absolute_url()
+ })
+ if limit:
+ books = search.hint_books(prefix)
+ for b in books:
+ if not limit:
+ break
+ limit -= 1
+ data.append({
+ 'label': b.title,
+ 'category': _('book'),
+ 'id': b.id,
+ 'url': b.get_absolute_url()
+ })
+
+ callback = request.GET.get('callback', None)
+ if callback:
+ return HttpResponse("%s(%s);" % (callback, json.dumps(data)),
+ content_type="application/json; charset=utf-8")
+ else:
+ return JsonResponse(data, safe=False)
+
+
+@cache.never_cache