{% extends "base.html" %}
{% block body %}

<h1>Search all Releases</h1>
<form class="" role="search" action="/release/search" method="get">
  <div class="ui form">
    <div class="ui action input huge fluid">
      <input type="text" placeholder="Query..." name="q" value="{% if query %}{{ query }}{% endif %}" aria-label="search release metadata">
      <button class="ui button">Search</button>
    </div>
    <div class="ui checkbox" style="float: right; margin: 1em;">
      <input type="checkbox" name="fulltext_only" value="true" {% if fulltext_only %}checked{% endif %}>
      <label>Fulltext Available Only</label>
    </div>
  </div>
</form>

<br clear="all" />

{% if found %}
{% if found.results %}
  <i>Showing top {{ found.count_returned }} out of {{ found.count_found }} results for: <code>{{ found.query.q }}</code></i>
{% for paper in found.results %}
<div>
  <h4 style="margin-top: 1em; margin-bottom: 4px; font-size: 1.1em;"><a href="/release/{{ paper.ident }}" style="color: #2224c7;">{{ paper['title'] }}</a>
  {% if paper.best_pdf_url %}
  &nbsp;&nbsp;<a href="{{ paper.best_pdf_url }}" class="ui label small"><i class="file icon"></i>fulltext</a>
  {% endif %}
  </h4>
  <h5 style="margin-top: 4px; margin-bottom: 4px; font-size: 1em;">{{ ", ".join(paper.contrib_names[:12]) }}
    {% if paper.contrib_names|length > 12 %}<i>(+{{ paper.contrib_names|length - 12 }} others)</i>{% endif %}
  </h5>
  {% if paper.doi %}
  DOI: <a href="https://doi.org/{{paper.doi }}" style="color: green;">{{ paper.doi }}</a>
  - {{ paper.release_type }}
    {% if paper.release_year %}
    - {{ paper.release_year }}
    {% endif %}
  <br>
  {% endif %}
  {% if paper.container_name %}
    {% if paper.container_issnl %}
      <a href="/container/lookup?issnl={{ paper.container_issnl}}" style="color: black;">{{ paper.container_name }}</a>
    {% else %}
      {{ paper.container_name }}
    {% endif %}
    {% if paper.container_is_oa %}<i class="icon unlock orange small"></i>{% endif %}
  {% endif %}
</div>
{% endfor %}
{% if found.results|length > 8 %}
  <br>
  <i>Showing top {{ found.count_returned }} out of {{ found.count_found }} results for: <code>{{ found.query.q }}</code></i>
{% endif %}
{% else %}
<div class="featurette-inner text-center" style="padding-top: 15%;">
  <h3>No results found!</h3>
  <i>Query was: <code>{{ found.query.q }}</code></i>
  <br/>
  <p>Try:</p>
  <ul>
    <li>Search <a href="https://dissem.in/search?q={{ found.query.q | urlencode }}">dissem.in</a></li>
    <li>Search <a href="https://www.base-search.net/Search/Results?lookfor={{ found.query.q | urlencode }}">BASE</a></li>
    <li>Search <a href="https://scholar.google.com/scholar?q={{ found.query.q | urlencode }}">Google Scholar</a></li>
  </ul>
</div>
{% endif %}
{% endif %}

{% endblock %}