search - did you mean?
[wolnelektury.git] / wolnelektury / templates / catalogue / search_multiple_hits.html
index 414dcfd..7a3e580 100644 (file)
@@ -9,21 +9,40 @@
 {% block body %}
     <h1>{% trans "Search" %}</h1>
 
+    {% if did_you_mean %}
+      <span class="did_you_mean">{% trans "Dod you mean" %} <a href="{% url search %}?q={{did_you_mean|urlencode}}">{{did_you_mean|lower}}</a></b>?</span>
+    {% endif %}
     <div id="results">
       <ol>
       {% for result in results %}
       <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.process_hits %}
+         {% for hit in result.hits %}
          <li>
            {% if hit.fragment %}
            <a href="{{hit.fragment.get_absolute_url}}">Idź do fragmentu</a>
            <div style="">Tagi/Motywy: {% for tag in hit.themes %}{{tag.name}} {% endfor %}</div>
+           {# snippets or short html? #}
+           {% if hit.snippets %}
+            {% for snip in hit.snippets %}
+              {{snip|safe}}<br/>
+            {% endfor %}
+           {% else %}
+            {{hit.fragment.short_text|safe}}
+           {% endif %}
+           
+           {% else %}
+           {# it's a section #}
+           <a href="{% url book_text result.book.slug %}#f{{hit.section_number}}">{{hit.header_index}}</a>
+            {% if hit.snippets %}
+             {% for snip in hit.snippets %}
+               {{snip|safe}}<br/>
+             {% endfor %}
+            {% else %}
+              [section matched but no snippets :-(]
+            {% endif %}
            {% endif %}
-           {% for snip in hit.snippets %}
-             {{snip|safe}}<br/>
-           {% endfor %}
          </li>
          {% endfor %}