searcg revamp 😧

This commit is contained in:
Lars Behrends
2025-11-06 13:39:46 +01:00
parent a44c311e89
commit 0f0fb3b410
8 changed files with 1526 additions and 144 deletions

View File

@@ -0,0 +1,511 @@
{% extends 'admin/layout.twig' %}
{% block title %}Manage Actors - Admin Panel - MediaLib{% endblock %}
{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
<div>
<h1 class="h3 mb-0">Manage Actors</h1>
<p class="text-muted mb-0">View and manage actors, find and merge duplicates</p>
</div>
<div class="btn-group">
<a href="{{ path_for('admin.actors.index') }}" class="btn btn-outline-primary {% if not filters.duplicates %}active{% endif %}">
<i class="bi bi-people me-2"></i>All Actors
</a>
<a href="{{ path_for('admin.actors.index', {}, {'duplicates': 1}) }}" class="btn btn-outline-warning {% if filters.duplicates %}active{% endif %}">
<i class="bi bi-exclamation-triangle me-2"></i>Duplicates
</a>
</div>
</div>
<div class="card">
<div class="card-body">
{% if flash.success %}
<div class="alert alert-success">
{{ flash.success }}
</div>
{% endif %}
{% if filters.duplicates %}
<!-- Duplicate Actors View -->
<div class="d-flex justify-content-between align-items-center mb-3">
<div>
<h5 class="mb-0">Duplicate Actor Groups</h5>
<small class="text-muted">Actors with similar names that may need to be merged</small>
</div>
<button type="button" class="btn btn-success btn-sm" onclick="autoMergeAll()">
<i class="bi bi-magic me-1"></i>Auto-Merge All
</button>
</div>
<div class="row">
{% for group in actors %}
<div class="col-md-6 mb-4">
<div class="card border-warning">
<div class="card-header bg-warning-subtle">
<div class="d-flex justify-content-between align-items-center">
<h6 class="mb-0">{{ group.normalized_name|title }}</h6>
<span class="badge bg-warning">{{ group.duplicate_count }} duplicates</span>
</div>
</div>
<div class="card-body">
<div class="row g-3">
{% for actor in group.actors %}
<div class="col-12">
<div class="d-flex align-items-center p-2 border rounded">
<div class="form-check me-3">
<input class="form-check-input duplicate-checkbox"
type="checkbox"
value="{{ actor.id }}"
id="actor_{{ actor.id }}"
data-group="{{ group.normalized_name }}">
</div>
{% if actor.thumbnail_path %}
<img src="/images/{{ actor.thumbnail_path }}"
alt="{{ actor.name }}"
class="rounded me-3"
style="width: 40px; height: 40px; object-fit: cover;">
{% else %}
<div class="bg-light rounded d-flex align-items-center justify-content-center me-3"
style="width: 40px; height: 40px;">
<i class="bi bi-person text-muted"></i>
</div>
{% endif %}
<div class="flex-grow-1">
<div class="fw-bold">{{ actor.name }}</div>
<small class="text-muted">
{{ actor.stats.movie_count }} movies,
{{ actor.stats.tv_show_count }} TV shows,
{{ actor.stats.adult_video_count }} adult videos
<span class="text-primary">({{ actor.stats.total_media_count }} total)</span>
</small>
</div>
<div class="text-end">
<small class="text-muted d-block">ID: {{ actor.id }}</small>
{% if actor.thumbnail_path %}
<i class="bi bi-image text-success" title="Has thumbnail"></i>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
<div class="mt-3">
<button type="button"
class="btn btn-primary btn-sm me-2"
onclick="mergeSelected('{{ group.normalized_name }}')">
<i class="bi bi-arrow-merge me-1"></i>Merge Selected
</button>
<button type="button"
class="btn btn-success btn-sm"
onclick="autoMergeGroup('{{ group.normalized_name }}')">
<i class="bi bi-robot me-1"></i>Auto-Merge Group
</button>
</div>
</div>
</div>
</div>
{% else %}
<div class="col-12">
<div class="text-center py-5">
<i class="bi bi-check-circle text-success" style="font-size: 3rem;"></i>
<h5 class="mt-3">No Duplicate Actors Found</h5>
<p class="text-muted">All actors in your database appear to be unique.</p>
</div>
</div>
{% endfor %}
</div>
<!-- Pagination for duplicates -->
{% if pagination.total > 1 %}
<nav class="mt-4">
<ul class="pagination justify-content-center">
{% if pagination.current > 1 %}
<li class="page-item">
<a class="page-link"
href="{{ path_for('admin.actors.index', {}, {
'duplicates': 1,
'page': pagination.current - 1,
'search': filters.search,
'sort': filters.sort
}) }}"
aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
{% endif %}
{% set start = max(1, pagination.current - 2) %}
{% set end = min(pagination.total, pagination.current + 2) %}
{% if start > 1 %}
<li class="page-item">
<a class="page-link"
href="{{ path_for('admin.actors.index', {}, {
'duplicates': 1,
'page': 1,
'search': filters.search,
'sort': filters.sort
}) }}">1</a>
</li>
{% if start > 2 %}
<li class="page-item disabled">
<span class="page-link">...</span>
</li>
{% endif %}
{% endif %}
{% for i in start..end %}
<li class="page-item {% if i == pagination.current %}active{% endif %}">
<a class="page-link"
href="{{ path_for('admin.actors.index', {}, {
'duplicates': 1,
'page': i,
'search': filters.search,
'sort': filters.sort
}) }}">
{{ i }}
</a>
</li>
{% endfor %}
{% if end < pagination.total %}
{% if end < pagination.total - 1 %}
<li class="page-item disabled">
<span class="page-link">...</span>
</li>
{% endif %}
<li class="page-item">
<a class="page-link"
href="{{ path_for('admin.actors.index', {}, {
'duplicates': 1,
'page': pagination.total,
'search': filters.search,
'sort': filters.sort
}) }}">
{{ pagination.total }}
</a>
</li>
{% endif %}
{% if pagination.current < pagination.total %}
<li class="page-item">
<a class="page-link"
href="{{ path_for('admin.actors.index', {}, {
'duplicates': 1,
'page': pagination.current + 1,
'search': filters.search,
'sort': filters.sort
}) }}"
aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
{% endif %}
</ul>
</nav>
{% endif %}
{% else %}
<!-- All Actors View -->
<form method="get" class="mb-4">
<div class="row g-3">
<div class="col-md-6">
<div class="input-group">
<input type="text"
class="form-control"
name="search"
placeholder="Search actors..."
value="{{ filters.search }}">
<button class="btn btn-primary" type="submit">
<i class="bi bi-search"></i>
</button>
</div>
</div>
<div class="col-md-3">
<select name="sort" class="form-select">
<option value="name_asc" {{ filters.sort == 'name_asc' ? 'selected' : '' }}>Name (A-Z)</option>
<option value="name_desc" {{ filters.sort == 'name_desc' ? 'selected' : '' }}>Name (Z-A)</option>
<option value="media_desc" {{ filters.sort == 'media_desc' ? 'selected' : '' }}>Most Media</option>
<option value="media_asc" {{ filters.sort == 'media_asc' ? 'selected' : '' }}>Least Media</option>
</select>
</div>
<div class="col-md-3">
<div class="btn-group w-100">
<button type="submit" class="btn btn-primary">
<i class="bi bi-funnel me-1"></i> Filter
</button>
<a href="{{ path_for('admin.actors.index') }}" class="btn btn-outline-secondary">
<i class="bi bi-x-lg"></i>
</a>
</div>
</div>
</div>
</form>
<!-- Results Summary -->
<div class="d-flex justify-content-between align-items-center mb-3">
<div class="text-muted">
Showing {{ pagination.from }} to {{ pagination.to }} of {{ pagination.total_items }} actors
</div>
</div>
<div class="table-responsive">
<table class="table table-hover align-middle">
<thead class="table-light">
<tr>
<th style="width: 60px;">Photo</th>
<th>Name</th>
<th>Movies</th>
<th>TV Shows</th>
<th>Adult Videos</th>
<th>Total Media</th>
<th class="text-end">Actions</th>
</tr>
</thead>
<tbody>
{% for actor in actors %}
<tr>
<td>
{% if actor.thumbnail_path %}
<img src="/images/{{ actor.thumbnail_path }}" alt="{{ actor.name }}" style="width: 50px; height: 50px; object-fit: cover; border-radius: 50%;">
{% else %}
<div class="bg-light d-flex align-items-center justify-content-center rounded-circle" style="width: 50px; height: 50px;">
<i class="bi bi-person text-muted"></i>
</div>
{% endif %}
</td>
<td>{{ actor.name }}</td>
<td>{{ actor.movies|length }}</td>
<td>{{ actor.tvShows|length }}</td>
<td>{{ actor.adultVideos|length }}</td>
<td>
<span class="badge bg-primary">{{ actor.movies|length + actor.tvShows|length + actor.adultVideos|length }}</span>
</td>
<td>
<div class="btn-group btn-group-sm">
<a href="{{ path_for('actors.show', {id: actor.id}) }}" class="btn btn-outline-info" target="_blank">
<i class="bi bi-eye"></i>
</a>
<a href="{{ path_for('actors.edit', {id: actor.id}) }}" class="btn btn-outline-primary">
<i class="bi bi-pencil"></i>
</a>
</div>
</td>
</tr>
{% else %}
<tr>
<td colspan="7" class="text-center py-4">
<div class="text-muted">No actors found.</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- Pagination for all actors -->
{% if pagination.total > 1 %}
<nav class="mt-4">
<ul class="pagination justify-content-center">
{% if pagination.current > 1 %}
<li class="page-item">
<a class="page-link"
href="{{ path_for('admin.actors.index', {}, {
'page': pagination.current - 1,
'search': filters.search,
'sort': filters.sort
}) }}"
aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
{% endif %}
{% set start = max(1, pagination.current - 2) %}
{% set end = min(pagination.total, pagination.current + 2) %}
{% if start > 1 %}
<li class="page-item">
<a class="page-link"
href="{{ path_for('admin.actors.index', {}, {
'page': 1,
'search': filters.search,
'sort': filters.sort
}) }}">1</a>
</li>
{% if start > 2 %}
<li class="page-item disabled">
<span class="page-link">...</span>
</li>
{% endif %}
{% endif %}
{% for i in start..end %}
<li class="page-item {% if i == pagination.current %}active{% endif %}">
<a class="page-link"
href="{{ path_for('admin.actors.index', {}, {
'page': i,
'search': filters.search,
'sort': filters.sort
}) }}">
{{ i }}
</a>
</li>
{% endfor %}
{% if end < pagination.total %}
{% if end < pagination.total - 1 %}
<li class="page-item disabled">
<span class="page-link">...</span>
</li>
{% endif %}
<li class="page-item">
<a class="page-link"
href="{{ path_for('admin.actors.index', {}, {
'page': pagination.total,
'search': filters.search,
'sort': filters.sort
}) }}">
{{ pagination.total }}
</a>
</li>
{% endif %}
{% if pagination.current < pagination.total %}
<li class="page-item">
<a class="page-link"
href="{{ path_for('admin.actors.index', {}, {
'page': pagination.current + 1,
'search': filters.search,
'sort': filters.sort
}) }}"
aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
{% endif %}
</ul>
</nav>
{% endif %}
{% endif %}
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
function mergeSelected(groupName) {
const checkboxes = document.querySelectorAll(`.duplicate-checkbox[data-group="${groupName}"]:checked`);
const selectedIds = Array.from(checkboxes).map(cb => parseInt(cb.value));
if (selectedIds.length < 2) {
alert('Please select at least 2 actors to merge.');
return;
}
if (!confirm(`Are you sure you want to merge ${selectedIds.length} actors? The first selected actor will be kept as the master.`)) {
return;
}
// Use the first selected as master
const masterId = selectedIds[0];
const duplicates = selectedIds.slice(1);
fetch('{{ path_for("admin.actors.merge") }}', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
master_actor_id: masterId,
duplicate_actor_ids: duplicates
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
alert(data.message);
location.reload();
} else {
alert('Error: ' + data.message);
}
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred while merging actors.');
});
}
function autoMergeGroup(groupName) {
if (!confirm(`Are you sure you want to auto-merge all actors in the "${groupName}" group? This will automatically choose the best master actor.`)) {
return;
}
fetch('{{ path_for("admin.actors.auto_merge") }}', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
actor_group_ids: [groupName]
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
alert(data.message);
location.reload();
} else {
alert('Error: ' + data.message);
}
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred while auto-merging actors.');
});
}
function autoMergeAll() {
const groups = Array.from(document.querySelectorAll('.duplicate-checkbox')).reduce((acc, cb) => {
const group = cb.getAttribute('data-group');
if (!acc.includes(group)) {
acc.push(group);
}
return acc;
}, []);
if (groups.length === 0) {
alert('No duplicate groups found.');
return;
}
if (!confirm(`Are you sure you want to auto-merge all ${groups.length} duplicate groups? This action cannot be undone.`)) {
return;
}
fetch('{{ path_for("admin.actors.auto_merge") }}', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
actor_group_ids: groups
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
alert(data.message);
location.reload();
} else {
alert('Error: ' + data.message);
}
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred while auto-merging actors.');
});
}
</script>
{% endblock %}

View File

@@ -232,6 +232,12 @@
<span>TV Shows</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ path_for('admin.actors') }}">
<i class="bi bi-people"></i>
<span>Actors</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ path_for('admin.music') }}">
<i class="bi bi-music-note-list"></i>

View File

@@ -190,12 +190,18 @@
<!-- Page Content -->
<main class="flex min-h-screen">
<!-- Left Sidebar -->
<aside class="w-64 bg-slate-800 text-white shadow-lg hidden lg:block" x-data="{ collapsed: false }">
<aside class="bg-slate-800 text-white shadow-lg hidden lg:block transition-all duration-300 ease-in-out" :class="collapsed ? 'w-16' : 'w-64'" x-data="{
collapsed: JSON.parse(localStorage.getItem('leftSidebarCollapsed') || 'false'),
toggle() {
this.collapsed = !this.collapsed;
localStorage.setItem('leftSidebarCollapsed', JSON.stringify(this.collapsed));
}
}">
<div class="flex flex-col h-full">
<!-- Sidebar Header -->
<div class="flex items-center justify-between p-4 border-b border-slate-700">
<div class="flex items-center justify-between p-4 border-b border-slate-700" :class="collapsed ? 'px-3' : 'p-4'">
<h2 class="text-lg font-semibold" x-show="!collapsed">Library</h2>
<button @click="collapsed = !collapsed" class="p-1 rounded-md hover:bg-slate-700">
<button @click="toggle()" class="p-1 rounded-md hover:bg-slate-700">
<svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path x-show="!collapsed" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
<path x-show="collapsed" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
@@ -267,7 +273,7 @@
{% endif %}
</nav>
<!-- Collapsed State Icon -->
<!-- Collapsed State Icons -->
<div class="px-2 py-4" x-show="collapsed">
<div class="space-y-2">
<a href="{{ path_for('dashboard.index') }}" class="flex justify-center p-2 text-slate-300 hover:bg-slate-700 hover:text-white rounded-md" title="Dashboard">
@@ -290,6 +296,39 @@
</svg>
</a>
{% endif %}
{% if is_media_type_visible('tvshows') %}
<a href="{{ path_for('tvshows.index') }}" class="flex justify-center p-2 text-slate-300 hover:bg-slate-700 hover:text-white rounded-md" title="TV Shows">
<svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
</svg>
</a>
{% endif %}
{% if is_media_type_visible('music') %}
<a href="{{ path_for('music.index') }}" class="flex justify-center p-2 text-slate-300 hover:bg-slate-700 hover:text-white rounded-md" title="Music">
<svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19V6l12-3v13M9 19c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zm12-3c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zM9 10l12-3" />
</svg>
</a>
{% endif %}
{% if is_media_type_visible('adult') %}
<div class="space-y-1">
<div class="flex justify-center p-2 text-slate-300">
<svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" />
</svg>
</div>
<a href="{{ path_for('adult.index') }}" class="flex justify-center p-2 text-slate-400 hover:bg-slate-700 hover:text-white rounded-md" title="Adult Videos">
<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="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>
</a>
<a href="{{ path_for('actors.index') }}" class="flex justify-center p-2 text-slate-400 hover:bg-slate-700 hover:text-white rounded-md" title="Performers">
<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="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
</svg>
</a>
</div>
{% endif %}
</div>
</div>
</div>
@@ -331,12 +370,18 @@
</div>
<!-- Right Sidebar -->
<aside class="w-80 bg-white shadow-lg border-l border-gray-200 hidden xl:block" x-data="{ collapsed: false }">
<aside class="bg-white shadow-lg border-l border-gray-200 hidden xl:block transition-all duration-300 ease-in-out" :class="collapsed ? 'w-12' : 'w-80'" x-data="{
collapsed: JSON.parse(localStorage.getItem('rightSidebarCollapsed') || 'false'),
toggle() {
this.collapsed = !this.collapsed;
localStorage.setItem('rightSidebarCollapsed', JSON.stringify(this.collapsed));
}
}">
<div class="flex flex-col h-full">
<!-- Sidebar Header -->
<div class="flex items-center justify-between p-4 border-b border-gray-200">
<div class="flex items-center justify-between p-4 border-b border-gray-200" :class="collapsed ? 'px-3' : 'p-4'">
<h2 class="text-lg font-semibold text-gray-900" x-show="!collapsed">Details</h2>
<button @click="collapsed = !collapsed" class="p-1 rounded-md hover:bg-gray-100">
<button @click="toggle()" class="p-1 rounded-md hover:bg-gray-100">
<svg class="h-5 w-5 text-gray-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path x-show="!collapsed" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
<path x-show="collapsed" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />

View File

@@ -1,110 +1,294 @@
{% extends "layouts/app.twig" %}
{% block content %}
<div class="px-4 py-3">
<div class="mb-4">
<h1 class="display-4 fw-bold text-dark">Search</h1>
<div class="min-h-screen bg-gray-50">
<!-- Header Section -->
<div class="bg-white shadow-sm border-b border-gray-200">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
<div class="flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold text-gray-900">Search</h1>
{% if search %}
<p class="mt-1 text-lg text-gray-600">Results for "{{ search }}"</p>
{% else %}
<p class="mt-1 text-lg text-gray-600">Discover your media collection</p>
{% endif %}
</div>
{% if search and totalResults > 0 %}
<div class="text-right">
<p class="text-sm text-gray-500">{{ totalResults }} results found</p>
<p class="text-xs text-gray-400">Page {{ page }} of {{ totalPages }}</p>
</div>
{% endif %}
</div>
</div>
</div>
<!-- Search and Filters -->
<div class="bg-white shadow-sm border-b border-gray-200">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4">
<form method="GET" class="space-y-4" x-data="{ showAdvanced: false }">
<!-- Main Search Bar -->
<div class="flex gap-4">
<div class="flex-1 relative">
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<svg class="h-5 w-5 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
</svg>
</div>
<input
type="text"
name="q"
value="{{ search }}"
placeholder="Search movies, games, TV shows, music, and more..."
class="block w-full pl-10 pr-3 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-gray-900 placeholder-gray-500"
autofocus
>
</div>
<button type="submit" class="px-6 py-3 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors">
Search
</button>
<button type="button" @click="showAdvanced = !showAdvanced" class="px-4 py-3 border border-gray-300 text-gray-700 font-medium rounded-lg hover:bg-gray-50 focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors">
<svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 100 4m0-4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 100 4m0-4v2m0-6V4"/>
</svg>
</button>
</div>
<!-- Advanced Filters -->
<div x-show="showAdvanced" x-transition class="border-t border-gray-200 pt-4 space-y-4">
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<!-- Media Type Filter -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Media Type</label>
<select name="type" class="block w-full border border-gray-300 rounded-md px-3 py-2 focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
<option value="all" {{ type == 'all' ? 'selected' : '' }}>All Types</option>
<option value="movies" {{ type == 'movies' ? 'selected' : '' }}>Movies</option>
<option value="games" {{ type == 'games' ? 'selected' : '' }}>Games</option>
<option value="tvshows" {{ type == 'tvshows' ? 'selected' : '' }}>TV Shows</option>
<option value="music" {{ type == 'music' ? 'selected' : '' }}>Music</option>
<option value="adult" {{ type == 'adult' ? 'selected' : '' }}>Adult Videos</option>
<option value="actors" {{ type == 'actors' ? 'selected' : '' }}>Performers</option>
</select>
</div>
<!-- Sort Options -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Sort By</label>
<select name="sort" class="block w-full border border-gray-300 rounded-md px-3 py-2 focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
<option value="relevance" {{ sort == 'relevance' ? 'selected' : '' }}>Relevance</option>
<option value="title" {{ sort == 'title' ? 'selected' : '' }}>Title (A-Z)</option>
<option value="date" {{ sort == 'date' ? 'selected' : '' }}>Date Added</option>
<option value="rating" {{ sort == 'rating' ? 'selected' : '' }}>Rating</option>
</select>
</div>
<!-- Clear Filters -->
<div class="flex items-end">
<a href="{{ path_for('search.index') }}" class="w-full px-4 py-2 text-center border border-gray-300 text-gray-700 font-medium rounded-md hover:bg-gray-50 focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors">
Clear Filters
</a>
</div>
</div>
</div>
</form>
</div>
</div>
<!-- Results Section -->
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
{% if search %}
<p class="lead text-muted">Search results for "{{ search }}"</p>
{% if hasResults %}
<!-- Results Grid -->
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 xl:grid-cols-6 gap-6">
{% for mediaType, items in results %}
{% for item in items %}
<div class="group relative bg-white rounded-lg shadow-sm hover:shadow-lg transition-shadow duration-200 overflow-hidden">
<!-- Media Poster/Image -->
<div class="aspect-[2/3] bg-gray-200 relative overflow-hidden">
{% if item.poster_url %}
<img src="/images/{{ item.poster_url }}" alt="{{ item.title or item.name }}" class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-200">
{% elseif item.cover_image %}
<img src="/images/playnite/{{ item.cover_image }}" alt="{{ item.title or item.name }}" class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-200">
{% elseif item.image_url %}
<img src="/images/playnite/{{ item.image_url }}" alt="{{ item.title or item.name }}" class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-200">
{% elseif item.thumbnail %}
<img src="{{ item.thumbnail }}" alt="{{ item.title or item.name }}" class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-200">
{% else %}
<div class="w-full h-full bg-gradient-to-br from-gray-300 to-gray-400 flex items-center justify-center">
<svg class="h-12 w-12 text-gray-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
{% if item.type == 'movie' or item.type == 'tvshow' or item.type == 'adult' %}
<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"/>
{% elseif item.type == 'game' %}
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>
{% elseif item.type == 'music' %}
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19V6l12-3v13M9 19c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zm12-3c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zM9 10l12-3"/>
{% elseif item.type == 'actor' %}
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>
{% endif %}
</svg>
</div>
{% endif %}
<!-- Media Type Badge -->
<div class="absolute top-2 left-2">
<span class="inline-flex items-center px-2 py-1 rounded-full text-xs font-medium
{% if item.type == 'movie' %}bg-blue-100 text-blue-800
{% elseif item.type == 'game' %}bg-green-100 text-green-800
{% elseif item.type == 'tvshow' %}bg-purple-100 text-purple-800
{% elseif item.type == 'music' %}bg-yellow-100 text-yellow-800
{% elseif item.type == 'adult' %}bg-red-100 text-red-800
{% elseif item.type == 'actor' %}bg-pink-100 text-pink-800
{% endif %}">
{% if item.type == 'movie' %}Movie
{% elseif item.type == 'game' %}Game
{% elseif item.type == 'tvshow' %}TV Show
{% elseif item.type == 'music' %}Music
{% elseif item.type == 'adult' %}Adult
{% elseif item.type == 'actor' %}Actor
{% endif %}
</span>
</div>
<!-- Hover Overlay -->
<div class="absolute inset-0 opacity-0 bg-black group-hover:opacity-50 transition-all duration-200 flex items-center justify-center">
<a href="
{% if item.type == 'movie' %}{{ path_for('movies.show', {'id': item.id}) }}
{% elseif item.type == 'game' %}{{ path_for('games.show', {'game_key': item.game_key}) }}
{% elseif item.type == 'tvshow' %}{{ path_for('tvshows.show', {'id': item.id}) }}
{% elseif item.type == 'music' %}{{ path_for('music.show', {'id': item.id}) }}
{% elseif item.type == 'adult' %}{{ path_for('adult.show', {'id': item.id}) }}
{% elseif item.type == 'actor' %}{{ path_for('actors.show', {'id': item.id}) }}
{% endif %}"
class="opacity-0 group-hover:opacity-100 bg-white text-gray-900 px-4 py-2 rounded-lg font-medium text-sm transition-all duration-200 hover:bg-gray-100">
View Details
</a>
</div>
</div>
<!-- Content -->
<div class="p-4">
<h3 class="font-medium text-gray-900 text-sm leading-tight line-clamp-2 mb-1">
<a href="
{% if item.type == 'movie' %}{{ path_for('movies.show', {'id': item.id}) }}
{% elseif item.type == 'game' %}{{ path_for('games.show', {'game_key': item.game_key}) }}
{% elseif item.type == 'tvshow' %}{{ path_for('tvshows.show', {'id': item.id}) }}
{% elseif item.type == 'music' %}{{ path_for('music.show', {'id': item.id}) }}
{% elseif item.type == 'adult' %}{{ path_for('adult.show', {'id': item.id}) }}
{% elseif item.type == 'actor' %}{{ path_for('actors.show', {'id': item.id}) }}
{% endif %}"
class="hover:text-blue-600 transition-colors">
{{ item.title }}
</a>
</h3>
{% if item.source_name %}
<p class="text-xs text-gray-500 mb-2">{{ item.source_name }}</p>
{% endif %}
{% if item.artist %}
<p class="text-xs text-gray-600 mb-2">{{ item.artist }}</p>
{% endif %}
{% if item.release_date %}
<p class="text-xs text-gray-500">{{ item.release_date|date('Y') }}</p>
{% endif %}
{% if item.added_date %}
<p class="text-xs text-gray-400">Added {{ item.added_date|date('M j, Y') }}</p>
{% endif %}
</div>
</div>
{% endfor %}
{% endfor %}
</div>
<!-- Pagination -->
{% if totalPages > 1 %}
<div class="mt-12 flex items-center justify-between">
<div class="text-sm text-gray-700">
Showing page {{ page }} of {{ totalPages }}
</div>
<div class="flex items-center space-x-2">
{% if page > 1 %}
<a href="?q={{ search|url_encode }}&type={{ type }}&sort={{ sort }}&page={{ page - 1 }}" class="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-md hover:bg-gray-50">
Previous
</a>
{% endif %}
{% set startPage = max(1, page - 2) %}
{% set endPage = min(totalPages, page + 2) %}
{% if startPage > 1 %}
<a href="?q={{ search|url_encode }}&type={{ type }}&sort={{ sort }}&page=1" class="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-md hover:bg-gray-50">1</a>
{% if startPage > 2 %}
<span class="px-2 py-2 text-sm text-gray-400">...</span>
{% endif %}
{% endif %}
{% for i in startPage..endPage %}
<a href="?q={{ search|url_encode }}&type={{ type }}&sort={{ sort }}&page={{ i }}" class="px-3 py-2 text-sm font-medium {{ i == page ? 'text-blue-600 bg-blue-50 border-blue-500' : 'text-gray-500 bg-white border-gray-300' }} border rounded-md hover:bg-gray-50">
{{ i }}
</a>
{% endfor %}
{% if endPage < totalPages %}
{% if endPage < totalPages - 1 %}
<span class="px-2 py-2 text-sm text-gray-400">...</span>
{% endif %}
<a href="?q={{ search|url_encode }}&type={{ type }}&sort={{ sort }}&page={{ totalPages }}" class="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-md hover:bg-gray-50">{{ totalPages }}</a>
{% endif %}
{% if page < totalPages %}
<a href="?q={{ search|url_encode }}&type={{ type }}&sort={{ sort }}&page={{ page + 1 }}" class="px-3 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-md hover:bg-gray-50">
Next
</a>
{% endif %}
</div>
</div>
{% endif %}
{% else %}
<!-- No Results -->
<div class="text-center py-16">
<div class="mx-auto w-24 h-24 bg-gray-100 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="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
</svg>
</div>
<h3 class="text-xl font-medium text-gray-900 mb-2">No results found</h3>
<p class="text-gray-500 mb-6">Try adjusting your search terms or filters</p>
<div class="flex justify-center space-x-4">
<a href="{{ path_for('dashboard.index') }}" class="inline-flex items-center px-4 py-2 border border-gray-300 text-gray-700 font-medium rounded-lg hover:bg-gray-50 transition-colors">
Browse Library
</a>
<a href="{{ path_for('search.index') }}" class="inline-flex items-center px-4 py-2 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 transition-colors">
Clear Search
</a>
</div>
</div>
{% endif %}
{% else %}
<p class="lead text-muted">Search across all your media collections</p>
<!-- Empty State -->
<div class="text-center py-16">
<div class="mx-auto w-24 h-24 bg-blue-100 rounded-full flex items-center justify-center mb-6">
<svg class="w-12 h-12 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
</svg>
</div>
<h3 class="text-xl font-medium text-gray-900 mb-2">Search your media collection</h3>
<p class="text-gray-500">Find movies, games, TV shows, music, and more</p>
</div>
{% endif %}
</div>
<!-- Search Form -->
<form method="GET" class="mb-4">
<div class="input-group">
<input
type="text"
name="q"
value="{{ search }}"
placeholder="Search movies, games, and more..."
class="form-control form-control-lg"
autofocus
>
<button type="submit" class="btn btn-primary">
<svg class="me-2" width="20" height="20" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
</svg>
Search
</button>
</div>
</form>
{% if search and results %}
<!-- Search Results -->
{% if results.movies %}
<div class="mb-4">
<h2 class="h5 fw-semibold text-dark mb-3">Movies ({{ results.movies|length }})</h2>
<div class="row g-3">
{% for movie in results.movies %}
<div class="col-12 col-sm-6 col-md-4 col-lg-1">
<div class="card h-100">
{% if movie.poster_url %}
<div style="aspect-ratio: 2/3; background-color: #f8f9fa; border-radius: 0.375rem 0.375rem 0 0; overflow: hidden;">
<img src="/images/{{ movie.poster_url }}" alt="{{ movie.title }}" class="w-100 h-100" style="object-fit: cover;">
</div>
{% endif %}
<div class="card-body">
<h6 class="card-title text-truncate">
<a href="/media/movies/{{ movie.id }}" class="text-decoration-none">
{{ movie.title }}
</a>
</h6>
<p class="card-text small text-muted">{{ movie.source_name }}</p>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
{% if results.games %}
<div class="mb-4">
<h2 class="h5 fw-semibold text-dark mb-3">Games ({{ results.games|length }})</h2>
<div class="row g-3">
{% for game in results.games %}
<div class="col-12 col-sm-6 col-md-4 col-lg-1">
<div class="card h-100">
{% if game.cover_image %}
<div style="aspect-ratio: 2/3; background-color: #f8f9fa; border-radius: 0.375rem 0.375rem 0 0; overflow: hidden;">
<img src="{{ game.cover_image }}" alt="{{ game.name }}" class="w-100 h-100" style="object-fit: cover;">
</div>
{% endif %}
<div class="card-body">
<h6 class="card-title text-truncate">
<a href="/media/games/{{ game.game_key }}" class="text-decoration-none">
{{ game.title }}
</a>
</h6>
<p class="card-text small text-muted">{{ game.source_name }}</p>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
{% if not results.movies and not results.games %}
<div class="text-center py-5">
<svg class="mx-auto text-muted mb-3" width="48" height="48" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
</svg>
<h3 class="h5 fw-medium text-dark">No results found</h3>
<p class="text-muted">Try adjusting your search terms or browse categories directly.</p>
</div>
{% endif %}
{% elseif search %}
<div class="text-center py-5">
<svg class="mx-auto text-muted mb-3" width="48" height="48" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
</svg>
<h3 class="h5 fw-medium text-dark">No results found</h3>
<p class="text-muted">Try adjusting your search terms or browse categories directly.</p>
</div>
{% endif %}
</div>
<style>
.line-clamp-2 {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
</style>
{% endblock %}