annotate gpp/templates/search/search.html @ 415:d4d167876c25

Fixing #205; search result pagination wasn't including models. Created a custom model search form so that the query term and model selections would persist across pages.
author Brian Neal <bgneal@gmail.com>
date Sun, 10 Apr 2011 00:32:14 +0000
parents b1f939b1fb01
children aabee29cadac
rev   line source
bgneal@219 1 {% extends 'base.html' %}
bgneal@219 2 {% load highlight %}
bgneal@219 3 {% block title %}Search{% endblock %}
bgneal@323 4 {% block custom_js %}
bgneal@323 5 <script type="text/javascript">
bgneal@323 6 //<![CDATA[
bgneal@323 7 $(document).ready(function() {
bgneal@415 8 var chkboxes = $('#search-form input[type="checkbox"]');
bgneal@323 9 $('#chk_all').click(function() {
bgneal@323 10 chkboxes.each(function(index) {
bgneal@323 11 $(this).attr('checked', true);
bgneal@323 12 });
bgneal@323 13 return false;
bgneal@323 14 });
bgneal@323 15 $('#chk_none').click(function() {
bgneal@323 16 chkboxes.each(function(index) {
bgneal@323 17 $(this).attr('checked', false);
bgneal@323 18 });
bgneal@323 19 return false;
bgneal@323 20 });
bgneal@415 21 $('#search-form ul').addClass('no-bullet-inline-block');
bgneal@323 22 });
bgneal@323 23 //]]>
bgneal@323 24 </script>
bgneal@323 25 {% endblock %}
bgneal@219 26 {% block content %}
bgneal@312 27 <h2>Search <img src="{{ STATIC_URL }}icons/magnifier.png" alt="Search" /></h2>
bgneal@323 28 <form id="search-form" method="get" action=".">
bgneal@415 29 {{ form.q }} <input type="submit" value="Search" />
bgneal@276 30 <fieldset>
bgneal@276 31 <legend>Search in:</legend>
bgneal@415 32 {{ form.models }}
bgneal@323 33 <p><a href="#" id="chk_all">Check all</a> | <a href="#" id="chk_none">Check none</a></p>
bgneal@276 34 </fieldset>
bgneal@323 35 </form>
bgneal@276 36
bgneal@219 37 {% if query %}
bgneal@277 38 <h3>Results for &quot;{{ query }}&quot; page {{ page.number }} of {{ page.paginator.num_pages }}</h3>
bgneal@277 39
bgneal@277 40 {% if page.paginator.count %}
bgneal@277 41 <p>
bgneal@277 42 <strong>{{ page.paginator.count }} hit{{ page.paginator.count|pluralize }}</strong>
bgneal@277 43 </p>
bgneal@277 44 {% endif %}
bgneal@277 45
bgneal@219 46 {% if page.object_list %}
bgneal@219 47 <dl>
bgneal@219 48 {% for result in page.object_list %}
bgneal@219 49 <dt>
bgneal@222 50 {{ result.verbose_name }}: <a href="{{ result.object.get_absolute_url }}">{{ result.object.search_title }}</a> ({{ result.score }})
bgneal@219 51 </dt>
bgneal@219 52 <dd>
bgneal@220 53 {% highlight result.object.search_summary with query css_class "highlight" max_length 200 %}
bgneal@219 54 </dd>
bgneal@219 55 {% endfor %}
bgneal@219 56 </dl>
bgneal@220 57 {% else %}
bgneal@220 58 <p>No results found for <em>{{ query }}</em>.</p>
bgneal@219 59 {% endif %}
bgneal@219 60
bgneal@219 61 {% if page.has_previous or page.has_next %}
bgneal@219 62 <div>
bgneal@415 63 {% if page.has_previous %}<a href="?{{ search_params }}&amp;page={{ page.previous_page_number }}">{% endif %}&laquo; Previous{% if page.has_previous %}</a>{% endif %}
bgneal@219 64 |
bgneal@415 65 {% if page.has_next %}<a href="?{{ search_params }}&amp;page={{ page.next_page_number }}">{% endif %}Next &raquo;{% if page.has_next %}</a>{% endif %}
bgneal@219 66 </div>
bgneal@219 67 {% endif %}
bgneal@219 68 {% else %}
bgneal@219 69 {# Show some example queries to run, maybe query syntax, something else? #}
bgneal@219 70 {% endif %}
bgneal@219 71 {% endblock %}