mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Fix pagination, samples and previews
This commit is contained in:
@@ -18,7 +18,7 @@ class CoverController extends Controller
|
||||
public function show(string $type, string $filename)
|
||||
{
|
||||
// Validate cover type
|
||||
$validTypes = ['anime', 'audio', 'audiosample', 'book', 'console', 'games', 'movies', 'music', 'preview', 'sample', 'tvrage', 'video', 'xxx'];
|
||||
$validTypes = ['anime', 'audio', 'audiosample', 'book', 'console', 'games', 'movies', 'music', 'preview', 'sample', 'tvrage', 'video', 'xxx', 'tvshows'];
|
||||
|
||||
if (! in_array($type, $validTypes)) {
|
||||
abort(404);
|
||||
@@ -27,6 +27,18 @@ class CoverController extends Controller
|
||||
// Build the file path
|
||||
$filePath = storage_path("covers/{$type}/{$filename}");
|
||||
|
||||
// For preview and sample images, try with _thumb suffix if original doesn't exist
|
||||
if (! file_exists($filePath) && in_array($type, ['preview', 'sample'])) {
|
||||
// Try with _thumb suffix
|
||||
$pathInfo = pathinfo($filename);
|
||||
$thumbFilename = $pathInfo['filename'].'_thumb.'.($pathInfo['extension'] ?? 'jpg');
|
||||
$thumbPath = storage_path("covers/{$type}/{$thumbFilename}");
|
||||
|
||||
if (file_exists($thumbPath)) {
|
||||
$filePath = $thumbPath;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if file exists
|
||||
if (! file_exists($filePath)) {
|
||||
// Return placeholder image
|
||||
@@ -37,9 +49,19 @@ class CoverController extends Controller
|
||||
abort(404);
|
||||
}
|
||||
|
||||
// Determine content type
|
||||
$extension = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
|
||||
$contentType = match ($extension) {
|
||||
'jpg', 'jpeg' => 'image/jpeg',
|
||||
'png' => 'image/png',
|
||||
'gif' => 'image/gif',
|
||||
'webp' => 'image/webp',
|
||||
default => 'image/jpeg',
|
||||
};
|
||||
|
||||
// Serve the file with proper headers
|
||||
return response()->file($filePath, [
|
||||
'Content-Type' => 'image/jpeg',
|
||||
'Content-Type' => $contentType,
|
||||
'Cache-Control' => 'public, max-age=31536000', // Cache for 1 year
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,8 @@ class DetailsController extends BasePageController
|
||||
ReleaseComment::addComment($data['id'], $data['gid'], $request->input('txtAddComment'), $this->userdata->id, $request->ip());
|
||||
}
|
||||
|
||||
$nfo = ReleaseNfo::getReleaseNfo($data['id']);
|
||||
$nfoData = ReleaseNfo::getReleaseNfo($data['id']);
|
||||
$nfo = $nfoData ? $nfoData->nfo : null;
|
||||
$reVideo = $re->getVideo($data['id']);
|
||||
$reAudio = $re->getAudio($data['id']);
|
||||
$reSubs = $re->getSubs($data['id']);
|
||||
|
||||
@@ -17,7 +17,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Paginator::useBootstrapFive();
|
||||
Paginator::useTailwind();
|
||||
$smarty = app('smarty.view');
|
||||
view()->share('smarty', $smarty);
|
||||
Gate::define('viewPulse', function (User $user) {
|
||||
|
||||
@@ -104,6 +104,11 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Top Pagination -->
|
||||
<div class="px-6 py-3 bg-gray-50 border-b border-gray-200">
|
||||
{{ $results->links() }}
|
||||
</div>
|
||||
|
||||
<!-- Results Table -->
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-gray-200">
|
||||
@@ -139,10 +144,18 @@
|
||||
<button type="button"
|
||||
class="preview-badge inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-purple-100 text-purple-800 hover:bg-purple-200 transition cursor-pointer"
|
||||
data-guid="{{ $result->guid }}"
|
||||
title="View sample image">
|
||||
title="View preview image">
|
||||
<i class="fas fa-image mr-1"></i> Preview
|
||||
</button>
|
||||
@endif
|
||||
@if(isset($result->jpgstatus) && $result->jpgstatus == 1)
|
||||
<button type="button"
|
||||
class="sample-badge inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800 hover:bg-green-200 transition cursor-pointer"
|
||||
data-guid="{{ $result->guid }}"
|
||||
title="View sample image">
|
||||
<i class="fas fa-images mr-1"></i> Sample
|
||||
</button>
|
||||
@endif
|
||||
@if(isset($result->reid) && $result->reid != null)
|
||||
<button type="button"
|
||||
class="mediainfo-badge inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-800 hover:bg-blue-200 transition cursor-pointer"
|
||||
@@ -201,8 +214,8 @@
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Pagination -->
|
||||
<div class="px-6 py-4 border-t border-gray-200">
|
||||
<!-- Bottom Pagination -->
|
||||
<div class="px-6 py-3 bg-gray-50 border-t border-gray-200">
|
||||
{{ $results->links() }}
|
||||
</div>
|
||||
</form>
|
||||
@@ -214,12 +227,15 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<!-- Preview Image Modal -->
|
||||
<!-- Preview/Sample Image Modal -->
|
||||
<div id="previewModal" class="hidden fixed inset-0 bg-black bg-opacity-75 items-center justify-center p-4" style="display: none; z-index: 9999 !important;">
|
||||
<div class="relative max-w-4xl w-full">
|
||||
<button type="button" onclick="closePreviewModal()" class="absolute top-4 right-4 text-white hover:text-gray-300 text-3xl font-bold z-10">
|
||||
<i class="fas fa-times"></i>
|
||||
</button>
|
||||
<div class="text-center mb-2">
|
||||
<h3 id="previewTitle" class="text-white text-lg font-semibold"></h3>
|
||||
</div>
|
||||
<img id="previewImage" src="" alt="Preview" class="max-w-full max-h-[90vh] mx-auto rounded-lg shadow-2xl">
|
||||
<div class="text-center mt-4">
|
||||
<p id="previewError" class="text-red-400 hidden"></p>
|
||||
@@ -257,23 +273,28 @@ function closePreviewModal() {
|
||||
modal.classList.add('hidden');
|
||||
}
|
||||
|
||||
function showPreviewImage(guid) {
|
||||
function showPreviewImage(guid, type = 'preview') {
|
||||
const modal = document.getElementById('previewModal');
|
||||
const img = document.getElementById('previewImage');
|
||||
const error = document.getElementById('previewError');
|
||||
const title = document.getElementById('previewTitle');
|
||||
|
||||
// Show modal
|
||||
modal.style.display = 'flex';
|
||||
modal.classList.remove('hidden');
|
||||
|
||||
// Set image source - preview images are stored as {guid}.jpg in storage/covers/preview/
|
||||
const previewUrl = '/covers/preview/' + guid + '.jpg';
|
||||
// Set title based on type
|
||||
title.textContent = type === 'sample' ? 'Sample Image' : 'Preview Image';
|
||||
|
||||
img.src = previewUrl;
|
||||
// Set image source - images are stored as {guid}.jpg in storage/covers/{type}/
|
||||
const imageUrl = '/covers/' + type + '/' + guid + '.jpg';
|
||||
|
||||
img.src = imageUrl;
|
||||
error.classList.add('hidden');
|
||||
img.style.display = 'block';
|
||||
|
||||
img.onerror = function() {
|
||||
error.textContent = 'Preview image not available';
|
||||
error.textContent = (type === 'sample' ? 'Sample' : 'Preview') + ' image not available';
|
||||
error.classList.remove('hidden');
|
||||
img.style.display = 'none';
|
||||
};
|
||||
@@ -486,13 +507,20 @@ function showMediainfo(releaseId) {
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Preview badge click handlers
|
||||
// Preview and Sample badge click handlers
|
||||
document.addEventListener('click', function(e) {
|
||||
const previewBadge = e.target.closest('.preview-badge');
|
||||
if (previewBadge) {
|
||||
e.preventDefault();
|
||||
const guid = previewBadge.dataset.guid;
|
||||
showPreviewImage(guid);
|
||||
showPreviewImage(guid, 'preview');
|
||||
}
|
||||
|
||||
const sampleBadge = e.target.closest('.sample-badge');
|
||||
if (sampleBadge) {
|
||||
e.preventDefault();
|
||||
const guid = sampleBadge.dataset.guid;
|
||||
showPreviewImage(guid, 'sample');
|
||||
}
|
||||
|
||||
// Mediainfo badge click handlers
|
||||
|
||||
@@ -42,26 +42,49 @@
|
||||
</div>
|
||||
|
||||
<!-- Sample/Preview Images -->
|
||||
@if(isset($release->haspreview) && $release->haspreview == 1)
|
||||
@php
|
||||
$hasPreviewImage = isset($release->haspreview) && $release->haspreview == 1;
|
||||
$hasSampleImage = isset($release->jpgstatus) && $release->jpgstatus == 1;
|
||||
@endphp
|
||||
|
||||
@if($hasPreviewImage || $hasSampleImage)
|
||||
<div class="border-b border-gray-200 pb-4">
|
||||
<h3 class="text-lg font-semibold text-gray-800 mb-3 flex items-center">
|
||||
<i class="fas fa-images mr-2 text-purple-600"></i> Sample Images
|
||||
<i class="fas fa-images mr-2 text-purple-600"></i>
|
||||
@if($hasPreviewImage && $hasSampleImage)
|
||||
Preview & Sample Images
|
||||
@elseif($hasPreviewImage)
|
||||
Preview Image
|
||||
@else
|
||||
Sample Image
|
||||
@endif
|
||||
</h3>
|
||||
<div class="grid grid-cols-2 md:grid-cols-3 gap-4">
|
||||
<!-- Preview image -->
|
||||
<a href="{{ url('/covers/preview/' . $release->guid . '.jpg') }}" target="_blank" class="block">
|
||||
<img src="{{ url('/covers/preview/' . $release->guid . '.jpg') }}"
|
||||
alt="Preview"
|
||||
class="w-full h-auto rounded-lg shadow-md hover:shadow-lg transition cursor-pointer"
|
||||
onerror="this.parentElement.style.display='none'">
|
||||
</a>
|
||||
<!-- Sample image (if exists) -->
|
||||
<a href="{{ url('/covers/sample/' . $release->guid . '.jpg') }}" target="_blank" class="block">
|
||||
<img src="{{ url('/covers/sample/' . $release->guid . '.jpg') }}"
|
||||
alt="Sample"
|
||||
class="w-full h-auto rounded-lg shadow-md hover:shadow-lg transition cursor-pointer"
|
||||
onerror="this.parentElement.style.display='none'">
|
||||
</a>
|
||||
@if($hasPreviewImage)
|
||||
<!-- Preview image -->
|
||||
<div>
|
||||
<a href="{{ url('/covers/preview/' . $release->guid . '.jpg') }}" target="_blank" class="block">
|
||||
<img src="{{ url('/covers/preview/' . $release->guid . '.jpg') }}"
|
||||
alt="Preview"
|
||||
class="w-full h-auto rounded-lg shadow-md hover:shadow-lg transition cursor-pointer"
|
||||
loading="lazy">
|
||||
</a>
|
||||
<p class="text-xs text-gray-500 mt-1 text-center">Preview</p>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if($hasSampleImage)
|
||||
<!-- Sample image -->
|
||||
<div>
|
||||
<a href="{{ url('/covers/sample/' . $release->guid . '.jpg') }}" target="_blank" class="block">
|
||||
<img src="{{ url('/covers/sample/' . $release->guid . '.jpg') }}"
|
||||
alt="Sample"
|
||||
class="w-full h-auto rounded-lg shadow-md hover:shadow-lg transition cursor-pointer"
|
||||
loading="lazy">
|
||||
</a>
|
||||
<p class="text-xs text-gray-500 mt-1 text-center">Sample</p>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
Reference in New Issue
Block a user