{% raw %}
{% extends "base.html" %}
{% load wagtailcore_tags wagtailimages_tags i18n%}

{% block content %}
{% if search_results %}
  <div class="search">
    <h3>{{search_query}}</h3>
  </div>
  {% for page in search_results %}
    {% with parent_section=page.get_parent_section ancestor=page.get_parent_section.get_ancestors.last %}
      <a href="{% pageurl page %}">
        <div class="nav">
          {% if ancestor.sectionpage.image %}
              <h6>{{ancestor.title}}</h6>
          {% else %}
              <h6>{{parent_section.title}}</h6>
          {% endif %}
          {% if page.title_highlight %}
              <h3>{{page.title_highlight|safe}}</h3>
          {% else %}
              <h3>{{page.title}}</h3>
          {% endif %}
          {% if page.subtitle_highlight or page.body_highlight %}
              {% if page.subtitle_highlight %}
                  <p>{{page.subtitle_highlight|safe}}</p>
              {% elif page.body_highlight %}
                  <p>{{page.body_highlight|safe}}</p>
              {% endif %}
          {% else %}
              <p>{{page.subtitle}}</p>
          {% endif %}
        </div>
      </a>
    {% endwith %}
  {% endfor %}

  <div class="step-links">
    {% if search_results.has_previous %}
        <a href="?p={{ search_results.previous_page_number }}&amp;q={{search_query}}">&larr;</a>
    {% endif %}
    <span class="current">
        Page {{ search_results.number }} of {{ search_results.paginator.num_pages }}
    </span>
    {% if search_results.has_next %}
        <a href="?p={{ search_results.next_page_number }}&amp;q={{search_query}}">&rarr;</a>
    {% endif %}
  </div>

  {% else %}
    <div>
        <h3>{% trans "Search" %}</h3>
        <p>{% trans "No search results for " %}{{search_query}}.</p>
        <div class="nav">
            <form action="{% url 'search' %}">
              <input placeholder="{% trans "I am looking for" %}" name="q" type="search">
              <input type="submit" value="{% trans "Search"%}">
            </form>
        </div>
    </div>
  {% endif %}
{% endblock %}

{% block search %}
  {% if search_results %}
      {% include "search/search_block.html" %}
  {% endif %}
{% endblock %}

{% endraw %}
