{% extends "base.html" %}

{% block extra_head %}
    <style type="text/css">
        #content {width: 80%;}
    </style>
    <script type="text/javascript">
        $(function() {
            $("table").dataTable({"bPaginate": false, "aaSorting": []});
        });
    </script>
{% endblock %}

{% block title %}{{ site.domain }}: Search Results{% endblock %}

{% block nav_path %}<a href="/">{{ site.domain }}</a> &rsaquo; Search Results{% endblock %}

{% block content %}
    {% if too_small %}
        <h1>No Search Results</h1>
        <p>Search string "{{ search_string }}" too small.</p>
    {% else %}
        <h1>Search Results for "{{ search_string }}"</h1>
        <h2>Title Matches</h2> 
        {% if title_matches %}
            <ol>
            {% for page in title_matches %}
                <li><a href="/{{ page.slug }}">{{ page.title }}</a></li>
            {% endfor %}
            </ol>
        {% else %}
            <p>No matching titles found.</p>
        {% endif %}
        <h2>Content Matches</h2> 
        {% if content_matches %}
            <ol>
            {% for match in content_matches %}
                <li><a href="/{{ match.page.slug }}">{{ match.page.title }}</a>,
                    found {{ match.number_found }} {% if match.number_found == 1 %}match{% else %}matches{% endif %}:
                    <ul>
                        {% for matching_line in match.matching_lines %}
                            <li><code>{{ matching_line }}</code></li>
                        {% endfor %}
                    </ul>
                </li>
            {% endfor %}
            </ol>
        {% else %}
            <p>No matching content found.</p>
        {% endif %}
    {% endif %}
{% endblock %}