From 6c08fb68b8e7883df7f6c1a2ba7c56ced4c1153b Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 25 Jan 2016 17:31:45 +0100 Subject: [PATCH] add txt export --- app/config/parameters.yml.dist | 1 - .../CoreBundle/Helper/EntriesExport.php | 22 +++++++++++++++++++ .../themes/material/Entry/entry.html.twig | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index 7c7413fb..5d6d742b 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -43,5 +43,4 @@ parameters: # fosuser stuff fosuser_confirmation: true - from_email: no-reply@wallabag.org diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index 965a40b6..79fe6eaa 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php @@ -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). * diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig index dad96187..2d3fd516 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig @@ -118,7 +118,7 @@ {% if craue_setting('export_pdf') %}
  • PDF
  • {% endif %} {% if craue_setting('export_csv') %}
  • CSV
  • {% endif %} {% if craue_setting('export_json') %}
  • JSON
  • {% endif %} - {% if craue_setting('export_txt') %}
  • TXT
  • {% endif %} + {% if craue_setting('export_txt') %}
  • TXT
  • {% endif %} {% if craue_setting('export_xml') %}
  • XML
  • {% endif %} -- 2.41.0