diff --git a/src/Wallabag/CoreBundle/Controller/ExportController.php b/src/Wallabag/CoreBundle/Controller/ExportController.php
index 3921881a9..c958a382c 100644
--- a/src/Wallabag/CoreBundle/Controller/ExportController.php
+++ b/src/Wallabag/CoreBundle/Controller/ExportController.php
@@ -61,13 +61,21 @@ class ExportController extends AbstractController
*
* @return Response
*/
- public function downloadEntriesAction(Request $request, EntryRepository $entryRepository, TagRepository $tagRepository, EntriesExport $entriesExport, string $format, string $category)
+ public function downloadEntriesAction(Request $request, EntryRepository $entryRepository, TagRepository $tagRepository, EntriesExport $entriesExport, string $format, string $category, int $entry = 0)
{
$method = ucfirst($category);
$methodBuilder = 'getBuilderFor' . $method . 'ByUser';
$title = $method;
- if ('tag_entries' === $category) {
+ if ('same_domain' === $category) {
+ $entries = $entryRepository->getBuilderForSameDomainByUser(
+ $this->getUser()->getId(),
+ $request->get('entry')
+ )->getQuery()
+ ->getResult();
+
+ $title = 'Same domain';
+ } elseif ('tag_entries' === $category) {
$tag = $tagRepository->findOneBySlug($request->query->get('tag'));
$entries = $entryRepository->findAllByTagId(
diff --git a/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig
index a08d1b1fb..443e4fb64 100644
--- a/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/Entry/entries.html.twig
@@ -96,16 +96,17 @@
{% if searchTerm is defined %}
{% set export_search_term = searchTerm %}
{% endif %}
+ {% set entry = app.request.attributes.get('id') %}
{% set previous_route = app.request.attributes.get('currentRoute') %}
{{ 'entry.list.export_title'|trans }}
- {% if craue_setting('export_epub') %}- EPUB
{% endif %}
- {% if craue_setting('export_mobi') %}- MOBI (deprecated)
{% endif %}
- {% if craue_setting('export_pdf') %}- PDF
{% endif %}
- {% if craue_setting('export_json') %}- JSON
{% endif %}
- {% if craue_setting('export_csv') %}- CSV
{% endif %}
- {% if craue_setting('export_txt') %}- TXT
{% endif %}
- {% if craue_setting('export_xml') %}- XML
{% endif %}
+ {% if craue_setting('export_epub') %}- EPUB
{% endif %}
+ {% if craue_setting('export_mobi') %}- MOBI (deprecated)
{% endif %}
+ {% if craue_setting('export_pdf') %}- PDF
{% endif %}
+ {% if craue_setting('export_json') %}- JSON
{% endif %}
+ {% if craue_setting('export_csv') %}- CSV
{% endif %}
+ {% if craue_setting('export_txt') %}- TXT
{% endif %}
+ {% if craue_setting('export_xml') %}- XML
{% endif %}
diff --git a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php
index 26191178b..8ed942020 100644
--- a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php
@@ -10,6 +10,8 @@ class ExportControllerTest extends WallabagCoreTestCase
{
private $adminEntry;
private $bobEntry;
+ private $sameDomainEntry;
+ private $sameDomainEntry2;
public function testLogin()
{
@@ -326,6 +328,26 @@ class ExportControllerTest extends WallabagCoreTestCase
$this->assertNotEmpty('updated_at', (string) $content->entry[0]->updated_at);
}
+ public function testJsonExportFromSameDomain()
+ {
+ $this->logInAs('admin');
+ $client = $this->getTestClient();
+
+ ob_start();
+ $crawler = $client->request('GET', '/export/same_domain.json?entry=1');
+ ob_end_clean();
+
+ $this->assertSame(200, $client->getResponse()->getStatusCode());
+
+ $headers = $client->getResponse()->headers;
+ $this->assertSame('application/json', $headers->get('content-type'));
+ $this->assertSame('attachment; filename="Same domain articles.json"', $headers->get('content-disposition'));
+ $this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
+
+ $content = json_decode($client->getResponse()->getContent(), true);
+ $this->assertCount(4, $content);
+ }
+
private function setUpForJsonExportFromSearch()
{
$client = $this->getTestClient();