fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
minimal allauth support
[wolnelektury.git]
/
apps
/
search
/
templatetags
/
search_tags.py
diff --git
a/apps/search/templatetags/search_tags.py
b/apps/search/templatetags/search_tags.py
index
03e33c8
..
97deb9d
100644
(file)
--- a/
apps/search/templatetags/search_tags.py
+++ b/
apps/search/templatetags/search_tags.py
@@
-22,10
+22,9
@@
from catalogue.models import Book
register = template.Library()
register = template.Library()
-@register.inclusion_tag('catalogue/book_searched.html')
-def book_searched(result):
+@register.inclusion_tag('catalogue/book_searched.html'
, takes_context=True
)
+def book_searched(
context,
result):
book = Book.objects.get(pk=result.book_id)
book = Book.objects.get(pk=result.book_id)
- vals = book_wide(book)
# snippets = []
# for hit in result.hits:
# snippets = []
# for hit in result.hits:
@@
-36,10
+35,18
@@
def book_searched(result):
# We don't need hits which lead to sections but do not have
# snippets.
# 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'])
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(),
+ }
+