Added:
- turbo + code adaptation - cover & thumbnails download
This commit is contained in:
152
templates/manga/_chapter_list.html.twig
Normal file
152
templates/manga/_chapter_list.html.twig
Normal 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>
|
||||
Reference in New Issue
Block a user