mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-23 17:41:01 +00:00
Merge pull request #3266 from egilli/export-domain-as-author
Use the article publisher as author for exported files
This commit is contained in:
commit
f39152ad6e
4 changed files with 35 additions and 6 deletions
|
@ -180,6 +180,7 @@ class EntryRestController extends WallabagRestController
|
||||||
return $this->get('wallabag_core.helper.entries_export')
|
return $this->get('wallabag_core.helper.entries_export')
|
||||||
->setEntries($entry)
|
->setEntries($entry)
|
||||||
->updateTitle('entry')
|
->updateTitle('entry')
|
||||||
|
->updateAuthor('entry')
|
||||||
->exportAs($request->attributes->get('_format'));
|
->exportAs($request->attributes->get('_format'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ class ExportCommand extends ContainerAwareCommand
|
||||||
$data = $this->getContainer()->get('wallabag_core.helper.entries_export')
|
$data = $this->getContainer()->get('wallabag_core.helper.entries_export')
|
||||||
->setEntries($entries)
|
->setEntries($entries)
|
||||||
->updateTitle('All')
|
->updateTitle('All')
|
||||||
|
->updateAuthor('All')
|
||||||
->exportJsonData();
|
->exportJsonData();
|
||||||
file_put_contents($filePath, $data);
|
file_put_contents($filePath, $data);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
|
|
|
@ -33,6 +33,7 @@ class ExportController extends Controller
|
||||||
return $this->get('wallabag_core.helper.entries_export')
|
return $this->get('wallabag_core.helper.entries_export')
|
||||||
->setEntries($entry)
|
->setEntries($entry)
|
||||||
->updateTitle('entry')
|
->updateTitle('entry')
|
||||||
|
->updateAuthor('entry')
|
||||||
->exportAs($format);
|
->exportAs($format);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
throw new NotFoundHttpException($e->getMessage());
|
throw new NotFoundHttpException($e->getMessage());
|
||||||
|
@ -76,6 +77,7 @@ class ExportController extends Controller
|
||||||
return $this->get('wallabag_core.helper.entries_export')
|
return $this->get('wallabag_core.helper.entries_export')
|
||||||
->setEntries($entries)
|
->setEntries($entries)
|
||||||
->updateTitle($method)
|
->updateTitle($method)
|
||||||
|
->updateAuthor($method)
|
||||||
->exportAs($format);
|
->exportAs($format);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
throw new NotFoundHttpException($e->getMessage());
|
throw new NotFoundHttpException($e->getMessage());
|
||||||
|
|
|
@ -18,7 +18,7 @@ class EntriesExport
|
||||||
private $logoPath;
|
private $logoPath;
|
||||||
private $title = '';
|
private $title = '';
|
||||||
private $entries = [];
|
private $entries = [];
|
||||||
private $authors = ['wallabag'];
|
private $author = 'wallabag';
|
||||||
private $language = '';
|
private $language = '';
|
||||||
private $footerTemplate = '<div style="text-align:center;">
|
private $footerTemplate = '<div style="text-align:center;">
|
||||||
<p>Produced by wallabag with %EXPORT_METHOD%</p>
|
<p>Produced by wallabag with %EXPORT_METHOD%</p>
|
||||||
|
@ -72,6 +72,33 @@ class EntriesExport
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the author for one entry or category.
|
||||||
|
*
|
||||||
|
* The publishers are used, or the domain name if empty.
|
||||||
|
*
|
||||||
|
* @param string $method Method to get articles
|
||||||
|
*
|
||||||
|
* @return EntriesExport
|
||||||
|
*/
|
||||||
|
public function updateAuthor($method)
|
||||||
|
{
|
||||||
|
if ('entry' !== $method) {
|
||||||
|
$this->author = $method . ' authors';
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->author = $this->entries[0]->getDomainName();
|
||||||
|
|
||||||
|
$publishedBy = $this->entries[0]->getPublishedBy();
|
||||||
|
if (!empty($publishedBy)) {
|
||||||
|
$this->author = implode(', ', $publishedBy);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the output format.
|
* Sets the output format.
|
||||||
*
|
*
|
||||||
|
@ -128,9 +155,7 @@ class EntriesExport
|
||||||
$book->setLanguage($this->language);
|
$book->setLanguage($this->language);
|
||||||
$book->setDescription('Some articles saved on my wallabag');
|
$book->setDescription('Some articles saved on my wallabag');
|
||||||
|
|
||||||
foreach ($this->authors as $author) {
|
$book->setAuthor($this->author, $this->author);
|
||||||
$book->setAuthor($author, $author);
|
|
||||||
}
|
|
||||||
|
|
||||||
// I hope this is a non existant address :)
|
// I hope this is a non existant address :)
|
||||||
$book->setPublisher('wallabag', 'wallabag');
|
$book->setPublisher('wallabag', 'wallabag');
|
||||||
|
@ -196,7 +221,7 @@ class EntriesExport
|
||||||
* Book metadata
|
* Book metadata
|
||||||
*/
|
*/
|
||||||
$content->set('title', $this->title);
|
$content->set('title', $this->title);
|
||||||
$content->set('author', implode($this->authors));
|
$content->set('author', $this->author);
|
||||||
$content->set('subject', $this->title);
|
$content->set('subject', $this->title);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -247,7 +272,7 @@ class EntriesExport
|
||||||
* Book metadata
|
* Book metadata
|
||||||
*/
|
*/
|
||||||
$pdf->SetCreator(PDF_CREATOR);
|
$pdf->SetCreator(PDF_CREATOR);
|
||||||
$pdf->SetAuthor('wallabag');
|
$pdf->SetAuthor($this->author);
|
||||||
$pdf->SetTitle($this->title);
|
$pdf->SetTitle($this->title);
|
||||||
$pdf->SetSubject('Articles via wallabag');
|
$pdf->SetSubject('Articles via wallabag');
|
||||||
$pdf->SetKeywords('wallabag');
|
$pdf->SetKeywords('wallabag');
|
||||||
|
|
Loading…
Reference in a new issue