]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
add txt export
authorThomas Citharel <citharel@info21-27.iut45.univ-orleans.fr>
Mon, 25 Jan 2016 16:31:45 +0000 (17:31 +0100)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Thu, 4 Feb 2016 19:30:51 +0000 (20:30 +0100)
app/config/parameters.yml.dist
src/Wallabag/CoreBundle/Helper/EntriesExport.php
src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig

index 7c7413fb9b276c5c4338724c41d90c25f53a7679..5d6d742badd199d2665f83f07e822fcd059a42f5 100644 (file)
@@ -43,5 +43,4 @@ parameters:
 
     # fosuser stuff
     fosuser_confirmation: true
-
     from_email: no-reply@wallabag.org
index 965a40b6a1ec190bb06c4f0bb0956fcd0f709ada..79fe6eaadc8f6eff7b4e5a5b9f4064f88e90b6cb 100644 (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).
      *
index dad96187cfe8b561772b0a6791dcb44abd2bff24..2d3fd5169f7d134a25d5fadfc43ef44f42f17e09 100644 (file)
                     {% if craue_setting('export_pdf') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'pdf' }) }}" title="Generate PDF file">PDF</a></li>{% endif %}
                     {% if craue_setting('export_csv') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'csv' }) }}" title="Generate CSV file">CSV</a></li>{% endif %}
                     {% if craue_setting('export_json') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'json' }) }}" title="Generate JSON file">JSON</a></li>{% endif %}
-                    {% 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 %}
+                    {% if craue_setting('export_txt') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'txt' }) }}" title="Generate TXT file">TXT</a></li>{% endif %}
                     {% if craue_setting('export_xml') %}<li><a href="{{ path('export_entry', { 'id': entry.id, 'format': 'xml' }) }}" title="Generate XML file">XML</a></li>{% endif %}
                 </ul>
             </div>