From: Marcin Koziej Date: Mon, 3 Sep 2012 14:48:59 +0000 (+0200) Subject: small fixes X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/fa9ab52217a8e6912fa4677fc7bb1da21044b470?ds=inline small fixes --- diff --git a/apps/catalogue/management/commands/importbooks.py b/apps/catalogue/management/commands/importbooks.py index 93c68a2f7..1f08f7cff 100644 --- a/apps/catalogue/management/commands/importbooks.py +++ b/apps/catalogue/management/commands/importbooks.py @@ -48,7 +48,6 @@ class Command(BaseCommand): 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): diff --git a/apps/catalogue/templates/catalogue/book_searched.html b/apps/catalogue/templates/catalogue/book_searched.html index a965bfc9e..4ac66fb19 100644 --- a/apps/catalogue/templates/catalogue/book_searched.html +++ b/apps/catalogue/templates/catalogue/book_searched.html @@ -15,7 +15,13 @@ {% if hit.themes_hit %} {% inline_tag_list hit.themes_hit %} {% endif %} - {{hit.fragment.text|truncatewords_html:15|safe}} + + {% if hit.snippet %} + {{hit.snippet|safe}} + {% else %} + {{hit.fragment.text|truncatewords_html:15|safe}} + {% endif %} + {% endif %} {% endif %} diff --git a/apps/search/custom.py b/apps/search/custom.py index 6cb18fd24..6c16f228f 100644 --- a/apps/search/custom.py +++ b/apps/search/custom.py @@ -119,8 +119,8 @@ class CustomSolrInterface(sunburnt.SolrInterface): if matches: return self.substring(kwargs['text'], matches, - margins=kwargs.get('margins', 30), - mark=kwargs.get('mark', ("", ""))) + margins=kwargs.get('margins', 30), + mark=kwargs.get('mark', ("", ""))) else: return None @@ -151,5 +151,6 @@ class CustomSolrInterface(sunburnt.SolrInterface): 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 diff --git a/apps/search/index.py b/apps/search/index.py index 5c05ffb33..557f4045c 100644 --- a/apps/search/index.py +++ b/apps/search/index.py @@ -968,6 +968,7 @@ class Search(SolrIndex): 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): diff --git a/apps/search/templates/newsearch/search.html b/apps/search/templates/newsearch/search.html index c494ca602..635bae86a 100644 --- a/apps/search/templates/newsearch/search.html +++ b/apps/search/templates/newsearch/search.html @@ -29,11 +29,9 @@
  • {{result.book.pretty_title}} (id: {{result.book_id}}, score: {{result.score}})