fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
minor fixes in search
[wolnelektury.git]
/
src
/
search
/
templatetags
/
search_tags.py
diff --git
a/src/search/templatetags/search_tags.py
b/src/search/templatetags/search_tags.py
index
c135b80
..
517f18f
100644
(file)
--- a/
src/search/templatetags/search_tags.py
+++ b/
src/search/templatetags/search_tags.py
@@
-32,7
+32,6
@@
def book_searched(context, result):
# We don't need hits which lead to sections but do not have
# snippets.
hits = filter(lambda (idx, h):
# We don't need hits which lead to sections but do not have
# snippets.
hits = filter(lambda (idx, h):
- 'fragment' in h or
result.snippets[idx] is not None,
enumerate(result.hits))
# print "[tmpl: from %d hits selected %d]" % (len(result.hits), len(hits))
result.snippets[idx] is not None,
enumerate(result.hits))
# print "[tmpl: from %d hits selected %d]" % (len(result.hits), len(hits))
@@
-45,8
+44,8
@@
def book_searched(context, result):
continue
snip = result.snippets[idx]
# fix some formattting
continue
snip = result.snippets[idx]
# fix some formattting
- snip = re.sub
n(r"(^[ \t\n]+|[ \t\n]+$)", u"",
- re.subn(r"[ \t\n]*\n[ \t\n]*", u"\n", snip)[0])[0]
+ snip = re.sub
(r"[ \t\n]*\n[ \t\n]*", u"\n", snip)
+ snip = re.sub(r"(^[ \t\n]+|[ \t\n]+$)", u"", snip)
snip = snip.replace("\n", "<br />").replace('---', '—')
hit['snippet'] = snip
snip = snip.replace("\n", "<br />").replace('---', '—')
hit['snippet'] = snip
@@
-54,5
+53,5
@@
def book_searched(context, result):
return {
'request': context['request'],
'book': book,
return {
'request': context['request'],
'book': book,
- 'hits':
hits and zip(*hits)[1] or
[]
+ 'hits':
zip(*hits)[1] if hits else
[]
}
}