1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-08-01 17:38:38 +00:00

add txt export

This commit is contained in:
Thomas Citharel 2016-01-25 17:31:45 +01:00 committed by Jeremy Benoist
parent 27c837dcd1
commit 6c08fb68b8
3 changed files with 23 additions and 2 deletions

View file

@ -6,6 +6,7 @@ use JMS\Serializer;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\SerializerBuilder;
use PHPePub\Core\EPub;
use Html2Text\Html2Text;
use PHPePub\Core\Structure\OPF\DublinCore;
use Symfony\Component\HttpFoundation\Response;
use Craue\ConfigBundle\Util\Config;
@ -99,6 +100,8 @@ class EntriesExport
case 'xml':
return $this->produceXML();
case 'txt':
return $this->produceTXT();
}
throw new \InvalidArgumentException(sprintf('The format "%s" is not yet supported.', $format));
@ -359,6 +362,25 @@ class EntriesExport
)->send();
}
private function produceTXT()
{
$content = '';
foreach ($this->entries as $entry) {
$content .= $entry->getTitle();
$content .= strip_tags($entry->getContent());
}
return Response::create(
$content,
200,
array(
'Content-type' => 'text/plain',
'Content-Disposition' => 'attachment; filename="'.$this->title.'.txt"',
'Content-Transfer-Encoding' => 'UTF-8',
)
)->send();
}
/**
* Return a Serializer object for producing processes that need it (JSON & XML).
*