refactor(reader): serve pages as static files instead of base64
Replace the per-page API call (base64 payload) with static image URLs
served directly by Caddy from public/images/pages/{chapterId}/.
- LocalImageStorage now stores to public/images/ (was MANGA_DATA_PATH)
- LegacyChapterRepository returns /images/pages/{id}/{file} URLs,
uses getimagesize() instead of loading file content into memory
- Delete GetChapterPage query/handler/response, ChapterPageResource,
ChapterPageProvider, PageContent model
- Remove getPageContent() from ChapterRepositoryInterface
- Frontend: loadChapter() fetches chapter + all pages in parallel,
ReaderPage uses URL instead of base64 data URI, InfiniteReader drops
lazy-load observer side effect, readerStore drops loadedPages/preload
- GetChapterPagesTest: extract fixture images from CBZ at runtime,
ignore tests/Fixtures/pages/ in .gitignore
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6875ad4222
commit
322c396165
@@ -9,18 +9,27 @@ use App\Factory\MangaFactory;
|
||||
use App\Tests\Feature\AbstractApiTestCase;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Zenstruck\Foundry\Test\ResetDatabase;
|
||||
use ZipArchive;
|
||||
|
||||
final class GetChapterPagesTest extends AbstractApiTestCase
|
||||
{
|
||||
use ResetDatabase;
|
||||
|
||||
private int $chapterId;
|
||||
private string $pagesDirectory;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// Création d'un manga et d'un chapitre avec les factories
|
||||
// Extraire quelques images du CBZ dans un dossier temporaire
|
||||
$this->pagesDirectory = sys_get_temp_dir() . '/mangarr-test-pages-' . uniqid();
|
||||
mkdir($this->pagesDirectory);
|
||||
$zip = new ZipArchive();
|
||||
$zip->open(__DIR__ . '/../../Fixtures/chapter.cbz');
|
||||
$zip->extractTo($this->pagesDirectory, ['007.jpg', '008.jpg']);
|
||||
$zip->close();
|
||||
|
||||
$manga = MangaFactory::createOne([
|
||||
'title' => 'Test Manga',
|
||||
'slug' => 'test-manga'
|
||||
@@ -32,12 +41,22 @@ final class GetChapterPagesTest extends AbstractApiTestCase
|
||||
'number' => 1.0,
|
||||
'volume' => 1,
|
||||
'visible' => true,
|
||||
'cbzPath' => __DIR__ . '/../../Fixtures/chapter.cbz'
|
||||
'pagesDirectory' => $this->pagesDirectory
|
||||
]);
|
||||
|
||||
$this->chapterId = $chapter->getId();
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
foreach (glob($this->pagesDirectory . '/*') as $file) {
|
||||
unlink($file);
|
||||
}
|
||||
rmdir($this->pagesDirectory);
|
||||
}
|
||||
|
||||
public function testItReturnsNotFoundWhenChapterDoesNotExist(): void
|
||||
{
|
||||
$response = static::createClient()->request('GET', '/api/reader/chapter/999/pages');
|
||||
|
||||
Reference in New Issue
Block a user