mirror of
https://github.com/wallabag/wallabag.git
synced 2024-10-31 22:28:54 +00:00
EntriesExport/epub: use sha1 sums for filenames, fix and rename title chapters
This commit renames entry chapters file using a sha1 sum of their title for simplicity. Also we fix the 'Title' chapter duplicate issue by using the hash of the related entry and the suffix '_title'. Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
This commit is contained in:
parent
063d5e7bda
commit
edd1825b58
1 changed files with 6 additions and 6 deletions
|
@ -173,6 +173,8 @@ class EntriesExport
|
||||||
}
|
}
|
||||||
|
|
||||||
$entryIds = [];
|
$entryIds = [];
|
||||||
|
$entryCount = \count($this->entries);
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Adding actual entries
|
* Adding actual entries
|
||||||
|
@ -180,20 +182,18 @@ class EntriesExport
|
||||||
|
|
||||||
// set tags as subjects
|
// set tags as subjects
|
||||||
foreach ($this->entries as $entry) {
|
foreach ($this->entries as $entry) {
|
||||||
|
++$i;
|
||||||
foreach ($entry->getTags() as $tag) {
|
foreach ($entry->getTags() as $tag) {
|
||||||
$book->setSubject($tag->getLabel());
|
$book->setSubject($tag->getLabel());
|
||||||
}
|
}
|
||||||
|
$filename = sha1($entry->getTitle());
|
||||||
// the reader in Kobo Devices doesn't likes special caracters
|
|
||||||
// in filenames, we limit to A-z/0-9
|
|
||||||
$filename = preg_replace('/[^A-Za-z0-9\-]/', '', $entry->getTitle());
|
|
||||||
|
|
||||||
$titlepage = $content_start . '<h1>' . $entry->getTitle() . '</h1>' . $this->getExportInformation('PHPePub') . $bookEnd;
|
$titlepage = $content_start . '<h1>' . $entry->getTitle() . '</h1>' . $this->getExportInformation('PHPePub') . $bookEnd;
|
||||||
$book->addChapter('Title', 'Title.html', $titlepage, true, EPub::EXTERNAL_REF_ADD);
|
$book->addChapter("Entry {$i} of {$entryCount}", "{$filename}_cover.html", $titlepage, true, EPub::EXTERNAL_REF_ADD);
|
||||||
$chapter = $content_start . $entry->getContent() . $bookEnd;
|
$chapter = $content_start . $entry->getContent() . $bookEnd;
|
||||||
$book->addChapter($entry->getTitle(), htmlspecialchars($filename) . '.html', $chapter, true, EPub::EXTERNAL_REF_ADD);
|
|
||||||
|
|
||||||
$entryIds[] = $entry->getId();
|
$entryIds[] = $entry->getId();
|
||||||
|
$book->addChapter($entry->getTitle(), "{$filename}.html", $chapter, true, EPub::EXTERNAL_REF_ADD);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Could also be the ISBN number, prefered for published books, or a UUID.
|
// Could also be the ISBN number, prefered for published books, or a UUID.
|
||||||
|
|
Loading…
Reference in a new issue