{% extends "base.html" %}
{% load i18n %}
{% load search_filters %}
{% load pagination_tags %}
{% load markup %}

{% block title %}{{ block.super }} | {% trans "Search" %}{% endblock %}

{% block breadcrumb %}{{ block.super }} &raquo; {% if not query %}{% trans "Search" %}{% else %}<a href="{% url search %}">{% trans "Search" %}</a> &raquo; {% trans "Results" %}{% endif %}{% endblock %}

{% block body_class %}search project_list{% endblock %}

{% block content_title %}
  <h2 class="pagetitle">
    {% if not query %}{% trans "Search projects" %}{% else %}{% trans "Search results" %}{% endif %}
  </h2>
{% endblock %}
  
{% block content %}

  {% with "content_header_prim" as extra_searchform_classes %}
      {% include "search_form.html" %}
  {% endwith %}

  {% if query %}
    {% if results %}
      <h3 class="pagetitle">
        {% with results|length as result_count %}{% blocktrans %}Search Results ({{ result_count }}){% endblocktrans %}</h3>{% endwith %}
      {% autopaginate results 10 %}
      <div class="project_list">
      {% for project in results %}
        {% highlight terms as name %} {# set `name` object #}
            {{ project.name }}
        {% endhighlight %}
        {% searchexcerpt terms 6 as description %} {# set `description` object #}
            {{ project.description|striptags }}
        {% endsearchexcerpt %}
        {% searchexcerpt terms 10 as long_description %} {# set `description` object #}
            {{ project.long_description|markdown|striptags }}
        {% endsearchexcerpt %}
        <div class="info">
          <p class="name"><a href="{{ project.get_absolute_url }}">{{ name.highlighted }}</a></p>
          <p class="description">{{ description.excerpt|highlight:terms }}</p>
          <p class="long_description">{{ long_description.excerpt|highlight:terms }}</p>
        </div>
      {% endfor %}
      <div class="pagination top">{% paginate %}</div>
      </div>
    {% else %}
      <p class="i16 notice notfound">
          {% blocktrans with query|escape as q %}No projects found for "{{ q }}". You might want to change your query a bit.{% endblocktrans %}
      </p>
    {% endif %}
  {% endif %}

{% endblock %}

{% block content_footer %}
{% if request.user.is_authenticated and perms.projects.add_project %}
  <div id="content_footer_center">
   <span class="i16 tip">
       {% trans "Couldn't find your project? Why don't you go ahead and " %}<a href="{% url project_create %}">{% trans "add it"%}</a>?
   </span>   
  </div>
{% endif %}
{% endblock %}
