From: Étienne Gilli Date: Sat, 8 Jul 2017 15:55:58 +0000 (+0200) Subject: Use the article domain as author for export files X-Git-Tag: 2.3.0~31^2~39^2~2 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=07320a2bd25c6ace1f9b1aa06b1b08e8dbf4f4fa;p=github%2Fwallabag%2Fwallabag.git 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. --- 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 return $this->get('wallabag_core.helper.entries_export') ->setEntries($entry) ->updateTitle('entry') + ->updateAuthor('entry') ->exportAs($request->attributes->get('_format')); } 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 $data = $this->getContainer()->get('wallabag_core.helper.entries_export') ->setEntries($entries) ->updateTitle('All') + ->updateAuthor('All') ->exportJsonData(); file_put_contents($filePath, $data); } 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 return $this->get('wallabag_core.helper.entries_export') ->setEntries($entry) ->updateTitle('entry') + ->updateAuthor('entry') ->exportAs($format); } catch (\InvalidArgumentException $e) { throw new NotFoundHttpException($e->getMessage()); @@ -76,6 +77,7 @@ class ExportController extends Controller return $this->get('wallabag_core.helper.entries_export') ->setEntries($entries) ->updateTitle($method) + ->updateAuthor($method) ->exportAs($format); } catch (\InvalidArgumentException $e) { 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 private $logoPath; private $title = ''; private $entries = []; - private $authors = ['wallabag']; + private $author = 'wallabag'; private $language = ''; private $footerTemplate = '

Produced by wallabag with %EXPORT_METHOD%

@@ -72,6 +72,24 @@ class EntriesExport return $this; } + /** + * Sets the author for just one entry. + * + * @param string $method Method to get articles + * + * @return EntriesExport + */ + public function updateAuthor($method) + { + $this->author = $method.' authors'; + + if ('entry' === $method) { + $this->author = $this->entries[0]->getDomainName(); + } + + return $this; + } + /** * Sets the output format. * @@ -128,9 +146,7 @@ class EntriesExport $book->setLanguage($this->language); $book->setDescription('Some articles saved on my wallabag'); - foreach ($this->authors as $author) { - $book->setAuthor($author, $author); - } + $book->setAuthor($this->author, $this->author); // I hope this is a non existant address :) $book->setPublisher('wallabag', 'wallabag'); @@ -196,7 +212,7 @@ class EntriesExport * Book metadata */ $content->set('title', $this->title); - $content->set('author', implode($this->authors)); + $content->set('author', $this->author); $content->set('subject', $this->title); /* @@ -247,7 +263,7 @@ class EntriesExport * Book metadata */ $pdf->SetCreator(PDF_CREATOR); - $pdf->SetAuthor('wallabag'); + $pdf->SetAuthor($this->author); $pdf->SetTitle($this->title); $pdf->SetSubject('Articles via wallabag'); $pdf->SetKeywords('wallabag');