aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle
diff options
context:
space:
mode:
authorlizyn <zhiylin@outlook.com>2020-02-24 10:04:13 +0800
committerGitHub <noreply@github.com>2020-02-24 10:04:13 +0800
commitb19df31d78d881a43bcf6b3215e5fc3781e8e8aa (patch)
treed0d9861694a4b5e5fbfdbeb53c255ecd15fe9328 /src/Wallabag/ImportBundle
parent4d0c632c70ea50d459c3c55ddda2e0f394dd51cb (diff)
parent04d918cae0227c06a41d27fb6533dddbf30dfe71 (diff)
downloadwallabag-b19df31d78d881a43bcf6b3215e5fc3781e8e8aa.tar.gz
wallabag-b19df31d78d881a43bcf6b3215e5fc3781e8e8aa.tar.zst
wallabag-b19df31d78d881a43bcf6b3215e5fc3781e8e8aa.zip
Merge pull request #1 from wallabag/master
Keep up with the master again
Diffstat (limited to 'src/Wallabag/ImportBundle')
-rw-r--r--src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php7
-rw-r--r--src/Wallabag/ImportBundle/Controller/BrowserController.php4
-rw-r--r--src/Wallabag/ImportBundle/Controller/ChromeController.php2
-rw-r--r--src/Wallabag/ImportBundle/Controller/ElcuratorController.php41
-rw-r--r--src/Wallabag/ImportBundle/Controller/FirefoxController.php2
-rw-r--r--src/Wallabag/ImportBundle/Controller/ImportController.php4
-rw-r--r--src/Wallabag/ImportBundle/Controller/InstapaperController.php2
-rw-r--r--src/Wallabag/ImportBundle/Controller/PinboardController.php2
-rw-r--r--src/Wallabag/ImportBundle/Controller/PocketController.php2
-rw-r--r--src/Wallabag/ImportBundle/Controller/ReadabilityController.php2
-rw-r--r--src/Wallabag/ImportBundle/Controller/WallabagController.php2
-rw-r--r--src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php2
-rw-r--r--src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/AbstractImport.php25
-rw-r--r--src/Wallabag/ImportBundle/Import/BrowserImport.php18
-rw-r--r--src/Wallabag/ImportBundle/Import/ChromeImport.php14
-rw-r--r--src/Wallabag/ImportBundle/Import/ElcuratorImport.php54
-rw-r--r--src/Wallabag/ImportBundle/Import/FirefoxImport.php14
-rw-r--r--src/Wallabag/ImportBundle/Import/ImportChain.php3
-rw-r--r--src/Wallabag/ImportBundle/Import/InstapaperImport.php21
-rw-r--r--src/Wallabag/ImportBundle/Import/PinboardImport.php14
-rw-r--r--src/Wallabag/ImportBundle/Import/PocketImport.php108
-rw-r--r--src/Wallabag/ImportBundle/Import/ReadabilityImport.php14
-rw-r--r--src/Wallabag/ImportBundle/Import/WallabagImport.php16
-rw-r--r--src/Wallabag/ImportBundle/Import/WallabagV1Import.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/WallabagV2Import.php4
-rw-r--r--src/Wallabag/ImportBundle/Resources/config/rabbit.yml8
-rw-r--r--src/Wallabag/ImportBundle/Resources/config/redis.yml21
-rw-r--r--src/Wallabag/ImportBundle/Resources/config/services.yml28
-rw-r--r--src/Wallabag/ImportBundle/Resources/views/Elcurator/index.html.twig3
30 files changed, 335 insertions, 106 deletions
diff --git a/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php b/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php
index b035f5cc..e4bfbdf0 100644
--- a/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php
+++ b/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php
@@ -52,6 +52,13 @@ abstract class AbstractConsumer
52 52
53 $this->import->setUser($user); 53 $this->import->setUser($user);
54 54
55 if (false === $this->import->validateEntry($storedEntry)) {
56 $this->logger->warning('Entry is invalid', ['entry' => $storedEntry]);
57
58 // return true to skip message
59 return true;
60 }
61
55 $entry = $this->import->parseEntry($storedEntry); 62 $entry = $this->import->parseEntry($storedEntry);
56 63
57 if (null === $entry) { 64 if (null === $entry) {
diff --git a/src/Wallabag/ImportBundle/Controller/BrowserController.php b/src/Wallabag/ImportBundle/Controller/BrowserController.php
index 6418925c..8c2bdfe5 100644
--- a/src/Wallabag/ImportBundle/Controller/BrowserController.php
+++ b/src/Wallabag/ImportBundle/Controller/BrowserController.php
@@ -2,10 +2,10 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller; 5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request; 6use Symfony\Component\HttpFoundation\Request;
8use Symfony\Component\HttpFoundation\Response; 7use Symfony\Component\HttpFoundation\Response;
8use Symfony\Component\Routing\Annotation\Route;
9use Wallabag\ImportBundle\Form\Type\UploadImportType; 9use Wallabag\ImportBundle\Form\Type\UploadImportType;
10 10
11abstract class BrowserController extends Controller 11abstract class BrowserController extends Controller
@@ -13,8 +13,6 @@ abstract class BrowserController extends Controller
13 /** 13 /**
14 * @Route("/browser", name="import_browser") 14 * @Route("/browser", name="import_browser")
15 * 15 *
16 * @param Request $request
17 *
18 * @return Response 16 * @return Response
19 */ 17 */
20 public function indexAction(Request $request) 18 public function indexAction(Request $request)
diff --git a/src/Wallabag/ImportBundle/Controller/ChromeController.php b/src/Wallabag/ImportBundle/Controller/ChromeController.php
index 0cb418a1..6628cdb0 100644
--- a/src/Wallabag/ImportBundle/Controller/ChromeController.php
+++ b/src/Wallabag/ImportBundle/Controller/ChromeController.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Component\HttpFoundation\Request; 5use Symfony\Component\HttpFoundation\Request;
6use Symfony\Component\Routing\Annotation\Route;
7 7
8class ChromeController extends BrowserController 8class ChromeController extends BrowserController
9{ 9{
diff --git a/src/Wallabag/ImportBundle/Controller/ElcuratorController.php b/src/Wallabag/ImportBundle/Controller/ElcuratorController.php
new file mode 100644
index 00000000..174c2c96
--- /dev/null
+++ b/src/Wallabag/ImportBundle/Controller/ElcuratorController.php
@@ -0,0 +1,41 @@
1<?php
2
3namespace Wallabag\ImportBundle\Controller;
4
5use Symfony\Component\HttpFoundation\Request;
6use Symfony\Component\Routing\Annotation\Route;
7
8class ElcuratorController extends WallabagController
9{
10 /**
11 * @Route("/elcurator", name="import_elcurator")
12 */
13 public function indexAction(Request $request)
14 {
15 return parent::indexAction($request);
16 }
17
18 /**
19 * {@inheritdoc}
20 */
21 protected function getImportService()
22 {
23 $service = $this->get('wallabag_import.elcurator.import');
24
25 if ($this->get('craue_config')->get('import_with_rabbitmq')) {
26 $service->setProducer($this->get('old_sound_rabbit_mq.import_elcurator_producer'));
27 } elseif ($this->get('craue_config')->get('import_with_redis')) {
28 $service->setProducer($this->get('wallabag_import.producer.redis.elcurator'));
29 }
30
31 return $service;
32 }
33
34 /**
35 * {@inheritdoc}
36 */
37 protected function getImportTemplate()
38 {
39 return 'WallabagImportBundle:Elcurator:index.html.twig';
40 }
41}
diff --git a/src/Wallabag/ImportBundle/Controller/FirefoxController.php b/src/Wallabag/ImportBundle/Controller/FirefoxController.php
index 88697f9d..dce8455f 100644
--- a/src/Wallabag/ImportBundle/Controller/FirefoxController.php
+++ b/src/Wallabag/ImportBundle/Controller/FirefoxController.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Component\HttpFoundation\Request; 5use Symfony\Component\HttpFoundation\Request;
6use Symfony\Component\Routing\Annotation\Route;
7 7
8class FirefoxController extends BrowserController 8class FirefoxController extends BrowserController
9{ 9{
diff --git a/src/Wallabag/ImportBundle/Controller/ImportController.php b/src/Wallabag/ImportBundle/Controller/ImportController.php
index 7e4fd174..5a7e53d6 100644
--- a/src/Wallabag/ImportBundle/Controller/ImportController.php
+++ b/src/Wallabag/ImportBundle/Controller/ImportController.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller; 5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6use Symfony\Component\Routing\Annotation\Route;
7 7
8class ImportController extends Controller 8class ImportController extends Controller
9{ 9{
@@ -43,6 +43,7 @@ class ImportController extends Controller
43 + $this->getTotalMessageInRabbitQueue('chrome') 43 + $this->getTotalMessageInRabbitQueue('chrome')
44 + $this->getTotalMessageInRabbitQueue('instapaper') 44 + $this->getTotalMessageInRabbitQueue('instapaper')
45 + $this->getTotalMessageInRabbitQueue('pinboard') 45 + $this->getTotalMessageInRabbitQueue('pinboard')
46 + $this->getTotalMessageInRabbitQueue('elcurator')
46 ; 47 ;
47 } catch (\Exception $e) { 48 } catch (\Exception $e) {
48 $rabbitNotInstalled = true; 49 $rabbitNotInstalled = true;
@@ -59,6 +60,7 @@ class ImportController extends Controller
59 + $redis->llen('wallabag.import.chrome') 60 + $redis->llen('wallabag.import.chrome')
60 + $redis->llen('wallabag.import.instapaper') 61 + $redis->llen('wallabag.import.instapaper')
61 + $redis->llen('wallabag.import.pinboard') 62 + $redis->llen('wallabag.import.pinboard')
63 + $redis->llen('wallabag.import.elcurator')
62 ; 64 ;
63 } catch (\Exception $e) { 65 } catch (\Exception $e) {
64 $redisNotInstalled = true; 66 $redisNotInstalled = true;
diff --git a/src/Wallabag/ImportBundle/Controller/InstapaperController.php b/src/Wallabag/ImportBundle/Controller/InstapaperController.php
index f184baf9..faed3b72 100644
--- a/src/Wallabag/ImportBundle/Controller/InstapaperController.php
+++ b/src/Wallabag/ImportBundle/Controller/InstapaperController.php
@@ -2,9 +2,9 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller; 5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request; 6use Symfony\Component\HttpFoundation\Request;
7use Symfony\Component\Routing\Annotation\Route;
8use Wallabag\ImportBundle\Form\Type\UploadImportType; 8use Wallabag\ImportBundle\Form\Type\UploadImportType;
9 9
10class InstapaperController extends Controller 10class InstapaperController extends Controller
diff --git a/src/Wallabag/ImportBundle/Controller/PinboardController.php b/src/Wallabag/ImportBundle/Controller/PinboardController.php
index 6f54c69a..cc6fae79 100644
--- a/src/Wallabag/ImportBundle/Controller/PinboardController.php
+++ b/src/Wallabag/ImportBundle/Controller/PinboardController.php
@@ -2,9 +2,9 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller; 5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request; 6use Symfony\Component\HttpFoundation\Request;
7use Symfony\Component\Routing\Annotation\Route;
8use Wallabag\ImportBundle\Form\Type\UploadImportType; 8use Wallabag\ImportBundle\Form\Type\UploadImportType;
9 9
10class PinboardController extends Controller 10class PinboardController extends Controller
diff --git a/src/Wallabag/ImportBundle/Controller/PocketController.php b/src/Wallabag/ImportBundle/Controller/PocketController.php
index 9f28819a..71ceb427 100644
--- a/src/Wallabag/ImportBundle/Controller/PocketController.php
+++ b/src/Wallabag/ImportBundle/Controller/PocketController.php
@@ -2,10 +2,10 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller; 5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\Form\Extension\Core\Type\CheckboxType; 6use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
8use Symfony\Component\HttpFoundation\Request; 7use Symfony\Component\HttpFoundation\Request;
8use Symfony\Component\Routing\Annotation\Route;
9use Symfony\Component\Routing\Generator\UrlGeneratorInterface; 9use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
10 10
11class PocketController extends Controller 11class PocketController extends Controller
diff --git a/src/Wallabag/ImportBundle/Controller/ReadabilityController.php b/src/Wallabag/ImportBundle/Controller/ReadabilityController.php
index 729a97a3..b120ef96 100644
--- a/src/Wallabag/ImportBundle/Controller/ReadabilityController.php
+++ b/src/Wallabag/ImportBundle/Controller/ReadabilityController.php
@@ -2,9 +2,9 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller; 5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request; 6use Symfony\Component\HttpFoundation\Request;
7use Symfony\Component\Routing\Annotation\Route;
8use Wallabag\ImportBundle\Form\Type\UploadImportType; 8use Wallabag\ImportBundle\Form\Type\UploadImportType;
9 9
10class ReadabilityController extends Controller 10class ReadabilityController extends Controller
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagController.php b/src/Wallabag/ImportBundle/Controller/WallabagController.php
index d182dd2c..5180006d 100644
--- a/src/Wallabag/ImportBundle/Controller/WallabagController.php
+++ b/src/Wallabag/ImportBundle/Controller/WallabagController.php
@@ -16,8 +16,6 @@ abstract class WallabagController extends Controller
16 /** 16 /**
17 * Handle import request. 17 * Handle import request.
18 * 18 *
19 * @param Request $request
20 *
21 * @return Response|RedirectResponse 19 * @return Response|RedirectResponse
22 */ 20 */
23 public function indexAction(Request $request) 21 public function indexAction(Request $request)
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php b/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php
index d700d8a8..e1c35343 100644
--- a/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php
+++ b/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Component\HttpFoundation\Request; 5use Symfony\Component\HttpFoundation\Request;
6use Symfony\Component\Routing\Annotation\Route;
7 7
8class WallabagV1Controller extends WallabagController 8class WallabagV1Controller extends WallabagController
9{ 9{
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php b/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php
index ab26400c..c4116c1d 100644
--- a/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php
+++ b/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Component\HttpFoundation\Request; 5use Symfony\Component\HttpFoundation\Request;
6use Symfony\Component\Routing\Annotation\Route;
7 7
8class WallabagV2Controller extends WallabagController 8class WallabagV2Controller extends WallabagController
9{ 9{
diff --git a/src/Wallabag/ImportBundle/Import/AbstractImport.php b/src/Wallabag/ImportBundle/Import/AbstractImport.php
index 58a234f4..1b073e99 100644
--- a/src/Wallabag/ImportBundle/Import/AbstractImport.php
+++ b/src/Wallabag/ImportBundle/Import/AbstractImport.php
@@ -46,8 +46,6 @@ abstract class AbstractImport implements ImportInterface
46 /** 46 /**
47 * Set RabbitMQ/Redis Producer to send each entry to a queue. 47 * Set RabbitMQ/Redis Producer to send each entry to a queue.
48 * This method should be called when user has enabled RabbitMQ. 48 * This method should be called when user has enabled RabbitMQ.
49 *
50 * @param ProducerInterface $producer
51 */ 49 */
52 public function setProducer(ProducerInterface $producer) 50 public function setProducer(ProducerInterface $producer)
53 { 51 {
@@ -57,8 +55,6 @@ abstract class AbstractImport implements ImportInterface
57 /** 55 /**
58 * Set current user. 56 * Set current user.
59 * Could the current *connected* user or one retrieve by the consumer. 57 * Could the current *connected* user or one retrieve by the consumer.
60 *
61 * @param User $user
62 */ 58 */
63 public function setUser(User $user) 59 public function setUser(User $user)
64 { 60 {
@@ -112,13 +108,18 @@ abstract class AbstractImport implements ImportInterface
112 /** 108 /**
113 * Parse one entry. 109 * Parse one entry.
114 * 110 *
115 * @param array $importedEntry
116 *
117 * @return Entry 111 * @return Entry
118 */ 112 */
119 abstract public function parseEntry(array $importedEntry); 113 abstract public function parseEntry(array $importedEntry);
120 114
121 /** 115 /**
116 * Validate that an entry is valid (like has some required keys, etc.).
117 *
118 * @return bool
119 */
120 abstract public function validateEntry(array $importedEntry);
121
122 /**
122 * Fetch content from the ContentProxy (using graby). 123 * Fetch content from the ContentProxy (using graby).
123 * If it fails return the given entry to be saved in all case (to avoid user to loose the content). 124 * If it fails return the given entry to be saved in all case (to avoid user to loose the content).
124 * 125 *
@@ -140,10 +141,8 @@ abstract class AbstractImport implements ImportInterface
140 141
141 /** 142 /**
142 * Parse and insert all given entries. 143 * Parse and insert all given entries.
143 *
144 * @param $entries
145 */ 144 */
146 protected function parseEntries($entries) 145 protected function parseEntries(array $entries)
147 { 146 {
148 $i = 1; 147 $i = 1;
149 $entryToBeFlushed = []; 148 $entryToBeFlushed = [];
@@ -153,6 +152,10 @@ abstract class AbstractImport implements ImportInterface
153 $importedEntry = $this->setEntryAsRead($importedEntry); 152 $importedEntry = $this->setEntryAsRead($importedEntry);
154 } 153 }
155 154
155 if (false === $this->validateEntry($importedEntry)) {
156 continue;
157 }
158
156 $entry = $this->parseEntry($importedEntry); 159 $entry = $this->parseEntry($importedEntry);
157 160
158 if (null === $entry) { 161 if (null === $entry) {
@@ -197,8 +200,6 @@ abstract class AbstractImport implements ImportInterface
197 * 200 *
198 * Faster parse entries for Producer. 201 * Faster parse entries for Producer.
199 * We don't care to make check at this time. They'll be done by the consumer. 202 * We don't care to make check at this time. They'll be done by the consumer.
200 *
201 * @param array $entries
202 */ 203 */
203 protected function parseEntriesForProducer(array $entries) 204 protected function parseEntriesForProducer(array $entries)
204 { 205 {
@@ -220,8 +221,6 @@ abstract class AbstractImport implements ImportInterface
220 * Set current imported entry to archived / read. 221 * Set current imported entry to archived / read.
221 * Implementation is different accross all imports. 222 * Implementation is different accross all imports.
222 * 223 *
223 * @param array $importedEntry
224 *
225 * @return array 224 * @return array
226 */ 225 */
227 abstract protected function setEntryAsRead(array $importedEntry); 226 abstract protected function setEntryAsRead(array $importedEntry);
diff --git a/src/Wallabag/ImportBundle/Import/BrowserImport.php b/src/Wallabag/ImportBundle/Import/BrowserImport.php
index 225f1791..ea7afd3d 100644
--- a/src/Wallabag/ImportBundle/Import/BrowserImport.php
+++ b/src/Wallabag/ImportBundle/Import/BrowserImport.php
@@ -77,7 +77,7 @@ abstract class BrowserImport extends AbstractImport
77 */ 77 */
78 public function parseEntry(array $importedEntry) 78 public function parseEntry(array $importedEntry)
79 { 79 {
80 if ((!array_key_exists('guid', $importedEntry) || (!array_key_exists('id', $importedEntry))) && \is_array(reset($importedEntry))) { 80 if ((!\array_key_exists('guid', $importedEntry) || (!\array_key_exists('id', $importedEntry))) && \is_array(reset($importedEntry))) {
81 if ($this->producer) { 81 if ($this->producer) {
82 $this->parseEntriesForProducer($importedEntry); 82 $this->parseEntriesForProducer($importedEntry);
83 83
@@ -89,7 +89,7 @@ abstract class BrowserImport extends AbstractImport
89 return; 89 return;
90 } 90 }
91 91
92 if (array_key_exists('children', $importedEntry)) { 92 if (\array_key_exists('children', $importedEntry)) {
93 if ($this->producer) { 93 if ($this->producer) {
94 $this->parseEntriesForProducer($importedEntry['children']); 94 $this->parseEntriesForProducer($importedEntry['children']);
95 95
@@ -101,11 +101,11 @@ abstract class BrowserImport extends AbstractImport
101 return; 101 return;
102 } 102 }
103 103
104 if (!array_key_exists('uri', $importedEntry) && !array_key_exists('url', $importedEntry)) { 104 if (!\array_key_exists('uri', $importedEntry) && !\array_key_exists('url', $importedEntry)) {
105 return; 105 return;
106 } 106 }
107 107
108 $url = array_key_exists('uri', $importedEntry) ? $importedEntry['uri'] : $importedEntry['url']; 108 $url = \array_key_exists('uri', $importedEntry) ? $importedEntry['uri'] : $importedEntry['url'];
109 109
110 $existingEntry = $this->em 110 $existingEntry = $this->em
111 ->getRepository('WallabagCoreBundle:Entry') 111 ->getRepository('WallabagCoreBundle:Entry')
@@ -126,14 +126,14 @@ abstract class BrowserImport extends AbstractImport
126 // update entry with content (in case fetching failed, the given entry will be return) 126 // update entry with content (in case fetching failed, the given entry will be return)
127 $this->fetchContent($entry, $data['url'], $data); 127 $this->fetchContent($entry, $data['url'], $data);
128 128
129 if (array_key_exists('tags', $data)) { 129 if (\array_key_exists('tags', $data)) {
130 $this->tagsAssigner->assignTagsToEntry( 130 $this->tagsAssigner->assignTagsToEntry(
131 $entry, 131 $entry,
132 $data['tags'] 132 $data['tags']
133 ); 133 );
134 } 134 }
135 135
136 $entry->setArchived($data['is_archived']); 136 $entry->updateArchived($data['is_archived']);
137 137
138 if (!empty($data['created_at'])) { 138 if (!empty($data['created_at'])) {
139 $dt = new \DateTime(); 139 $dt = new \DateTime();
@@ -148,10 +148,8 @@ abstract class BrowserImport extends AbstractImport
148 148
149 /** 149 /**
150 * Parse and insert all given entries. 150 * Parse and insert all given entries.
151 *
152 * @param $entries
153 */ 151 */
154 protected function parseEntries($entries) 152 protected function parseEntries(array $entries)
155 { 153 {
156 $i = 1; 154 $i = 1;
157 $entryToBeFlushed = []; 155 $entryToBeFlushed = [];
@@ -199,8 +197,6 @@ abstract class BrowserImport extends AbstractImport
199 * 197 *
200 * Faster parse entries for Producer. 198 * Faster parse entries for Producer.
201 * We don't care to make check at this time. They'll be done by the consumer. 199 * We don't care to make check at this time. They'll be done by the consumer.
202 *
203 * @param array $entries
204 */ 200 */
205 protected function parseEntriesForProducer(array $entries) 201 protected function parseEntriesForProducer(array $entries)
206 { 202 {
diff --git a/src/Wallabag/ImportBundle/Import/ChromeImport.php b/src/Wallabag/ImportBundle/Import/ChromeImport.php
index 09183abe..4ae82ade 100644
--- a/src/Wallabag/ImportBundle/Import/ChromeImport.php
+++ b/src/Wallabag/ImportBundle/Import/ChromeImport.php
@@ -33,6 +33,18 @@ class ChromeImport extends BrowserImport
33 /** 33 /**
34 * {@inheritdoc} 34 * {@inheritdoc}
35 */ 35 */
36 public function validateEntry(array $importedEntry)
37 {
38 if (empty($importedEntry['url'])) {
39 return false;
40 }
41
42 return true;
43 }
44
45 /**
46 * {@inheritdoc}
47 */
36 protected function prepareEntry(array $entry = []) 48 protected function prepareEntry(array $entry = [])
37 { 49 {
38 $data = [ 50 $data = [
@@ -45,7 +57,7 @@ class ChromeImport extends BrowserImport
45 'created_at' => substr($entry['date_added'], 0, 10), 57 'created_at' => substr($entry['date_added'], 0, 10),
46 ]; 58 ];
47 59
48 if (array_key_exists('tags', $entry) && '' !== $entry['tags']) { 60 if (\array_key_exists('tags', $entry) && '' !== $entry['tags']) {
49 $data['tags'] = $entry['tags']; 61 $data['tags'] = $entry['tags'];
50 } 62 }
51 63
diff --git a/src/Wallabag/ImportBundle/Import/ElcuratorImport.php b/src/Wallabag/ImportBundle/Import/ElcuratorImport.php
new file mode 100644
index 00000000..d1281613
--- /dev/null
+++ b/src/Wallabag/ImportBundle/Import/ElcuratorImport.php
@@ -0,0 +1,54 @@
1<?php
2
3namespace Wallabag\ImportBundle\Import;
4
5class ElcuratorImport extends WallabagImport
6{
7 /**
8 * {@inheritdoc}
9 */
10 public function getName()
11 {
12 return 'elcurator';
13 }
14
15 /**
16 * {@inheritdoc}
17 */
18 public function getUrl()
19 {
20 return 'import_elcurator';
21 }
22
23 /**
24 * {@inheritdoc}
25 */
26 public function getDescription()
27 {
28 return 'import.elcurator.description';
29 }
30
31 /**
32 * {@inheritdoc}
33 */
34 protected function prepareEntry($entry = [])
35 {
36 return [
37 'url' => $entry['url'],
38 'title' => $entry['title'],
39 'created_at' => $entry['created_at'],
40 'is_archived' => 0,
41 'is_starred' => $entry['is_saved'],
42 ] + $entry;
43 }
44
45 /**
46 * {@inheritdoc}
47 */
48 protected function setEntryAsRead(array $importedEntry)
49 {
50 $importedEntry['is_archived'] = 1;
51
52 return $importedEntry;
53 }
54}
diff --git a/src/Wallabag/ImportBundle/Import/FirefoxImport.php b/src/Wallabag/ImportBundle/Import/FirefoxImport.php
index 73269fe1..b3558f21 100644
--- a/src/Wallabag/ImportBundle/Import/FirefoxImport.php
+++ b/src/Wallabag/ImportBundle/Import/FirefoxImport.php
@@ -33,6 +33,18 @@ class FirefoxImport extends BrowserImport
33 /** 33 /**
34 * {@inheritdoc} 34 * {@inheritdoc}
35 */ 35 */
36 public function validateEntry(array $importedEntry)
37 {
38 if (empty($importedEntry['uri'])) {
39 return false;
40 }
41
42 return true;
43 }
44
45 /**
46 * {@inheritdoc}
47 */
36 protected function prepareEntry(array $entry = []) 48 protected function prepareEntry(array $entry = [])
37 { 49 {
38 $data = [ 50 $data = [
@@ -45,7 +57,7 @@ class FirefoxImport extends BrowserImport
45 'created_at' => substr($entry['dateAdded'], 0, 10), 57 'created_at' => substr($entry['dateAdded'], 0, 10),
46 ]; 58 ];
47 59
48 if (array_key_exists('tags', $entry) && '' !== $entry['tags']) { 60 if (\array_key_exists('tags', $entry) && '' !== $entry['tags']) {
49 $data['tags'] = $entry['tags']; 61 $data['tags'] = $entry['tags'];
50 } 62 }
51 63
diff --git a/src/Wallabag/ImportBundle/Import/ImportChain.php b/src/Wallabag/ImportBundle/Import/ImportChain.php
index 9dd77956..e1b5867d 100644
--- a/src/Wallabag/ImportBundle/Import/ImportChain.php
+++ b/src/Wallabag/ImportBundle/Import/ImportChain.php
@@ -14,8 +14,7 @@ class ImportChain
14 /** 14 /**
15 * Add an import to the chain. 15 * Add an import to the chain.
16 * 16 *
17 * @param ImportInterface $import 17 * @param string $alias
18 * @param string $alias
19 */ 18 */
20 public function addImport(ImportInterface $import, $alias) 19 public function addImport(ImportInterface $import, $alias)
21 { 20 {
diff --git a/src/Wallabag/ImportBundle/Import/InstapaperImport.php b/src/Wallabag/ImportBundle/Import/InstapaperImport.php
index e4f0970c..f7bee9ef 100644
--- a/src/Wallabag/ImportBundle/Import/InstapaperImport.php
+++ b/src/Wallabag/ImportBundle/Import/InstapaperImport.php
@@ -62,7 +62,7 @@ class InstapaperImport extends AbstractImport
62 } 62 }
63 63
64 $entries = []; 64 $entries = [];
65 $handle = fopen($this->filepath, 'rb'); 65 $handle = fopen($this->filepath, 'r');
66 while (false !== ($data = fgetcsv($handle, 10240))) { 66 while (false !== ($data = fgetcsv($handle, 10240))) {
67 if ('URL' === $data[0]) { 67 if ('URL' === $data[0]) {
68 continue; 68 continue;
@@ -79,7 +79,6 @@ class InstapaperImport extends AbstractImport
79 $entries[] = [ 79 $entries[] = [
80 'url' => $data[0], 80 'url' => $data[0],
81 'title' => $data[1], 81 'title' => $data[1],
82 'status' => $data[3],
83 'is_archived' => 'Archive' === $data[3] || 'Starred' === $data[3], 82 'is_archived' => 'Archive' === $data[3] || 'Starred' === $data[3],
84 'is_starred' => 'Starred' === $data[3], 83 'is_starred' => 'Starred' === $data[3],
85 'html' => false, 84 'html' => false,
@@ -94,6 +93,10 @@ class InstapaperImport extends AbstractImport
94 return false; 93 return false;
95 } 94 }
96 95
96 // most recent articles are first, which means we should create them at the end so they will show up first
97 // as Instapaper doesn't export the creation date of the article
98 $entries = array_reverse($entries);
99
97 if ($this->producer) { 100 if ($this->producer) {
98 $this->parseEntriesForProducer($entries); 101 $this->parseEntriesForProducer($entries);
99 102
@@ -108,6 +111,18 @@ class InstapaperImport extends AbstractImport
108 /** 111 /**
109 * {@inheritdoc} 112 * {@inheritdoc}
110 */ 113 */
114 public function validateEntry(array $importedEntry)
115 {
116 if (empty($importedEntry['url'])) {
117 return false;
118 }
119
120 return true;
121 }
122
123 /**
124 * {@inheritdoc}
125 */
111 public function parseEntry(array $importedEntry) 126 public function parseEntry(array $importedEntry)
112 { 127 {
113 $existingEntry = $this->em 128 $existingEntry = $this->em
@@ -135,7 +150,7 @@ class InstapaperImport extends AbstractImport
135 ); 150 );
136 } 151 }
137 152
138 $entry->setArchived($importedEntry['is_archived']); 153 $entry->updateArchived($importedEntry['is_archived']);
139 $entry->setStarred($importedEntry['is_starred']); 154 $entry->setStarred($importedEntry['is_starred']);
140 155
141 $this->em->persist($entry); 156 $this->em->persist($entry);
diff --git a/src/Wallabag/ImportBundle/Import/PinboardImport.php b/src/Wallabag/ImportBundle/Import/PinboardImport.php
index 110b0464..202eb1b3 100644
--- a/src/Wallabag/ImportBundle/Import/PinboardImport.php
+++ b/src/Wallabag/ImportBundle/Import/PinboardImport.php
@@ -83,6 +83,18 @@ class PinboardImport extends AbstractImport
83 /** 83 /**
84 * {@inheritdoc} 84 * {@inheritdoc}
85 */ 85 */
86 public function validateEntry(array $importedEntry)
87 {
88 if (empty($importedEntry['href'])) {
89 return false;
90 }
91
92 return true;
93 }
94
95 /**
96 * {@inheritdoc}
97 */
86 public function parseEntry(array $importedEntry) 98 public function parseEntry(array $importedEntry)
87 { 99 {
88 $existingEntry = $this->em 100 $existingEntry = $this->em
@@ -119,7 +131,7 @@ class PinboardImport extends AbstractImport
119 ); 131 );
120 } 132 }
121 133
122 $entry->setArchived($data['is_archived']); 134 $entry->updateArchived($data['is_archived']);
123 $entry->setStarred($data['is_starred']); 135 $entry->setStarred($data['is_starred']);
124 $entry->setCreatedAt(new \DateTime($data['created_at'])); 136 $entry->setCreatedAt(new \DateTime($data['created_at']));
125 137
diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php
index c1b35b7e..24fdaa2b 100644
--- a/src/Wallabag/ImportBundle/Import/PocketImport.php
+++ b/src/Wallabag/ImportBundle/Import/PocketImport.php
@@ -2,13 +2,22 @@
2 2
3namespace Wallabag\ImportBundle\Import; 3namespace Wallabag\ImportBundle\Import;
4 4
5use GuzzleHttp\Client; 5use Http\Client\Common\HttpMethodsClient;
6use GuzzleHttp\Exception\RequestException; 6use Http\Client\Common\Plugin\ErrorPlugin;
7use Http\Client\Common\PluginClient;
8use Http\Client\Exception\RequestException;
9use Http\Client\HttpClient;
10use Http\Discovery\MessageFactoryDiscovery;
11use Http\Message\MessageFactory;
12use Psr\Http\Message\ResponseInterface;
7use Wallabag\CoreBundle\Entity\Entry; 13use Wallabag\CoreBundle\Entity\Entry;
8 14
9class PocketImport extends AbstractImport 15class PocketImport extends AbstractImport
10{ 16{
11 const NB_ELEMENTS = 5000; 17 const NB_ELEMENTS = 5000;
18 /**
19 * @var HttpMethodsClient
20 */
12 private $client; 21 private $client;
13 private $accessToken; 22 private $accessToken;
14 23
@@ -55,24 +64,18 @@ class PocketImport extends AbstractImport
55 */ 64 */
56 public function getRequestToken($redirectUri) 65 public function getRequestToken($redirectUri)
57 { 66 {
58 $request = $this->client->createRequest('POST', 'https://getpocket.com/v3/oauth/request',
59 [
60 'body' => json_encode([
61 'consumer_key' => $this->user->getConfig()->getPocketConsumerKey(),
62 'redirect_uri' => $redirectUri,
63 ]),
64 ]
65 );
66
67 try { 67 try {
68 $response = $this->client->send($request); 68 $response = $this->client->post('https://getpocket.com/v3/oauth/request', [], json_encode([
69 'consumer_key' => $this->user->getConfig()->getPocketConsumerKey(),
70 'redirect_uri' => $redirectUri,
71 ]));
69 } catch (RequestException $e) { 72 } catch (RequestException $e) {
70 $this->logger->error(sprintf('PocketImport: Failed to request token: %s', $e->getMessage()), ['exception' => $e]); 73 $this->logger->error(sprintf('PocketImport: Failed to request token: %s', $e->getMessage()), ['exception' => $e]);
71 74
72 return false; 75 return false;
73 } 76 }
74 77
75 return $response->json()['code']; 78 return $this->jsonDecode($response)['code'];
76 } 79 }
77 80
78 /** 81 /**
@@ -85,24 +88,18 @@ class PocketImport extends AbstractImport
85 */ 88 */
86 public function authorize($code) 89 public function authorize($code)
87 { 90 {
88 $request = $this->client->createRequest('POST', 'https://getpocket.com/v3/oauth/authorize',
89 [
90 'body' => json_encode([
91 'consumer_key' => $this->user->getConfig()->getPocketConsumerKey(),
92 'code' => $code,
93 ]),
94 ]
95 );
96
97 try { 91 try {
98 $response = $this->client->send($request); 92 $response = $this->client->post('https://getpocket.com/v3/oauth/authorize', [], json_encode([
93 'consumer_key' => $this->user->getConfig()->getPocketConsumerKey(),
94 'code' => $code,
95 ]));
99 } catch (RequestException $e) { 96 } catch (RequestException $e) {
100 $this->logger->error(sprintf('PocketImport: Failed to authorize client: %s', $e->getMessage()), ['exception' => $e]); 97 $this->logger->error(sprintf('PocketImport: Failed to authorize client: %s', $e->getMessage()), ['exception' => $e]);
101 98
102 return false; 99 return false;
103 } 100 }
104 101
105 $this->accessToken = $response->json()['access_token']; 102 $this->accessToken = $this->jsonDecode($response)['access_token'];
106 103
107 return true; 104 return true;
108 } 105 }
@@ -114,29 +111,23 @@ class PocketImport extends AbstractImport
114 { 111 {
115 static $run = 0; 112 static $run = 0;
116 113
117 $request = $this->client->createRequest('POST', 'https://getpocket.com/v3/get',
118 [
119 'body' => json_encode([
120 'consumer_key' => $this->user->getConfig()->getPocketConsumerKey(),
121 'access_token' => $this->accessToken,
122 'detailType' => 'complete',
123 'state' => 'all',
124 'sort' => 'newest',
125 'count' => self::NB_ELEMENTS,
126 'offset' => $offset,
127 ]),
128 ]
129 );
130
131 try { 114 try {
132 $response = $this->client->send($request); 115 $response = $this->client->post('https://getpocket.com/v3/get', [], json_encode([
116 'consumer_key' => $this->user->getConfig()->getPocketConsumerKey(),
117 'access_token' => $this->accessToken,
118 'detailType' => 'complete',
119 'state' => 'all',
120 'sort' => 'newest',
121 'count' => self::NB_ELEMENTS,
122 'offset' => $offset,
123 ]));
133 } catch (RequestException $e) { 124 } catch (RequestException $e) {
134 $this->logger->error(sprintf('PocketImport: Failed to import: %s', $e->getMessage()), ['exception' => $e]); 125 $this->logger->error(sprintf('PocketImport: Failed to import: %s', $e->getMessage()), ['exception' => $e]);
135 126
136 return false; 127 return false;
137 } 128 }
138 129
139 $entries = $response->json(); 130 $entries = $this->jsonDecode($response);
140 131
141 if ($this->producer) { 132 if ($this->producer) {
142 $this->parseEntriesForProducer($entries['list']); 133 $this->parseEntriesForProducer($entries['list']);
@@ -159,13 +150,23 @@ class PocketImport extends AbstractImport
159 } 150 }
160 151
161 /** 152 /**
162 * Set the Guzzle client. 153 * Set the Http client.
163 * 154 */
164 * @param Client $client 155 public function setClient(HttpClient $client, MessageFactory $messageFactory = null)
156 {
157 $this->client = new HttpMethodsClient(new PluginClient($client, [new ErrorPlugin()]), $messageFactory ?: MessageFactoryDiscovery::find());
158 }
159
160 /**
161 * {@inheritdoc}
165 */ 162 */
166 public function setClient(Client $client) 163 public function validateEntry(array $importedEntry)
167 { 164 {
168 $this->client = $client; 165 if (empty($importedEntry['resolved_url']) && empty($importedEntry['given_url'])) {
166 return false;
167 }
168
169 return true;
169 } 170 }
170 171
171 /** 172 /**
@@ -194,10 +195,10 @@ class PocketImport extends AbstractImport
194 $this->fetchContent($entry, $url); 195 $this->fetchContent($entry, $url);
195 196
196 // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted 197 // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted
197 $entry->setArchived(1 === $importedEntry['status'] || $this->markAsRead); 198 $entry->updateArchived(1 === (int) $importedEntry['status'] || $this->markAsRead);
198 199
199 // 0 or 1 - 1 If the item is starred 200 // 0 or 1 - 1 if the item is starred
200 $entry->setStarred(1 === $importedEntry['favorite']); 201 $entry->setStarred(1 === (int) $importedEntry['favorite']);
201 202
202 $title = 'Untitled'; 203 $title = 'Untitled';
203 if (isset($importedEntry['resolved_title']) && '' !== $importedEntry['resolved_title']) { 204 if (isset($importedEntry['resolved_title']) && '' !== $importedEntry['resolved_title']) {
@@ -240,4 +241,15 @@ class PocketImport extends AbstractImport
240 241
241 return $importedEntry; 242 return $importedEntry;
242 } 243 }
244
245 protected function jsonDecode(ResponseInterface $response)
246 {
247 $data = json_decode((string) $response->getBody(), true);
248
249 if (JSON_ERROR_NONE !== json_last_error()) {
250 throw new \InvalidArgumentException('Unable to parse JSON data: ' . json_last_error_msg());
251 }
252
253 return $data;
254 }
243} 255}
diff --git a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php
index 002b27f4..c5abf189 100644
--- a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php
+++ b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php
@@ -83,6 +83,18 @@ class ReadabilityImport extends AbstractImport
83 /** 83 /**
84 * {@inheritdoc} 84 * {@inheritdoc}
85 */ 85 */
86 public function validateEntry(array $importedEntry)
87 {
88 if (empty($importedEntry['article__url'])) {
89 return false;
90 }
91
92 return true;
93 }
94
95 /**
96 * {@inheritdoc}
97 */
86 public function parseEntry(array $importedEntry) 98 public function parseEntry(array $importedEntry)
87 { 99 {
88 $existingEntry = $this->em 100 $existingEntry = $this->em
@@ -111,7 +123,7 @@ class ReadabilityImport extends AbstractImport
111 // update entry with content (in case fetching failed, the given entry will be return) 123 // update entry with content (in case fetching failed, the given entry will be return)
112 $this->fetchContent($entry, $data['url'], $data); 124 $this->fetchContent($entry, $data['url'], $data);
113 125
114 $entry->setArchived($data['is_archived']); 126 $entry->updateArchived($data['is_archived']);
115 $entry->setStarred($data['is_starred']); 127 $entry->setStarred($data['is_starred']);
116 $entry->setCreatedAt(new \DateTime($data['created_at'])); 128 $entry->setCreatedAt(new \DateTime($data['created_at']));
117 129
diff --git a/src/Wallabag/ImportBundle/Import/WallabagImport.php b/src/Wallabag/ImportBundle/Import/WallabagImport.php
index c64ccd64..75a28fbf 100644
--- a/src/Wallabag/ImportBundle/Import/WallabagImport.php
+++ b/src/Wallabag/ImportBundle/Import/WallabagImport.php
@@ -89,6 +89,18 @@ abstract class WallabagImport extends AbstractImport
89 /** 89 /**
90 * {@inheritdoc} 90 * {@inheritdoc}
91 */ 91 */
92 public function validateEntry(array $importedEntry)
93 {
94 if (empty($importedEntry['url'])) {
95 return false;
96 }
97
98 return true;
99 }
100
101 /**
102 * {@inheritdoc}
103 */
92 public function parseEntry(array $importedEntry) 104 public function parseEntry(array $importedEntry)
93 { 105 {
94 $existingEntry = $this->em 106 $existingEntry = $this->em
@@ -110,7 +122,7 @@ abstract class WallabagImport extends AbstractImport
110 // update entry with content (in case fetching failed, the given entry will be return) 122 // update entry with content (in case fetching failed, the given entry will be return)
111 $this->fetchContent($entry, $data['url'], $data); 123 $this->fetchContent($entry, $data['url'], $data);
112 124
113 if (array_key_exists('tags', $data)) { 125 if (\array_key_exists('tags', $data)) {
114 $this->tagsAssigner->assignTagsToEntry( 126 $this->tagsAssigner->assignTagsToEntry(
115 $entry, 127 $entry,
116 $data['tags'], 128 $data['tags'],
@@ -122,7 +134,7 @@ abstract class WallabagImport extends AbstractImport
122 $entry->setPreviewPicture($importedEntry['preview_picture']); 134 $entry->setPreviewPicture($importedEntry['preview_picture']);
123 } 135 }
124 136
125 $entry->setArchived($data['is_archived']); 137 $entry->updateArchived($data['is_archived']);
126 $entry->setStarred($data['is_starred']); 138 $entry->setStarred($data['is_starred']);
127 139
128 if (!empty($data['created_at'])) { 140 if (!empty($data['created_at'])) {
diff --git a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
index b9bb525a..e0562611 100644
--- a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
+++ b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
@@ -61,7 +61,7 @@ class WallabagV1Import extends WallabagImport
61 $data['html'] = $this->fetchingErrorMessage; 61 $data['html'] = $this->fetchingErrorMessage;
62 } 62 }
63 63
64 if (array_key_exists('tags', $entry) && '' !== $entry['tags']) { 64 if (\array_key_exists('tags', $entry) && '' !== $entry['tags']) {
65 $data['tags'] = $entry['tags']; 65 $data['tags'] = $entry['tags'];
66 } 66 }
67 67
diff --git a/src/Wallabag/ImportBundle/Import/WallabagV2Import.php b/src/Wallabag/ImportBundle/Import/WallabagV2Import.php
index 3e085ecf..2ba26003 100644
--- a/src/Wallabag/ImportBundle/Import/WallabagV2Import.php
+++ b/src/Wallabag/ImportBundle/Import/WallabagV2Import.php
@@ -35,7 +35,9 @@ class WallabagV2Import extends WallabagImport
35 { 35 {
36 return [ 36 return [
37 'html' => $entry['content'], 37 'html' => $entry['content'],
38 'content_type' => $entry['mimetype'], 38 'headers' => [
39 'content-type' => $entry['mimetype'],
40 ],
39 'is_archived' => (bool) ($entry['is_archived'] || $this->markAsRead), 41 'is_archived' => (bool) ($entry['is_archived'] || $this->markAsRead),
40 'is_starred' => (bool) $entry['is_starred'], 42 'is_starred' => (bool) $entry['is_starred'],
41 ] + $entry; 43 ] + $entry;
diff --git a/src/Wallabag/ImportBundle/Resources/config/rabbit.yml b/src/Wallabag/ImportBundle/Resources/config/rabbit.yml
index e9ecb846..0bf0e761 100644
--- a/src/Wallabag/ImportBundle/Resources/config/rabbit.yml
+++ b/src/Wallabag/ImportBundle/Resources/config/rabbit.yml
@@ -48,6 +48,14 @@ services:
48 - "@wallabag_import.wallabag_v2.import" 48 - "@wallabag_import.wallabag_v2.import"
49 - "@event_dispatcher" 49 - "@event_dispatcher"
50 - "@logger" 50 - "@logger"
51 wallabag_import.consumer.amqp.elcurator:
52 class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
53 arguments:
54 - "@doctrine.orm.entity_manager"
55 - "@wallabag_user.user_repository"
56 - "@wallabag_import.elcurator.import"
57 - "@event_dispatcher"
58 - "@logger"
51 wallabag_import.consumer.amqp.firefox: 59 wallabag_import.consumer.amqp.firefox:
52 class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer 60 class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
53 arguments: 61 arguments:
diff --git a/src/Wallabag/ImportBundle/Resources/config/redis.yml b/src/Wallabag/ImportBundle/Resources/config/redis.yml
index 091cdba0..40a6e224 100644
--- a/src/Wallabag/ImportBundle/Resources/config/redis.yml
+++ b/src/Wallabag/ImportBundle/Resources/config/redis.yml
@@ -126,6 +126,27 @@ services:
126 - "@event_dispatcher" 126 - "@event_dispatcher"
127 - "@logger" 127 - "@logger"
128 128
129 # elcurator
130 wallabag_import.queue.redis.elcurator:
131 class: Simpleue\Queue\RedisQueue
132 arguments:
133 - "@wallabag_core.redis.client"
134 - "wallabag.import.elcurator"
135
136 wallabag_import.producer.redis.elcurator:
137 class: Wallabag\ImportBundle\Redis\Producer
138 arguments:
139 - "@wallabag_import.queue.redis.elcurator"
140
141 wallabag_import.consumer.redis.elcurator:
142 class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer
143 arguments:
144 - "@doctrine.orm.entity_manager"
145 - "@wallabag_user.user_repository"
146 - "@wallabag_import.elcurator.import"
147 - "@event_dispatcher"
148 - "@logger"
149
129 # firefox 150 # firefox
130 wallabag_import.queue.redis.firefox: 151 wallabag_import.queue.redis.firefox:
131 class: Simpleue\Queue\RedisQueue 152 class: Simpleue\Queue\RedisQueue
diff --git a/src/Wallabag/ImportBundle/Resources/config/services.yml b/src/Wallabag/ImportBundle/Resources/config/services.yml
index b224a6a2..d824da4a 100644
--- a/src/Wallabag/ImportBundle/Resources/config/services.yml
+++ b/src/Wallabag/ImportBundle/Resources/config/services.yml
@@ -7,13 +7,7 @@ services:
7 class: Wallabag\ImportBundle\Import\ImportChain 7 class: Wallabag\ImportBundle\Import\ImportChain
8 8
9 wallabag_import.pocket.client: 9 wallabag_import.pocket.client:
10 class: GuzzleHttp\Client 10 alias: 'httplug.client.wallabag_import.pocket.client'
11 arguments:
12 -
13 defaults:
14 headers:
15 content-type: "application/json"
16 X-Accept: "application/json"
17 11
18 wallabag_import.pocket.import: 12 wallabag_import.pocket.import:
19 class: Wallabag\ImportBundle\Import\PocketImport 13 class: Wallabag\ImportBundle\Import\PocketImport
@@ -54,6 +48,18 @@ services:
54 tags: 48 tags:
55 - { name: wallabag_import.import, alias: wallabag_v2 } 49 - { name: wallabag_import.import, alias: wallabag_v2 }
56 50
51 wallabag_import.elcurator.import:
52 class: Wallabag\ImportBundle\Import\ElcuratorImport
53 arguments:
54 - "@doctrine.orm.entity_manager"
55 - "@wallabag_core.content_proxy"
56 - "@wallabag_core.tags_assigner"
57 - "@event_dispatcher"
58 calls:
59 - [ setLogger, [ "@logger" ]]
60 tags:
61 - { name: wallabag_import.import, alias: elcurator }
62
57 wallabag_import.readability.import: 63 wallabag_import.readability.import:
58 class: Wallabag\ImportBundle\Import\ReadabilityImport 64 class: Wallabag\ImportBundle\Import\ReadabilityImport
59 arguments: 65 arguments:
@@ -112,3 +118,11 @@ services:
112 - [ setLogger, [ "@logger" ]] 118 - [ setLogger, [ "@logger" ]]
113 tags: 119 tags:
114 - { name: wallabag_import.import, alias: chrome } 120 - { name: wallabag_import.import, alias: chrome }
121
122 wallabag_import.command.import:
123 class: Wallabag\ImportBundle\Command\ImportCommand
124 tags: ['console.command']
125
126 wallabag_import.command.redis_worker:
127 class: Wallabag\ImportBundle\Command\RedisWorkerCommand
128 tags: ['console.command']
diff --git a/src/Wallabag/ImportBundle/Resources/views/Elcurator/index.html.twig b/src/Wallabag/ImportBundle/Resources/views/Elcurator/index.html.twig
new file mode 100644
index 00000000..e3a0d709
--- /dev/null
+++ b/src/Wallabag/ImportBundle/Resources/views/Elcurator/index.html.twig
@@ -0,0 +1,3 @@
1{% extends "WallabagImportBundle:WallabagV1:index.html.twig" %}
2
3{% block title %}{{ 'import.elcurator.page_title'|trans }}{% endblock %}