- turbo + code adaptation
- cover & thumbnails download
This commit is contained in:
Jérémy Guillot
2024-07-06 21:25:07 +02:00
parent 7dee9d71be
commit 54c581b229
35 changed files with 1126 additions and 573 deletions

View File

@@ -23,13 +23,24 @@
</thead>
<tbody class="text-gray-700">
{% for manga in status %}
<tr class="border-b border-gray-200 hover:bg-gray-50 transition duration-150 ease-in-out">
<tr class="border-b border-gray-200 hover:bg-gray-50 transition duration-150 ease-in-out"
data-controller="chapter-progress"
data-chapter-progress-chapter-id-value="{{ manga.chapterId }}">
<td class="py-4 px-4 text-center">
<input type="checkbox" class="form-checkbox h-5 w-5 text-green-600">
</td>
<td class="py-4 px-4 font-medium">{{ manga.manga }}</td>
<td class="py-4 px-4">{{ manga.volume }}</td>
<td class="py-4 px-4">{{ manga.chapter }}</td>
<td class="py-4 px-4">
{{ manga.chapter }}
<div class="mt-2 hidden" data-chapter-progress-target="progressBar">
<div class="bg-gray-200 rounded-full h-2.5 dark:bg-gray-700">
<div class="bg-green-600 h-2.5 rounded-full" style="width: 0"></div>
</div>
<div class="text-xs mt-1 text-center" data-chapter-progress-target="progressText">
</div>
</div>
</td>
<td class="py-4 px-4">{{ manga.title }}</td>
<td class="py-4 px-4">
<button class="text-red-500 hover:text-red-700 transition duration-150 ease-in-out">
@@ -46,9 +57,5 @@
</table>
</div>
</div>
{# <div class="mt-6 ml-4 flex justify-between items-center"> #}
{# <span class="text-sm text-gray-600">Total des enregistrements: {{ status|length }}</span> #}
{# </div> #}
</div>
{% endblock %}

View File

@@ -10,7 +10,9 @@
{% endblock %}
{% block javascripts %}
{{ encore_entry_script_tags('app') }}
{# {{ encore_entry_script_tags('turbo') }} #}
{% endblock %}
<meta name="turbo-refresh-scroll" content="preserve">
</head>
<body class="bg-gray-50 h-full overflow-hidden" data-controller="menu">
<div data-controller="mercure" data-mercure-topic="notification"></div>
@@ -51,19 +53,21 @@
<i class="fas fa-bars"></i>
</button>
<div class="ml-4 w-60 relative">
<twig:Search/> <!-- Search component -->
<twig:Search/>
</div>
</header>
<!-- Main content area -->
<div class="flex h-full pt-16">
<!-- Sidebar -->
<nav data-menu-target="sidebar" class="w-60 bg-white h-full overflow-y-auto fixed left-0 transform -translate-x-full transition-transform duration-200 ease-in-out md:translate-x-0 z-40">
{% include 'menu/menu.html.twig' %} <!-- Menu component -->
<nav data-menu-target="sidebar"
class="w-60 bg-white h-full overflow-y-auto fixed left-0 transform -translate-x-full transition-transform duration-200 ease-in-out md:translate-x-0 z-40">
{% include 'menu/menu.html.twig' %}
</nav>
<!-- Main content -->
<main class="flex-1 flex flex-col overflow-hidden md:ml-60 w-full">
<!-- Toolbar -->
<div class="bg-white shadow z-20 w-full">
{% block toolbar %}

View File

@@ -4,13 +4,13 @@
<twig:ToolBarButton
icon="{{ icon }}"
text="{{ text }}"
action="toggle"
action="dropdown#toggle"
data-dropdown-target="button"
controller="dropdown"
/>
<div class="absolute left-0 mt-2 w-max z-10 bg-gray-800 rounded-sm shadow-lg hidden"
data-dropdown-target="menu" data-controller="toolbar">
<div class="py-1">
data-dropdown-target="menu">
<div class="py-1" data-controller="toolbar">
{% for item in items %}
<a href="#"
class="block px-4 py-2 text-sm text-white hover:text-green-500"

View File

@@ -11,7 +11,7 @@
<div {{ attributes }}>
<button class="flex flex-col justify-around min-h-14 w-min ml-4 items-center text-white group"
{% if action %}
{{ stimulus_action('toolbar', action) }}
data-action="{{ action }}"
{% endif %}
{{ buttonAttributes|join(' ') }}
>

View File

@@ -0,0 +1,152 @@
<turbo-frame id="chapter_list">
<div class="p-4">
{% for volume, chapters in chapters_by_volume %}
{% set is_first = loop.first %}
{% set volume_cbz_path = chapters|first.cbzPath %}
{% set all_chapters_same_cbz = chapters|reduce((carry, chapter) => carry and chapter.cbzPath == volume_cbz_path, true) %}
{% set available_chapters = chapters|filter(chapter => chapter.cbzPath is not null) %}
{% set total_chapters = chapters|length %}
<div data-controller="table" data-table-open-value="{{ is_first ? 'true' : 'false' }}">
<div class="bg-white rounded-sm shadow mb-4">
<div class="relative flex items-center justify-between bg-white p-4 rounded-t-sm">
<!-- Partie gauche -->
<div class="flex items-center space-x-4">
<i class="fas fa-bookmark text-gray-500 text-3xl w-8"></i>
<h2 class="text-xl font-semibold w-28">Volume {{ '%02d'|format(volume) }}</h2>
<div class="flex items-center w-16">
<span class="px-2 py-1 text-sm rounded w-full text-center
{% if available_chapters|length == 0 %}
bg-red-500 text-white
{% elseif available_chapters|length < total_chapters %}
bg-yellow-500 text-white
{% else %}
bg-green-500 text-white
{% endif %}">
{{ available_chapters|length }} / {{ total_chapters }}
</span>
</div>
</div>
<div class="absolute left-1/2 top-1/2 transform -translate-x-1/2 -translate-y-1/2">
<i data-table-target="toggleIcon" data-action="click->table#toggle"
class="bg-gray-400 rounded-full font-bold text-sm text-white p-1 hover:bg-green-500 fas fa-chevron-{{ is_first ? 'up' : 'down' }} cursor-pointer"></i>
</div>
<div class="flex space-x-2 text-xl text-bold">
<a href="#"
data-controller="download"
data-action="download#download"
data-download-url-value="{{ path('search_volume', {'mangaSlug': manga.slug, 'volume': volume}) }}"
class="w-8 text-center">
<i data-download-target="icon"
class="fas fa-search text-gray-500 hover:text-green-500"></i>
</a>
<a href="#"
data-controller="download"
data-action="download#download"
data-download-url-value="{{ path('download_volume', {'mangaSlug': manga.slug, 'volume': volume}) }}"
class="w-8 text-center">
<i data-download-target="icon"
class="fas fa-download text-gray-500 hover:text-green-500"></i>
</a>
</div>
</div>
<div data-table-target="body"
class="p-4 border-t" {{ not is_first ? 'style="display: none;"' : '' }}>
<table class="min-w-full table-auto">
<thead>
<tr>
<th class="px-4 py-2 text-left">#</th>
<th class="px-4 py-2 text-left">Title</th>
<th class="px-4 py-2 text-right">Actions</th>
</tr>
</thead>
<tbody>
{% 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_manga_read', { 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_manga_read', { 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>
</td>
</tr>
{% else %}
{% for chapter in chapters %}
<tr class="border-t hover:bg-green-100">
{% if chapter.cbzPath is not null %}
<td class="px-4 py-2 text-green-500">
<a data-turbo-frame="_top" href="{{ path('app_manga_read', { mangaSlug: manga.slug, chapterNumber: chapter.number, pageNumber: 1 }) }}">
{{ '%02d'|format(chapter.number) }}
</a>
</td>
{% else %}
<td class="px-4 py-2">{{ '%02d'|format(chapter.number) }}</td>
{% endif %}
<td class="px-4 py-2 w-full text-left">
{% if chapter.cbzPath is not null %}
<a data-turbo-frame="_top" href="{{ path('app_manga_read', { mangaSlug: manga.slug, chapterNumber: chapter.number, pageNumber: 1 }) }}">
{{ chapter.title ?? 'No title' }}
</a>
{% else %}
{{ chapter.title ?? 'No title' }}
{% endif %}
</td>
<td class="px-4 py-2 flex justify-end gap-2">
{% if chapter.cbzPath is null %}
<button
data-controller="download"
data-action="download#download"
data-download-url-value="{{ path('search_chapter', {id: chapter.id}) }}"
>
<span class="text-gray-500 hover:text-green-500">
<i data-download-target="icon" class="fas fa-search"></i>
</span>
</button>
{% else %}
<button disabled>
<span class="text-gray-500">
<i class="fas fa-search"></i>
</span>
</button>
{% endif %}
<a href="#"
data-controller="download"
data-action="download#download"
data-download-url-value="{{ path('download_cbz', {chapterId: chapter.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>
{% endfor %}
{% endif %}
</tbody>
</table>
<div class="relative flex items-center justify-between bg-white mt-4 mb-2 rounded-t-sm">
<div
class="absolute left-1/2 top-1/2 transform -translate-x-1/2 -translate-y-1/2">
<i data-table-target="toggleIcon" data-action="click->table#toggle"
class="bg-gray-400 rounded-full font-bold text-sm text-white p-1 hover:bg-green-500 fas fa-chevron-up cursor-pointer"></i>
</div>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</turbo-frame>

View File

@@ -0,0 +1,94 @@
{% block body %}
{% if currentView == 'poster' %}
{# Vue poster actuelle #}
<div
class="w-full p-4 grid sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-8 2xl:grid-cols-12 gap-4">
{% for manga in mangas %}
<div
class="bg-white overflow-hidden border border-gray-200 hover:shadow-2xl hover:border-gray-400 transition-all duration-300 flex flex-col">
<a href="{{ path('app_manga_show', { 'mangaSlug': manga.slug }) }}"
class="block relative w-full pb-[150%] overflow-hidden">
<img src="{{ manga.thumbnailUrl ?? 'https://placehold.co/150x220' }}"
alt="{{ manga.title }}"
class="absolute top-0 left-0 w-full h-full object-cover">
</a>
<div class="p-2 flex flex-col justify-between flex-grow">
<div>
<h3 class="text-sm font-semibold truncate">{{ manga.title }}</h3>
<p class="text-xs text-gray-500">{{ manga.publicationYear }}</p>
</div>
<p class="text-xs text-gray-400 mt-1">Added: {{ manga.createdAt|date('M d, Y') }}</p>
</div>
</div>
{% else %}
<p class="col-span-full text-center text-gray-500">Aucun manga trouvé.</p>
{% endfor %}
</div>
{% elseif currentView == 'resume' %}
{# Vue résumé #}
<div class="w-full p-4 space-y-4">
{% for manga in mangas %}
<div
class="bg-white overflow-hidden border border-gray-200 hover:shadow-lg hover:border-gray-400 transition-all duration-300 flex">
<a class="flex flex-row" href="{{ path('app_manga_show', {'mangaSlug': manga.slug}) }}">
<img src="{{ manga.imageUrl ?? 'https://placehold.co/150x220' }}"
alt="{{ manga.title }}"
class="w-32 h-48 object-cover">
<div class="p-4 flex flex-col justify-between flex-grow">
<div>
<h3 class="text-lg font-semibold">{{ manga.title }}</h3>
<p class="text-sm text-gray-500">{{ manga.publicationYear }}</p>
<p class="text-sm text-gray-600 mt-2">{{ manga.description|truncate(350) }}</p>
</div>
<p class="text-xs text-gray-400 mt-2">
Added: {{ manga.createdAt|date('M d, Y') }}</p>
</div>
</a>
</div>
{% else %}
<p class="text-center text-gray-500">Aucun manga trouvé.</p>
{% endfor %}
</div>
{% elseif currentView == 'table' %}
<div class="p-4">
<table class="min-w-full bg-white">
<thead>
<tr class="bg-gray-100 text-gray-600 uppercase text-sm leading-normal">
<th class="py-3 px-6 text-left">Manga Title</th>
{# <th class="py-3 px-6 text-center">Volumes</th> #}
<th class="py-3 px-6 text-center">Chapters</th>
</tr>
</thead>
<tbody class="text-gray-600 text-sm">
{% for manga in mangas %}
<tr class="border-b border-gray-200 hover:bg-gray-100">
<td class="py-3 px-6 text-left whitespace-nowrap">
<div class="flex items-center">
<span class="font-medium">{{ manga.title }}</span>
</div>
</td>
{# <td class="py-3 px-6 text-center"> #}
{# {{ manga.volumes|length }} #}
{# </td> #}
<td class="py-3 px-6 text-center">
{% set total_chapters = manga.chapters|length %}
{% set available_chapters = manga.chapters|filter(chapter => chapter.cbzPath is not null)|length %}
<div class="flex items-center justify-center">
<div class="w-48 bg-gray-200 rounded-full h-2.5">
<div class="bg-blue-600 h-2.5 rounded-full"
style="width: {{ (available_chapters / total_chapters * 100)|round }}%"></div>
</div>
<span class="ml-2">{{ available_chapters }} / {{ total_chapters }}</span>
</div>
</td>
</tr>
{% else %}
<tr>
<td colspan="6" class="py-3 px-6 text-center">Aucun manga trouvé.</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,112 @@
{% block body %}
<div class="relative">
<div class="shadow-lg text-white">
<div class="relative h-96 bg-cover bg-center" style="background-image: url('{{ manga.imageUrl }}')">
<div class="absolute inset-0 bg-black opacity-50"></div>
<div class="absolute inset-0 flex flex-row justify-center p-4">
<div class="hidden mr-12 xl:block 2xl:block">
<img src="{{ manga.thumbnailUrl }}" alt="{{ manga.title }}" class="max-w-72 max-h-72 ml-4">
</div>
<div class="flex flex-col">
<div class="flex items-center mb-4">
<i class="fas fa-bookmark text-white text-3xl"></i>
<h1 class="text-3xl font-bold ml-4">{{ manga.title }}</h1>
</div>
<div class="flex items-center mb-4">
<span class="mr-4">{{ manga.publicationYear }}</span>
<span>Chapters: {{ manga.chapters.count }}</span>
</div>
<div class="flex items-center mb-4">
<i class="fas fa-folder text-gray-400 mr-2"></i>
<span
class="truncate">/media/mangas/{{ manga.title }} ({{ manga.publicationYear }})</span>
<span
class="ml-auto bg-green-600 py-1 px-2 rounded">{{ manga.status ?? 'Terminé' }}</span>
</div>
<div class="flex items-center mb-4">
{% set genre_count = 0 %}
{% for genre in manga.genres %}
{% if genre_count < 5 %}
<span class="bg-gray-700 py-1 px-2 rounded-sm mr-2">{{ genre }}</span>
{% set genre_count = genre_count + 1 %}
{% endif %}
{% endfor %}
{% if genre_count == 5 and manga.genres|length > 5 %}
<span class="bg-gray-700 py-1 px-2 rounded-sm mr-2">...</span>
{% endif %}
</div>
<div class="mb-4">
<div class="flex items-center mb-2">
<i class="fas fa-heart text-red-500 mr-2"></i>
<span>{{ manga.rating|round(2) }}</span>
</div>
<p>{{ manga.description|truncate(500) }}</p>
</div>
</div>
</div>
</div>
</div>
</div>
<turbo-frame id="chapter_list" src="{{ fragment_uri(controller('App\\Controller\\MangaController::_chaptersByManga', {'id': manga.id})) }}"></turbo-frame>
{# Modal d'édition #}
<twig:Modal
openTrigger="openEditModal"
closeTrigger="closeEditModal"
title="Edit Manga"
>
{% block content %}
<form id="editForm" method="post" action="">
<div class="mb-4">
<label for="title" class="block text-gray-700 text-sm font-bold mb-2">Title:</label>
<input type="text" id="title" name="title" value="{{ manga.title }}"
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
</div>
<div class="mb-4">
<label for="description"
class="block text-gray-700 text-sm font-bold mb-2">Description:</label>
<textarea id="description" name="description"
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
rows="3">{{ manga.description }}</textarea>
</div>
{# Ajoutez d'autres champs selon vos besoins #}
</form>
{% endblock %}
{% block footer %}
<button type="submit" form="editForm"
class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:ml-3 sm:w-auto sm:text-sm">
Save
</button>
<button type="button" data-action="modal#close"
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">
Cancel
</button>
{% endblock %}
</twig:Modal>
{# Modal de confirmation de suppression #}
<twig:Modal
openTrigger="openDeleteModal"
closeTrigger="closeDeleteModal"
title="Delete Manga"
>
<twig:block name="content">
<p class="text-sm text-gray-500">
Are you sure you want to delete this manga? This action cannot be undone.
</p>
</twig:block>
<twig:block name="footer">
<form id="deleteForm" method="post" action="">
<button type="submit"
class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-600 text-base font-medium text-white hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 sm:ml-3 sm:w-auto sm:text-sm">
Delete
</button>
</form>
<button type="button" data-action="modal#close"
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">
Cancel
</button>
</twig:block>
</twig:Modal>
{% endblock %}

View File

@@ -1,96 +1,9 @@
{% extends 'base.html.twig' %}
{% block toolbar %}
{% if toolbar %}
{% if toolbar is defined %}
<twig:Toolbar toolbar="{{ toolbar }}"/>
{% endif %}
{% endblock %}
{% block body %}
{% if currentView == 'poster' %}
{# Vue poster actuelle #}
<div class="w-full p-4 grid sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-8 2xl:grid-cols-12 gap-4">
{% for manga in mangas %}
<div
class="bg-white overflow-hidden border border-gray-200 hover:shadow-2xl hover:border-gray-400 transition-all duration-300 flex flex-col">
<a href="{{ path('app_manga_show', { 'mangaSlug': manga.slug }) }}"
class="block relative w-full pb-[150%] overflow-hidden">
<img src="{{ manga.imageUrl ?? 'https://placehold.co/150x220' }}" alt="{{ manga.title }}"
class="absolute top-0 left-0 w-full h-full object-cover">
</a>
<div class="p-2 flex flex-col justify-between flex-grow">
<div>
<h3 class="text-sm font-semibold truncate">{{ manga.title }}</h3>
<p class="text-xs text-gray-500">{{ manga.publicationYear }}</p>
</div>
<p class="text-xs text-gray-400 mt-1">Added: {{ manga.createdAt|date('M d, Y') }}</p>
</div>
</div>
{% else %}
<p class="col-span-full text-center text-gray-500">Aucun manga trouvé.</p>
{% endfor %}
</div>
{% elseif currentView == 'resume' %}
{# Vue résumé #}
<div class="w-full p-4 space-y-4">
{% for manga in mangas %}
<div
class="bg-white overflow-hidden border border-gray-200 hover:shadow-lg hover:border-gray-400 transition-all duration-300 flex">
<a class="flex flex-row" href="{{ path('app_manga_show', {'mangaSlug': manga.slug}) }}">
<img src="{{ manga.imageUrl ?? 'https://placehold.co/150x220' }}" alt="{{ manga.title }}"
class="w-32 h-48 object-cover">
<div class="p-4 flex flex-col justify-between flex-grow">
<div>
<h3 class="text-lg font-semibold">{{ manga.title }}</h3>
<p class="text-sm text-gray-500">{{ manga.publicationYear }}</p>
<p class="text-sm text-gray-600 mt-2">{{ manga.description|truncate(350) }}</p>
</div>
<p class="text-xs text-gray-400 mt-2">Added: {{ manga.createdAt|date('M d, Y') }}</p>
</div>
</a>
</div>
{% else %}
<p class="text-center text-gray-500">Aucun manga trouvé.</p>
{% endfor %}
</div>
{% elseif currentView == 'table' %}
<div class="p-4">
<table class="min-w-full bg-white">
<thead>
<tr class="bg-gray-100 text-gray-600 uppercase text-sm leading-normal">
<th class="py-3 px-6 text-left">Manga Title</th>
{# <th class="py-3 px-6 text-center">Volumes</th> #}
<th class="py-3 px-6 text-center">Chapters</th>
</tr>
</thead>
<tbody class="text-gray-600 text-sm">
{% for manga in mangas %}
<tr class="border-b border-gray-200 hover:bg-gray-100">
<td class="py-3 px-6 text-left whitespace-nowrap">
<div class="flex items-center">
<span class="font-medium">{{ manga.title }}</span>
</div>
</td>
{# <td class="py-3 px-6 text-center"> #}
{# {{ manga.volumes|length }} #}
{# </td> #}
<td class="py-3 px-6 text-center">
{% set total_chapters = manga.chapters|length %}
{% set available_chapters = manga.chapters|filter(chapter => chapter.cbzPath is not null)|length %}
<div class="flex items-center justify-center">
<div class="w-48 bg-gray-200 rounded-full h-2.5">
<div class="bg-blue-600 h-2.5 rounded-full"
style="width: {{ (available_chapters / total_chapters * 100)|round }}%"></div>
</div>
<span class="ml-2">{{ available_chapters }} / {{ total_chapters }}</span>
</div>
</td>
</tr>
{% else %}
<tr>
<td colspan="6" class="py-3 px-6 text-center">Aucun manga trouvé.</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{% include 'manga/_list.html.twig' %}
{% endblock %}

View File

@@ -5,248 +5,6 @@
{% endif %}
{% endblock %}
{% block body %}
<div class="relative">
<div class="shadow-lg text-white">
<div class="relative h-96 bg-cover bg-center" style="background-image: url('{{ manga.imageUrl }}')">
<div class="absolute inset-0 bg-black opacity-50"></div>
<div class="absolute inset-0 flex flex-row justify-center p-4">
<div class="hidden mr-12 xl:block 2xl:block">
<img src="{{ manga.imageUrl }}" alt="{{ manga.title }}" class="max-w-72 max-h-72 ml-4">
</div>
<div class="flex flex-col">
<div class="flex items-center mb-4">
<i class="fas fa-bookmark text-white text-3xl"></i>
<h1 class="text-3xl font-bold ml-4">{{ manga.title }}</h1>
</div>
<div class="flex items-center mb-4">
<span class="mr-4">{{ manga.publicationYear }}</span>
<span>Chapters: {{ manga.chapters.count }}</span>
</div>
<div class="flex items-center mb-4">
<i class="fas fa-folder text-gray-400 mr-2"></i>
<span class="truncate">/media/mangas/{{ manga.title }} ({{ manga.publicationYear }})</span>
<span class="ml-auto bg-green-600 py-1 px-2 rounded">{{ manga.status ?? 'Terminé' }}</span>
</div>
<div class="flex items-center mb-4">
{% set genre_count = 0 %}
{% for genre in manga.genres %}
{% if genre_count < 5 %}
<span class="bg-gray-700 py-1 px-2 rounded-sm mr-2">{{ genre }}</span>
{% set genre_count = genre_count + 1 %}
{% endif %}
{% endfor %}
{% if genre_count == 5 and manga.genres|length > 5 %}
<span class="bg-gray-700 py-1 px-2 rounded-sm mr-2">...</span>
{% endif %}
</div>
<div class="mb-4">
<div class="flex items-center mb-2">
<i class="fas fa-heart text-red-500 mr-2"></i>
<span>{{ manga.rating|round(2) }}</span>
</div>
<p>{{ manga.description|truncate(500) }}</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="p-4">
{% for volume, chapters in chapters_by_volume %}
{% set is_first = loop.first %}
{% set volume_cbz_path = chapters|first.cbzPath %}
{% set all_chapters_same_cbz = chapters|reduce((carry, chapter) => carry and chapter.cbzPath == volume_cbz_path, true) %}
{% set available_chapters = chapters|filter(chapter => chapter.cbzPath is not null) %}
{% set total_chapters = chapters|length %}
<div data-controller="table" data-table-open-value="{{ is_first ? 'true' : 'false' }}">
<div class="bg-white rounded-sm shadow mb-4">
<div class="relative flex items-center justify-between bg-white p-4 rounded-t-sm">
<!-- Partie gauche -->
<div class="flex items-center space-x-4">
<i class="fas fa-bookmark text-gray-500 text-3xl w-8"></i>
<h2 class="text-xl font-semibold w-28">Volume {{ '%02d'|format(volume) }}</h2>
<div class="flex items-center w-16">
<span class="px-2 py-1 text-sm rounded w-full text-center
{% if available_chapters|length == 0 %}
bg-red-500 text-white
{% elseif available_chapters|length < total_chapters %}
bg-yellow-500 text-white
{% else %}
bg-green-500 text-white
{% endif %}">
{{ available_chapters|length }} / {{ total_chapters }}
</span>
</div>
</div>
<!-- Chevron centré -->
<div class="absolute left-1/2 top-1/2 transform -translate-x-1/2 -translate-y-1/2">
<i data-table-target="toggleIcon" data-action="click->table#toggle"
class="bg-gray-400 rounded-full font-bold text-sm text-white p-1 hover:bg-green-500 fas fa-chevron-{{ is_first ? 'up' : 'down' }} cursor-pointer"></i>
</div>
<!-- Partie droite -->
<div class="flex space-x-2 text-xl text-bold">
<a href="#" class="w-8 text-center">
<i class="fas fa-search text-gray-500 hover:text-green-500"></i>
</a>
<a href="#" class="w-8 text-center">
<i class="fas fa-download text-gray-500 hover:text-green-500"></i>
</a>
</div>
</div>
<div data-table-target="body"
class="p-4 border-t" {{ not is_first ? 'style="display: none;"' : '' }}>
<table class="min-w-full table-auto">
<thead>
<tr>
<th class="px-4 py-2 text-left">#</th>
<th class="px-4 py-2 text-left">Title</th>
<th class="px-4 py-2 text-right">Actions</th>
</tr>
</thead>
<tbody>
{% 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 href="{{ path('app_manga_read', { 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 href="{{ path('app_manga_read', { 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>
</td>
</tr>
{% else %}
{% for chapter in chapters %}
<tr class="border-t hover:bg-green-100">
{% if chapter.cbzPath is not null %}
<td class="px-4 py-2 text-green-500">
<a href="{{ path('app_manga_read', { mangaSlug: manga.slug, chapterNumber: chapter.number, pageNumber: 1 }) }}">
{{ '%02d'|format(chapter.number) }}
</a>
</td>
{% else %}
<td class="px-4 py-2">{{ '%02d'|format(chapter.number) }}</td>
{% endif %}
<td class="px-4 py-2 w-full text-left">
{% if chapter.cbzPath is not null %}
<a href="{{ path('app_manga_read', { mangaSlug: manga.slug, chapterNumber: chapter.number, pageNumber: 1 }) }}">
{{ chapter.title ?? 'No title' }}
</a>
{% else %}
{{ chapter.title ?? 'No title' }}
{% endif %}
</td>
<td class="px-4 py-2 flex justify-end gap-2">
{% if chapter.cbzPath is null %}
<button
data-controller="download-chapter"
data-action="click->download-chapter#handleClick"
data-url="{{ path('add_chapter', {id: chapter.id}) }}"
>
<span class="text-gray-500 hover:text-green-500">
<i data-download-chapter-target="icon"
class="fas fa-search"></i>
</span>
</button>
{% else %}
<button disabled>
<span class="text-gray-500">
<i class="fas fa-search"></i>
</span>
</button>
{% endif %}
<a href="{{ path('download_cbz', {chapterId: chapter.id}) }}"
class="text-gray-500 hover:text-green-500">
<i class="fas fa-download"></i>
</a>
</td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
<div class="relative flex items-center justify-between bg-white mt-4 mb-2 rounded-t-sm">
<div
class="absolute left-1/2 top-1/2 transform -translate-x-1/2 -translate-y-1/2">
<i data-table-target="toggleIcon" data-action="click->table#toggle"
class="bg-gray-400 rounded-full font-bold text-sm text-white p-1 hover:bg-green-500 fas fa-chevron-up cursor-pointer"></i>
</div>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
{# Modal d'édition #}
<twig:Modal
openTrigger="openEditModal"
closeTrigger="closeEditModal"
title="Edit Manga"
>
{% block content %}
<form id="editForm" method="post" action="">
<div class="mb-4">
<label for="title" class="block text-gray-700 text-sm font-bold mb-2">Title:</label>
<input type="text" id="title" name="title" value="{{ manga.title }}"
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline">
</div>
<div class="mb-4">
<label for="description" class="block text-gray-700 text-sm font-bold mb-2">Description:</label>
<textarea id="description" name="description"
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
rows="3">{{ manga.description }}</textarea>
</div>
{# Ajoutez d'autres champs selon vos besoins #}
</form>
{% endblock %}
{% block footer %}
<button type="submit" form="editForm"
class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 sm:ml-3 sm:w-auto sm:text-sm">
Save
</button>
<button type="button" data-action="modal#close"
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">
Cancel
</button>
{% endblock %}
</twig:Modal>
{# Modal de confirmation de suppression #}
<twig:Modal
openTrigger="openDeleteModal"
closeTrigger="closeDeleteModal"
title="Delete Manga"
>
<twig:block name="content">
<p class="text-sm text-gray-500">
Are you sure you want to delete this manga? This action cannot be undone.
</p>
</twig:block>
<twig:block name="footer">
<form id="deleteForm" method="post" action="">
<button type="submit"
class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-600 text-base font-medium text-white hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 sm:ml-3 sm:w-auto sm:text-sm">
Delete
</button>
</form>
<button type="button" data-action="modal#close"
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">
Cancel
</button>
</twig:block>
</twig:Modal>
{% include 'manga/_manga_details.html.twig' %}
{% endblock %}