{% extends "master.html" %}

{% block title %}Search Projects · Anitya{% endblock %}

{% block body %}

<div class="page-header">
  <h1>Search projects{% if distroname %} in {{ distroname }}{% endif %}</h1>
</div>

<div class="row show-grid">
  <div class="col-sm-6">
    {% if total_page > 1 %}
    <ul class="pagination pagination-sm">
        <li>
            {% if page > 1%}
              <a href="{{ url_for('anitya_ui.projects_search', page=page-1, pattern=pattern) }}">
                «
              </a>
            {% else %}
              <a> « </a>
            {% endif %}
        </li>
        <li>
            <a> {{ page }} / {{ total_page }} </a>
        </li>
        <li>
            {% if page < total_page %}
              <a href="{{ url_for('anitya_ui.projects_search', page=page+1, pattern=pattern) }}">
                »
              </a>
            {% else %}
              <a> » </a>
            {% endif %}
        </li>
    </ul>
    {% endif %}
  </div>

  <div class="col-sm-6">
    {% if distroname %}
    <form action="{{ url_for('anitya_ui.distro_projects_search', distroname=distroname) }}">
      <div class="form-group">
        <input type="text" name="pattern" placeholder="Project name"
            class="form-control input-sm" value="{{ pattern }}"/>
        <button type="submit" class="btn btn-sm btn-default">Search</button>
      </div>
    </form>
    {% endif %}
  </div>
</div>

<div class="row">
  <div class="col-md-6">
    <p>{{ projects_count }} projects found</p>
    <div class="list-group">
    {% if projects %}
      <div class="list-group-item">
        <p class="list-group-item-text">
          <dl class="dl-horizontal">
            <table class="table table-condensed">
            {% for project in projects %}
              <tr>
                <td>
                  <a href="{{ url_for('anitya_ui.project', project_id=project.id) }}">
                    {{project.name}}
                  </a>
                </td>
                <td>
                  <a href="{{ project.homepage }}" target="_blank" rel="noopener noreferrer">
                    {{ project.homepage }}
                  </a>
                </td>
                <td>
                  {{project.backend}}
                </td>
                <td>
                  {% if project.latest_version %}
                    {{ project.latest_version }}
                  {% endif %}
                </td>
              </tr>
            {% endfor %}
            </table>
          </dl>
        </p>
        <div class="clearfix"></div>
      </div>
    {% else %}
    <blockquote>
        Oups this is embarrassing, it seems that no projects are being
        monitored currently.
        <p><a href="{{ url_for('anitya_ui.new_project', name=pattern) }}">Click Here</a> to add this project instead. </p>
    </blockquote>
    {% endif %}
    </div>
  </div>
</div>

{% endblock %}
