- callback = request.GET.get('callback', None)
- data = [{'label': t.name,
- 'category': category_name(t.category),
- 'id': t.id,
- 'url': t.get_absolute_url()}
- for t in tags] + \
- [{'label': b.title,
+ try:
+ limit = int(request.GET.get('max', ''))
+ except ValueError:
+ limit = -1
+ else:
+ if limit < 1:
+ limit = -1
+
+ data = []
+
+ 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,