mirror of
https://github.com/wallabag/wallabag.git
synced 2025-07-22 17:18:37 +00:00
add txt export
This commit is contained in:
parent
27c837dcd1
commit
6c08fb68b8
3 changed files with 23 additions and 2 deletions
|
@ -43,5 +43,4 @@ parameters:
|
||||||
|
|
||||||
# fosuser stuff
|
# fosuser stuff
|
||||||
fosuser_confirmation: true
|
fosuser_confirmation: true
|
||||||
|
|
||||||
from_email: no-reply@wallabag.org
|
from_email: no-reply@wallabag.org
|
||||||
|
|
|
@ -6,6 +6,7 @@ use JMS\Serializer;
|
||||||
use JMS\Serializer\SerializationContext;
|
use JMS\Serializer\SerializationContext;
|
||||||
use JMS\Serializer\SerializerBuilder;
|
use JMS\Serializer\SerializerBuilder;
|
||||||
use PHPePub\Core\EPub;
|
use PHPePub\Core\EPub;
|
||||||
|
use Html2Text\Html2Text;
|
||||||
use PHPePub\Core\Structure\OPF\DublinCore;
|
use PHPePub\Core\Structure\OPF\DublinCore;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Craue\ConfigBundle\Util\Config;
|
use Craue\ConfigBundle\Util\Config;
|
||||||
|
@ -99,6 +100,8 @@ class EntriesExport
|
||||||
|
|
||||||
case 'xml':
|
case 'xml':
|
||||||
return $this->produceXML();
|
return $this->produceXML();
|
||||||
|
case 'txt':
|
||||||
|
return $this->produceTXT();
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \InvalidArgumentException(sprintf('The format "%s" is not yet supported.', $format));
|
throw new \InvalidArgumentException(sprintf('The format "%s" is not yet supported.', $format));
|
||||||
|
@ -359,6 +362,25 @@ class EntriesExport
|
||||||
)->send();
|
)->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).
|
* Return a Serializer object for producing processes that need it (JSON & XML).
|
||||||
*
|
*
|
||||||
|
|
|
@ -118,7 +118,7 @@
|
||||||
{% 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_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_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_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 %}
|
{% 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>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue