snipt/templates/search/search.html

110 lines
4.1 KiB
HTML

{% extends "base.html" %}
{% block page-title %}/ search {% if query %}/ “{{ query }}”{% 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 extra-scripts %}
{% endblock %}
{% block content %}
<section class="snipts" id="snipts"></section>
<div class="static-box {% if page.object_list|length > 0 %}has-snipts{% endif %}">
<form method="get" class="form-search" action=".">
{% if not request.user.profile.has_teams %}
<input type="text" class="search-query" name="q"
placeholder="Search snipts" id="id_q"
value="{{ query }}" />
{% if request.user.is_authenticated %}
<label class="checkbox inline mine-only">
<input {% if 'mine-only' in request.GET %}checked{% endif %} type="checkbox" name="mine-only"> Mine only
</label>
{% endif %}
{% else %}
<div class="with-teams-search">
<input type="text" class="search-query" name="q"
placeholder="Search snipts" id="id_q"
value="{{ query }}"
/>
<select name="author">
<option
{% if not request.GET.author or request.GET.author == '' %}selected{% endif %}
value=""
>
Mine and all public
</option>
<option
{% if request.GET.author == request.user.username %}selected{% endif %}
value="{{ request.user.username }}"
>
Mine only
</option>
{% for team in request.user.profile.teams %}
<option
{% if request.GET.author == team.slug %}selected{% endif %}
value="{{ team.slug }}"
>
{{ team.name }}
</option>
{% endfor %}
</select>
</div>
{% endif %}
<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 %}
{% endblock %}