- 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

@@ -0,0 +1,43 @@
{% extends 'base.html.twig' %}
{% block body %}
<div class="container mx-auto p-4">
<div class="bg-white shadow-lg rounded-sm overflow-hidden">
<div class="bg-gray-800 text-white p-4">
<h1 class="text-2xl font-bold">
<i class="fas fa-exchange-alt mr-2"></i>Convertir CBR en CBZ
</h1>
</div>
<div class="p-6">
<form method="post" enctype="multipart/form-data" action="{{ path('app_convert') }}" data-turbo="false">
<div class="mb-4">
<label for="file-upload" class="block text-sm font-medium text-gray-700 mb-2">
Choisir un fichier CBR
</label>
<div class="mt-1 flex justify-center px-6 pt-5 pb-6 border-2 border-gray-300 border-dashed rounded-md">
<div class="space-y-1 text-center">
<i class="fas fa-file-archive text-4xl text-gray-400 mb-3"></i>
<div class="flex text-sm text-gray-600">
<label for="file-upload" class="relative cursor-pointer bg-white rounded-md font-medium text-green-600 hover:text-green-500">
<span>Sélectionner un fichier</span>
<input id="file-upload" name="file" type="file" class="sr-only" accept=".cbr" required>
</label>
<p class="pl-1">ou glisser-déposer</p>
</div>
<p class="text-xs text-gray-500">
CBR jusqu'à 100MB
</p>
</div>
</div>
</div>
<div class="mt-6">
<button type="submit" class="w-full flex items-center justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-green-600 hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500">
<span class="mr-2">Convertir en CBZ</span>
<i class="fas fa-arrow-right"></i>
</button>
</div>
</form>
</div>
</div>
</div>
{% endblock %}

View File

@@ -5,27 +5,27 @@
<div class="bg-white shadow-lg rounded-sm overflow-hidden">
<div class="bg-gray-800 text-white p-4">
<h1 class="text-2xl font-bold">
<i class="fas fa-file-import mr-2"></i>Importer un Manga
<i class="fas fa-file-import mr-2"></i>Importer des Mangas
</h1>
</div>
<div class="p-6">
<form method="post" enctype="multipart/form-data">
<div class="mb-4">
<label for="file-upload" class="block text-sm font-medium text-gray-700 mb-2">
Choisir un fichier CBZ
Choisir des fichiers CBZ ou CBR
</label>
<div class="mt-1 flex justify-center px-6 pt-5 pb-6 border-2 border-gray-300 border-dashed rounded-md">
<div class="space-y-1 text-center">
<i class="fas fa-file-archive text-4xl text-gray-400 mb-3"></i>
<div class="flex text-sm text-gray-600">
<label for="file-upload" class="relative cursor-pointer bg-white rounded-md font-medium text-green-600 hover:text-green-500">
<span>Sélectionner un fichier</span>
<input id="file-upload" name="file" type="file" class="sr-only" accept=".cbz" required>
<span>Sélectionner des fichiers</span>
<input id="file-upload" name="files[]" type="file" class="sr-only" accept=".cbz,.cbr" multiple required>
</label>
<p class="pl-1">ou glisser-déposer</p>
</div>
<p class="text-xs text-gray-500">
CBZ jusqu'à 100MB
CBZ ou CBR jusqu'à 100MB chacun
</p>
</div>
</div>

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 %}

View File

@@ -67,19 +67,25 @@
{% if all_chapters_same_cbz and volume_cbz_path is not null %}
<tr class="border-t hover:bg-green-100">
<td class="px-4 py-2 text-green-500">
<a data-turbo-frame="_top" href="{{ path('app_reader', { mangaSlug: manga.slug, chapterNumber: chapters|first.number, pageNumber: 1 }) }}">
<a data-turbo-frame="_top"
href="{{ path('app_reader', { mangaSlug: manga.slug, chapterNumber: chapters|first.number, pageNumber: 1 }) }}">
{{ '%02d'|format(volume) }}
</a>
</td>
<td class="px-4 py-2 w-full text-left">
<a data-turbo-frame="_top" href="{{ path('app_reader', { mangaSlug: manga.slug, chapterNumber: chapters|first.number, pageNumber: 1 }) }}">
<a data-turbo-frame="_top"
href="{{ path('app_reader', { mangaSlug: manga.slug, chapterNumber: chapters|first.number, pageNumber: 1 }) }}">
Volume {{ '%02d'|format(volume) }}
</a>
</td>
<td class="px-4 py-2 flex justify-end gap-2">
<a href="{{ path('download_cbz', {chapterId: chapters|first.id}) }}"
class="text-gray-500 hover:text-green-500">
<i class="fas fa-download"></i>
<a href="#"
data-controller="download"
data-action="download#download"
data-download-url-value="{{ path('download_cbz', {chapterId: chapters|first.id}) }}"
class="w-8 text-center">
<i data-download-target="icon"
class="fas fa-download text-gray-500 hover:text-green-500"></i>
</a>
</td>
</tr>

View File

@@ -14,6 +14,12 @@
</ul>
{% endif %}
</li>
<li class="{{ app.request.get('_route') == 'app_convert' ? 'border-l-4 border-green-600' : '' }}">
<a href="{{ path('app_convert') }}" class="block pl-4 py-2 flex items-center {{ app.request.get('_route') == 'app_convert' ? 'text-green-600 bg-gray-800' : 'hover:bg-gray-700' }}">
<i class="fas fa-exchange-alt mr-2"></i>
<span>Convertir CBR en CBZ</span>
</a>
</li>
<li class="{{ app.request.get('_route') == 'app_calendar' ? 'border-l-4 border-green-600' : '' }}">
<a href="{{ path('app_calendar') }}" class="block pl-4 py-2 flex items-center {{ app.request.get('_route') == 'app_calendar' ? 'text-green-600 bg-gray-800' : 'hover:bg-gray-700' }}">
<i class="fas fa-calendar-alt mr-2"></i>