{% extends "base.html" %}

{% block page-title %}/ search {% if query %}/ &ldquo;{{ query }}&rdquo;{% endif %}{% endblock %}
{% block html-class %}search{% endblock %}
{% block body-class %}search static{% endblock %}

{% block js %}
        {{ block.super }}
        window.detail = false;
{% endblock %}

{% block breadcrumb %}
    <li><a href="/search/">search</a></li>
    {% if query %}
        <li><span class="prompt">/</span> <a href="/search?q={{ query|urlencode }}">&ldquo;{{ query }}&rdquo;</a></li>
    {% endif %}
{% endblock %}

{% block content %}
    <div class="static-box {% if page.object_list|length > 0 %}has-snipts{% endif %}">
        <form method="get" class="form-search" action=".">
            <input type="text" class="search-query" name="q" value="{% if form.q.value %}{{ form.q.value }}{% endif %}" placeholder="Search snipts" id="id_q">
            <button type="submit" class="btn">Search</button>
        </form>
    </div>
    {% if query %}
        {% if page.object_list|length > 0 %}
            <section class="snipts" id="snipts">
        {% endif %}
        {% for result in page.object_list %}
            {% with result.object as snipt %}
                {% include "snipts/snipt-list.html" %}
            {% endwith %}
        {% empty %}
            <div class="empty-snipts">
                No snipts found for &ldquo;{{ query }}&rdquo;.
            </div>
        {% endfor %}
        {% if page.object_list|length > 0 %}
            </section>
        {% endif %}
        {% if page.has_previous or page.has_next %}
            <div class="pagination">
                <ul>
                    {% if page.has_previous %}
                        <li class="prev">
                            <a id="prev-page" href="?q={{ query }}&amp;page={{ page.previous_page_number }}">&larr;</a>
                        </li>
                    {% else %}
                        <li class="disabled prev">
                            <a href="#">&larr;</a>
                        </li>
                    {% endif %}
                    {% if page.has_next %}
                        <li class="next">
                            <a id="next-page" href="?q={{ query }}&amp;page={{ page.next_page_number }}">&rarr;</a>
                        </li>
                    {% else %}
                        <li class="disabled next">
                            <a href="#">&rarr;</a>
                        </li>
                    {% endif %}
                </ul>
            </div>
        {% endif %}
    {% endif %}
    <script type="text/javascript" id="disqus">
        var disqus_shortname = 'snipt-net';
        {% if debug %}
            var disqus_developer = 1;
        {% endif %}

        (function () {
            var s = document.createElement('script'); s.async = true;
            s.type = 'text/javascript';
            s.src = 'https://' + disqus_shortname + '.disqus.com/count.js';
            (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
        }());
    </script>
    <script type="text/html" id="disqus-template">
        var disqus_shortname = 'snipt-net';
        {% if debug %}
            var disqus_developer = 1;
        {% endif %}

        (function () {
            var s = document.createElement('script'); s.async = true;
            s.type = 'text/javascript';
            s.src = 'https://' + disqus_shortname + '.disqus.com/count.js';
            (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
        }());
    </script>
{% endblock %}
