view gpp/templates/search/search.html @ 467:b910cc1460c8

Add the ability to conditionally add model instances to the search index on update. This is not perfect, as some instances should be deleted from the index if they are updated such that they should not be in the index anymore. Will think about and address that later.
author Brian Neal <bgneal@gmail.com>
date Sun, 24 Jul 2011 18:12:20 +0000
parents 524fd1b3919a
children
line wrap: on
line source
{% extends 'base.html' %}
{% load highlight %}
{% load core_tags %}
{% block title %}Search{% endblock %}
{% block custom_js %}
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
      var chkboxes = $('#search-form input[type="checkbox"]');
      $('#chk_all').click(function() {
         chkboxes.each(function(index) {
            $(this).attr('checked', true);
         });
         return false;
      });
      $('#chk_none').click(function() {
         chkboxes.each(function(index) {
            $(this).attr('checked', false);
         });
         return false;
      });
      $('#search-form ul').addClass('no-bullet-inline-block');
      $('#search-form ul li input').css('vertical-align', 'middle');
});
//]]>
</script>
{% endblock %}
{% block content %}
<h2>Search <img src="{{ STATIC_URL }}icons/magnifier.png" alt="Search" /></h2>
<form id="search-form" method="get" action=".">
{{ form.q }} <input type="submit" value="Search" />
<fieldset>
<legend>Search in:</legend>
{{ form.models }}
<p><a href="#" id="chk_all">Check all</a> | <a href="#" id="chk_none">Check none</a></p>
</fieldset>
</form>

  {% if query %}
  <h3>Results for &quot;{{ query }}&quot; page {{ page.number }} of {{ page.paginator.num_pages }}</h3>

     {% if page.paginator.count %}
     <p>
     <strong>{{ page.paginator.count }} hit{{ page.paginator.count|pluralize }}</strong>
     </p>
     {% endif %}

      {% if page.object_list %}
      <dl>
      {% for result in page.object_list %}
         <dt>
         {{ result.verbose_name }}: <a href="{{ result.object.get_absolute_url }}">{{ result.object.search_title }}</a> ({{ result.score }})
         </dt>
         <dd>
            {% highlight result.object.search_summary with query css_class "highlight" max_length 200 %}
         </dd>
      {% endfor %}
      </dl>
      {% else %}
      <p>No results found for <em>{{ query }}</em>.</p>
      {% endif %}

      {% if page.has_previous or page.has_next %}
          <div>
              {% if page.has_previous %}<a href="?{% encode_params request.GET 'q' 'models' %}&amp;page={{ page.previous_page_number }}">{% endif %}&laquo; Previous{% if page.has_previous %}</a>{% endif %}
              |
              {% if page.has_next %}<a href="?{% encode_params request.GET 'q' 'models' %}&amp;page={{ page.next_page_number }}">{% endif %}Next &raquo;{% if page.has_next %}</a>{% endif %}
          </div>
      {% endif %}
  {% else %}
      {# Show some example queries to run, maybe query syntax, something else? #}
  {% endif %}
{% endblock %}