{% extends "base.html" %}

{% block title %}
{{ _("'%(query)s' - Search Package Releases", query=query) }}
{% endblock %}

{% block content %}
	<a class="btn btn-secondary float-end" href="{{ url_for('zipgrep.zipgrep_search') }}">New Query</a>
	<h1>{{ _("Search in Package Releases") }}</h1>
	<h2>{{ query }}</h2>

	<p class="text-muted">
		Found in {{ matches | count }} package(s).
	</p>

	<div class="list-group">
		{% for match in matches %}
			<div class="list-group-item">
				<div class="row">
					<div class="col-sm-2 text-muted">
						<img
							class="img-fluid"
							src="{{ match.package.get_thumb_or_placeholder() }}" />

						<div class="mt-2">
							<a href="{{ match.package.get_url('packages.view') }}">
								{{ match.package.title }}
							</a>
							by {{ match.package.author.display_name }}
						</div>

						<p class="mt-4">
							{{ match.lines.split("\n") | select | list | count }} match(es)
						</p>

						<a class="mt-4 btn btn-secondary" href="{{ match.package.get_download_release().get_download_url() }}">
							Download
						</a>
					</div>
					<div class="col-sm-10">
						<pre style="max-height: 300px;" class="m-0">{{ match.lines }}</pre>
					</div>
				</div>
			</div>
		{% endfor %}
	</div>
{% endblock %}
