@register.inclusion_tag('catalogue/book_searched.html', takes_context=True)
def book_searched(context, result):
book = Book.objects.get(pk=result.book_id)
- vals = book_wide(context, book)
# snippets = []
# for hit in result.hits:
# We don't need hits which lead to sections but do not have
# snippets.
- vals['hits'] = filter(lambda h: 'fragment' in h or
- h['snippets'], result.hits)
+ hits = filter(lambda h: 'fragment' in h or
+ h['snippets'], result.hits)[0:5]
- for hit in vals['hits']:
+ for hit in hits:
hit['snippets'] = map(lambda s: s.replace("\n", "<br />").replace('---', '—'), hit['snippets'])
- return vals
+ return {
+ 'related': book.related_info(),
+ 'book': book,
+ 'main_link': book.get_absolute_url(),
+ 'request': context.get('request'),
+ 'hits': hits,
+ 'main_link': book.get_absolute_url(),
+ }
+