374 lines
12 KiB
PHP

@extends('layouts.app')
@section('title', isset($query) ? 'Search: ' . $query . ' | ' . config('app.name') : 'Video Gallery | ' . config('app.name'))
@section('extra_styles')
<style>
/* Search info */
.search-info {
margin-bottom: 20px;
padding: 16px;
background: var(--bg-secondary);
border-radius: 12px;
}
.search-info h2 {
font-size: 20px;
margin: 0;
}
.search-info p {
color: var(--text-secondary);
margin: 8px 0 0;
}
/* Video Grid */
.yt-video-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 24px;
}
.yt-video-card {
cursor: pointer;
}
.yt-video-thumb {
position: relative;
aspect-ratio: 16/9;
border-radius: 12px;
overflow: hidden;
background: #1a1a1a;
}
.yt-video-thumb img {
width: 100%;
height: 100%;
object-fit: cover;
position: absolute;
top: 0;
left: 0;
}
.yt-video-thumb video {
width: 100%;
height: 100%;
object-fit: contain;
position: absolute;
top: 0;
left: 0;
opacity: 0;
transition: opacity 0.3s ease;
background: #000;
}
.yt-video-thumb video.active {
opacity: 1;
}
.yt-video-duration {
position: absolute;
bottom: 8px;
right: 8px;
background: rgba(0,0,0,0.8);
color: white;
padding: 3px 6px;
border-radius: 4px;
font-size: 12px;
font-weight: 500;
}
.yt-video-info {
display: flex;
margin-top: 12px;
gap: 12px;
}
.yt-channel-icon {
width: 36px;
height: 36px;
border-radius: 50%;
background: #555;
flex-shrink: 0;
}
.yt-video-details {
flex: 1;
}
.yt-video-title {
font-size: 16px;
font-weight: 500;
color: var(--text-primary);
margin: 0 0 4px;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
line-height: 1.3;
}
.yt-video-title a {
color: inherit;
text-decoration: none;
}
.yt-channel-name, .yt-video-meta {
color: var(--text-secondary);
font-size: 14px;
}
/* More button */
.yt-more-btn {
background: transparent;
border: none;
color: var(--text-primary);
cursor: pointer;
padding: 4px;
border-radius: 50%;
}
.yt-more-dropdown {
background: var(--bg-secondary);
border: 1px solid var(--border-color);
border-radius: 12px;
padding: 8px 0;
min-width: 200px;
}
.yt-more-dropdown-item {
display: flex;
align-items: center;
gap: 16px;
padding: 10px 16px;
color: var(--text-primary);
text-decoration: none;
cursor: pointer;
background: transparent;
border: none;
width: 100%;
text-align: left;
font-size: 14px;
}
.yt-more-dropdown-item:hover { background: var(--border-color); }
/* Empty State */
.yt-empty {
text-align: center;
padding: 80px 20px;
}
.yt-empty-icon {
font-size: 80px;
color: var(--text-secondary);
}
.yt-empty-title {
font-size: 24px;
margin: 20px 0 8px;
}
.yt-empty-text {
color: var(--text-secondary);
margin-bottom: 20px;
}
/* Responsive */
@media (max-width: 1200px) {
.yt-video-grid {
grid-template-columns: repeat(3, 1fr);
gap: 20px;
}
}
@media (max-width: 992px) {
.yt-video-grid {
grid-template-columns: repeat(2, 1fr);
}
}
@media (max-width: 576px) {
.yt-video-grid {
grid-template-columns: 1fr;
}
.yt-header-right .yt-icon-btn:not(:last-child) { display: none; }
}
</style>
@endsection
@section('content')
@isset($query)
<div class="search-info">
<h2>Search results for "{{ $query }}"</h2>
<p>{{ $videos->total() }} videos found</p>
</div>
@endif
@if($videos->isEmpty())
<div class="yt-empty">
<i class="bi bi-camera-video yt-empty-icon"></i>
@isset($query)
<h2 class="yt-empty-title">No results found</h2>
<p class="yt-empty-text">Try different keywords or browse all videos.</p>
@else
<h2 class="yt-empty-title">No videos yet</h2>
<p class="yt-empty-text">Be the first to upload a video!</p>
@endisset
@auth
<a href="/videos/create" class="yt-upload-btn" style="display: inline-flex;">
<i class="bi bi-plus-lg"></i>
Upload Video
</a>
@else
<a href="{{ route('login') }}" class="yt-upload-btn" style="display: inline-flex;">
<i class="bi bi-box-arrow-in-right"></i>
Login to Upload
</a>
@endauth
</div>
@else
<div class="yt-video-grid">
@foreach($videos as $video)
<div class="yt-video-card"
data-video-url="{{ asset('storage/videos/' . $video->filename) }}"
onmouseenter="playVideo(this)"
onmouseleave="stopVideo(this)">
<a href="{{ route('videos.show', $video->id) }}">
<div class="yt-video-thumb">
@if($video->thumbnail)
<img src="{{ asset('storage/thumbnails/' . $video->thumbnail) }}" alt="{{ $video->title }}">
@else
<img src="https://picsum.photos/seed/{{ $video->id }}/640/360" alt="{{ $video->title }}">
@endif
<video preload="none">
<source src="{{ asset('storage/videos/' . $video->filename) }}" type="{{ $video->mime_type ?? 'video/mp4' }}">
</video>
@if($video->duration)
<span class="yt-video-duration">{{ gmdate('i:s', $video->duration) }}</span>
@endif
</div>
</a>
<div class="yt-video-info">
<div class="yt-channel-icon">
@if($video->user && $video->user->avatar_url)
<img src="{{ $video->user->avatar_url }}" alt="{{ $video->user->name }}" style="width: 100%; height: 100%; object-fit: cover; border-radius: 50%;">
@endif
</div>
<div class="yt-video-details">
<h3 class="yt-video-title">
<a href="{{ route('videos.show', $video->id) }}">{{ $video->title }}</a>
</h3>
<div class="yt-channel-name">{{ $video->user->name ?? 'Unknown' }}</div>
<div class="yt-video-meta">
{{ number_format($video->size / 1024 / 1024, 0) }} MB {{ $video->created_at->diffForHumans() }}
</div>
</div>
<div class="position-relative">
<button class="yt-more-btn" data-bs-toggle="dropdown">
<i class="bi bi-three-dots-vertical"></i>
</button>
<ul class="dropdown-menu dropdown-menu-dark yt-more-dropdown dropdown-menu-end">
<li>
<button class="yt-more-dropdown-item" onclick="addToQueue('{{ $video->id }}')">
<i class="bi bi-list-nested"></i> Add to queue
</button>
</li>
<li>
<button class="yt-more-dropdown-item" onclick="saveToWatchLater('{{ $video->id }}')">
<i class="bi bi-clock"></i> Save to Watch later
</button>
</li>
<li>
<button class="yt-more-dropdown-item" onclick="openPlaylistModal('{{ $video->id }}')">
<i class="bi bi-bookmark"></i> Save to playlist
</button>
</li>
<li>
<a class="yt-more-dropdown-item" href="{{ route('videos.download', $video->id) }}">
<i class="bi bi-download"></i> Download
</a>
</li>
@if($video->isShareable())
<li>
<button class="yt-more-dropdown-item" onclick="openShareModal('{{ $video->share_url }}', '{{ addslashes($video->title) }}')">
<i class="bi bi-share"></i> Share
</button>
</li>
@endif
<li><hr class="dropdown-divider"></li>
<li>
<button class="yt-more-dropdown-item" onclick="notInterested('{{ $video->id }}')">
<i class="bi bi-dash-circle"></i> Not interested
</button>
</li>
<li>
<button class="yt-more-dropdown-item" onclick="dontRecommendChannel('{{ $video->user_id }}')">
<i class="bi bi-x-circle"></i> Don't recommend channel
</button>
</li>
<li>
<button class="yt-more-dropdown-item" onclick="reportVideo('{{ $video->id }}')">
<i class="bi bi-flag"></i> Report
</button>
</li>
</ul>
</div>
</div>
</div>
@endforeach
</div>
<div class="mt-4">{{ $videos->links() }}</div>
@endif
@include('layouts.partials.share-modal')
@endsection
@section('scripts')
<script>
function playVideo(card) {
const video = card.querySelector('video');
if (video) {
video.currentTime = 0;
video.volume = 0.10; // Set volume to 10%
video.play().catch(function(e) {
// Auto-play may be blocked, ignore error
});
video.classList.add('active');
}
}
function stopVideo(card) {
const video = card.querySelector('video');
if (video) {
video.pause();
video.currentTime = 0;
video.classList.remove('active');
}
}
// Mobile touch support for hover-like behavior
document.addEventListener('touchstart', function(e) {
const card = e.target.closest('.yt-video-card');
if (card) {
// Stop any other playing videos first
document.querySelectorAll('.yt-video-card').forEach(function(otherCard) {
if (otherCard !== card) {
stopVideo(otherCard);
}
});
playVideo(card);
}
}, { passive: true });
document.addEventListener('touchend', function(e) {
const card = e.target.closest('.yt-video-card');
if (card) {
stopVideo(card);
}
}, { passive: true });
</script>
@endsection