small fixes
authorMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Mon, 3 Sep 2012 14:48:59 +0000 (16:48 +0200)
committerMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Mon, 3 Sep 2012 14:48:59 +0000 (16:48 +0200)
apps/catalogue/management/commands/importbooks.py
apps/catalogue/templates/catalogue/book_searched.html
apps/search/custom.py
apps/search/index.py
apps/search/templates/newsearch/search.html
apps/search/templatetags/search_tags.py

index 93c68a2..1f08f7c 100644 (file)
@@ -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'),
                                                     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):
                                                     search_index_tags=False)
         for ebook_format in Book.ebook_formats:
             if os.path.isfile(file_base + '.' + ebook_format):
index a965bfc..4ac66fb 100644 (file)
     {% if hit.themes_hit %}
     {% inline_tag_list hit.themes_hit  %}
     {% endif %}
     {% 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 %}
   </div>
   {% endif %}
   {% endif %}
index 6cb18fd..6c16f22 100644 (file)
@@ -119,8 +119,8 @@ class CustomSolrInterface(sunburnt.SolrInterface):
 
         if matches:
             return self.substring(kwargs['text'], matches,
 
         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
 
         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
             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
 
         return snip
 
index 5c05ffb..557f404 100644 (file)
@@ -968,6 +968,7 @@ class Search(SolrIndex):
         snips = map(lambda s: s and s.replace("/\n", "\n"), snips)
 
         searchresult.snippets = snips
         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):
         return snips
 
     def hint_tags(self, query, pdcounter=True, prefix=True):
index c494ca6..635bae8 100644 (file)
       <li>
        <p><a href="{{result.book.get_absolute_url}}">{{result.book.pretty_title}}</a> (id: {{result.book_id}}, score: {{result.score}})</p>
        <ul>
       <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>
          <li>
-           {% for snip in hit.3.snippets %}
-             {{snip|safe}}<br/>
-           {% endfor %}
+           {{snip|safe}}<br/>
          </li>
          {% endfor %}
 
          </li>
          {% endfor %}
 
index b19593e..6a2ccad 100644 (file)
@@ -42,7 +42,7 @@ def book_searched(context, result):
 
     for (idx, hit) in hits:
         # currently we generate one snipper per hit though.
 
     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
             continue
         snip = result.snippets[idx]
         # fix some formattting