build_txt=options.get('build_txt'),
build_pdf=options.get('build_pdf'),
build_mobi=options.get('build_mobi'),
- search_index=options.get('search_index'),
search_index_tags=False)
for ebook_format in Book.ebook_formats:
if os.path.isfile(file_base + '.' + ebook_format):
{% if hit.themes_hit %}
{% inline_tag_list hit.themes_hit %}
{% endif %}
- <a href="{{hit.fragment.get_absolute_url}}">{{hit.fragment.text|truncatewords_html:15|safe}}</a>
+ <a href="{{hit.fragment.get_absolute_url}}">
+ {% if hit.snippet %}
+ {{hit.snippet|safe}}
+ {% else %}
+ {{hit.fragment.text|truncatewords_html:15|safe}}
+ {% endif %}
+ </a>
</div>
{% endif %}
{% endif %}
if matches:
return self.substring(kwargs['text'], matches,
- margins=kwargs.get('margins', 30),
- mark=kwargs.get('mark', ("<b>", "</b>")))
+ margins=kwargs.get('margins', 30),
+ mark=kwargs.get('mark', ("<b>", "</b>")))
else:
return None
snip = snip[:e + off] + mark[1] + snip[e + off:]
snip = snip[:s + off] + mark[0] + snip[s + off:]
# maybe break on word boundaries
+
return snip
snips = map(lambda s: s and s.replace("/\n", "\n"), snips)
searchresult.snippets = snips
+
return snips
def hint_tags(self, query, pdcounter=True, prefix=True):
<li>
<p><a href="{{result.book.get_absolute_url}}">{{result.book.pretty_title}}</a> (id: {{result.book_id}}, score: {{result.score}})</p>
<ul>
- {% for hit in result.hits %}
+ {% for snip in hit.snippets %}
<li>
- {% for snip in hit.3.snippets %}
- {{snip|safe}}<br/>
- {% endfor %}
+ {{snip|safe}}<br/>
</li>
{% endfor %}
for (idx, hit) in hits:
# currently we generate one snipper per hit though.
- if 'fragment' in hit:
+ if result.snippets[idx] is None:
continue
snip = result.snippets[idx]
# fix some formattting