mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-01 17:38:38 +00:00
Merge pull request #3826 from wallabag/epub-toc
Rework of EPUB/PDF exports
This commit is contained in:
commit
3625833b2c
17 changed files with 165 additions and 32 deletions
|
@ -98,7 +98,7 @@ class ExportControllerTest extends WallabagCoreTestCase
|
|||
|
||||
$headers = $client->getResponse()->headers;
|
||||
$this->assertSame('application/x-mobipocket-ebook', $headers->get('content-type'));
|
||||
$this->assertSame('attachment; filename="' . preg_replace('/[^A-Za-z0-9\-]/', '', $content->getTitle()) . '.mobi"', $headers->get('content-disposition'));
|
||||
$this->assertSame('attachment; filename="' . $this->getSanitizedFilename($content->getTitle()) . '.mobi"', $headers->get('content-disposition'));
|
||||
$this->assertSame('binary', $headers->get('content-transfer-encoding'));
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ class ExportControllerTest extends WallabagCoreTestCase
|
|||
|
||||
$headers = $client->getResponse()->headers;
|
||||
$this->assertSame('application/pdf', $headers->get('content-type'));
|
||||
$this->assertSame('attachment; filename="Tag_entries articles.pdf"', $headers->get('content-disposition'));
|
||||
$this->assertSame('attachment; filename="Tag foo bar articles.pdf"', $headers->get('content-disposition'));
|
||||
$this->assertSame('binary', $headers->get('content-transfer-encoding'));
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,7 @@ class ExportControllerTest extends WallabagCoreTestCase
|
|||
|
||||
$headers = $client->getResponse()->headers;
|
||||
$this->assertSame('application/json', $headers->get('content-type'));
|
||||
$this->assertSame('attachment; filename="' . $contentInDB->getTitle() . '.json"', $headers->get('content-disposition'));
|
||||
$this->assertSame('attachment; filename="' . $this->getSanitizedFilename($contentInDB->getTitle()) . '.json"', $headers->get('content-disposition'));
|
||||
$this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
|
||||
|
||||
$content = json_decode($client->getResponse()->getContent(), true);
|
||||
|
@ -281,4 +281,9 @@ class ExportControllerTest extends WallabagCoreTestCase
|
|||
$this->assertNotEmpty('created_at', (string) $content->entry[0]->created_at);
|
||||
$this->assertNotEmpty('updated_at', (string) $content->entry[0]->updated_at);
|
||||
}
|
||||
|
||||
private function getSanitizedFilename($title)
|
||||
{
|
||||
return preg_replace('/[^A-Za-z0-9\- \']/', '', iconv('utf-8', 'us-ascii//TRANSLIT', $title));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue