Add nfo badges and popups

This commit is contained in:
DariusIII
2025-10-08 00:35:26 +02:00
parent 5c494caadf
commit aef2c4a478
5 changed files with 163 additions and 19 deletions
+19 -19
View File
@@ -12,7 +12,7 @@ class NfoController extends BasePageController
/**
* @throws \Exception
*/
public function showNfo(Request $request, string $id = ''): void
public function showNfo(Request $request, string $id = '')
{
if ($id) {
$rel = Release::getByGuid($id);
@@ -26,31 +26,31 @@ class NfoController extends BasePageController
if ($nfo !== null) {
$nfo['nfoUTF'] = Utility::cp437toUTF($nfo['nfo']);
$this->smarty->assign('rel', $rel);
$this->smarty->assign('nfo', $nfo);
$title = 'NFO File';
$meta_title = 'View Nfo';
$meta_keywords = 'view,nzb,nfo,description,details';
$meta_description = 'View Nfo File';
$modal = false;
if ($request->has('modal')) {
$modal = true;
$this->smarty->assign('modal', true);
}
$content = $this->smarty->fetch('viewnfo.tpl');
$modal = $request->has('modal');
if ($modal) {
echo $content;
// Return just the NFO content for modal display
return view('nfo.view', [
'rel' => $rel,
'nfo' => $nfo,
'modal' => true,
]);
} else {
$this->smarty->assign(compact('title', 'content', 'meta_title', 'meta_keywords', 'meta_description'));
$this->pagerender();
// Return full page view
return view('nfo.view', [
'rel' => $rel,
'nfo' => $nfo,
'modal' => false,
'meta_title' => 'View NFO - '.$rel['searchname'],
'meta_keywords' => 'view,nzb,nfo,description,details',
'meta_description' => 'View NFO File for '.$rel['searchname'],
]);
}
} else {
abort(404, 'NFO does not exist');
}
}
abort(404, 'Invalid request');
}
}
+11
View File
@@ -177,6 +177,14 @@
<i class="fas fa-info-circle mr-1"></i> Media Info
</button>
@endif
@if(isset($result->nfostatus) && $result->nfostatus == 1)
<button type="button"
class="nfo-badge inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-yellow-100 dark:bg-yellow-900 text-yellow-800 dark:text-yellow-200 hover:bg-yellow-200 dark:hover:bg-yellow-800 transition cursor-pointer"
data-guid="{{ $result->guid }}"
title="View NFO file">
<i class="fas fa-file-alt mr-1"></i> NFO
</button>
@endif
</div>
<div class="text-xs text-gray-500 dark:text-gray-400 mt-1">
@if($result->group_name)
@@ -311,6 +319,9 @@
</div>
</div>
</div>
<!-- NFO Modal -->
@include('partials.nfo-modal')
</div>
@endsection
+8
View File
@@ -44,6 +44,11 @@
<a href="#" class="add-to-cart px-4 py-2 bg-blue-600 dark:bg-blue-700 text-white rounded-lg hover:bg-blue-700 dark:hover:bg-blue-800 transition inline-flex items-center" data-guid="{{ $release->guid }}">
<i class="icon_cart fas fa-shopping-basket mr-2"></i> Add to Cart
</a>
@if(isset($release->nfostatus) && $release->nfostatus == 1)
<button type="button" class="nfo-badge px-4 py-2 bg-yellow-600 dark:bg-yellow-700 text-white rounded-lg hover:bg-yellow-700 dark:hover:bg-yellow-800 transition inline-flex items-center" data-guid="{{ $release->guid }}" title="View NFO file">
<i class="fas fa-file-alt mr-2"></i> View NFO
</button>
@endif
@auth
@if(auth()->user()->hasRole('Admin') || auth()->user()->hasRole('Moderator'))
<a href="{{ route('admin.release-edit', ['id' => $release->guid]) }}" class="px-4 py-2 bg-orange-600 text-white rounded-lg hover:bg-orange-700 transition inline-flex items-center" title="Edit Release">
@@ -800,6 +805,9 @@
</div>
</div>
<!-- NFO Modal -->
@include('partials.nfo-modal')
@push('scripts')
@include('partials.cart-script')
+35
View File
@@ -0,0 +1,35 @@
@if(isset($modal) && $modal)
<pre class="nfo-content">{{ $nfo['nfoUTF'] ?? $nfo['nfo'] ?? 'NFO content not available' }}</pre>
@else
@extends('layouts.main')
@section('content')
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-sm p-6">
<div class="mb-6">
<h1 class="text-2xl font-bold text-gray-800 dark:text-gray-200 mb-2">NFO File</h1>
<nav class="text-sm text-gray-600 dark:text-gray-400">
<a href="{{ url('/') }}" class="hover:text-blue-600">Home</a>
<i class="fas fa-chevron-right mx-2 text-xs"></i>
@if(isset($rel))
<a href="{{ url('/details/' . $rel['guid']) }}" class="hover:text-blue-600">{{ $rel['searchname'] }}</a>
<i class="fas fa-chevron-right mx-2 text-xs"></i>
@endif
<span>NFO</span>
</nav>
</div>
<div class="bg-gray-900 text-green-400 p-6 rounded-lg overflow-x-auto font-mono text-sm">
<pre class="whitespace-pre">{{ $nfo['nfoUTF'] ?? $nfo['nfo'] ?? 'NFO content not available' }}</pre>
</div>
@if(isset($rel))
<div class="mt-4">
<a href="{{ url('/details/' . $rel['guid']) }}" class="inline-flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition">
<i class="fas fa-arrow-left mr-2"></i> Back to Release
</a>
</div>
@endif
</div>
@endsection
@endif
@@ -0,0 +1,90 @@
<!-- NFO Modal -->
<div id="nfoModal" class="hidden fixed inset-0 z-50 overflow-y-auto" aria-labelledby="modal-title" role="dialog" aria-modal="true">
<div class="flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0">
<!-- Background overlay -->
<div class="fixed inset-0 bg-gray-500 dark:bg-gray-900 bg-opacity-75 dark:bg-opacity-75 transition-opacity" aria-hidden="true" onclick="closeNfoModal()"></div>
<!-- Modal panel -->
<div class="inline-block align-bottom bg-white dark:bg-gray-800 rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-4xl sm:w-full">
<div class="bg-white dark:bg-gray-800 px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
<div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-medium text-gray-900 dark:text-gray-100" id="modal-title">
<i class="fas fa-file-alt mr-2 text-yellow-600 dark:text-yellow-400"></i>NFO File
</h3>
<button type="button" class="text-gray-400 hover:text-gray-500 dark:hover:text-gray-300" onclick="closeNfoModal()">
<i class="fas fa-times text-xl"></i>
</button>
</div>
<div id="nfoContent" class="bg-gray-900 text-green-400 p-4 rounded-lg overflow-x-auto font-mono text-sm whitespace-pre" style="max-height: 70vh;">
<div class="flex items-center justify-center py-8">
<i class="fas fa-spinner fa-spin text-2xl mr-2"></i>
<span>Loading NFO...</span>
</div>
</div>
</div>
<div class="bg-gray-50 dark:bg-gray-700 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse">
<button type="button" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 dark:border-gray-600 shadow-sm px-4 py-2 bg-white dark:bg-gray-600 text-base font-medium text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm" onclick="closeNfoModal()">
Close
</button>
</div>
</div>
</div>
</div>
<script>
function openNfoModal(guid) {
const modal = document.getElementById('nfoModal');
const content = document.getElementById('nfoContent');
// Show modal
modal.classList.remove('hidden');
// Reset content with loading message
content.innerHTML = '<div class="flex items-center justify-center py-8"><i class="fas fa-spinner fa-spin text-2xl mr-2"></i><span>Loading NFO...</span></div>';
// Fetch NFO content
fetch(`{{ url('/nfo') }}/${guid}?modal=1`)
.then(response => {
if (!response.ok) {
throw new Error('NFO not found');
}
return response.text();
})
.then(html => {
// Extract the NFO content from the response
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
const nfoText = doc.querySelector('pre')?.textContent || doc.body.textContent;
content.textContent = nfoText;
})
.catch(error => {
content.innerHTML = '<div class="text-red-400 text-center py-8"><i class="fas fa-exclamation-triangle mr-2"></i>Error loading NFO file</div>';
console.error('Error loading NFO:', error);
});
}
function closeNfoModal() {
const modal = document.getElementById('nfoModal');
modal.classList.add('hidden');
}
// Close modal on Escape key
document.addEventListener('keydown', function(event) {
if (event.key === 'Escape') {
closeNfoModal();
}
});
// Add click handlers for NFO badges
document.addEventListener('click', function(event) {
if (event.target.closest('.nfo-badge')) {
event.preventDefault();
const badge = event.target.closest('.nfo-badge');
const guid = badge.getAttribute('data-guid');
if (guid) {
openNfoModal(guid);
}
}
});
</script>