mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-13 23:56:46 +02:00
675 lines
45 KiB
Twig
675 lines
45 KiB
Twig
{% extends "layouts/app.twig" %}
|
|
|
|
{% block nav_controls %}
|
|
<!-- Enhanced Search form -->
|
|
<form method="GET" class="flex gap-3 items-center">
|
|
<input type="hidden" name="view" value="{{ view_mode }}">
|
|
<input type="hidden" name="per_page" value="{{ pagination.per_page }}">
|
|
{% for genre in filters.genres %}
|
|
<input type="hidden" name="genres[]" value="{{ genre }}">
|
|
{% endfor %}
|
|
{% for year in filters.years %}
|
|
<input type="hidden" name="years[]" value="{{ year }}">
|
|
{% endfor %}
|
|
</form>
|
|
|
|
<!-- Enhanced View mode switcher -->
|
|
<div class="flex gap-1 bg-gray-100 rounded-lg p-1" role="group">
|
|
{% for mode in view_modes %}
|
|
<a
|
|
href="?view={{ mode }}{% if search %}&search={{ search }}{% endif %}{% if pagination.per_page != 24 %}&per_page={{ pagination.per_page }}{% endif %}{% for genre in filters.genres %}&genres[]={{ genre }}{% endfor %}{% for year in filters.years %}&years[]={{ year }}{% endfor %}"
|
|
class="inline-flex items-center px-3 py-2 text-sm font-medium rounded-md transition-all duration-200 {{ view_mode == mode ? 'bg-white text-blue-600 shadow-sm' : 'text-gray-600 hover:text-gray-900 hover:bg-gray-200' }}"
|
|
title="{{ mode|title }} View"
|
|
>
|
|
{% if mode == 'grid' %}
|
|
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"/>
|
|
</svg>
|
|
{% endif %}
|
|
{% if mode == 'list' %}
|
|
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 10h16M4 14h16M4 18h16"/>
|
|
</svg>
|
|
{% endif %}
|
|
{% if mode == 'covers' %}
|
|
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"/>
|
|
</svg>
|
|
{% endif %}
|
|
<span class="hidden sm:inline ml-1">{{ mode|title }}</span>
|
|
</a>
|
|
{% endfor %}
|
|
</div>
|
|
<!-- Sort dropdown -->
|
|
<div class="relative gap-1 bg-gray-100 rounded-lg p-1" x-data="{ open: false }">
|
|
<button @click="open = !open" class="inline-flex items-center px-3 py-2 text-sm font-medium rounded-md transition-all duration-200 {{ view_mode == mode ? 'bg-white text-blue-600 shadow-sm' : 'text-gray-600 hover:text-gray-900 hover:bg-gray-200' }}">
|
|
<svg class="mr-1 h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 4h14M3 8h9m-9 4h6m4 0l4-4m0 0l4 4m-4-4v12"/>
|
|
</svg>
|
|
<span class="hidden sm:inline">Sort</span>
|
|
</button>
|
|
<div x-show="open" @click.away="open = false" class="absolute right-0 z-50 mt-2 w-56 bg-white rounded-md shadow-lg ring-1 ring-black ring-opacity-5">
|
|
<div class="py-1">
|
|
{% for key, label in sort_options %}
|
|
<a class="flex items-center justify-between px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 {{ sort == key ? 'bg-gray-50' : '' }}"
|
|
href="?sort={{ key }}&view={{ view_mode }}{% if search %}&search={{ search }}{% endif %}{% if pagination.per_page != 24 %}&per_page={{ pagination.per_page }}{% endif %}{% for genre in filters.genres %}&genres[]={{ genre }}{% endfor %}{% for director in filters.directors %}&directors[]={{ director }}{% endfor %}">
|
|
{{ label }}
|
|
{% if sort == key %}
|
|
<svg class="h-4 w-4 text-blue-600" fill="currentColor" viewBox="0 0 16 16">
|
|
<path d="M12.5 15a.5.5 0 0 1-.5-.5v-13a.5.5 0 0 1 1 0v13a.5.5 0 0 1-.5.5zM10 8a.5.5 0 0 1-.5.5H3.707l2.147 2.146a.5.5 0 0 1-.708.708l-3-3a.5.5 0 0 1 0-.708l3-3a.5.5 0 1 1 .708.708L3.707 7.5H9.5a.5.5 0 0 1 .5.5z"/>
|
|
</svg>
|
|
{% endif %}
|
|
</a>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block sidebar %}
|
|
<div class="space-y-4">
|
|
<!-- Filters -->
|
|
<div class="bg-gray-50 rounded-lg p-4">
|
|
<h3 class="text-sm font-medium text-gray-900 mb-4">Filters</h3>
|
|
|
|
<!-- Filter form -->
|
|
<form method="GET" id="filterForm">
|
|
<input type="hidden" name="view" value="{{ view_mode }}">
|
|
<input type="hidden" name="per_page" value="{{ pagination.per_page }}">
|
|
<input type="hidden" name="search" value="{{ search }}">
|
|
|
|
<!-- Genre filter -->
|
|
{% if available_filters.genres %}
|
|
<div class="mb-4">
|
|
<label class="block text-xs font-medium text-gray-700 mb-1">Genres</label>
|
|
<select class="select2 w-full text-sm border border-gray-300 rounded focus:ring-blue-500 focus:border-blue-500" name="genres[]" multiple data-placeholder="Select genres...">
|
|
{% for genre in available_filters.genres %}
|
|
<option value="{{ genre }}" {{ genre in filters.genres ? 'selected' : '' }}>
|
|
{{ genre }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Year filter -->
|
|
{% if available_filters.years %}
|
|
<div class="mb-4">
|
|
<label class="block text-xs font-medium text-gray-700 mb-1">Years</label>
|
|
<select class="select2 w-full text-sm border border-gray-300 rounded focus:ring-blue-500 focus:border-blue-500" name="years[]" multiple data-placeholder="Select years...">
|
|
{% for year in available_filters.years %}
|
|
<option value="{{ year }}" {{ year in filters.years ? 'selected' : '' }}>
|
|
{{ year }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Filter actions -->
|
|
<div class="space-y-2">
|
|
<button type="submit" class="w-full bg-blue-600 text-white px-3 py-2 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 text-sm">
|
|
Apply Filters
|
|
</button>
|
|
<a href="{{ path_for('tvshows.index') }}" class="w-full bg-gray-100 text-gray-700 px-3 py-2 rounded-md hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 block text-center text-sm">
|
|
Clear All
|
|
</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Active Filters Summary -->
|
|
{% if filters.genres or filters.years or search %}
|
|
<div class="bg-blue-50 rounded-lg p-4">
|
|
<h3 class="text-sm font-medium text-gray-900 mb-3">Active Filters</h3>
|
|
<div class="space-y-2">
|
|
{% if search %}
|
|
<div class="flex items-center justify-between">
|
|
<span class="text-sm text-gray-600">Search: "{{ search }}"</span>
|
|
<a href="?{% for key, value in filters %}{% if key != 'search' %}{{ key }}={{ value }}&{% endif %}{% endfor %}" class="text-blue-600 hover:text-blue-800">
|
|
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
|
</svg>
|
|
</a>
|
|
</div>
|
|
{% endif %}
|
|
{% for genre in filters.genres %}
|
|
<div class="flex items-center justify-between">
|
|
<span class="text-sm text-gray-600">Genre: {{ genre }}</span>
|
|
<a href="?{% for key, value in filters %}{% if key != 'genres' or (key == 'genres' and value != genre) %}{{ key }}={{ value }}&{% endif %}{% endfor %}" class="text-blue-600 hover:text-blue-800">
|
|
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
|
</svg>
|
|
</a>
|
|
</div>
|
|
{% endfor %}
|
|
{% for year in filters.years %}
|
|
<div class="flex items-center justify-between">
|
|
<span class="text-sm text-gray-600">Year: {{ year }}</span>
|
|
<a href="?{% for key, value in filters %}{% if key != 'years' or (key == 'years' and value != year) %}{{ key }}={{ value }}&{% endif %}{% endfor %}" class="text-blue-600 hover:text-blue-800">
|
|
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
|
</svg>
|
|
</a>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Quick Stats -->
|
|
<div class="bg-gray-50 rounded-lg p-4">
|
|
<h3 class="text-sm font-medium text-gray-900 mb-3">Quick Stats</h3>
|
|
<div class="space-y-2">
|
|
<div class="flex justify-between text-sm">
|
|
<span class="text-gray-600">Total TV Shows</span>
|
|
<span class="font-medium text-gray-900">{{ pagination.total_items }}</span>
|
|
</div>
|
|
<div class="flex justify-between text-sm">
|
|
<span class="text-gray-600">This Page</span>
|
|
<span class="font-medium text-gray-900">{{ tvshows|length }}</span>
|
|
</div>
|
|
{% if pagination.total_pages > 1 %}
|
|
<div class="flex justify-between text-sm">
|
|
<span class="text-gray-600">Page</span>
|
|
<span class="font-medium text-gray-900">{{ pagination.current_page }} of {{ pagination.total_pages }}</span>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<!-- Main content area -->
|
|
<div class="min-h-screen bg-gradient-to-br from-gray-50 to-gray-100" data-content>
|
|
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
|
<!-- Header -->
|
|
<div class="mb-8">
|
|
<div class="flex items-center justify-between">
|
|
<div>
|
|
<h1 class="text-4xl font-bold text-gray-900 mb-2">TV Shows</h1>
|
|
{% if pagination.total_items > 0 %}
|
|
<div class="flex items-center gap-3 text-gray-600">
|
|
<span class="text-lg">{{ pagination.total_items }} TV shows</span>
|
|
{% if search %}
|
|
<span class="text-sm bg-blue-50 text-blue-700 px-3 py-1 rounded-full">matching "{{ search }}"</span>
|
|
{% endif %}
|
|
{% if filters.genres %}
|
|
<span class="text-sm bg-purple-50 text-purple-700 px-3 py-1 rounded-full">{{ filters.genres|join(', ') }}</span>
|
|
{% endif %}
|
|
{% if filters.years %}
|
|
<span class="text-sm bg-green-50 text-green-700 px-3 py-1 rounded-full">{{ filters.years|join(', ') }}</span>
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
<!-- Sort dropdown -->
|
|
<div class="flex items-center gap-4">
|
|
<div class="flex items-center gap-2">
|
|
<label for="sort" class="text-sm font-medium text-gray-700">Sort by:</label>
|
|
<select id="sort" class="text-sm border border-gray-300 rounded-lg px-3 py-2 bg-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-colors">
|
|
<option value="title_asc" {{ sort == 'title_asc' ? 'selected' : '' }}>Title A-Z</option>
|
|
<option value="title_desc" {{ sort == 'title_desc' ? 'selected' : '' }}>Title Z-A</option>
|
|
<option value="year_desc" {{ sort == 'year_desc' ? 'selected' : '' }}>Newest First</option>
|
|
<option value="year_asc" {{ sort == 'year_asc' ? 'selected' : '' }}>Oldest First</option>
|
|
<option value="rating_desc" {{ sort == 'rating_desc' ? 'selected' : '' }}>Highest Rated</option>
|
|
<option value="rating_asc" {{ sort == 'rating_asc' ? 'selected' : '' }}>Lowest Rated</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% if tvshows is empty %}
|
|
<div class="text-center py-16">
|
|
<div class="mx-auto w-24 h-24 bg-gradient-to-br from-gray-100 to-gray-200 rounded-full flex items-center justify-center mb-6">
|
|
<svg class="w-12 h-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 4V2a1 1 0 011-1h8a1 1 0 011 1v2h4a1 1 0 010 2h-1v14a2 2 0 01-2 2H6a2 2 0 01-2-2V6H3a1 1 0 010-2h4z"/>
|
|
</svg>
|
|
</div>
|
|
<h3 class="text-2xl font-semibold text-gray-900 mb-3">
|
|
{% if search or filters.genres or filters.years %}
|
|
No TV shows found matching your criteria
|
|
{% else %}
|
|
No TV shows found
|
|
{% endif %}
|
|
</h3>
|
|
<p class="text-gray-600 text-lg mb-6 max-w-md mx-auto">
|
|
{% if search or filters.genres or filters.years %}
|
|
Try adjusting your search terms or filters to find what you're looking for.
|
|
{% else %}
|
|
Start syncing your TV show libraries to see your collection here.
|
|
{% endif %}
|
|
</p>
|
|
{% if search or filters.genres or filters.years %}
|
|
<a href="{{ path_for('tvshows.index') }}" class="inline-flex items-center px-6 py-3 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors">
|
|
<svg class="w-5 h-5 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
|
|
</svg>
|
|
Clear filters
|
|
</a>
|
|
{% endif %}
|
|
</div>
|
|
{% else %}
|
|
<!-- TV Shows content based on view mode -->
|
|
{% if view_mode == 'list' %}
|
|
<!-- Enhanced List view -->
|
|
<div class="bg-white rounded-xl shadow-lg border border-gray-200 overflow-hidden">
|
|
<ul class="divide-y divide-gray-100">
|
|
{% for tvshow in tvshows %}
|
|
<li class="group hover:bg-gray-50 transition-colors duration-200">
|
|
<div class="px-6 py-4">
|
|
<div class="flex items-center justify-between">
|
|
<div class="flex items-center space-x-4 flex-1">
|
|
<!-- Poster -->
|
|
<div class="flex-shrink-0">
|
|
{% if tvshow.poster_url %}
|
|
<div class="relative overflow-hidden rounded-lg shadow-sm group-hover:shadow-md transition-shadow duration-200">
|
|
<img class="w-16 h-24 object-cover transform group-hover:scale-105 transition-transform duration-200" src="/images/{{ tvshow.poster_url }}" alt="{{ tvshow.title }}">
|
|
</div>
|
|
{% else %}
|
|
<div class="w-16 h-24 bg-gradient-to-br from-gray-100 to-gray-200 rounded-lg flex items-center justify-center shadow-sm">
|
|
<svg class="w-8 h-8 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 4V2a1 1 0 011-1h8a1 1 0 011 1v2h4a1 1 0 010 2h-1v14a2 2 0 01-2 2H6a2 2 0 01-2-2V6H3a1 1 0 010-2h4z"/>
|
|
</svg>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Content -->
|
|
<div class="flex-1 min-w-0">
|
|
<div class="flex items-start justify-between">
|
|
<div class="flex-1">
|
|
<h3 class="text-lg font-semibold text-gray-900 mb-1 group-hover:text-blue-600 transition-colors">
|
|
<a href="{{ path_for('tvshows.show', {'id': tvshow.id}) }}" class="block truncate">
|
|
{{ tvshow.title }}
|
|
</a>
|
|
</h3>
|
|
|
|
<!-- Metadata row -->
|
|
<div class="flex items-center gap-4 text-sm text-gray-600 mb-2">
|
|
{% if tvshow.first_air_date %}
|
|
<div class="flex items-center gap-1">
|
|
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
|
|
</svg>
|
|
<span>{{ tvshow.first_air_date|date('Y') }}</span>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if tvshow.rating %}
|
|
<div class="flex items-center gap-1">
|
|
<svg class="w-4 h-4 text-yellow-500" fill="currentColor" viewBox="0 0 24 24">
|
|
<path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/>
|
|
</svg>
|
|
<span>{{ tvshow.rating }}/10</span>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if tvshow.number_of_seasons %}
|
|
<div class="flex items-center gap-1">
|
|
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"/>
|
|
</svg>
|
|
<span>{{ tvshow.number_of_seasons }} season{{ tvshow.number_of_seasons > 1 ? 's' : '' }}</span>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if tvshow.number_of_episodes %}
|
|
<div class="flex items-center gap-1">
|
|
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"/>
|
|
</svg>
|
|
<span>{{ tvshow.number_of_episodes }} episode{{ tvshow.number_of_episodes > 1 ? 's' : '' }}</span>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Overview preview -->
|
|
{% if tvshow.overview %}
|
|
<p class="text-sm text-gray-600 line-clamp-2 mb-2">
|
|
{{ tvshow.overview|slice(0, 120) }}{% if tvshow.overview|length > 120 %}...{% endif %}
|
|
</p>
|
|
{% endif %}
|
|
|
|
<!-- Source -->
|
|
<div class="flex items-center gap-1 text-xs text-gray-500">
|
|
<svg class="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"/>
|
|
</svg>
|
|
<span>{{ tvshow.source_name }}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Actions -->
|
|
<div class="flex items-center gap-3">
|
|
{% if tvshow.is_favorite %}
|
|
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-red-100 text-red-800 border border-red-200">
|
|
<svg class="w-3 h-3 mr-1" fill="currentColor" viewBox="0 0 24 24">
|
|
<path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/>
|
|
</svg>
|
|
Favorite
|
|
</span>
|
|
{% endif %}
|
|
|
|
<a href="{{ path_for('tvshows.show', {'id': tvshow.id}) }}"
|
|
class="inline-flex items-center px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors opacity-0 group-hover:opacity-100 transform translate-x-2 group-hover:translate-x-0 transition-all duration-200">
|
|
View Details
|
|
<svg class="w-4 h-4 ml-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
|
|
</svg>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</li>
|
|
{% endfor %}
|
|
</ul>
|
|
</div>
|
|
|
|
{% elseif view_mode == 'covers' %}
|
|
<!-- Cover grid view -->
|
|
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-4">
|
|
{% for tvshow in tvshows %}
|
|
<div class="bg-white rounded-lg shadow-md border border-gray-200 overflow-hidden h-full">
|
|
{% if tvshow.poster_url %}
|
|
<div class="relative aspect-[2/3] overflow-hidden">
|
|
<img src="/images/{{ tvshow.poster_url }}" alt="{{ tvshow.title }}" class="w-full h-full object-cover">
|
|
</div>
|
|
{% else %}
|
|
<div class="flex items-center justify-center bg-gray-100 aspect-[2/3] min-h-[200px]">
|
|
<svg class="text-gray-600" width="48" height="48" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 4V2a1 1 0 011-1h8a1 1 0 011 1v2h4a1 1 0 010 2h-1v14a2 2 0 01-2 2H6a2 2 0 01-2-2V6H3a1 1 0 010-2h4z"/>
|
|
</svg>
|
|
</div>
|
|
{% endif %}
|
|
<div class="p-3">
|
|
<h6 class="text-sm font-semibold truncate" title="{{ tvshow.title }}">
|
|
<a href="{{ path_for('tvshows.show', {'id': tvshow.id}) }}" class="no-underline text-gray-900 hover:text-blue-600">
|
|
{{ tvshow.title }}
|
|
</a>
|
|
</h6>
|
|
{% if tvshow.first_air_date %}
|
|
<p class="text-xs text-gray-600 mt-1">{{ tvshow.first_air_date|date('Y') }}</p>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
|
|
{% else %}
|
|
<!-- Enhanced Default grid view -->
|
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-6 gap-6">
|
|
{% for tvshow in tvshows %}
|
|
<div class="group bg-white rounded-xl shadow-lg border border-gray-200 hover:shadow-xl transition-all duration-300 transform hover:-translate-y-1 h-full overflow-hidden">
|
|
<div class="p-6">
|
|
<div class="flex items-start space-x-4">
|
|
<!-- Poster -->
|
|
<div class="flex-shrink-0">
|
|
{% if tvshow.poster_url %}
|
|
<div class="relative overflow-hidden rounded-lg shadow-md group-hover:shadow-lg transition-shadow duration-300">
|
|
<img class="w-20 h-30 object-cover transform group-hover:scale-105 transition-transform duration-300" src="/images/{{ tvshow.poster_url }}" alt="{{ tvshow.title }}">
|
|
</div>
|
|
{% else %}
|
|
<div class="w-20 h-30 bg-gradient-to-br from-gray-100 to-gray-200 rounded-lg flex items-center justify-center shadow-sm">
|
|
<svg class="w-8 h-8 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 4V2a1 1 0 011-1h8a1 1 0 011 1v2h4a1 1 0 010 2h-1v14a2 2 0 01-2 2H6a2 2 0 01-2-2V6H3a1 1 0 010-2h4z"/>
|
|
</svg>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Content -->
|
|
<div class="flex-1 min-w-0">
|
|
<h5 class="text-xl font-bold text-gray-900 mb-2 group-hover:text-blue-600 transition-colors line-clamp-2">
|
|
<a href="{{ path_for('tvshows.show', {'id': tvshow.id}) }}" class="block">
|
|
{{ tvshow.title }}
|
|
</a>
|
|
</h5>
|
|
|
|
<!-- Metadata -->
|
|
<div class="flex items-center gap-3 text-sm text-gray-600 mb-3">
|
|
{% if tvshow.first_air_date %}
|
|
<div class="flex items-center gap-1">
|
|
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
|
|
</svg>
|
|
<span>{{ tvshow.first_air_date|date('Y') }}</span>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if tvshow.rating %}
|
|
<div class="flex items-center gap-1">
|
|
<svg class="w-4 h-4 text-yellow-500" fill="currentColor" viewBox="0 0 24 24">
|
|
<path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/>
|
|
</svg>
|
|
<span class="font-medium">{{ tvshow.rating }}/10</span>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Source -->
|
|
{% if tvshow.source_name %}
|
|
<div class="flex items-center gap-1 text-sm text-gray-500 mb-3">
|
|
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"/>
|
|
</svg>
|
|
<span>{{ tvshow.source_name }}</span>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Overview -->
|
|
{% if tvshow.overview %}
|
|
<div class="mb-4">
|
|
<p class="text-sm text-gray-600 line-clamp-3 leading-relaxed">
|
|
{{ tvshow.overview|slice(0, 180) }}{% if tvshow.overview|length > 180 %}...{% endif %}
|
|
</p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Footer -->
|
|
<div class="flex items-center justify-between">
|
|
<div class="flex items-center gap-3 text-sm text-gray-600">
|
|
{% if tvshow.number_of_seasons %}
|
|
<span class="flex items-center gap-1">
|
|
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"/>
|
|
</svg>
|
|
{{ tvshow.number_of_seasons }} season{{ tvshow.number_of_seasons > 1 ? 's' : '' }}
|
|
</span>
|
|
{% endif %}
|
|
|
|
{% if tvshow.number_of_episodes %}
|
|
<span class="flex items-center gap-1">
|
|
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"/>
|
|
</svg>
|
|
{{ tvshow.number_of_episodes }} episode{{ tvshow.number_of_episodes > 1 ? 's' : '' }}
|
|
</span>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="flex items-center gap-2">
|
|
{% if tvshow.is_favorite %}
|
|
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-red-100 text-red-800 border border-red-200">
|
|
<svg class="w-3 h-3 mr-1" fill="currentColor" viewBox="0 0 24 24">
|
|
<path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/>
|
|
</svg>
|
|
Favorite
|
|
</span>
|
|
{% endif %}
|
|
|
|
<a href="{{ path_for('tvshows.show', {'id': tvshow.id}) }}"
|
|
class="inline-flex items-center px-3 py-2 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors opacity-0 group-hover:opacity-100 transform translate-x-2 group-hover:translate-x-0 transition-all duration-200">
|
|
View
|
|
<svg class="w-4 h-4 ml-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
|
|
</svg>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Top Pagination & Controls -->
|
|
{% if pagination.total_pages > 1 %}
|
|
<div class="flex items-center justify-between mb-6 p-4 bg-gray-50 rounded-lg">
|
|
<div class="flex items-center gap-4">
|
|
<div class="text-sm text-gray-700">
|
|
Showing {{ (pagination.current_page - 1) * pagination.per_page + 1 }} to {{ min(pagination.current_page * pagination.per_page, pagination.total_items) }} of {{ pagination.total_items }} TV shows
|
|
</div>
|
|
<div class="flex items-center gap-2">
|
|
<label for="per_page_top" class="text-sm font-medium text-gray-700">Show:</label>
|
|
<select id="per_page_top" class="text-sm border border-gray-300 rounded px-2 py-1 focus:ring-blue-500 focus:border-blue-500">
|
|
<option value="12" {{ pagination.per_page == 12 ? 'selected' : '' }}>12</option>
|
|
<option value="24" {{ pagination.per_page == 24 ? 'selected' : '' }}>24</option>
|
|
<option value="48" {{ pagination.per_page == 48 ? 'selected' : '' }}>48</option>
|
|
<option value="100" {{ pagination.per_page == 100 ? 'selected' : '' }}>100</option>
|
|
</select>
|
|
<span class="text-sm text-gray-600">per page</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex items-center space-x-2">
|
|
<!-- Previous Button -->
|
|
{% if pagination.has_prev %}
|
|
<a href="?page={{ pagination.prev_page }}{% if search %}&search={{ search }}{% endif %}{% if pagination.per_page != 24 %}&per_page={{ pagination.per_page }}{% endif %}&view={{ view_mode }}{% for genre in filters.genres %}&genres[]={{ genre }}{% endfor %}{% for year in filters.years %}&years[]={{ year }}{% endfor %}"
|
|
class="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 hover:text-gray-700 transition-colors flex items-center">
|
|
<svg class="w-4 h-4 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/>
|
|
</svg>
|
|
Previous
|
|
</a>
|
|
{% else %}
|
|
<span class="px-3 py-2 text-sm font-medium text-gray-300 bg-gray-100 border border-gray-200 rounded-lg cursor-not-allowed flex items-center">
|
|
<svg class="w-4 h-4 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/>
|
|
</svg>
|
|
Previous
|
|
</span>
|
|
{% endif %}
|
|
|
|
<!-- Page Numbers -->
|
|
{% set start_page = max(1, pagination.current_page - 2) %}
|
|
{% set end_page = min(pagination.total_pages, pagination.current_page + 2) %}
|
|
|
|
{% if start_page > 1 %}
|
|
<a href="?page=1{% if search %}&search={{ search }}{% endif %}{% if pagination.per_page != 24 %}&per_page={{ pagination.per_page }}{% endif %}&view={{ view_mode }}{% for genre in filters.genres %}&genres[]={{ genre }}{% endfor %}{% for year in filters.years %}&years[]={{ year }}{% endfor %}"
|
|
class="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 hover:text-gray-700 transition-colors">1</a>
|
|
{% if start_page > 2 %}
|
|
<span class="px-2 py-2 text-sm font-medium text-gray-500">...</span>
|
|
{% endif %}
|
|
{% endif %}
|
|
|
|
{% for page_num in start_page..end_page %}
|
|
{% if page_num == pagination.current_page %}
|
|
<span class="px-3 py-2 text-sm font-medium text-white bg-blue-600 border border-blue-600 rounded-lg">{{ page_num }}</span>
|
|
{% else %}
|
|
<a href="?page={{ page_num }}{% if search %}&search={{ search }}{% endif %}{% if pagination.per_page != 24 %}&per_page={{ pagination.per_page }}{% endif %}&view={{ view_mode }}{% for genre in filters.genres %}&genres[]={{ genre }}{% endfor %}{% for year in filters.years %}&years[]={{ year }}{% endfor %}"
|
|
class="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 hover:text-gray-700 transition-colors">{{ page_num }}</a>
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% if end_page < pagination.total_pages %}
|
|
{% if end_page < pagination.total_pages - 1 %}
|
|
<span class="px-2 py-2 text-sm font-medium text-gray-500">...</span>
|
|
{% endif %}
|
|
<a href="?page={{ pagination.total_pages }}{% if search %}&search={{ search }}{% endif %}{% if pagination.per_page != 24 %}&per_page={{ pagination.per_page }}{% endif %}&view={{ view_mode }}{% for genre in filters.genres %}&genres[]={{ genre }}{% endfor %}{% for year in filters.years %}&years[]={{ year }}{% endfor %}"
|
|
class="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 hover:text-gray-700 transition-colors">{{ pagination.total_pages }}</a>
|
|
{% endif %}
|
|
|
|
<!-- Next Button -->
|
|
{% if pagination.has_next %}
|
|
<a href="?page={{ pagination.next_page }}{% if search %}&search={{ search }}{% endif %}{% if pagination.per_page != 24 %}&per_page={{ pagination.per_page }}{% endif %}&view={{ view_mode }}{% for genre in filters.genres %}&genres[]={{ genre }}{% endfor %}{% for year in filters.years %}&years[]={{ year }}{% endfor %}"
|
|
class="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-lg hover:bg-gray-50 hover:text-gray-700 transition-colors flex items-center">
|
|
Next
|
|
<svg class="w-4 h-4 ml-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
|
|
</svg>
|
|
</a>
|
|
{% else %}
|
|
<span class="px-3 py-2 text-sm font-medium text-gray-300 bg-gray-100 border border-gray-200 rounded-lg cursor-not-allowed flex items-center">
|
|
Next
|
|
<svg class="w-4 h-4 ml-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
|
|
</svg>
|
|
</span>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
/* Custom styles for Select2 integration */
|
|
.select2-container {
|
|
z-index: 1050; /* Ensure Select2 dropdown appears above other elements */
|
|
}
|
|
|
|
.select2-selection {
|
|
min-height: 38px;
|
|
}
|
|
|
|
.select2-selection__choice {
|
|
background-color: #0d6efd !important;
|
|
border: none !important;
|
|
color: white !important;
|
|
}
|
|
|
|
.select2-selection__choice__remove {
|
|
color: white !important;
|
|
margin-right: 5px;
|
|
}
|
|
|
|
.select2-selection__choice__remove:hover {
|
|
color: #f8f9fa !important;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
// Initialize Select2 for all select2 elements
|
|
$('.select2').select2({
|
|
width: '100%',
|
|
allowClear: true,
|
|
placeholder: function() {
|
|
return $(this).data('placeholder');
|
|
}
|
|
});
|
|
|
|
// Auto-submit filter form when Select2 selection changes
|
|
$('.select2').on('change', function() {
|
|
document.getElementById('filterForm').submit();
|
|
});
|
|
});
|
|
|
|
document.getElementById('per_page')?.addEventListener('change', function() {
|
|
const url = new URL(window.location);
|
|
url.searchParams.set('per_page', this.value);
|
|
url.searchParams.set('page', '1'); // Reset to first page
|
|
window.location = url.toString();
|
|
});
|
|
|
|
document.getElementById('per_page_top')?.addEventListener('change', function() {
|
|
const url = new URL(window.location);
|
|
url.searchParams.set('per_page', this.value);
|
|
url.searchParams.set('page', '1'); // Reset to first page
|
|
window.location = url.toString();
|
|
});
|
|
</script>
|
|
|
|
{% endblock %}
|