]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Merge pull request #3826 from wallabag/epub-toc
authorJérémy Benoist <j0k3r@users.noreply.github.com>
Fri, 11 Jan 2019 12:34:38 +0000 (13:34 +0100)
committerGitHub <noreply@github.com>
Fri, 11 Jan 2019 12:34:38 +0000 (13:34 +0100)
Rework of EPUB/PDF exports

17 files changed:
src/Wallabag/CoreBundle/Controller/ExportController.php
src/Wallabag/CoreBundle/Helper/EntriesExport.php
src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml
src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml
src/Wallabag/CoreBundle/Resources/translations/messages.th.yml
src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php

index 7ca89239430dc7b2ec3da1d18fd1b88779ee944e..9e9dbe49a96f1446411c77e2cfd8ab4c9d37a610 100644 (file)
@@ -58,6 +58,7 @@ class ExportController extends Controller
         $method = ucfirst($category);
         $methodBuilder = 'getBuilderFor' . $method . 'ByUser';
         $repository = $this->get('wallabag_core.entry_repository');
+        $title = $method;
 
         if ('tag_entries' === $category) {
             $tag = $this->get('wallabag_core.tag_repository')->findOneBySlug($request->query->get('tag'));
@@ -66,6 +67,8 @@ class ExportController extends Controller
                 $this->getUser()->getId(),
                 $tag->getId()
             );
+
+            $title = 'Tag ' . $tag->getLabel();
         } else {
             $entries = $repository
                 ->$methodBuilder($this->getUser()->getId())
@@ -76,7 +79,7 @@ class ExportController extends Controller
         try {
             return $this->get('wallabag_core.helper.entries_export')
                 ->setEntries($entries)
-                ->updateTitle($method)
+                ->updateTitle($title)
                 ->updateAuthor($method)
                 ->exportAs($format);
         } catch (\InvalidArgumentException $e) {
index 6082f6b9c47f444a6c5abad61dd167032d8f815b..64591687d58e66a42eb129bb021f5fcfe5dbed79 100644 (file)
@@ -85,7 +85,7 @@ class EntriesExport
     public function updateAuthor($method)
     {
         if ('entry' !== $method) {
-            $this->author = $method . ' authors';
+            $this->author = 'Various authors';
 
             return $this;
         }
@@ -173,6 +173,8 @@ class EntriesExport
         }
 
         $entryIds = [];
+        $entryCount = \count($this->entries);
+        $i = 0;
 
         /*
          * Adding actual entries
@@ -180,35 +182,47 @@ class EntriesExport
 
         // set tags as subjects
         foreach ($this->entries as $entry) {
+            ++$i;
             foreach ($entry->getTags() as $tag) {
                 $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());
+            $publishedBy = $entry->getPublishedBy();
+            $authors = $this->translator->trans('export.unknown');
+            if (!empty($publishedBy)) {
+                $authors = implode(',', $publishedBy);
+            }
 
-            $titlepage = $content_start . '<h1>' . $entry->getTitle() . '</h1>' . $this->getExportInformation('PHPePub') . $bookEnd;
-            $book->addChapter('Title', 'Title.html', $titlepage, true, EPub::EXTERNAL_REF_ADD);
+            $titlepage = $content_start .
+                '<h1>' . $entry->getTitle() . '</h1>' .
+                '<dl>' .
+                '<dt>' . $this->translator->trans('entry.view.published_by') . '</dt><dd>' . $authors . '</dd>' .
+                '<dt>' . $this->translator->trans('entry.metadata.reading_time') . '</dt><dd>' . $this->translator->trans('entry.metadata.reading_time_minutes_short', ['%readingTime%' => $entry->getReadingTime()]) . '</dd>' .
+                '<dt>' . $this->translator->trans('entry.metadata.added_on') . '</dt><dd>' . $entry->getCreatedAt()->format('Y-m-d') . '</dd>' .
+                '<dt>' . $this->translator->trans('entry.metadata.address') . '</dt><dd><a href="' . $entry->getUrl() . '">' . $entry->getUrl() . '</a></dd>' .
+                '</dl>' .
+                $bookEnd;
+            $book->addChapter("Entry {$i} of {$entryCount}", "{$filename}_cover.html", $titlepage, true, EPub::EXTERNAL_REF_ADD);
             $chapter = $content_start . $entry->getContent() . $bookEnd;
-            $book->addChapter($entry->getTitle(), htmlspecialchars($filename) . '.html', $chapter, true, EPub::EXTERNAL_REF_ADD);
 
             $entryIds[] = $entry->getId();
+            $book->addChapter($entry->getTitle(), "{$filename}.html", $chapter, true, EPub::EXTERNAL_REF_ADD);
         }
 
+        $book->addChapter('Notices', 'Cover2.html', $content_start . $this->getExportInformation('PHPePub') . $bookEnd);
+
         // 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();
-
         return Response::create(
             $book->getBook(),
             200,
             [
                 'Content-Description' => 'File Transfer',
                 'Content-type' => 'application/epub+zip',
-                'Content-Disposition' => 'attachment; filename="' . $this->title . '.epub"',
+                'Content-Disposition' => 'attachment; filename="' . $this->getSanitizedFilename() . '.epub"',
                 'Content-Transfer-Encoding' => 'binary',
             ]
         );
@@ -250,9 +264,6 @@ class EntriesExport
         }
         $mobi->setContentProvider($content);
 
-        // the browser inside Kindle Devices doesn't likes special caracters either, we limit to A-z/0-9
-        $this->title = preg_replace('/[^A-Za-z0-9\-]/', '', $this->title);
-
         return Response::create(
             $mobi->toString(),
             200,
@@ -260,7 +271,7 @@ class EntriesExport
                 'Accept-Ranges' => 'bytes',
                 'Content-Description' => 'File Transfer',
                 'Content-type' => 'application/x-mobipocket-ebook',
-                'Content-Disposition' => 'attachment; filename="' . $this->title . '.mobi"',
+                'Content-Disposition' => 'attachment; filename="' . $this->getSanitizedFilename() . '.mobi"',
                 'Content-Transfer-Encoding' => 'binary',
             ]
         );
@@ -284,14 +295,6 @@ class EntriesExport
         $pdf->SetSubject('Articles via wallabag');
         $pdf->SetKeywords('wallabag');
 
-        /*
-         * Front page
-         */
-        $pdf->AddPage();
-        $intro = '<h1>' . $this->title . '</h1>' . $this->getExportInformation('tcpdf');
-
-        $pdf->writeHTMLCell(0, 0, '', '', $intro, 0, 1, 0, true, '', true);
-
         /*
          * Adding actual entries
          */
@@ -300,6 +303,22 @@ class EntriesExport
                 $pdf->SetKeywords($tag->getLabel());
             }
 
+            $publishedBy = $entry->getPublishedBy();
+            $authors = $this->translator->trans('export.unknown');
+            if (!empty($publishedBy)) {
+                $authors = implode(',', $publishedBy);
+            }
+
+            $pdf->addPage();
+            $html = '<h1>' . $entry->getTitle() . '</h1>' .
+                '<dl>' .
+                '<dt>' . $this->translator->trans('entry.view.published_by') . '</dt><dd>' . $authors . '</dd>' .
+                '<dt>' . $this->translator->trans('entry.metadata.reading_time') . '</dt><dd>' . $this->translator->trans('entry.metadata.reading_time_minutes_short', ['%readingTime%' => $entry->getReadingTime()]) . '</dd>' .
+                '<dt>' . $this->translator->trans('entry.metadata.added_on') . '</dt><dd>' . $entry->getCreatedAt()->format('Y-m-d') . '</dd>' .
+                '<dt>' . $this->translator->trans('entry.metadata.address') . '</dt><dd><a href="' . $entry->getUrl() . '">' . $entry->getUrl() . '</a></dd>' .
+                '</dl>';
+            $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
+
             $pdf->AddPage();
             $html = '<h1>' . $entry->getTitle() . '</h1>';
             $html .= $entry->getContent();
@@ -307,6 +326,14 @@ class EntriesExport
             $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
         }
 
+        /*
+         * Last page
+         */
+        $pdf->AddPage();
+        $html = $this->getExportInformation('tcpdf');
+
+        $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
+
         // set image scale factor
         $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
 
@@ -316,7 +343,7 @@ class EntriesExport
             [
                 'Content-Description' => 'File Transfer',
                 'Content-type' => 'application/pdf',
-                'Content-Disposition' => 'attachment; filename="' . $this->title . '.pdf"',
+                'Content-Disposition' => 'attachment; filename="' . $this->getSanitizedFilename() . '.pdf"',
                 'Content-Transfer-Encoding' => 'binary',
             ]
         );
@@ -362,7 +389,7 @@ class EntriesExport
             200,
             [
                 'Content-type' => 'application/csv',
-                'Content-Disposition' => 'attachment; filename="' . $this->title . '.csv"',
+                'Content-Disposition' => 'attachment; filename="' . $this->getSanitizedFilename() . '.csv"',
                 'Content-Transfer-Encoding' => 'UTF-8',
             ]
         );
@@ -380,7 +407,7 @@ class EntriesExport
             200,
             [
                 'Content-type' => 'application/json',
-                'Content-Disposition' => 'attachment; filename="' . $this->title . '.json"',
+                'Content-Disposition' => 'attachment; filename="' . $this->getSanitizedFilename() . '.json"',
                 'Content-Transfer-Encoding' => 'UTF-8',
             ]
         );
@@ -398,7 +425,7 @@ class EntriesExport
             200,
             [
                 'Content-type' => 'application/xml',
-                'Content-Disposition' => 'attachment; filename="' . $this->title . '.xml"',
+                'Content-Disposition' => 'attachment; filename="' . $this->getSanitizedFilename() . '.xml"',
                 'Content-Transfer-Encoding' => 'UTF-8',
             ]
         );
@@ -424,7 +451,7 @@ class EntriesExport
             200,
             [
                 'Content-type' => 'text/plain',
-                'Content-Disposition' => 'attachment; filename="' . $this->title . '.txt"',
+                'Content-Disposition' => 'attachment; filename="' . $this->getSanitizedFilename() . '.txt"',
                 'Content-Transfer-Encoding' => 'UTF-8',
             ]
         );
@@ -467,4 +494,15 @@ class EntriesExport
 
         return str_replace('%IMAGE%', '', $info);
     }
+
+    /**
+     * Return a sanitized version of the title by applying translit iconv
+     * and removing non alphanumeric characters, - and space.
+     *
+     * @return string Sanitized filename
+     */
+    private function getSanitizedFilename()
+    {
+        return preg_replace('/[^A-Za-z0-9\- \']/', '', iconv('utf-8', 'us-ascii//TRANSLIT', $this->title));
+    }
 }
index e3ff21f149526a2bcc7978ff5a18041ab579201c..97eb874d28b54335c5e83ff9de81fb6f120e48e8 100644 (file)
@@ -253,6 +253,11 @@ entry:
     confirm:
         # delete: "Are you sure you want to remove that article?"
         # delete_tag: "Are you sure you want to remove that tag from that article?"
+    metadata:
+        # reading_time: "Estimated reading time"
+        # reading_time_minutes_short: "%readingTime% min"
+        # address: "Address"
+        # added_on: "Added on"
 
 about:
     page_title: 'Om'
@@ -402,6 +407,7 @@ tag:
 
 # export:
 #     footer_template: '<div style="text-align:center;"><p>Produced by wallabag with %method%</p><p>Please open <a href="https://github.com/wallabag/wallabag/issues">an issue</a> if you have trouble with the display of this E-Book on your device.</p></div>'
+#     unknown: 'Unknown'
 
 import:
     # page_title: 'Import'
index c297ffb5dedf9ff3d219e796fd71bf2d0bb4112f..0cf3b138e92c5bd9f23e21ef691dc16a98396037 100644 (file)
@@ -253,6 +253,11 @@ entry:
     confirm:
         delete: 'Bist du sicher, dass du diesen Artikel löschen möchtest?'
         delete_tag: 'Bist du sicher, dass du diesen Tag vom Artikel entfernen möchtest?'
+    metadata:
+        # reading_time: "Estimated reading time"
+        # reading_time_minutes_short: "%readingTime% min"
+        # address: "Address"
+        # added_on: "Added on"
 
 about:
     page_title: 'Über'
@@ -402,6 +407,7 @@ tag:
 
 export:
     footer_template: '<div style="text-align:center;"><p>Generiert von wallabag mit Hilfe von %method%</p><p>Bitte öffne <a href="https://github.com/wallabag/wallabag/issues">ein Ticket</a> wenn du ein Problem mit der Darstellung von diesem E-Book auf deinem Gerät hast.</p></div>'
+    # unknown: 'Unknown'
 
 import:
     page_title: 'Importieren'
index 169ae728e32d0fca3be3e8eeb9063b01ff9e8007..6085be14006852fc0430b48dec1c97e9dad33082 100644 (file)
@@ -253,6 +253,11 @@ entry:
     confirm:
         delete: "Are you sure you want to remove that article?"
         delete_tag: "Are you sure you want to remove that tag from that article?"
+    metadata:
+        reading_time: "Estimated reading time"
+        reading_time_minutes_short: "%readingTime% min"
+        address: "Address"
+        added_on: "Added on"
 
 about:
     page_title: 'About'
@@ -402,6 +407,7 @@ tag:
 
 export:
     footer_template: '<div style="text-align:center;"><p>Produced by wallabag with %method%</p><p>Please open <a href="https://github.com/wallabag/wallabag/issues">an issue</a> if you have trouble with the display of this E-Book on your device.</p></div>'
+    unknown: 'Unknown'
 
 import:
     page_title: 'Import'
index 039a1867c236fa7fa910ab4ddd65afaca20da3d6..f2a8fb890b67bca57935aee308f648ff555fab7e 100644 (file)
@@ -253,6 +253,11 @@ entry:
     confirm:
         # delete: "Are you sure you want to remove that article?"
         # delete_tag: "Are you sure you want to remove that tag from that article?"
+    metadata:
+        # reading_time: "Estimated reading time"
+        # reading_time_minutes_short: "%readingTime% min"
+        # address: "Address"
+        # added_on: "Added on"
 
 about:
     page_title: 'Acerca de'
@@ -402,6 +407,7 @@ tag:
 
 # export:
 #     footer_template: '<div style="text-align:center;"><p>Produced by wallabag with %method%</p><p>Please open <a href="https://github.com/wallabag/wallabag/issues">an issue</a> if you have trouble with the display of this E-Book on your device.</p></div>'
+#     unknown: 'Unknown'
 
 import:
     page_title: 'Importar'
index b3f2eb584fc442baaf2ea452a65fea89d667d20a..a5cbd7ecbf0c8d62c1822dfa7d8347a7d1fff827 100644 (file)
@@ -253,6 +253,11 @@ entry:
     confirm:
         # delete: "Are you sure you want to remove that article?"
         # delete_tag: "Are you sure you want to remove that tag from that article?"
+    metadata:
+        # reading_time: "Estimated reading time"
+        # reading_time_minutes_short: "%readingTime% min"
+        # address: "Address"
+        # added_on: "Added on"
 
 about:
     page_title: 'درباره'
@@ -402,6 +407,7 @@ tag:
 
 # export:
 #     footer_template: '<div style="text-align:center;"><p>Produced by wallabag with %method%</p><p>Please open <a href="https://github.com/wallabag/wallabag/issues">an issue</a> if you have trouble with the display of this E-Book on your device.</p></div>'
+#     unknown: 'Unknown'
 
 import:
     page_title: 'درون‌ریزی'
index 5cdd836ea89aa10cb00152db6bca0686f043f218..a36d84ae1377abce04c8418cc527b1944d4f5f4f 100644 (file)
@@ -253,6 +253,11 @@ entry:
     confirm:
         delete: "Voulez-vous vraiment supprimer cet article ?"
         delete_tag: "Voulez-vous vraiment supprimer ce tag de cet article ?"
+    metadata:
+        reading_time: "Durée de lecture estimée"
+        reading_time_minutes_short: "%readingTime% min"
+        address: "Adresse"
+        added_on: "Ajouté le"
 
 about:
     page_title: "À propos"
@@ -402,6 +407,7 @@ tag:
 
 export:
     footer_template: '<div style="text-align:center;"><p>Généré par wallabag with %method%</p><p>Merci d''ouvrir <a href="https://github.com/wallabag/wallabag/issues">un ticket</a> si vous rencontrez des soucis d''affichage avec ce document sur votre support.</p></div>'
+    unknown: 'Inconnu'
 
 import:
     page_title: "Importer"
index 83b3edcdd42968e77e7b4701484b1e413d7b4c0f..1649c0e4fc2054539acdfb0bef12a62623d384c8 100644 (file)
@@ -253,6 +253,11 @@ entry:
     confirm:
         delete: "Vuoi veramente rimuovere quell'articolo?"
         delete_tag: "Vuoi veramente rimuovere quell'etichetta da quell'articolo?"
+    metadata:
+        # reading_time: "Estimated reading time"
+        # reading_time_minutes_short: "%readingTime% min"
+        # address: "Address"
+        # added_on: "Added on"
 
 about:
     page_title: 'A proposito'
@@ -402,6 +407,7 @@ tag:
 
 # export:
 #     footer_template: '<div style="text-align:center;"><p>Produced by wallabag with %method%</p><p>Please open <a href="https://github.com/wallabag/wallabag/issues">an issue</a> if you have trouble with the display of this E-Book on your device.</p></div>'
+#     unknown: 'Unknown'
 
 import:
     page_title: 'Importa'
index 95bc9560f896a1de726600b17c79777749936e7d..e2298f1f6206987c9d940d0f428aa87ea8d252c7 100644 (file)
@@ -253,6 +253,11 @@ entry:
     confirm:
         delete: "Sètz segur de voler suprimir aqueste article ?"
         delete_tag: "Sètz segur de voler levar aquesta etiqueta de l'article ?"
+    metadata:
+        # reading_time: "Estimated reading time"
+        # reading_time_minutes_short: "%readingTime% min"
+        # address: "Address"
+        # added_on: "Added on"
 
 about:
     page_title: 'A prepaus'
@@ -402,6 +407,7 @@ tag:
 
 export:
     footer_template: '<div style="text-align:center;"><p>Produch per wallabag amb %method%</p><p>Mercés de dobrir <a href="https://github.com/wallabag/wallabag/issues">una sollicitacion</a> s’avètz de problèmas amb l’afichatge d’aqueste E-Book sus vòstre periferic.</p></div>'
+    # unknown: 'Unknown'
 
 import:
     page_title: 'Importar'
index a64e60b015646dcd4236c63b0b8345aadec89f5f..a5712733bd58a1a8459776e5017888fa892522fb 100644 (file)
@@ -253,6 +253,11 @@ entry:
     confirm:
         delete: "Czy jesteś pewien, że chcesz usunąć ten artykuł?"
         delete_tag: "Czy jesteś pewien, że chcesz usunąć ten tag, z tego artykułu?"
+    metadata:
+        # reading_time: "Estimated reading time"
+        # reading_time_minutes_short: "%readingTime% min"
+        # address: "Address"
+        # added_on: "Added on"
 
 about:
     page_title: 'O nas'
@@ -401,7 +406,8 @@ tag:
         placeholder: 'Możesz dodać kilka tagów, oddzielając je przecinkami.'
 
 export:
-     footer_template: '<div style="text-align:center;"><p>Stworzone przez wallabag z %method%</p><p>Proszę zgłoś <a href="https://github.com/wallabag/wallabag/issues">sprawę</a>, jeżeli masz problem z wyświetleniem tego e-booka na swoim urządzeniu.</p></div>'
+    footer_template: '<div style="text-align:center;"><p>Stworzone przez wallabag z %method%</p><p>Proszę zgłoś <a href="https://github.com/wallabag/wallabag/issues">sprawę</a>, jeżeli masz problem z wyświetleniem tego e-booka na swoim urządzeniu.</p></div>'
+    # unknown: 'Unknown'
 
 import:
     page_title: 'Import'
index 58d2d0587c29c142ff9f99b759874f93016c5a72..1ccf49e1b7252fe2b85f2b147bcab84bff5cb318 100644 (file)
@@ -253,6 +253,11 @@ entry:
     confirm:
         # delete: "Are you sure you want to remove that article?"
         # delete_tag: "Are you sure you want to remove that tag from that article?"
+    metadata:
+        # reading_time: "Estimated reading time"
+        # reading_time_minutes_short: "%readingTime% min"
+        # address: "Address"
+        # added_on: "Added on"
 
 about:
     page_title: 'Sobre'
@@ -402,6 +407,7 @@ tag:
 
 # export:
 #     footer_template: '<div style="text-align:center;"><p>Produced by wallabag with %method%</p><p>Please open <a href="https://github.com/wallabag/wallabag/issues">an issue</a> if you have trouble with the display of this E-Book on your device.</p></div>'
+#     unknown: 'Unknown'
 
 import:
     page_title: 'Importar'
index 564fed945bd13a98c778ce1b032c8caf462a4574..6c0e18e1c4af62c78c4ffc34a630ddd18e8222ab 100644 (file)
@@ -253,6 +253,11 @@ entry:
     confirm:
         # delete: "Are you sure you want to remove that article?"
         # delete_tag: "Are you sure you want to remove that tag from that article?"
+    metadata:
+        # reading_time: "Estimated reading time"
+        # reading_time_minutes_short: "%readingTime% min"
+        # address: "Address"
+        # added_on: "Added on"
 
 about:
     page_title: 'Despre'
@@ -402,6 +407,7 @@ tag:
 
 # export:
 #     footer_template: '<div style="text-align:center;"><p>Produced by wallabag with %method%</p><p>Please open <a href="https://github.com/wallabag/wallabag/issues">an issue</a> if you have trouble with the display of this E-Book on your device.</p></div>'
+#     unknown: 'Unknown'
 
 import:
     # page_title: 'Import'
index 5f210c934dc4e05695bb1eacc83e8bf95db9c3d1..48753b5558276fb2c356ea6ab714168d73e31ecb 100644 (file)
@@ -241,6 +241,11 @@ entry:
         save_label: 'Сохранить'
     public:
         shared_by_wallabag: "Запись была опубликована <a href='%wallabag_instance%'>wallabag</a>"
+    metadata:
+        # reading_time: "Estimated reading time"
+        # reading_time_minutes_short: "%readingTime% min"
+        # address: "Address"
+        # added_on: "Added on"
 
 about:
     page_title: 'О'
@@ -388,6 +393,10 @@ tag:
         add: 'Добавить'
         placeholder: 'Вы можете добавить несколько тегов, разделенных запятой.'
 
+# export:
+#     footer_template: '<div style="text-align:center;"><p>Produced by wallabag with %method%</p><p>Please open <a href="https://github.com/wallabag/wallabag/issues">an issue</a> if you have trouble with the display of this E-Book on your device.</p></div>'
+#     unknown: 'Unknown'
+
 import:
     page_title: 'Импорт'
     page_description: 'Добро пожаловать в импортер wallabag. Выберите сервис, из которого вы хотите перенести данные.'
index 9d22f90d3096062370a5c465afdb2aae82a21d7e..5524b1f124547892331afc9b5be673a59931abf6 100644 (file)
@@ -251,6 +251,11 @@ entry:
     confirm:
         delete: "คุณแน่ใจหรือไม่ว่าคุณต้องการลบบทความนี้?"
         delete_tag: "คุณแน่ใจหรือไม่ว่าคุณต้องการลบแท็กจากบทความนี้?"
+    metadata:
+        # reading_time: "Estimated reading time"
+        # reading_time_minutes_short: "%readingTime% min"
+        # address: "Address"
+        # added_on: "Added on"
 
 about:
     page_title: 'เกี่ยวกับ'
@@ -400,6 +405,7 @@ tag:
 
 export:
     footer_template: '<div style="text-align:center;"><p>ผลิตโดย wallabag กับ %method%</p><p>ให้ทำการเปิด <a href="https://github.com/wallabag/wallabag/issues">ฉบับนี้</a> ถ้าคุณมีข้อบกพร่องif you have trouble with the display of this E-Book on your device.</p></div>'
+    # unknown: 'Unknown'
 
 import:
     page_title: 'นำข้อมูลเช้า'
index 4c71f0b969be8e8387faa261564ac85cf582cab7..e2156d47984b11cfaa48fdfd41d9549c7ed80cef 100644 (file)
@@ -251,6 +251,11 @@ entry:
     confirm:
         # delete: "Are you sure you want to remove that article?"
         # delete_tag: "Are you sure you want to remove that tag from that article?"
+    metadata:
+        # reading_time: "Estimated reading time"
+        # reading_time_minutes_short: "%readingTime% min"
+        # address: "Address"
+        # added_on: "Added on"
 
 about:
     page_title: 'Hakkımızda'
@@ -400,6 +405,7 @@ tag:
 
 # export:
 #     footer_template: '<div style="text-align:center;"><p>Produced by wallabag with %method%</p><p>Please open <a href="https://github.com/wallabag/wallabag/issues">an issue</a> if you have trouble with the display of this E-Book on your device.</p></div>'
+#     unknown: 'Unknown'
 
 import:
     page_title: 'İçe Aktar'
index 6f3308e56f337bd1d02d8cc7a36fca40a844deba..0c3d4c83adc721c2b0ac9a84d82f9d7cc9d19db4 100644 (file)
@@ -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));
+    }
 }