aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKevin Decherf <kevin@kdecherf.com>2019-01-06 18:38:02 +0100
committerKevin Decherf <kevin@kdecherf.com>2019-01-06 23:29:32 +0100
commitbf22266a6230be105ec9a91eccf00e489108405c (patch)
treec5a87d29a3fc0d7283136d6bb575a6b9c2d9f394
parent8f5c4b083ccf354e7942b4f50626de945d29aad7 (diff)
downloadwallabag-bf22266a6230be105ec9a91eccf00e489108405c.tar.gz
wallabag-bf22266a6230be105ec9a91eccf00e489108405c.tar.zst
wallabag-bf22266a6230be105ec9a91eccf00e489108405c.zip
EntriesExport/epub: replace epub identifier with unique urn
We replace the title used as the unique identifier of the epub file with a urn following the format: urn:wallabag:{sha1("wallabagUrl:listOfEntryIdsSeparatedByComma")} This format is repeatable: it always gives the same uid for the same list of entries. Fixes #3811 Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
-rw-r--r--src/Wallabag/CoreBundle/Helper/EntriesExport.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
index cbf1037b..6082f6b9 100644
--- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php
+++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
@@ -150,8 +150,6 @@ class EntriesExport
150 */ 150 */
151 151
152 $book->setTitle($this->title); 152 $book->setTitle($this->title);
153 // Could also be the ISBN number, prefered for published books, or a UUID.
154 $book->setIdentifier($this->title, EPub::IDENTIFIER_URI);
155 // 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. 153 // 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.
156 $book->setLanguage($this->language); 154 $book->setLanguage($this->language);
157 $book->setDescription('Some articles saved on my wallabag'); 155 $book->setDescription('Some articles saved on my wallabag');
@@ -174,6 +172,8 @@ class EntriesExport
174 $book->setCoverImage('Cover.png', file_get_contents($this->logoPath), 'image/png'); 172 $book->setCoverImage('Cover.png', file_get_contents($this->logoPath), 'image/png');
175 } 173 }
176 174
175 $entryIds = [];
176
177 /* 177 /*
178 * Adding actual entries 178 * Adding actual entries
179 */ 179 */
@@ -192,8 +192,14 @@ class EntriesExport
192 $book->addChapter('Title', 'Title.html', $titlepage, true, EPub::EXTERNAL_REF_ADD); 192 $book->addChapter('Title', 'Title.html', $titlepage, true, EPub::EXTERNAL_REF_ADD);
193 $chapter = $content_start . $entry->getContent() . $bookEnd; 193 $chapter = $content_start . $entry->getContent() . $bookEnd;
194 $book->addChapter($entry->getTitle(), htmlspecialchars($filename) . '.html', $chapter, true, EPub::EXTERNAL_REF_ADD); 194 $book->addChapter($entry->getTitle(), htmlspecialchars($filename) . '.html', $chapter, true, EPub::EXTERNAL_REF_ADD);
195
196 $entryIds[] = $entry->getId();
195 } 197 }
196 198
199 // Could also be the ISBN number, prefered for published books, or a UUID.
200 $hash = sha1(sprintf('%s:%s', $this->wallabagUrl, implode(',', $entryIds)));
201 $book->setIdentifier(sprintf('urn:wallabag:%s', $hash), EPub::IDENTIFIER_URI);
202
197 $book->buildTOC(); 203 $book->buildTOC();
198 204
199 return Response::create( 205 return Response::create(