Files
twitch-drop-notifier/core/templates/index.html
2025-05-01 02:41:25 +02:00

112 lines
6.1 KiB
HTML

{% extends "base.html" %}
{% load custom_filters static time_filters %}
{% block content %}
<div class="container mt-4">
{% include "partials/info_box.html" %}
<!-- Drop Campaigns Section -->
<section class="drop-campaigns">
<h2>
Drop Campaigns -
<span class="d-inline text-muted">{{ grouped_drops|length }} game{{ grouped_drops|length|pluralize }}</span>
</h2>
{% if grouped_drops %}
{% for game, drops_list in grouped_drops.items %}
{# Retain card structure for layout, replace table with list #}
<div class="card mb-4 shadow-sm">
<div class="row g-0">
<!-- Game Box Art -->
<div class="col-md-2">
{% if game and game.box_art_url %}
<img src="{{ game.box_art_url }}" alt="{{ game.display_name|default:'Game name unknown' }} box art"
class="img-fluid rounded-start" height="283" width="212" loading="lazy" />
{% else %}
<img src="{% static 'images/404_boxart.jpg' %}"
alt="{% if game %}{{ game.display_name }}{% else %}Unknown Game{% endif %} box art"
class="img-fluid rounded-start" height="283" width="212" loading="lazy" />
{% endif %}
</div>
<!-- Game Details -->
<div class="col-md-10">
<div class="card-body">
<h2 class="card-title h5">
{% if game %}
<a href="{% if game.game_id %}{% url 'game_detail' game.game_id %}{% else %}#{% endif %}"
class="text-decoration-none">{{ game.display_name|default:'Unknown Game' }}</a>
{% if game.slug %}
- <a href="https://www.twitch.tv/directory/category/{{ game.slug }}"
class="text-decoration-none text-muted">Twitch</a>
{% endif %}
{% else %}
Drops without an associated Game
{% endif %}
</h2>
{% if drops_list %}
<!-- NEW Drop List Structure -->
<ul class="list-unstyled mt-3">
{% for drop in drops_list %}
<li class="mb-3"> {# Add margin between list items #}
<strong>{{ drop.name|default:'Unknown Drop' }}</strong>
(Requires {{ drop.required_minutes_watched|minutes_to_hours }})
<br>
<em>Campaign:
<a href="{{ drop.campaign.details_url|default:'#' }}" class="text-decoration-none"
title="{{ drop.campaign.name|default:'Unknown Campaign' }}">
{{ drop.campaign.name|truncatechars:40|default:'N/A' }} {# Adjusted truncate #}
</a>
{% if drop.campaign.details_url != drop.campaign.account_link_url and drop.campaign.account_link_url %}
| <a href="{{ drop.campaign.account_link_url }}" class="text-decoration-none"
title="Link Account for {{ drop.campaign.name }}">Link</a>
{% endif %}
</em>
<br>
Ends in: <abbr
title="{{ drop.campaign.start_at|date:'l d F H:i' }} - {{ drop.campaign.end_at|date:'l d F H:i' }}">
{{ drop.campaign.end_at|timeuntil }}
</abbr>
{% if drop.benefits.exists %}
<br>
Benefits:
<ul class="list-inline">
{% for benefit in drop.benefits.all %}
<li class="list-inline-item">
<abbr title="{{ benefit.name|default:'Unknown Benefit' }}">
{% if benefit.image_asset_url %}
<img src="{{ benefit.image_asset_url|default:'https://static-cdn.jtvnw.net/ttv-static/404_boxart.jpg' }}"
alt="{{ benefit.name|default:'Unknown Benefit' }}"
class="img-fluid rounded me-1 align-middle" {# Added align-middle #}
height="20" width="20" loading="lazy" />
{% endif %}
<small>{{ benefit.name|truncatechars:25|default:'Unknown Benefit' }}</small>
{# Wrap text in small #}
</abbr>
</li>
{% endfor %}
</ul>
{% endif %}
{# Removed hr, using li margin instead #}
</li>
{% endfor %}
</ul>
{% else %}
<p class="mt-3 text-muted">No active drops found for this game currently.</p>
{% endif %}
</div>
</div>
</div>
</div>
{% empty %}
<div class="alert alert-info" role="alert">
There are currently no active Twitch drops found matching the criteria.
</div>
{% endfor %}
{% else %}
<div class="alert alert-info" role="alert">
There are currently no active Twitch drops found.
</div>
{% endif %}
</section>
</div>
{% endblock content %}