diff options
author | Étienne Gilli <etienne.gilli@gmail.com> | 2017-07-08 17:55:58 +0200 |
---|---|---|
committer | Étienne Gilli <etienne.gilli@gmail.com> | 2017-07-08 19:53:43 +0200 |
commit | 07320a2bd25c6ace1f9b1aa06b1b08e8dbf4f4fa (patch) | |
tree | 61d8992d8511c324208b8ad9fc9e2c6a8952492d /src/Wallabag | |
parent | b5d7eb148c4cd62ff187b08765f0c13c7d330fcf (diff) | |
download | wallabag-07320a2bd25c6ace1f9b1aa06b1b08e8dbf4f4fa.tar.gz wallabag-07320a2bd25c6ace1f9b1aa06b1b08e8dbf4f4fa.tar.zst wallabag-07320a2bd25c6ace1f9b1aa06b1b08e8dbf4f4fa.zip |
Use the article domain as author for export files
When exporting an entry, use the domain name as author name for epub,
mobi and pdf formats, instead of 'wallabag'.
Change the author from array to string, because for now, there is always
only one author.
Diffstat (limited to 'src/Wallabag')
4 files changed, 26 insertions, 6 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php index 8a206124..9277e1a1 100644 --- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php +++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php | |||
@@ -180,6 +180,7 @@ class EntryRestController extends WallabagRestController | |||
180 | return $this->get('wallabag_core.helper.entries_export') | 180 | return $this->get('wallabag_core.helper.entries_export') |
181 | ->setEntries($entry) | 181 | ->setEntries($entry) |
182 | ->updateTitle('entry') | 182 | ->updateTitle('entry') |
183 | ->updateAuthor('entry') | ||
183 | ->exportAs($request->attributes->get('_format')); | 184 | ->exportAs($request->attributes->get('_format')); |
184 | } | 185 | } |
185 | 186 | ||
diff --git a/src/Wallabag/CoreBundle/Command/ExportCommand.php b/src/Wallabag/CoreBundle/Command/ExportCommand.php index 0dacb734..c2e4be05 100644 --- a/src/Wallabag/CoreBundle/Command/ExportCommand.php +++ b/src/Wallabag/CoreBundle/Command/ExportCommand.php | |||
@@ -56,6 +56,7 @@ class ExportCommand extends ContainerAwareCommand | |||
56 | $data = $this->getContainer()->get('wallabag_core.helper.entries_export') | 56 | $data = $this->getContainer()->get('wallabag_core.helper.entries_export') |
57 | ->setEntries($entries) | 57 | ->setEntries($entries) |
58 | ->updateTitle('All') | 58 | ->updateTitle('All') |
59 | ->updateAuthor('All') | ||
59 | ->exportJsonData(); | 60 | ->exportJsonData(); |
60 | file_put_contents($filePath, $data); | 61 | file_put_contents($filePath, $data); |
61 | } catch (\InvalidArgumentException $e) { | 62 | } catch (\InvalidArgumentException $e) { |
diff --git a/src/Wallabag/CoreBundle/Controller/ExportController.php b/src/Wallabag/CoreBundle/Controller/ExportController.php index 6fad122e..35a22046 100644 --- a/src/Wallabag/CoreBundle/Controller/ExportController.php +++ b/src/Wallabag/CoreBundle/Controller/ExportController.php | |||
@@ -33,6 +33,7 @@ class ExportController extends Controller | |||
33 | return $this->get('wallabag_core.helper.entries_export') | 33 | return $this->get('wallabag_core.helper.entries_export') |
34 | ->setEntries($entry) | 34 | ->setEntries($entry) |
35 | ->updateTitle('entry') | 35 | ->updateTitle('entry') |
36 | ->updateAuthor('entry') | ||
36 | ->exportAs($format); | 37 | ->exportAs($format); |
37 | } catch (\InvalidArgumentException $e) { | 38 | } catch (\InvalidArgumentException $e) { |
38 | throw new NotFoundHttpException($e->getMessage()); | 39 | throw new NotFoundHttpException($e->getMessage()); |
@@ -76,6 +77,7 @@ class ExportController extends Controller | |||
76 | return $this->get('wallabag_core.helper.entries_export') | 77 | return $this->get('wallabag_core.helper.entries_export') |
77 | ->setEntries($entries) | 78 | ->setEntries($entries) |
78 | ->updateTitle($method) | 79 | ->updateTitle($method) |
80 | ->updateAuthor($method) | ||
79 | ->exportAs($format); | 81 | ->exportAs($format); |
80 | } catch (\InvalidArgumentException $e) { | 82 | } catch (\InvalidArgumentException $e) { |
81 | throw new NotFoundHttpException($e->getMessage()); | 83 | throw new NotFoundHttpException($e->getMessage()); |
diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index cd74cc4f..d749dcf9 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php | |||
@@ -18,7 +18,7 @@ class EntriesExport | |||
18 | private $logoPath; | 18 | private $logoPath; |
19 | private $title = ''; | 19 | private $title = ''; |
20 | private $entries = []; | 20 | private $entries = []; |
21 | private $authors = ['wallabag']; | 21 | private $author = 'wallabag'; |
22 | private $language = ''; | 22 | private $language = ''; |
23 | private $footerTemplate = '<div style="text-align:center;"> | 23 | private $footerTemplate = '<div style="text-align:center;"> |
24 | <p>Produced by wallabag with %EXPORT_METHOD%</p> | 24 | <p>Produced by wallabag with %EXPORT_METHOD%</p> |
@@ -73,6 +73,24 @@ class EntriesExport | |||
73 | } | 73 | } |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * Sets the author for just one entry. | ||
77 | * | ||
78 | * @param string $method Method to get articles | ||
79 | * | ||
80 | * @return EntriesExport | ||
81 | */ | ||
82 | public function updateAuthor($method) | ||
83 | { | ||
84 | $this->author = $method.' authors'; | ||
85 | |||
86 | if ('entry' === $method) { | ||
87 | $this->author = $this->entries[0]->getDomainName(); | ||
88 | } | ||
89 | |||
90 | return $this; | ||
91 | } | ||
92 | |||
93 | /** | ||
76 | * Sets the output format. | 94 | * Sets the output format. |
77 | * | 95 | * |
78 | * @param string $format | 96 | * @param string $format |
@@ -128,9 +146,7 @@ class EntriesExport | |||
128 | $book->setLanguage($this->language); | 146 | $book->setLanguage($this->language); |
129 | $book->setDescription('Some articles saved on my wallabag'); | 147 | $book->setDescription('Some articles saved on my wallabag'); |
130 | 148 | ||
131 | foreach ($this->authors as $author) { | 149 | $book->setAuthor($this->author, $this->author); |
132 | $book->setAuthor($author, $author); | ||
133 | } | ||
134 | 150 | ||
135 | // I hope this is a non existant address :) | 151 | // I hope this is a non existant address :) |
136 | $book->setPublisher('wallabag', 'wallabag'); | 152 | $book->setPublisher('wallabag', 'wallabag'); |
@@ -196,7 +212,7 @@ class EntriesExport | |||
196 | * Book metadata | 212 | * Book metadata |
197 | */ | 213 | */ |
198 | $content->set('title', $this->title); | 214 | $content->set('title', $this->title); |
199 | $content->set('author', implode($this->authors)); | 215 | $content->set('author', $this->author); |
200 | $content->set('subject', $this->title); | 216 | $content->set('subject', $this->title); |
201 | 217 | ||
202 | /* | 218 | /* |
@@ -247,7 +263,7 @@ class EntriesExport | |||
247 | * Book metadata | 263 | * Book metadata |
248 | */ | 264 | */ |
249 | $pdf->SetCreator(PDF_CREATOR); | 265 | $pdf->SetCreator(PDF_CREATOR); |
250 | $pdf->SetAuthor('wallabag'); | 266 | $pdf->SetAuthor($this->author); |
251 | $pdf->SetTitle($this->title); | 267 | $pdf->SetTitle($this->title); |
252 | $pdf->SetSubject('Articles via wallabag'); | 268 | $pdf->SetSubject('Articles via wallabag'); |
253 | $pdf->SetKeywords('wallabag'); | 269 | $pdf->SetKeywords('wallabag'); |