{% extends "base.html" %}

{% block title -%}
	{{ _("Support Creators") }}
{%- endblock %}

{% block description -%}
	{{ _("Some content creators are accepting donations for their work.") }}
	{{ _("Donations are a great way to support your favorite modders, artists, and game developers.") }}
{% endblock %}

{% macro authorlink(author) %}
	<a href="{{ url_for('users.profile', username=author.username) }}">
		{{ author.display_name }}
	</a>
{% endmacro %}

{% macro render_packages(packages) %}
	<ul class="list-group">
		{% for package in packages %}
			<li class="list-group-item">
				<div class="row">
					<div class="col-sm-auto text-muted" style="min-width: 250px;">
						<a href="{{ package.get_url('packages.view') }}">
							<img
								class="img-fluid"
								style="max-height: 22px; max-width: 22px;"
								src="{{ package.get_thumb_or_placeholder() }}" />

							<span class="ps-2">
								{{ package.title }}
							</span>
						</a>
					</div>

					<div class="col-sm">
						{{ _("by %(author)s", author=authorlink(package.author)) }}
					</div>

					<div class="col-sm-auto">
						<a href="{{ package.get_url('packages.view') }}" class="btn btn-sm btn-secondary me-1">
							{{ _("View package") }}
						</a>
						<a href="{{ package.donate_url_actual }}" class="btn btn-sm btn-primary" rel="ugc">
							<i class="fas fa-heart me-1"></i>
							{{ _("Donate") }}
						</a>
					</div>
				</div>
			</li>
		{% endfor %}
	</ul>
{% endmacro %}


{% block content %}
	<h1>{{ self.title() }}</h1>
	<p class="lead">
		{{ self.description() }}
	</p>

	<h2 id="contentdb">{{ _("Support ContentDB") }}</h2>
	<p>
		{{ _("You can donate to rubenwardy to cover ContentDB's costs and support future development.") }}
	</p>
	<p>
		{{ _("For more information about the cost of ContentDB and what rubenwardy does, see his donation page:") }}
	</p>
	<p>
		<a href="https://rubenwardy.com/donate/" class="btn btn-primary me-1">{{ _("Donate") }}</a>
	</p>

	<h2>{{ _("Based on your reviews / favorites") }}</h2>
	{% if reviewed_packages %}
		{{ render_packages(reviewed_packages) }}
	{% elif current_user.is_authenticated %}
		<p class="text-muted">
			{{ _("No reviewed packages accepting donations. Consider reviewing your favourite packages") }}
		</p>
	{% else %}
		<p>
			{{ _("Sign in to see recommendations based on the packages you've reviewed") }}
		</p>
		<p>
			<a class="btn btn-primary" href="{{ url_for('users.login') }}">{{ _("Sign in") }}</a>
		</p>
	{% endif %}

	<h2>{{ _("Top packages") }}</h2>
	{{ render_packages(top_packages) }}
	<p class="text-center mt-5">
		<small>
			{{ _("%(count)d packages are looking for donations", count=packages_count) }}
		</small>
	</p>
{% endblock %}
