- CbrToCbzConverter.php
- import now convert .cbr to .cbz
- import improvement, multiple files
This commit is contained in:
Jérémy Guillot
2024-07-24 14:10:28 +02:00
parent 4484be4d4e
commit 7068bd1a34
14 changed files with 547 additions and 238 deletions

View File

@@ -1,81 +1,103 @@
{% extends 'base.html.twig' %}
{% block body %}
<div class="container mx-auto p-4">
<h1 class="text-2xl font-bold mb-6">Correspondances trouvées :</h1>
<form method="post" action="{{ path('import_confirm') }}" data-controller="import-match">
<div class="container mx-auto mt-8 p-2">
<div class="bg-white overflow-hidden">
<div class="overflow-x-auto">
<table class="min-w-full bg-white">
<thead>
<tr class="bg-gray-200 text-gray-800">
<th class="w-1/12 py-3 px-4 text-left">
<input type="checkbox" class="form-checkbox h-5 w-5 text-green-600"
data-action="change->import-match#toggleAllCheckboxes">
</th>
<th class="w-4/12 py-3 px-4 text-left">Original File</th>
<th class="w-4/12 py-3 px-4 text-left">Manga</th>
<th class="w-3/12 py-3 px-4 text-left">Content</th>
<th class="w-2/12 py-3 px-4 text-left">Actions</th>
</tr>
</thead>
<tbody class="text-gray-700">
{% for file in files %}
<tr class="border-b border-gray-200 hover:bg-gray-50 transition duration-150 ease-in-out">
<td class="py-4 px-4 text-center">
<input type="checkbox" class="form-checkbox h-5 w-5 text-green-600"
name="selected[]"
value="{{ file.id }}" data-import-match-target="checkbox">
</td>
<td>
<div class="py-4 px-4">
<div class="text-sm font-medium text-gray-900">{{ file.originalFileName }}</div>
<div class="text-sm text-gray-500">{{ file.fileSize }}</div>
</div>
</td>
<td class="py-4 px-4">
<select name="manga_slug[{{ file.id }}]"
class="w-full bg-white border border-gray-300 rounded-md shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"
data-action="change->import-match#updateMangaInfo"
data-file-id="{{ file.id }}">
{% for manga in file.mangaOptions %}
<option value="{{ manga.slug }}" {% if loop.first %}selected{% endif %}
data-manga-info="{{ manga|json_encode }}">{{ manga.title }}</option>
{% endfor %}
</select>
</td>
<td class="py-4 px-4">
{% if file.metadata.chapter %}
Chapter {{ file.metadata.chapter }}
<input type="hidden" name="chapter[{{ file.id }}]"
value="{{ file.metadata.chapter }}">
{% else %}
Volume {{ file.metadata.volume }}
<input type="hidden" name="volume[{{ file.id }}]"
value="{{ file.metadata.volume }}">
{% endif %}
</td>
<td class="py-4 px-4">
<button type="button"
class="text-blue-500 hover:text-blue-700 transition duration-150 ease-in-out"
data-action="click->import-match#showDetails" data-file-id="{{ file.id }}">
<i class="fas fa-info-circle"></i>
</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% if mangas %}
{% for manga in mangas %}
<div class="bg-white shadow-lg rounded-lg overflow-hidden mb-8">
<div class="flex bg-gray-100 p-4">
<div class="flex-none w-48">
<img src="{{ manga.imageUrl ?? 'https://placehold.co/150x220' }}" alt="{{ manga.title }}"
class="w-full h-full object-cover rounded" style="width: 150px; height: 220px;">
</div>
<div class="flex-grow ml-4">
<h2 class="text-xl font-bold text-gray-900">{{ manga.title }} <span class="text-gray-500">({{ manga.publicationYear }})</span></h2>
<div class="mt-2">
{% for genre in manga.genres %}
<span class="inline-block bg-gray-200 text-gray-800 text-xs font-semibold mr-2 mb-2 px-2.5 py-0.5 rounded">
{{ genre }}
</span>
{% endfor %}
</div>
<p class="text-gray-700 text-sm mt-2">{{ manga.description|truncate(150) }}</p>
<div class="mt-2">
<span class="text-gray-600 text-sm">
<i class="fas fa-star text-yellow-500"></i>
{{ manga.rating }}
</span>
</div>
<div class="mt-6 flex justify-end">
<button type="submit"
class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-green-600 hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500"
data-action="import-match#confirmSelected">
Importer les fichiers sélectionnés
</button>
</div>
</div>
<div class="fixed z-10 inset-0 overflow-y-auto hidden" data-import-match-target="modal">
<div class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
<div class="fixed inset-0 transition-opacity" aria-hidden="true">
<div class="absolute inset-0 bg-gray-500 opacity-75"></div>
</div>
<span class="hidden sm:inline-block sm:align-middle sm:h-screen" aria-hidden="true">&#8203;</span>
<div
class="inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full">
<div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
<div data-import-match-target="modalContent">
<!-- Will be filled by JavaScript -->
</div>
</div>
{% if chapters[manga.slug] is iterable %}
{% for volume, volumeChapters in chapters[manga.slug] %}
{% set is_first = loop.first %}
<div data-controller="table">
<div class="border-t border-gray-200">
<div class="bg-gray-50 px-4 py-3 flex justify-between items-center cursor-pointer" data-action="click->table#toggle">
<h3 class="text-lg font-semibold">Volume {{ '%02d'|format(volume) }}</h3>
<div class="flex items-center">
<span class="text-gray-600 mr-2">{{ volumeChapters|length }} Chapitres</span>
<i data-table-target="toggleIcon" class="fas fa-chevron-down"></i>
</div>
</div>
<div data-table-target="body" class="" style="display: none;">
<table class="min-w-full divide-y divide-gray-200">
<tbody class="bg-white divide-y divide-gray-200">
{% for chapter in volumeChapters %}
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ chapter.number }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ chapter.title ?? 'Sans titre' }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endfor %}
{% endif %}
<div class="bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse">
<form method="post" action="{{ path('import_confirm') }}" class="mt-4 sm:mt-0">
<input type="hidden" name="manga_slug" value="{{ manga.slug }}">
<input type="hidden" name="volume" value="{{ volume }}">
<button type="submit" name="action" value="confirm" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-green-600 text-base font-medium text-white hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500 sm:ml-3 sm:w-auto sm:text-sm">
Confirmer
</button>
<button type="submit" name="action" value="refuse" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm">
Refuser
</button>
</form>
<button type="button"
class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm"
data-action="click->import-match#closeModal">
Close
</button>
</div>
</div>
{% endfor %}
{% else %}
<p class="text-gray-700">Aucune correspondance trouvée.</p>
{% endif %}
</div>
</div>
</div>
</form>
{% endblock %}