view sg101/templates/search/search.html @ 1128:538f35ce3429

Fix typo in search page pagination.
author Brian Neal <bgneal@gmail.com>
date Tue, 13 Sep 2016 21:52:27 -0500
parents 829d3b7fc0f7
children c7a59d3a81ce
line wrap: on
line source
{% extends 'v3/base.html' %}
{% load highlight %}
{% load core_tags %}
{% load static from staticfiles %}
{% block title %}Search{% endblock %}
{% block content %}
<h2>Search <i class="fi-magnifying-glass"></i></h2>
{% if query_parser_error %}
<div class="alert callout">
   <p>
   <i class="fi-alert size-36"></i>
   Your search query could not be processed. This may happen because you've
   included terms like AND, OR, or NOT. These terms are not necessary.
   </p>
   <p>
   If you continue to have problems with this error, please
   <a href="{% url 'contact-form' %}?subject=Search%20Help">contact us</a>.
   </p>
</div>
{% endif %}
<form id="search-form" method="get" action=".">
   <fieldset class="fieldset">
   <legend>Find content with:</legend>
      {{ form.non_field_errors }}
      {{ form.q.errors }}
      <div class="row">
         <div class="columns">
            <label for="{{ form.q.id_for_label }}">{{ form.q.label }}
               {{ form.q }}
            </label>
         </div>
      </div>
      {{ form.exact.errors }}
      <div class="row">
         <div class="columns">
            <label for="{{ form.exact.id_for_label }}">{{ form.exact.label }}
               {{ form.exact }}
            </label>
         </div>
      </div>
      {{ form.exclude.errors }}
      <div class="row">
         <div class="columns">
            <label for="{{ form.exclude.id_for_label }}">{{ form.exclude.label }}
               {{ form.exclude }}
            </label>
         </div>
      </div>
   </fieldset>

   <fieldset class="fieldset">
   <legend>Search in</legend>
      {{ form.models.errors }}
      <div class="row">
         <div class="columns">
            {% for model in form.models %}
               {{ model.tag }}<label for="{{ model.id_for_label }}">
               {{ model.choice_label }}</label>
            {% endfor %}
         </div>
      </div>
      <div class="row">
         <div class="columns text-center">
            <a href="#" id="chk_all">Check all</a> |
            <a href="#" id="chk_none">Check none</a>
         </div>
      </div>
   </fieldset>
   <div class="row">
      <div class="columns">
         <input type="submit" value="Search" class="button" />
      </div>
   </div>
</form>

{% if form.is_valid and not query_parser_error %}
<h3>Search results <small>Page {{ page.number }} of {{ page.paginator.num_pages }}</small></h3>

   {% if page.paginator.count %}
   <p class="size-21">
      <strong>{{ page.paginator.count }} hit{{ page.paginator.count|pluralize }}</strong>
   </p>
   {% endif %}

   {% if page.object_list %}
   <dl class="search-results">
   {% 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 search results found.</p>
   {% endif %}

   {% if page.has_previous or page.has_next %}
   <ul class="pagination text-center" role="navigation" aria-label="Pagination">
      <li class="pagination-previous
         {% if not page.has_previous %}disabled{% endif %}">
            {% if page.has_previous %}<a href="?{% encode_params request.GET 'q' 'exact' 'exclude' 'models' %}&amp;page={{ page.previous_page_number }}">{% endif %}Previous Page{% if page.has_previous %}</a>{% endif %}
      </li>
      <li class="pagination-next
         {% if not page.has_next %}disabled{% endif %}">
            {% if page.has_next %}<a href="?{% encode_params request.GET 'q' 'exact' 'exclude' 'models' %}&amp;page={{ page.next_page_number }}">{% endif %}Next Page{% if page.has_next %}</a>{% endif %}
      </li>
   </ul>
   {% endif %}
{% else %}
<hr />
<div class="primary callout">
   <h5><i class="fi-info"></i> Search Tips</h5>
   <ul>
     <li>To perform a search, type your search query in the text boxes and check which areas of the site you wish to search.</li>
     <li>The three text boxes will be AND-ed together. You can omit two of the text boxes.</li>
     <li>You can search multiple areas of the site at the same time by checking more than one box.</li>
     <li>To search forum thread titles, check <em>Forum Topics</em>.</li>
     <li>To search forum thread post bodies, check <em>Forum Posts</em>.</li>
     <li>Our search engine removes punctuation when building its index. Thus, for example, a search query of
      <em>FRV-1</em> will not produce any results. Instead, it is better to search for <em>FRV 1</em> or even
      just <em>FRV</em>.</li>
      <li>Most content is searchable by author. For example, to find all forum threads by the user <em>SurferDood101</em>
      where the title contains <em>Gnarly</em>, your search term (to be placed in the first text box) would be <em>SurferDood101 Gnarly</em>.</li>
      <li>Search results are displayed newest first.</li>
   </ul>
</div>
{% endif %}
{% 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).prop('checked', true);
         });
         return false;
      });
      $('#chk_none').click(function() {
         chkboxes.each(function(index) {
            $(this).prop('checked', false);
         });
         return false;
      });
      $('#search-form ul').addClass('no-bullet-inline-block');
      $('#search-form ul li input').css('vertical-align', 'middle');
});
//]]>
</script>
{% endblock %}