Merge pull request #3827 from wallabag/epub-quote

EntriesExport/epub: replace epub identifier with unique urn
This commit is contained in:
Kevin Decherf 2019-01-07 11:59:38 +01:00 committed by GitHub
commit 5de17117a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -150,8 +150,6 @@ class EntriesExport
*/ */
$book->setTitle($this->title); $book->setTitle($this->title);
// Could also be the ISBN number, prefered for published books, or a UUID.
$book->setIdentifier($this->title, EPub::IDENTIFIER_URI);
// Not needed, but included for the example, Language is mandatory, but EPub defaults to "en". Use RFC3066 Language codes, such as "en", "da", "fr" etc. // Not needed, but included for the example, Language is mandatory, but EPub defaults to "en". Use RFC3066 Language codes, such as "en", "da", "fr" etc.
$book->setLanguage($this->language); $book->setLanguage($this->language);
$book->setDescription('Some articles saved on my wallabag'); $book->setDescription('Some articles saved on my wallabag');
@ -174,6 +172,8 @@ class EntriesExport
$book->setCoverImage('Cover.png', file_get_contents($this->logoPath), 'image/png'); $book->setCoverImage('Cover.png', file_get_contents($this->logoPath), 'image/png');
} }
$entryIds = [];
/* /*
* Adding actual entries * Adding actual entries
*/ */
@ -192,8 +192,14 @@ class EntriesExport
$book->addChapter('Title', 'Title.html', $titlepage, true, EPub::EXTERNAL_REF_ADD); $book->addChapter('Title', 'Title.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); $book->addChapter($entry->getTitle(), htmlspecialchars($filename) . '.html', $chapter, true, EPub::EXTERNAL_REF_ADD);
$entryIds[] = $entry->getId();
} }
// Could also be the ISBN number, prefered for published books, or a UUID.
$hash = sha1(sprintf('%s:%s', $this->wallabagUrl, implode(',', $entryIds)));
$book->setIdentifier(sprintf('urn:wallabag:%s', $hash), EPub::IDENTIFIER_URI);
$book->buildTOC(); $book->buildTOC();
return Response::create( return Response::create(