Audit fixes against /channel/{slug}:
1. Fluid video grid — repeat(auto-fill, minmax(260px, 1fr)) replaces
the three fixed breakpoints (3/2/4 cols at 1101/1500/… px) that
produced different card widths and could overflow 390 / 1280 /
1920. min-width:0 on every grid child so a long unbroken title
(CJK, "SPARTAWORRIOR") can't widen its track past 1fr.
2. Scoreboard thumbnail — stop including vs-mini + scorebar-mini on
match cards. Those partials leaked fighter names, "AKA/AO",
"ROUND 1", "0:00" into the card DOM, showing stale 0-0 for
finished matches and breaking title layout at narrow widths. The
regular <img> above is the thumbnail now; VS intro + live scorebar
still render on the full match player page where they belong.
3. Sort pills — Latest/Popular/Oldest now append #videos so the page
stays on the Videos tab after reload instead of jumping to Wall.
4. Shorts tab — always render for the owner (so the "My Shorts"
sidebar link always lands somewhere), with an empty-state card
when no shorts exist. Visitors still see it only when shorts > 0.
5. Subscriptions sidebar link — href="#" replaced by a real
/feed/subscriptions route backed by UserController@subscriptionsFeed
that reuses the videos/index view with the subscription feed.
6. Header view count — totalViews now sums video_views over public
videos for visitors (owner still sees the full total). Previously
leaked unlisted and private video view counts.
7. Card redundancy — new hideChannelInfo prop on <x-video-card/>
suppresses the per-card avatar + channel-name row. The channel
page passes it; everywhere else keeps the row.
9. Decorative logo — the second <img alt="Play"> in the responsive
header pair now has alt="" so a screen reader doesn't announce
"Play Play". ⋮ menu button gets aria-label="More actions".
10. Privacy — age, gender, location and horoscope strip now only
render to the owner on the channel header (horoscope strip is
also allowed when the compatibility match-up is being shown to
a signed-in visitor). Joined-month stays public.
11. Notifications dropdown — initial state is "No notifications"
not an indefinite "Loading…". Opening the panel now shows a
spinner while fetching, surfaces a Retry button on error, and
bails out of the "Loading…" state on non-ok HTTP responses.
Title clamp — .yt-video-title is now a 2-line box with
overflow-wrap:anywhere so CJK titles and long words wrap mid-word
and can't widen the card past its track.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
323 lines
15 KiB
PHP
323 lines
15 KiB
PHP
@props(['video' => null, 'size' => 'medium', 'hideChannelInfo' => false])
|
||
|
||
@php
|
||
use App\Data\Languages;
|
||
|
||
// When a specific audio track is being surfaced (e.g. via the language
|
||
// filter chips), the hover-preview should play that language, not the
|
||
// primary. audio-track route serves the track file directly.
|
||
$forceTrackIdEarly = $video ? $video->getAttribute('_force_track_id') : null;
|
||
$videoUrl = $video
|
||
? ($forceTrackIdEarly
|
||
? route('videos.audio-track', ['video' => $video, 'track' => $forceTrackIdEarly])
|
||
: route('videos.stream', $video))
|
||
: null;
|
||
$thumbnailUrl = $video && $video->thumbnail
|
||
? route('media.thumbnail', $video->thumbnail)
|
||
: ($video ? 'https://picsum.photos/seed/' . $video->id . '/640/360' : 'https://picsum.photos/seed/random/640/360');
|
||
|
||
$typeIcon = $video ? match($video->type) {
|
||
'music' => 'bi-music-note',
|
||
'match' => 'bi-trophy',
|
||
default => 'bi-film',
|
||
} : 'bi-film';
|
||
|
||
// Check if video is shorts
|
||
$isShorts = $video && $video->isShorts();
|
||
|
||
// Check if current user is the owner of the video
|
||
$isOwner = $video && auth()->check() && auth()->id() == $video->user_id;
|
||
|
||
// When surfacing a video via a secondary audio track (e.g. from the
|
||
// language filter chips) the controller tags it with these runtime
|
||
// attributes so the card links straight to that track and badges the
|
||
// thumbnail with its flag.
|
||
$forceTrackId = $video ? $video->getAttribute('_force_track_id') : null;
|
||
$forceTrackFlag = $video ? $video->getAttribute('_force_track_flag') : null;
|
||
|
||
// Language flag code (null when no language set). Prefer the forced
|
||
// track flag when set — it's the language the card is being surfaced for.
|
||
$langFlag = $forceTrackFlag ?: ($video ? Languages::flag($video->language) : null);
|
||
|
||
$showUrl = $video ? route('videos.show', $video) . ($forceTrackId ? ('?track=' . $forceTrackId) : '') : '#';
|
||
|
||
// Composed display title for match videos — matches the header on the
|
||
// match page: "{match title} – {blue flag+name} vs {red flag+name}
|
||
// ({weight})", with blue/red corner colours and inline flags. Falls
|
||
// back to plain $video->title for non-match cards.
|
||
$displayTitle = $video?->title;
|
||
$displayTitleHtml = null;
|
||
if ($video && $video->type === 'match' && $video->sportsMatch) {
|
||
$hdCard = $video->sportsMatch->headerData();
|
||
$blueN = $hdCard['blue']['name'] ?? null;
|
||
$redN = $hdCard['red']['name'] ?? null;
|
||
$blueF = $hdCard['blue']['flag'] ?? null;
|
||
$redF = $hdCard['red']['flag'] ?? null;
|
||
if ($blueN || $redN) {
|
||
$flagStyle = 'width:16px;height:12px;border-radius:2px;display:inline-block;vertical-align:middle;margin-right:4px;';
|
||
$mkSide = function ($name, $flag, $color) use ($flagStyle) {
|
||
if (!$name) return '';
|
||
$flagHtml = $flag ? '<span class="fi fi-'.e($flag).'" style="'.$flagStyle.'"></span>' : '';
|
||
return '<span style="color:'.$color.';font-weight:600;">'.$flagHtml.e($name).'</span>';
|
||
};
|
||
$blueHtml = $mkSide($blueN, $blueF, '#2563eb');
|
||
$redHtml = $mkSide($redN, $redF, '#ef4444');
|
||
|
||
$parts = [];
|
||
if (!empty($video->title)) $parts[] = e(strtoupper($video->title)) . ' –';
|
||
if ($blueHtml && $redHtml) $parts[] = $blueHtml . ' <span>vs</span> ' . $redHtml;
|
||
elseif ($blueHtml) $parts[] = $blueHtml;
|
||
elseif ($redHtml) $parts[] = $redHtml;
|
||
if (!empty($hdCard['weight_category'])) $parts[] = '(' . e($hdCard['weight_category']) . ')';
|
||
$displayTitleHtml = implode(' ', $parts);
|
||
}
|
||
}
|
||
|
||
// Size classes
|
||
$sizeClasses = match($size) {
|
||
'small' => 'yt-video-card-sm',
|
||
default => '',
|
||
};
|
||
|
||
@endphp
|
||
|
||
<div class="yt-video-card {{ $sizeClasses }}" data-video-url="{{ $videoUrl }}">
|
||
<a href="{{ $showUrl }}">
|
||
<div class="yt-video-thumb" onmouseenter="playVideo(this)" onmouseleave="stopVideo(this)"
|
||
data-audio="{{ $video && $video->isAudioOnly() ? 'true' : 'false' }}">
|
||
{{-- width/height let the browser reserve the card's thumb box
|
||
BEFORE the image decodes, so a grid of 60 cards doesn't shift
|
||
as each thumbnail finishes loading. The ratio is honored by
|
||
.yt-video-thumb's aspect-ratio: 16/9 regardless of actual px. --}}
|
||
<img src="{{ $thumbnailUrl }}" alt="{{ $video->title ?? 'Video' }}"
|
||
width="320" height="180"
|
||
loading="lazy" decoding="async"
|
||
onload="this.classList.add('loaded');this.closest('.yt-video-thumb').classList.add('loaded')">
|
||
@if($videoUrl)
|
||
{{-- Match cards preload metadata so the first frame is ready the
|
||
instant the user hovers (otherwise the browser fetches, buffers
|
||
then paints — showing a black frame behind the fade). Other
|
||
card types keep preload="none" to save bandwidth. --}}
|
||
<video preload="{{ $video && $video->type === 'match' ? 'metadata' : 'none' }}" playsinline>
|
||
<source src="{{ $videoUrl }}" type="{{ $video->mime_type ?? 'video/mp4' }}">
|
||
</video>
|
||
@endif
|
||
{{-- Match cards used to inline the full VS portrait + the live-scoring
|
||
scorebar as thumbnail overlays. Those partials leaked fighter
|
||
names, "AKA / AO", "ROUND 1", "0:00" and club text into the
|
||
card DOM — showing stale 0-0 for finished matches, breaking
|
||
the title layout at narrow widths, and inflating card HTML.
|
||
The regular <img> above is the thumbnail now; the VS intro
|
||
and live scorebar live on the full match player page only. --}}
|
||
{{-- Equalizer overlay shown when audio-only track is previewing --}}
|
||
<div class="audio-preview-overlay">
|
||
<div class="audio-eq">
|
||
<span></span><span></span><span></span><span></span><span></span>
|
||
</div>
|
||
</div>
|
||
@if($video && $video->duration)
|
||
<span class="yt-video-duration">{{ gmdate('i:s', $video->duration) }}</span>
|
||
@endif
|
||
@if($isShorts)
|
||
<span class="yt-shorts-badge">
|
||
<i class="bi bi-collection-play-fill"></i> SHORTS
|
||
</span>
|
||
@endif
|
||
@if($forceTrackId && $forceTrackFlag)
|
||
<span class="yt-track-lang-badge" title="Plays the {{ strtoupper($video->language ?? '') }} track's language variant">
|
||
<span class="fi fi-{{ $forceTrackFlag }}"></span>
|
||
<span>Track</span>
|
||
</span>
|
||
@endif
|
||
@if($isOwner && $video->visibility === 'private')
|
||
<span class="yt-visibility-badge yt-visibility-private">
|
||
<i class="bi bi-lock-fill"></i> Private
|
||
</span>
|
||
@elseif($isOwner && $video->visibility === 'unlisted')
|
||
<span class="yt-visibility-badge yt-visibility-unlisted">
|
||
<i class="bi bi-link-45deg"></i> Unlisted
|
||
</span>
|
||
@endif
|
||
</div>
|
||
</a>
|
||
<div class="yt-video-info {{ $hideChannelInfo ? 'yt-video-info-no-channel' : '' }}">
|
||
@unless($hideChannelInfo)
|
||
<a href="{{ $video && $video->user ? route('channel', $video->user->channel) : '#' }}"
|
||
class="yt-channel-icon" onclick="event.stopPropagation();">
|
||
@if($video && $video->user && $video->user->avatar_url)
|
||
<img src="{{ $video->user->avatar_url }}" alt="{{ $video->user->name }}" loading="lazy" decoding="async" onload="this.classList.add('loaded')" style="width: 100%; height: 100%; object-fit: cover; border-radius: 50%; opacity: 0; transition: opacity 0.25s ease;">
|
||
@endif
|
||
</a>
|
||
@endunless
|
||
<div class="yt-video-details">
|
||
<h3 class="yt-video-title">
|
||
<a href="{{ $showUrl }}">
|
||
@if($langFlag)
|
||
<span class="fi fi-{{ $langFlag }} vc-lang-flag"></span>
|
||
@endif
|
||
@if($displayTitleHtml)
|
||
{!! $displayTitleHtml !!}
|
||
@else
|
||
{{ $displayTitle ?? 'Untitled Video' }}
|
||
@endif
|
||
</a>
|
||
</h3>
|
||
@if($video && $video->user && ! $hideChannelInfo)
|
||
<a href="{{ route('channel', $video->user->channel) }}"
|
||
class="yt-channel-name" onclick="event.stopPropagation();">{{ $video->user->name }}</a>
|
||
@endif
|
||
@if($video)
|
||
<div class="yt-video-meta">
|
||
@if($video->type)
|
||
<span class="yt-type-label yt-type-{{ $video->type }}">
|
||
<i class="bi {{ $typeIcon }}"></i>
|
||
{{ ucfirst($video->type === 'match' ? 'Sports' : ($video->type === 'generic' ? 'Video' : $video->type)) }}
|
||
</span>
|
||
·
|
||
@endif
|
||
{{ number_format($video->view_count) }} views · {{ $video->created_at->diffForHumans() }}
|
||
</div>
|
||
@endif
|
||
</div>
|
||
@if($video)
|
||
<div class="position-relative">
|
||
<button class="yt-more-btn" type="button" data-bs-toggle="dropdown" data-bs-auto-close="true" aria-expanded="false" aria-label="More actions">
|
||
<i class="bi bi-three-dots-vertical" aria-hidden="true"></i>
|
||
</button>
|
||
<ul class="dropdown-menu dropdown-menu-end dropdown-menu-dark">
|
||
@if($isOwner)
|
||
<li>
|
||
<button type="button" class="dropdown-item" onclick="openEditVideoModal('{{ $video->getRouteKey() }}')">
|
||
<i class="bi bi-pencil"></i> Edit
|
||
</button>
|
||
</li>
|
||
<li>
|
||
<button type="button" class="dropdown-item text-danger" onclick="showDeleteModal('{{ $video->getRouteKey() }}', {{ json_encode($video->title) }})">
|
||
<i class="bi bi-trash"></i> Delete
|
||
</button>
|
||
</li>
|
||
<li><hr class="dropdown-divider"></li>
|
||
@endif
|
||
<li>
|
||
<button type="button" class="dropdown-item" onclick="addToQueue('{{ $video->getRouteKey() }}')">
|
||
<i class="bi bi-list-nested"></i> Add to queue
|
||
</button>
|
||
</li>
|
||
<li>
|
||
<button type="button" class="dropdown-item" onclick="saveToWatchLater('{{ $video->getRouteKey() }}')">
|
||
<i class="bi bi-clock"></i> Save to Watch later
|
||
</button>
|
||
</li>
|
||
<li>
|
||
<x-save-to-playlist-button :video="$video" tag="button" class="dropdown-item">
|
||
<i class="bi bi-bookmark"></i> Save to playlist
|
||
</x-save-to-playlist-button>
|
||
</li>
|
||
@if($video->allow_download)
|
||
<li>
|
||
<a class="dropdown-item" href="{{ route('videos.download', $video) }}">
|
||
<i class="bi bi-download"></i> Download
|
||
</a>
|
||
</li>
|
||
@endif
|
||
@if($video->isShareable())
|
||
<li>
|
||
<x-share-button :video="$video" tag="button" class="dropdown-item">
|
||
<i class="bi bi-share"></i> Share
|
||
</x-share-button>
|
||
</li>
|
||
@endif
|
||
{{-- "Not interested", "Don't recommend channel" and "Report"
|
||
only make sense for someone else's video. On your own, the
|
||
Edit/Delete items above are what you want instead. --}}
|
||
@unless($isOwner)
|
||
<li><hr class="dropdown-divider"></li>
|
||
<li>
|
||
<button type="button" class="dropdown-item" onclick="notInterested('{{ $video->getRouteKey() }}')">
|
||
<i class="bi bi-dash-circle"></i> Not interested
|
||
</button>
|
||
</li>
|
||
<li>
|
||
<button type="button" class="dropdown-item" onclick="dontRecommendChannel('{{ $video->user_id }}')">
|
||
<i class="bi bi-x-circle"></i> Don't recommend channel
|
||
</button>
|
||
</li>
|
||
<li>
|
||
<button type="button" class="dropdown-item" onclick="reportVideo('{{ $video->getRouteKey() }}')">
|
||
<i class="bi bi-flag"></i> Report
|
||
</button>
|
||
</li>
|
||
@endunless
|
||
</ul>
|
||
</div>
|
||
@endif
|
||
</div>
|
||
</div>
|
||
|
||
{{--
|
||
The per-card edit modal that used to live here (97 lines of markup, 100+ lines of JS)
|
||
was dead code — the singleton at resources/views/layouts/partials/edit-video-modal.blade.php
|
||
defines a global window.openEditVideoModal that always wins the last-definition race,
|
||
so clicking "Edit" on a card has always been going through the singleton. Removing the
|
||
per-card copy drops ~6000 lines of HTML from a 60-card feed page.
|
||
--}}
|
||
|
||
@include('components.partials.card-styles')
|
||
|
||
@once
|
||
<script>
|
||
// Global function to save to Watch Later
|
||
function saveToWatchLater(videoId) {
|
||
fetch(`/videos/${videoId}/watch-later`, {
|
||
method: 'POST',
|
||
headers: {
|
||
'X-CSRF-TOKEN': '{{ csrf_token() }}',
|
||
'Accept': 'application/json',
|
||
'X-Requested-With': 'XMLHttpRequest'
|
||
}
|
||
})
|
||
.then(response => response.json())
|
||
.then(data => {
|
||
if (data.success) {
|
||
showToast(data.message || 'Added to Watch Later', 'success');
|
||
}
|
||
})
|
||
.catch(error => console.error('Error:', error));
|
||
}
|
||
|
||
// Global function to add to queue
|
||
function addToQueue(videoId) {
|
||
showToast('Queue feature coming soon!', 'info');
|
||
}
|
||
|
||
function playVideo(element) {
|
||
const video = element.querySelector('video');
|
||
if (!video) return;
|
||
video.currentTime = 0;
|
||
const isAudio = element.dataset.audio === 'true';
|
||
video.volume = 0.5;
|
||
if (isAudio) {
|
||
// Keep thumbnail visible — just play audio, show equalizer
|
||
video.play().catch(function() {});
|
||
element.classList.add('audio-playing');
|
||
} else {
|
||
video.play().catch(function() {});
|
||
video.classList.add('active');
|
||
}
|
||
}
|
||
|
||
function stopVideo(element) {
|
||
const video = element.querySelector('video');
|
||
if (!video) return;
|
||
video.pause();
|
||
video.currentTime = 0;
|
||
video.classList.remove('active');
|
||
element.classList.remove('audio-playing');
|
||
}
|
||
|
||
// Edit-modal open/close + its form handlers live in the singleton at
|
||
// layouts/partials/edit-video-modal.blade.php (not here) — see the
|
||
// removed-markup note above the dropdown for why.
|
||
</script>
|
||
@endonce
|