aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
authorThomas Citharel <citharel@info21-27.iut45.univ-orleans.fr>2016-01-25 17:31:45 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-02-04 20:30:51 +0100
commit6c08fb68b8e7883df7f6c1a2ba7c56ced4c1153b (patch)
treece5149ae9b19dce99b499cae3fcfaf200c41226a /src/Wallabag
parent27c837dcd1640a7f5f0ed197e882eefd53ba8273 (diff)
downloadwallabag-6c08fb68b8e7883df7f6c1a2ba7c56ced4c1153b.tar.gz
wallabag-6c08fb68b8e7883df7f6c1a2ba7c56ced4c1153b.tar.zst
wallabag-6c08fb68b8e7883df7f6c1a2ba7c56ced4c1153b.zip
add txt export
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Helper/EntriesExport.php22
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig2
2 files changed, 23 insertions, 1 deletions
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;
6use JMS\Serializer\SerializationContext; 6use JMS\Serializer\SerializationContext;
7use JMS\Serializer\SerializerBuilder; 7use JMS\Serializer\SerializerBuilder;
8use PHPePub\Core\EPub; 8use PHPePub\Core\EPub;
9use Html2Text\Html2Text;
9use PHPePub\Core\Structure\OPF\DublinCore; 10use PHPePub\Core\Structure\OPF\DublinCore;
10use Symfony\Component\HttpFoundation\Response; 11use Symfony\Component\HttpFoundation\Response;
11use Craue\ConfigBundle\Util\Config; 12use Craue\ConfigBundle\Util\Config;
@@ -99,6 +100,8 @@ class EntriesExport
99 100
100 case 'xml': 101 case 'xml':
101 return $this->produceXML(); 102 return $this->produceXML();
103 case 'txt':
104 return $this->produceTXT();
102 } 105 }
103 106
104 throw new \InvalidArgumentException(sprintf('The format "%s" is not yet supported.', $format)); 107 throw new \InvalidArgumentException(sprintf('The format "%s" is not yet supported.', $format));
@@ -359,6 +362,25 @@ class EntriesExport
359 )->send(); 362 )->send();
360 } 363 }
361 364
365 private function produceTXT()
366 {
367 $content = '';
368 foreach ($this->entries as $entry) {
369 $content .= $entry->getTitle();
370 $content .= strip_tags($entry->getContent());
371 }
372 return Response::create(
373 $content,
374 200,
375 array(
376 'Content-type' => 'text/plain',
377 'Content-Disposition' => 'attachment; filename="'.$this->title.'.txt"',
378 'Content-Transfer-Encoding' => 'UTF-8',
379 )
380 )->send();
381 }
382
383
362 /** 384 /**
363 * Return a Serializer object for producing processes that need it (JSON & XML). 385 * Return a Serializer object for producing processes that need it (JSON & XML).
364 * 386 *
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 @@
118 {% if craue_setting('export_pdf') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'pdf' }) }}" title="Generate PDF file">PDF</a></li>{% endif %} 118 {% if craue_setting('export_pdf') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'pdf' }) }}" title="Generate PDF file">PDF</a></li>{% endif %}
119 {% if craue_setting('export_csv') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'csv' }) }}" title="Generate CSV file">CSV</a></li>{% endif %} 119 {% if craue_setting('export_csv') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'csv' }) }}" title="Generate CSV file">CSV</a></li>{% endif %}
120 {% if craue_setting('export_json') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'json' }) }}" title="Generate JSON file">JSON</a></li>{% endif %} 120 {% if craue_setting('export_json') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'json' }) }}" title="Generate JSON file">JSON</a></li>{% endif %}
121 {% if craue_setting('export_txt') %}<li><del><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'txt' }) }}" title="Generate TXT file">TXT</a></del></li>{% endif %} 121 {% if craue_setting('export_txt') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'txt' }) }}" title="Generate TXT file">TXT</a></li>{% endif %}
122 {% if craue_setting('export_xml') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'xml' }) }}" title="Generate XML file">XML</a></li>{% endif %} 122 {% if craue_setting('export_xml') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'xml' }) }}" title="Generate XML file">XML</a></li>{% endif %}
123 </ul> 123 </ul>
124 </div> 124 </div>