{% extends "admin/base.html" %}

{% load i18n admin_tags search_tags %}

{% block title %} {% trans "Search Results" %} {% endblock %}

{% block actions %}

{% endblock %}

{% block breadcrumb %}
  
  <div id="search_breadcrumb" class="col-sm-12">
    <ol class="breadcrumb float-sm-left">
        <li class="breadcrumb-item">
            <a href="{% url 'admin:index' %}"><i class="fa fa-home px-1"></i>{% trans "Home" %}</a>
        </li>
        <li class="breadcrumb-item">
            {% trans "Term" %}: {{search_term}}
        </li>
        {% if tags_list|length > 0 %}
          <li  class="breadcrumb-item">
            {% trans "Tags" %}:
          {% for tagname in tags_list %}
              <span class="ml-2 search-tag">{{ tagname }}</span>
              {% if not forloop.last %}
                {% if tags_op == 'any' %}
                  <span class="ml-2">{% trans "OR" %}</span>
                {% else %}
                  <span class="ml-2">{% trans "AND" %}</span>
                {% endif  %}
              {% endif %}
          {% endfor %}
          </li>
        {% endif %}
        {% if folder %}
          <li  class="breadcrumb-item">
            {% trans "Folder" %}: {{folder.title}}
          </li>
        {% endif %}

    </ol>
  </div><!-- /.col -->
{% endblock %}

{% block modals %}
{% endblock modals %}


{% block content %}
<div class="container-fluid">
  <div class="row">
    <div class="col-lg-12">
        <div id="search_results">
          <ul class="folders">
          {% for item in results_folders %}
            <li>
              <h4>
                <a href="{% url 'admin:index' %}">
                  <i class="fa fa-folder text-warning"></i>
                  {% search_folder_path item %}
                </a>
              </h4>
            </li>
          {% endfor %}
          </ul>
          <ul class="documents">
            {% for item in results_docs %}
              <li>
                <h4 class="d-flex flex-row">
                  <a href="{% url 'core:document' item.id %}">
                    <i class="fa fa-file"></i>
                    {{ item.title }}
                  </a>
                  <ul class="d-flex flex-row">
                    {% tags_line item %}
                  </ul>
                </h4>
                <div class="my-1">
                  <i class="fa fa-folder text-warning"></i> {% search_document_path item %}
                </div>

                <div class="page_highlight">
                    {% search_excerpt_tag item.text request.GET.q 5 as matched_context %}
                    {{ matched_context.excerpt }}
                    {% highlight_tag matched_context.excerpt request.GET.q  as highlighted_context %}
                    {{ highlighted_context.highlighted }}
                </div>
              </li>
            {% endfor %}  
          </ul>
        </div>
    </div>
  </div>
  <!-- /.row -->
</div><!-- /.container-fluid -->
{% endblock %}