aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/ImportBundle')
-rw-r--r--src/Wallabag/ImportBundle/Command/ImportCommand.php30
-rw-r--r--src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php4
-rw-r--r--src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php9
-rw-r--r--src/Wallabag/ImportBundle/Controller/BrowserController.php2
-rw-r--r--src/Wallabag/ImportBundle/Controller/ImportController.php2
-rw-r--r--src/Wallabag/ImportBundle/Controller/InstapaperController.php2
-rw-r--r--src/Wallabag/ImportBundle/Controller/PinboardController.php77
-rw-r--r--src/Wallabag/ImportBundle/Controller/ReadabilityController.php2
-rw-r--r--src/Wallabag/ImportBundle/Controller/WallabagController.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/AbstractImport.php24
-rw-r--r--src/Wallabag/ImportBundle/Import/BrowserImport.php17
-rw-r--r--src/Wallabag/ImportBundle/Import/ChromeImport.php5
-rw-r--r--src/Wallabag/ImportBundle/Import/FirefoxImport.php5
-rw-r--r--src/Wallabag/ImportBundle/Import/InstapaperImport.php3
-rw-r--r--src/Wallabag/ImportBundle/Import/PinboardImport.php141
-rw-r--r--src/Wallabag/ImportBundle/Import/PocketImport.php9
-rw-r--r--src/Wallabag/ImportBundle/Import/ReadabilityImport.php3
-rw-r--r--src/Wallabag/ImportBundle/Import/WallabagV1Import.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/WallabagV2Import.php3
-rw-r--r--src/Wallabag/ImportBundle/Resources/config/rabbit.yml15
-rw-r--r--src/Wallabag/ImportBundle/Resources/config/redis.yml28
-rw-r--r--src/Wallabag/ImportBundle/Resources/config/services.yml18
-rw-r--r--src/Wallabag/ImportBundle/Resources/views/Chrome/index.html.twig2
-rw-r--r--src/Wallabag/ImportBundle/Resources/views/Firefox/index.html.twig2
-rw-r--r--src/Wallabag/ImportBundle/Resources/views/Import/_information.html.twig (renamed from src/Wallabag/ImportBundle/Resources/views/Import/_workerEnabled.html.twig)7
-rw-r--r--src/Wallabag/ImportBundle/Resources/views/Import/index.html.twig8
-rw-r--r--src/Wallabag/ImportBundle/Resources/views/Instapaper/index.html.twig2
-rw-r--r--src/Wallabag/ImportBundle/Resources/views/Pinboard/index.html.twig45
-rw-r--r--src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig2
-rw-r--r--src/Wallabag/ImportBundle/Resources/views/Readability/index.html.twig2
-rw-r--r--src/Wallabag/ImportBundle/Resources/views/WallabagV1/index.html.twig2
31 files changed, 430 insertions, 45 deletions
diff --git a/src/Wallabag/ImportBundle/Command/ImportCommand.php b/src/Wallabag/ImportBundle/Command/ImportCommand.php
index d1325338..28d01715 100644
--- a/src/Wallabag/ImportBundle/Command/ImportCommand.php
+++ b/src/Wallabag/ImportBundle/Command/ImportCommand.php
@@ -14,10 +14,10 @@ class ImportCommand extends ContainerAwareCommand
14 { 14 {
15 $this 15 $this
16 ->setName('wallabag:import') 16 ->setName('wallabag:import')
17 ->setDescription('Import entries from a JSON export from a wallabag v1 instance') 17 ->setDescription('Import entries from a JSON export')
18 ->addArgument('userId', InputArgument::REQUIRED, 'User ID to populate') 18 ->addArgument('userId', InputArgument::REQUIRED, 'User ID to populate')
19 ->addArgument('filepath', InputArgument::REQUIRED, 'Path to the JSON file') 19 ->addArgument('filepath', InputArgument::REQUIRED, 'Path to the JSON file')
20 ->addOption('importer', null, InputArgument::OPTIONAL, 'The importer to use: wallabag v1, v2, firefox or chrome', 'v1') 20 ->addOption('importer', null, InputArgument::OPTIONAL, 'The importer to use: v1, v2, instapaper, pinboard, readability, firefox or chrome', 'v1')
21 ->addOption('markAsRead', null, InputArgument::OPTIONAL, 'Mark all entries as read', false) 21 ->addOption('markAsRead', null, InputArgument::OPTIONAL, 'Mark all entries as read', false)
22 ; 22 ;
23 } 23 }
@@ -42,32 +42,36 @@ class ImportCommand extends ContainerAwareCommand
42 42
43 switch ($input->getOption('importer')) { 43 switch ($input->getOption('importer')) {
44 case 'v2': 44 case 'v2':
45 $wallabag = $this->getContainer()->get('wallabag_import.wallabag_v2.import'); 45 $import = $this->getContainer()->get('wallabag_import.wallabag_v2.import');
46 break; 46 break;
47 case 'firefox': 47 case 'firefox':
48 $wallabag = $this->getContainer()->get('wallabag_import.firefox.import'); 48 $import = $this->getContainer()->get('wallabag_import.firefox.import');
49 break; 49 break;
50 case 'chrome': 50 case 'chrome':
51 $wallabag = $this->getContainer()->get('wallabag_import.chrome.import'); 51 $import = $this->getContainer()->get('wallabag_import.chrome.import');
52 break;
53 case 'readability':
54 $import = $this->getContainer()->get('wallabag_import.readability.import');
52 break; 55 break;
53 case 'instapaper': 56 case 'instapaper':
54 $wallabag = $this->getContainer()->get('wallabag_import.instapaper.import'); 57 $import = $this->getContainer()->get('wallabag_import.instapaper.import');
55 break; 58 break;
56 case 'v1': 59 case 'pinboard':
57 default: 60 $import = $this->getContainer()->get('wallabag_import.pinboard.import');
58 $wallabag = $this->getContainer()->get('wallabag_import.wallabag_v1.import');
59 break; 61 break;
62 default:
63 $import = $this->getContainer()->get('wallabag_import.wallabag_v1.import');
60 } 64 }
61 65
62 $wallabag->setMarkAsRead($input->getOption('markAsRead')); 66 $import->setMarkAsRead($input->getOption('markAsRead'));
63 $wallabag->setUser($user); 67 $import->setUser($user);
64 68
65 $res = $wallabag 69 $res = $import
66 ->setFilepath($input->getArgument('filepath')) 70 ->setFilepath($input->getArgument('filepath'))
67 ->import(); 71 ->import();
68 72
69 if (true === $res) { 73 if (true === $res) {
70 $summary = $wallabag->getSummary(); 74 $summary = $import->getSummary();
71 $output->writeln('<info>'.$summary['imported'].' imported</info>'); 75 $output->writeln('<info>'.$summary['imported'].' imported</info>');
72 $output->writeln('<comment>'.$summary['skipped'].' already saved</comment>'); 76 $output->writeln('<comment>'.$summary['skipped'].' already saved</comment>');
73 } 77 }
diff --git a/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php b/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php
index c2c11f11..2d06af44 100644
--- a/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php
+++ b/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php
@@ -17,7 +17,7 @@ class RedisWorkerCommand extends ContainerAwareCommand
17 $this 17 $this
18 ->setName('wallabag:import:redis-worker') 18 ->setName('wallabag:import:redis-worker')
19 ->setDescription('Launch Redis worker') 19 ->setDescription('Launch Redis worker')
20 ->addArgument('serviceName', InputArgument::REQUIRED, 'Service to use: wallabag_v1, wallabag_v2, pocket, readability, firefox, chrome or instapaper') 20 ->addArgument('serviceName', InputArgument::REQUIRED, 'Service to use: wallabag_v1, wallabag_v2, pocket, readability, pinboard, firefox, chrome or instapaper')
21 ->addOption('maxIterations', '', InputOption::VALUE_OPTIONAL, 'Number of iterations before stoping', false) 21 ->addOption('maxIterations', '', InputOption::VALUE_OPTIONAL, 'Number of iterations before stoping', false)
22 ; 22 ;
23 } 23 }
@@ -36,7 +36,7 @@ class RedisWorkerCommand extends ContainerAwareCommand
36 $worker = new QueueWorker( 36 $worker = new QueueWorker(
37 $this->getContainer()->get('wallabag_import.queue.redis.'.$serviceName), 37 $this->getContainer()->get('wallabag_import.queue.redis.'.$serviceName),
38 $this->getContainer()->get('wallabag_import.consumer.redis.'.$serviceName), 38 $this->getContainer()->get('wallabag_import.consumer.redis.'.$serviceName),
39 $input->getOption('maxIterations') 39 (int) $input->getOption('maxIterations')
40 ); 40 );
41 41
42 $worker->start(); 42 $worker->start();
diff --git a/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php b/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php
index b893ea29..fc175f67 100644
--- a/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php
+++ b/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php
@@ -9,19 +9,23 @@ use Wallabag\CoreBundle\Entity\Entry;
9use Wallabag\CoreBundle\Entity\Tag; 9use Wallabag\CoreBundle\Entity\Tag;
10use Psr\Log\LoggerInterface; 10use Psr\Log\LoggerInterface;
11use Psr\Log\NullLogger; 11use Psr\Log\NullLogger;
12use Symfony\Component\EventDispatcher\EventDispatcherInterface;
13use Wallabag\CoreBundle\Event\EntrySavedEvent;
12 14
13abstract class AbstractConsumer 15abstract class AbstractConsumer
14{ 16{
15 protected $em; 17 protected $em;
16 protected $userRepository; 18 protected $userRepository;
17 protected $import; 19 protected $import;
20 protected $eventDispatcher;
18 protected $logger; 21 protected $logger;
19 22
20 public function __construct(EntityManager $em, UserRepository $userRepository, AbstractImport $import, LoggerInterface $logger = null) 23 public function __construct(EntityManager $em, UserRepository $userRepository, AbstractImport $import, EventDispatcherInterface $eventDispatcher, LoggerInterface $logger = null)
21 { 24 {
22 $this->em = $em; 25 $this->em = $em;
23 $this->userRepository = $userRepository; 26 $this->userRepository = $userRepository;
24 $this->import = $import; 27 $this->import = $import;
28 $this->eventDispatcher = $eventDispatcher;
25 $this->logger = $logger ?: new NullLogger(); 29 $this->logger = $logger ?: new NullLogger();
26 } 30 }
27 31
@@ -59,6 +63,9 @@ abstract class AbstractConsumer
59 try { 63 try {
60 $this->em->flush(); 64 $this->em->flush();
61 65
66 // entry saved, dispatch event about it!
67 $this->eventDispatcher->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
68
62 // clear only affected entities 69 // clear only affected entities
63 $this->em->clear(Entry::class); 70 $this->em->clear(Entry::class);
64 $this->em->clear(Tag::class); 71 $this->em->clear(Tag::class);
diff --git a/src/Wallabag/ImportBundle/Controller/BrowserController.php b/src/Wallabag/ImportBundle/Controller/BrowserController.php
index 144a4880..e119098f 100644
--- a/src/Wallabag/ImportBundle/Controller/BrowserController.php
+++ b/src/Wallabag/ImportBundle/Controller/BrowserController.php
@@ -39,7 +39,7 @@ abstract class BrowserController extends Controller
39 $wallabag = $this->getImportService(); 39 $wallabag = $this->getImportService();
40 $wallabag->setUser($this->getUser()); 40 $wallabag->setUser($this->getUser());
41 41
42 if ($form->isValid()) { 42 if ($form->isSubmitted() && $form->isValid()) {
43 $file = $form->get('file')->getData(); 43 $file = $form->get('file')->getData();
44 $markAsRead = $form->get('mark_as_read')->getData(); 44 $markAsRead = $form->get('mark_as_read')->getData();
45 $name = $this->getUser()->getId().'.json'; 45 $name = $this->getUser()->getId().'.json';
diff --git a/src/Wallabag/ImportBundle/Controller/ImportController.php b/src/Wallabag/ImportBundle/Controller/ImportController.php
index 15de75ff..237c748e 100644
--- a/src/Wallabag/ImportBundle/Controller/ImportController.php
+++ b/src/Wallabag/ImportBundle/Controller/ImportController.php
@@ -42,6 +42,7 @@ class ImportController extends Controller
42 + $this->getTotalMessageInRabbitQueue('firefox') 42 + $this->getTotalMessageInRabbitQueue('firefox')
43 + $this->getTotalMessageInRabbitQueue('chrome') 43 + $this->getTotalMessageInRabbitQueue('chrome')
44 + $this->getTotalMessageInRabbitQueue('instapaper') 44 + $this->getTotalMessageInRabbitQueue('instapaper')
45 + $this->getTotalMessageInRabbitQueue('pinboard')
45 ; 46 ;
46 } catch (\Exception $e) { 47 } catch (\Exception $e) {
47 $rabbitNotInstalled = true; 48 $rabbitNotInstalled = true;
@@ -57,6 +58,7 @@ class ImportController extends Controller
57 + $redis->llen('wallabag.import.firefox') 58 + $redis->llen('wallabag.import.firefox')
58 + $redis->llen('wallabag.import.chrome') 59 + $redis->llen('wallabag.import.chrome')
59 + $redis->llen('wallabag.import.instapaper') 60 + $redis->llen('wallabag.import.instapaper')
61 + $redis->llen('wallabag.import.pinboard')
60 ; 62 ;
61 } catch (\Exception $e) { 63 } catch (\Exception $e) {
62 $redisNotInstalled = true; 64 $redisNotInstalled = true;
diff --git a/src/Wallabag/ImportBundle/Controller/InstapaperController.php b/src/Wallabag/ImportBundle/Controller/InstapaperController.php
index c3fc8a39..0251acb9 100644
--- a/src/Wallabag/ImportBundle/Controller/InstapaperController.php
+++ b/src/Wallabag/ImportBundle/Controller/InstapaperController.php
@@ -26,7 +26,7 @@ class InstapaperController extends Controller
26 $instapaper->setProducer($this->get('wallabag_import.producer.redis.instapaper')); 26 $instapaper->setProducer($this->get('wallabag_import.producer.redis.instapaper'));
27 } 27 }
28 28
29 if ($form->isValid()) { 29 if ($form->isSubmitted() && $form->isValid()) {
30 $file = $form->get('file')->getData(); 30 $file = $form->get('file')->getData();
31 $markAsRead = $form->get('mark_as_read')->getData(); 31 $markAsRead = $form->get('mark_as_read')->getData();
32 $name = 'instapaper_'.$this->getUser()->getId().'.csv'; 32 $name = 'instapaper_'.$this->getUser()->getId().'.csv';
diff --git a/src/Wallabag/ImportBundle/Controller/PinboardController.php b/src/Wallabag/ImportBundle/Controller/PinboardController.php
new file mode 100644
index 00000000..d0ad8aa8
--- /dev/null
+++ b/src/Wallabag/ImportBundle/Controller/PinboardController.php
@@ -0,0 +1,77 @@
1<?php
2
3namespace Wallabag\ImportBundle\Controller;
4
5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
7use Symfony\Component\HttpFoundation\Request;
8use Wallabag\ImportBundle\Form\Type\UploadImportType;
9
10class PinboardController extends Controller
11{
12 /**
13 * @Route("/pinboard", name="import_pinboard")
14 */
15 public function indexAction(Request $request)
16 {
17 $form = $this->createForm(UploadImportType::class);
18 $form->handleRequest($request);
19
20 $pinboard = $this->get('wallabag_import.pinboard.import');
21 $pinboard->setUser($this->getUser());
22
23 if ($this->get('craue_config')->get('import_with_rabbitmq')) {
24 $pinboard->setProducer($this->get('old_sound_rabbit_mq.import_pinboard_producer'));
25 } elseif ($this->get('craue_config')->get('import_with_redis')) {
26 $pinboard->setProducer($this->get('wallabag_import.producer.redis.pinboard'));
27 }
28
29 if ($form->isSubmitted() && $form->isValid()) {
30 $file = $form->get('file')->getData();
31 $markAsRead = $form->get('mark_as_read')->getData();
32 $name = 'pinboard_'.$this->getUser()->getId().'.json';
33
34 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
35 $res = $pinboard
36 ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
37 ->setMarkAsRead($markAsRead)
38 ->import();
39
40 $message = 'flashes.import.notice.failed';
41
42 if (true === $res) {
43 $summary = $pinboard->getSummary();
44 $message = $this->get('translator')->trans('flashes.import.notice.summary', [
45 '%imported%' => $summary['imported'],
46 '%skipped%' => $summary['skipped'],
47 ]);
48
49 if (0 < $summary['queued']) {
50 $message = $this->get('translator')->trans('flashes.import.notice.summary_with_queue', [
51 '%queued%' => $summary['queued'],
52 ]);
53 }
54
55 unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name);
56 }
57
58 $this->get('session')->getFlashBag()->add(
59 'notice',
60 $message
61 );
62
63 return $this->redirect($this->generateUrl('homepage'));
64 } else {
65 $this->get('session')->getFlashBag()->add(
66 'notice',
67 'flashes.import.notice.failed_on_file'
68 );
69 }
70 }
71
72 return $this->render('WallabagImportBundle:Pinboard:index.html.twig', [
73 'form' => $form->createView(),
74 'import' => $pinboard,
75 ]);
76 }
77}
diff --git a/src/Wallabag/ImportBundle/Controller/ReadabilityController.php b/src/Wallabag/ImportBundle/Controller/ReadabilityController.php
index d00e22c2..aa732ddd 100644
--- a/src/Wallabag/ImportBundle/Controller/ReadabilityController.php
+++ b/src/Wallabag/ImportBundle/Controller/ReadabilityController.php
@@ -26,7 +26,7 @@ class ReadabilityController extends Controller
26 $readability->setProducer($this->get('wallabag_import.producer.redis.readability')); 26 $readability->setProducer($this->get('wallabag_import.producer.redis.readability'));
27 } 27 }
28 28
29 if ($form->isValid()) { 29 if ($form->isSubmitted() && $form->isValid()) {
30 $file = $form->get('file')->getData(); 30 $file = $form->get('file')->getData();
31 $markAsRead = $form->get('mark_as_read')->getData(); 31 $markAsRead = $form->get('mark_as_read')->getData();
32 $name = 'readability_'.$this->getUser()->getId().'.json'; 32 $name = 'readability_'.$this->getUser()->getId().'.json';
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagController.php b/src/Wallabag/ImportBundle/Controller/WallabagController.php
index 9c0cde80..e81c1ca9 100644
--- a/src/Wallabag/ImportBundle/Controller/WallabagController.php
+++ b/src/Wallabag/ImportBundle/Controller/WallabagController.php
@@ -40,7 +40,7 @@ abstract class WallabagController extends Controller
40 $wallabag = $this->getImportService(); 40 $wallabag = $this->getImportService();
41 $wallabag->setUser($this->getUser()); 41 $wallabag->setUser($this->getUser());
42 42
43 if ($form->isValid()) { 43 if ($form->isSubmitted() && $form->isValid()) {
44 $file = $form->get('file')->getData(); 44 $file = $form->get('file')->getData();
45 $markAsRead = $form->get('mark_as_read')->getData(); 45 $markAsRead = $form->get('mark_as_read')->getData();
46 $name = $this->getUser()->getId().'.json'; 46 $name = $this->getUser()->getId().'.json';
diff --git a/src/Wallabag/ImportBundle/Import/AbstractImport.php b/src/Wallabag/ImportBundle/Import/AbstractImport.php
index 764b390a..1d4a6e27 100644
--- a/src/Wallabag/ImportBundle/Import/AbstractImport.php
+++ b/src/Wallabag/ImportBundle/Import/AbstractImport.php
@@ -10,12 +10,15 @@ use Wallabag\CoreBundle\Entity\Entry;
10use Wallabag\CoreBundle\Entity\Tag; 10use Wallabag\CoreBundle\Entity\Tag;
11use Wallabag\UserBundle\Entity\User; 11use Wallabag\UserBundle\Entity\User;
12use OldSound\RabbitMqBundle\RabbitMq\ProducerInterface; 12use OldSound\RabbitMqBundle\RabbitMq\ProducerInterface;
13use Symfony\Component\EventDispatcher\EventDispatcherInterface;
14use Wallabag\CoreBundle\Event\EntrySavedEvent;
13 15
14abstract class AbstractImport implements ImportInterface 16abstract class AbstractImport implements ImportInterface
15{ 17{
16 protected $em; 18 protected $em;
17 protected $logger; 19 protected $logger;
18 protected $contentProxy; 20 protected $contentProxy;
21 protected $eventDispatcher;
19 protected $producer; 22 protected $producer;
20 protected $user; 23 protected $user;
21 protected $markAsRead; 24 protected $markAsRead;
@@ -23,11 +26,12 @@ abstract class AbstractImport implements ImportInterface
23 protected $importedEntries = 0; 26 protected $importedEntries = 0;
24 protected $queuedEntries = 0; 27 protected $queuedEntries = 0;
25 28
26 public function __construct(EntityManager $em, ContentProxy $contentProxy) 29 public function __construct(EntityManager $em, ContentProxy $contentProxy, EventDispatcherInterface $eventDispatcher)
27 { 30 {
28 $this->em = $em; 31 $this->em = $em;
29 $this->logger = new NullLogger(); 32 $this->logger = new NullLogger();
30 $this->contentProxy = $contentProxy; 33 $this->contentProxy = $contentProxy;
34 $this->eventDispatcher = $eventDispatcher;
31 } 35 }
32 36
33 public function setLogger(LoggerInterface $logger) 37 public function setLogger(LoggerInterface $logger)
@@ -104,6 +108,7 @@ abstract class AbstractImport implements ImportInterface
104 protected function parseEntries($entries) 108 protected function parseEntries($entries)
105 { 109 {
106 $i = 1; 110 $i = 1;
111 $entryToBeFlushed = [];
107 112
108 foreach ($entries as $importedEntry) { 113 foreach ($entries as $importedEntry) {
109 if ($this->markAsRead) { 114 if ($this->markAsRead) {
@@ -116,10 +121,21 @@ abstract class AbstractImport implements ImportInterface
116 continue; 121 continue;
117 } 122 }
118 123
124 // store each entry to be flushed so we can trigger the entry.saved event for each of them
125 // entry.saved needs the entry to be persisted in db because it needs it id to generate
126 // images (at least)
127 $entryToBeFlushed[] = $entry;
128
119 // flush every 20 entries 129 // flush every 20 entries
120 if (($i % 20) === 0) { 130 if (($i % 20) === 0) {
121 $this->em->flush(); 131 $this->em->flush();
122 132
133 foreach ($entryToBeFlushed as $entry) {
134 $this->eventDispatcher->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
135 }
136
137 $entryToBeFlushed = [];
138
123 // clear only affected entities 139 // clear only affected entities
124 $this->em->clear(Entry::class); 140 $this->em->clear(Entry::class);
125 $this->em->clear(Tag::class); 141 $this->em->clear(Tag::class);
@@ -128,6 +144,12 @@ abstract class AbstractImport implements ImportInterface
128 } 144 }
129 145
130 $this->em->flush(); 146 $this->em->flush();
147
148 if (!empty($entryToBeFlushed)) {
149 foreach ($entryToBeFlushed as $entry) {
150 $this->eventDispatcher->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
151 }
152 }
131 } 153 }
132 154
133 /** 155 /**
diff --git a/src/Wallabag/ImportBundle/Import/BrowserImport.php b/src/Wallabag/ImportBundle/Import/BrowserImport.php
index 2ca1683b..8bf7d92e 100644
--- a/src/Wallabag/ImportBundle/Import/BrowserImport.php
+++ b/src/Wallabag/ImportBundle/Import/BrowserImport.php
@@ -5,6 +5,7 @@ namespace Wallabag\ImportBundle\Import;
5use Wallabag\CoreBundle\Entity\Entry; 5use Wallabag\CoreBundle\Entity\Entry;
6use Wallabag\UserBundle\Entity\User; 6use Wallabag\UserBundle\Entity\User;
7use Wallabag\CoreBundle\Helper\ContentProxy; 7use Wallabag\CoreBundle\Helper\ContentProxy;
8use Wallabag\CoreBundle\Event\EntrySavedEvent;
8 9
9abstract class BrowserImport extends AbstractImport 10abstract class BrowserImport extends AbstractImport
10{ 11{
@@ -81,6 +82,7 @@ abstract class BrowserImport extends AbstractImport
81 protected function parseEntries($entries) 82 protected function parseEntries($entries)
82 { 83 {
83 $i = 1; 84 $i = 1;
85 $entryToBeFlushed = [];
84 86
85 foreach ($entries as $importedEntry) { 87 foreach ($entries as $importedEntry) {
86 if ((array) $importedEntry !== $importedEntry) { 88 if ((array) $importedEntry !== $importedEntry) {
@@ -93,14 +95,29 @@ abstract class BrowserImport extends AbstractImport
93 continue; 95 continue;
94 } 96 }
95 97
98 // @see AbstractImport
99 $entryToBeFlushed[] = $entry;
100
96 // flush every 20 entries 101 // flush every 20 entries
97 if (($i % 20) === 0) { 102 if (($i % 20) === 0) {
98 $this->em->flush(); 103 $this->em->flush();
104
105 foreach ($entryToBeFlushed as $entry) {
106 $this->eventDispatcher->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
107 }
108
109 $entryToBeFlushed = [];
99 } 110 }
100 ++$i; 111 ++$i;
101 } 112 }
102 113
103 $this->em->flush(); 114 $this->em->flush();
115
116 if (!empty($entryToBeFlushed)) {
117 foreach ($entryToBeFlushed as $entry) {
118 $this->eventDispatcher->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
119 }
120 }
104 } 121 }
105 122
106 /** 123 /**
diff --git a/src/Wallabag/ImportBundle/Import/ChromeImport.php b/src/Wallabag/ImportBundle/Import/ChromeImport.php
index d7620bcb..2667890f 100644
--- a/src/Wallabag/ImportBundle/Import/ChromeImport.php
+++ b/src/Wallabag/ImportBundle/Import/ChromeImport.php
@@ -37,9 +37,10 @@ class ChromeImport extends BrowserImport
37 { 37 {
38 $data = [ 38 $data = [
39 'title' => $entry['name'], 39 'title' => $entry['name'],
40 'html' => '', 40 'html' => false,
41 'url' => $entry['url'], 41 'url' => $entry['url'],
42 'is_archived' => $this->markAsRead, 42 'is_archived' => (int) $this->markAsRead,
43 'is_starred' => false,
43 'tags' => '', 44 'tags' => '',
44 'created_at' => substr($entry['date_added'], 0, 10), 45 'created_at' => substr($entry['date_added'], 0, 10),
45 ]; 46 ];
diff --git a/src/Wallabag/ImportBundle/Import/FirefoxImport.php b/src/Wallabag/ImportBundle/Import/FirefoxImport.php
index e010f5a4..c50c69b3 100644
--- a/src/Wallabag/ImportBundle/Import/FirefoxImport.php
+++ b/src/Wallabag/ImportBundle/Import/FirefoxImport.php
@@ -37,9 +37,10 @@ class FirefoxImport extends BrowserImport
37 { 37 {
38 $data = [ 38 $data = [
39 'title' => $entry['title'], 39 'title' => $entry['title'],
40 'html' => '', 40 'html' => false,
41 'url' => $entry['uri'], 41 'url' => $entry['uri'],
42 'is_archived' => $this->markAsRead, 42 'is_archived' => (int) $this->markAsRead,
43 'is_starred' => false,
43 'tags' => '', 44 'tags' => '',
44 'created_at' => substr($entry['dateAdded'], 0, 10), 45 'created_at' => substr($entry['dateAdded'], 0, 10),
45 ]; 46 ];
diff --git a/src/Wallabag/ImportBundle/Import/InstapaperImport.php b/src/Wallabag/ImportBundle/Import/InstapaperImport.php
index cf4c785c..70a53f1a 100644
--- a/src/Wallabag/ImportBundle/Import/InstapaperImport.php
+++ b/src/Wallabag/ImportBundle/Import/InstapaperImport.php
@@ -74,8 +74,7 @@ class InstapaperImport extends AbstractImport
74 'status' => $data[3], 74 'status' => $data[3],
75 'is_archived' => $data[3] === 'Archive' || $data[3] === 'Starred', 75 'is_archived' => $data[3] === 'Archive' || $data[3] === 'Starred',
76 'is_starred' => $data[3] === 'Starred', 76 'is_starred' => $data[3] === 'Starred',
77 'content_type' => '', 77 'html' => false,
78 'language' => '',
79 ]; 78 ];
80 } 79 }
81 fclose($handle); 80 fclose($handle);
diff --git a/src/Wallabag/ImportBundle/Import/PinboardImport.php b/src/Wallabag/ImportBundle/Import/PinboardImport.php
new file mode 100644
index 00000000..d9865534
--- /dev/null
+++ b/src/Wallabag/ImportBundle/Import/PinboardImport.php
@@ -0,0 +1,141 @@
1<?php
2
3namespace Wallabag\ImportBundle\Import;
4
5use Wallabag\CoreBundle\Entity\Entry;
6
7class PinboardImport extends AbstractImport
8{
9 private $filepath;
10
11 /**
12 * {@inheritdoc}
13 */
14 public function getName()
15 {
16 return 'Pinboard';
17 }
18
19 /**
20 * {@inheritdoc}
21 */
22 public function getUrl()
23 {
24 return 'import_pinboard';
25 }
26
27 /**
28 * {@inheritdoc}
29 */
30 public function getDescription()
31 {
32 return 'import.pinboard.description';
33 }
34
35 /**
36 * Set file path to the json file.
37 *
38 * @param string $filepath
39 */
40 public function setFilepath($filepath)
41 {
42 $this->filepath = $filepath;
43
44 return $this;
45 }
46
47 /**
48 * {@inheritdoc}
49 */
50 public function import()
51 {
52 if (!$this->user) {
53 $this->logger->error('PinboardImport: user is not defined');
54
55 return false;
56 }
57
58 if (!file_exists($this->filepath) || !is_readable($this->filepath)) {
59 $this->logger->error('PinboardImport: unable to read file', ['filepath' => $this->filepath]);
60
61 return false;
62 }
63
64 $data = json_decode(file_get_contents($this->filepath), true);
65
66 if (empty($data)) {
67 $this->logger->error('PinboardImport: no entries in imported file');
68
69 return false;
70 }
71
72 if ($this->producer) {
73 $this->parseEntriesForProducer($data);
74
75 return true;
76 }
77
78 $this->parseEntries($data);
79
80 return true;
81 }
82
83 /**
84 * {@inheritdoc}
85 */
86 public function parseEntry(array $importedEntry)
87 {
88 $existingEntry = $this->em
89 ->getRepository('WallabagCoreBundle:Entry')
90 ->findByUrlAndUserId($importedEntry['href'], $this->user->getId());
91
92 if (false !== $existingEntry) {
93 ++$this->skippedEntries;
94
95 return;
96 }
97
98 $data = [
99 'title' => $importedEntry['description'],
100 'url' => $importedEntry['href'],
101 'is_archived' => ('no' === $importedEntry['toread']) || $this->markAsRead,
102 'is_starred' => false,
103 'created_at' => $importedEntry['time'],
104 'tags' => explode(' ', $importedEntry['tags']),
105 ];
106
107 $entry = new Entry($this->user);
108 $entry->setUrl($data['url']);
109 $entry->setTitle($data['title']);
110
111 // update entry with content (in case fetching failed, the given entry will be return)
112 $entry = $this->fetchContent($entry, $data['url'], $data);
113
114 if (!empty($data['tags'])) {
115 $this->contentProxy->assignTagsToEntry(
116 $entry,
117 $data['tags'],
118 $this->em->getUnitOfWork()->getScheduledEntityInsertions()
119 );
120 }
121
122 $entry->setArchived($data['is_archived']);
123 $entry->setStarred($data['is_starred']);
124 $entry->setCreatedAt(new \DateTime($data['created_at']));
125
126 $this->em->persist($entry);
127 ++$this->importedEntries;
128
129 return $entry;
130 }
131
132 /**
133 * {@inheritdoc}
134 */
135 protected function setEntryAsRead(array $importedEntry)
136 {
137 $importedEntry['toread'] = 'no';
138
139 return $importedEntry;
140 }
141}
diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php
index 327e2500..33093480 100644
--- a/src/Wallabag/ImportBundle/Import/PocketImport.php
+++ b/src/Wallabag/ImportBundle/Import/PocketImport.php
@@ -2,8 +2,6 @@
2 2
3namespace Wallabag\ImportBundle\Import; 3namespace Wallabag\ImportBundle\Import;
4 4
5use Psr\Log\NullLogger;
6use Doctrine\ORM\EntityManager;
7use GuzzleHttp\Client; 5use GuzzleHttp\Client;
8use GuzzleHttp\Exception\RequestException; 6use GuzzleHttp\Exception\RequestException;
9use Wallabag\CoreBundle\Entity\Entry; 7use Wallabag\CoreBundle\Entity\Entry;
@@ -16,13 +14,6 @@ class PocketImport extends AbstractImport
16 14
17 const NB_ELEMENTS = 5000; 15 const NB_ELEMENTS = 5000;
18 16
19 public function __construct(EntityManager $em, ContentProxy $contentProxy)
20 {
21 $this->em = $em;
22 $this->contentProxy = $contentProxy;
23 $this->logger = new NullLogger();
24 }
25
26 /** 17 /**
27 * Only used for test purpose. 18 * Only used for test purpose.
28 * 19 *
diff --git a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php
index b8c0f777..de320d23 100644
--- a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php
+++ b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php
@@ -98,11 +98,10 @@ class ReadabilityImport extends AbstractImport
98 $data = [ 98 $data = [
99 'title' => $importedEntry['article__title'], 99 'title' => $importedEntry['article__title'],
100 'url' => $importedEntry['article__url'], 100 'url' => $importedEntry['article__url'],
101 'content_type' => '',
102 'language' => '',
103 'is_archived' => $importedEntry['archive'] || $this->markAsRead, 101 'is_archived' => $importedEntry['archive'] || $this->markAsRead,
104 'is_starred' => $importedEntry['favorite'], 102 'is_starred' => $importedEntry['favorite'],
105 'created_at' => $importedEntry['date_added'], 103 'created_at' => $importedEntry['date_added'],
104 'html' => false,
106 ]; 105 ];
107 106
108 $entry = new Entry($this->user); 107 $entry = new Entry($this->user);
diff --git a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
index 4f001062..59e3ce02 100644
--- a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
+++ b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
@@ -37,8 +37,6 @@ class WallabagV1Import extends WallabagImport
37 'title' => $entry['title'], 37 'title' => $entry['title'],
38 'html' => $entry['content'], 38 'html' => $entry['content'],
39 'url' => $entry['url'], 39 'url' => $entry['url'],
40 'content_type' => '',
41 'language' => '',
42 'is_archived' => $entry['is_read'] || $this->markAsRead, 40 'is_archived' => $entry['is_read'] || $this->markAsRead,
43 'is_starred' => $entry['is_fav'], 41 'is_starred' => $entry['is_fav'],
44 'tags' => '', 42 'tags' => '',
diff --git a/src/Wallabag/ImportBundle/Import/WallabagV2Import.php b/src/Wallabag/ImportBundle/Import/WallabagV2Import.php
index 37c8ca14..d2a89d79 100644
--- a/src/Wallabag/ImportBundle/Import/WallabagV2Import.php
+++ b/src/Wallabag/ImportBundle/Import/WallabagV2Import.php
@@ -36,7 +36,8 @@ class WallabagV2Import extends WallabagImport
36 return [ 36 return [
37 'html' => $entry['content'], 37 'html' => $entry['content'],
38 'content_type' => $entry['mimetype'], 38 'content_type' => $entry['mimetype'],
39 'is_archived' => ($entry['is_archived'] || $this->markAsRead), 39 'is_archived' => (int) ($entry['is_archived'] || $this->markAsRead),
40 'is_starred' => false,
40 ] + $entry; 41 ] + $entry;
41 } 42 }
42 43
diff --git a/src/Wallabag/ImportBundle/Resources/config/rabbit.yml b/src/Wallabag/ImportBundle/Resources/config/rabbit.yml
index 70b8a0d4..e9ecb846 100644
--- a/src/Wallabag/ImportBundle/Resources/config/rabbit.yml
+++ b/src/Wallabag/ImportBundle/Resources/config/rabbit.yml
@@ -6,6 +6,7 @@ services:
6 - "@doctrine.orm.entity_manager" 6 - "@doctrine.orm.entity_manager"
7 - "@wallabag_user.user_repository" 7 - "@wallabag_user.user_repository"
8 - "@wallabag_import.pocket.import" 8 - "@wallabag_import.pocket.import"
9 - "@event_dispatcher"
9 - "@logger" 10 - "@logger"
10 wallabag_import.consumer.amqp.readability: 11 wallabag_import.consumer.amqp.readability:
11 class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer 12 class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
@@ -13,6 +14,7 @@ services:
13 - "@doctrine.orm.entity_manager" 14 - "@doctrine.orm.entity_manager"
14 - "@wallabag_user.user_repository" 15 - "@wallabag_user.user_repository"
15 - "@wallabag_import.readability.import" 16 - "@wallabag_import.readability.import"
17 - "@event_dispatcher"
16 - "@logger" 18 - "@logger"
17 wallabag_import.consumer.amqp.instapaper: 19 wallabag_import.consumer.amqp.instapaper:
18 class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer 20 class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
@@ -20,6 +22,15 @@ services:
20 - "@doctrine.orm.entity_manager" 22 - "@doctrine.orm.entity_manager"
21 - "@wallabag_user.user_repository" 23 - "@wallabag_user.user_repository"
22 - "@wallabag_import.instapaper.import" 24 - "@wallabag_import.instapaper.import"
25 - "@event_dispatcher"
26 - "@logger"
27 wallabag_import.consumer.amqp.pinboard:
28 class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
29 arguments:
30 - "@doctrine.orm.entity_manager"
31 - "@wallabag_user.user_repository"
32 - "@wallabag_import.pinboard.import"
33 - "@event_dispatcher"
23 - "@logger" 34 - "@logger"
24 wallabag_import.consumer.amqp.wallabag_v1: 35 wallabag_import.consumer.amqp.wallabag_v1:
25 class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer 36 class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
@@ -27,6 +38,7 @@ services:
27 - "@doctrine.orm.entity_manager" 38 - "@doctrine.orm.entity_manager"
28 - "@wallabag_user.user_repository" 39 - "@wallabag_user.user_repository"
29 - "@wallabag_import.wallabag_v1.import" 40 - "@wallabag_import.wallabag_v1.import"
41 - "@event_dispatcher"
30 - "@logger" 42 - "@logger"
31 wallabag_import.consumer.amqp.wallabag_v2: 43 wallabag_import.consumer.amqp.wallabag_v2:
32 class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer 44 class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
@@ -34,6 +46,7 @@ services:
34 - "@doctrine.orm.entity_manager" 46 - "@doctrine.orm.entity_manager"
35 - "@wallabag_user.user_repository" 47 - "@wallabag_user.user_repository"
36 - "@wallabag_import.wallabag_v2.import" 48 - "@wallabag_import.wallabag_v2.import"
49 - "@event_dispatcher"
37 - "@logger" 50 - "@logger"
38 wallabag_import.consumer.amqp.firefox: 51 wallabag_import.consumer.amqp.firefox:
39 class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer 52 class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
@@ -41,6 +54,7 @@ services:
41 - "@doctrine.orm.entity_manager" 54 - "@doctrine.orm.entity_manager"
42 - "@wallabag_user.user_repository" 55 - "@wallabag_user.user_repository"
43 - "@wallabag_import.firefox.import" 56 - "@wallabag_import.firefox.import"
57 - "@event_dispatcher"
44 - "@logger" 58 - "@logger"
45 wallabag_import.consumer.amqp.chrome: 59 wallabag_import.consumer.amqp.chrome:
46 class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer 60 class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
@@ -48,4 +62,5 @@ services:
48 - "@doctrine.orm.entity_manager" 62 - "@doctrine.orm.entity_manager"
49 - "@wallabag_user.user_repository" 63 - "@wallabag_user.user_repository"
50 - "@wallabag_import.chrome.import" 64 - "@wallabag_import.chrome.import"
65 - "@event_dispatcher"
51 - "@logger" 66 - "@logger"
diff --git a/src/Wallabag/ImportBundle/Resources/config/redis.yml b/src/Wallabag/ImportBundle/Resources/config/redis.yml
index 0a81e1b5..091cdba0 100644
--- a/src/Wallabag/ImportBundle/Resources/config/redis.yml
+++ b/src/Wallabag/ImportBundle/Resources/config/redis.yml
@@ -18,6 +18,7 @@ services:
18 - "@doctrine.orm.entity_manager" 18 - "@doctrine.orm.entity_manager"
19 - "@wallabag_user.user_repository" 19 - "@wallabag_user.user_repository"
20 - "@wallabag_import.readability.import" 20 - "@wallabag_import.readability.import"
21 - "@event_dispatcher"
21 - "@logger" 22 - "@logger"
22 23
23 # instapaper 24 # instapaper
@@ -38,6 +39,28 @@ services:
38 - "@doctrine.orm.entity_manager" 39 - "@doctrine.orm.entity_manager"
39 - "@wallabag_user.user_repository" 40 - "@wallabag_user.user_repository"
40 - "@wallabag_import.instapaper.import" 41 - "@wallabag_import.instapaper.import"
42 - "@event_dispatcher"
43 - "@logger"
44
45 # pinboard
46 wallabag_import.queue.redis.pinboard:
47 class: Simpleue\Queue\RedisQueue
48 arguments:
49 - "@wallabag_core.redis.client"
50 - "wallabag.import.pinboard"
51
52 wallabag_import.producer.redis.pinboard:
53 class: Wallabag\ImportBundle\Redis\Producer
54 arguments:
55 - "@wallabag_import.queue.redis.pinboard"
56
57 wallabag_import.consumer.redis.pinboard:
58 class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer
59 arguments:
60 - "@doctrine.orm.entity_manager"
61 - "@wallabag_user.user_repository"
62 - "@wallabag_import.pinboard.import"
63 - "@event_dispatcher"
41 - "@logger" 64 - "@logger"
42 65
43 # pocket 66 # pocket
@@ -58,6 +81,7 @@ services:
58 - "@doctrine.orm.entity_manager" 81 - "@doctrine.orm.entity_manager"
59 - "@wallabag_user.user_repository" 82 - "@wallabag_user.user_repository"
60 - "@wallabag_import.pocket.import" 83 - "@wallabag_import.pocket.import"
84 - "@event_dispatcher"
61 - "@logger" 85 - "@logger"
62 86
63 # wallabag v1 87 # wallabag v1
@@ -78,6 +102,7 @@ services:
78 - "@doctrine.orm.entity_manager" 102 - "@doctrine.orm.entity_manager"
79 - "@wallabag_user.user_repository" 103 - "@wallabag_user.user_repository"
80 - "@wallabag_import.wallabag_v1.import" 104 - "@wallabag_import.wallabag_v1.import"
105 - "@event_dispatcher"
81 - "@logger" 106 - "@logger"
82 107
83 # wallabag v2 108 # wallabag v2
@@ -98,6 +123,7 @@ services:
98 - "@doctrine.orm.entity_manager" 123 - "@doctrine.orm.entity_manager"
99 - "@wallabag_user.user_repository" 124 - "@wallabag_user.user_repository"
100 - "@wallabag_import.wallabag_v2.import" 125 - "@wallabag_import.wallabag_v2.import"
126 - "@event_dispatcher"
101 - "@logger" 127 - "@logger"
102 128
103 # firefox 129 # firefox
@@ -118,6 +144,7 @@ services:
118 - "@doctrine.orm.entity_manager" 144 - "@doctrine.orm.entity_manager"
119 - "@wallabag_user.user_repository" 145 - "@wallabag_user.user_repository"
120 - "@wallabag_import.firefox.import" 146 - "@wallabag_import.firefox.import"
147 - "@event_dispatcher"
121 - "@logger" 148 - "@logger"
122 149
123 # chrome 150 # chrome
@@ -138,4 +165,5 @@ services:
138 - "@doctrine.orm.entity_manager" 165 - "@doctrine.orm.entity_manager"
139 - "@wallabag_user.user_repository" 166 - "@wallabag_user.user_repository"
140 - "@wallabag_import.chrome.import" 167 - "@wallabag_import.chrome.import"
168 - "@event_dispatcher"
141 - "@logger" 169 - "@logger"
diff --git a/src/Wallabag/ImportBundle/Resources/config/services.yml b/src/Wallabag/ImportBundle/Resources/config/services.yml
index d600be0f..c4fe3f92 100644
--- a/src/Wallabag/ImportBundle/Resources/config/services.yml
+++ b/src/Wallabag/ImportBundle/Resources/config/services.yml
@@ -20,6 +20,7 @@ services:
20 arguments: 20 arguments:
21 - "@doctrine.orm.entity_manager" 21 - "@doctrine.orm.entity_manager"
22 - "@wallabag_core.content_proxy" 22 - "@wallabag_core.content_proxy"
23 - "@event_dispatcher"
23 calls: 24 calls:
24 - [ setClient, [ "@wallabag_import.pocket.client" ] ] 25 - [ setClient, [ "@wallabag_import.pocket.client" ] ]
25 - [ setLogger, [ "@logger" ]] 26 - [ setLogger, [ "@logger" ]]
@@ -31,6 +32,7 @@ services:
31 arguments: 32 arguments:
32 - "@doctrine.orm.entity_manager" 33 - "@doctrine.orm.entity_manager"
33 - "@wallabag_core.content_proxy" 34 - "@wallabag_core.content_proxy"
35 - "@event_dispatcher"
34 calls: 36 calls:
35 - [ setLogger, [ "@logger" ]] 37 - [ setLogger, [ "@logger" ]]
36 tags: 38 tags:
@@ -41,6 +43,7 @@ services:
41 arguments: 43 arguments:
42 - "@doctrine.orm.entity_manager" 44 - "@doctrine.orm.entity_manager"
43 - "@wallabag_core.content_proxy" 45 - "@wallabag_core.content_proxy"
46 - "@event_dispatcher"
44 calls: 47 calls:
45 - [ setLogger, [ "@logger" ]] 48 - [ setLogger, [ "@logger" ]]
46 tags: 49 tags:
@@ -51,6 +54,7 @@ services:
51 arguments: 54 arguments:
52 - "@doctrine.orm.entity_manager" 55 - "@doctrine.orm.entity_manager"
53 - "@wallabag_core.content_proxy" 56 - "@wallabag_core.content_proxy"
57 - "@event_dispatcher"
54 calls: 58 calls:
55 - [ setLogger, [ "@logger" ]] 59 - [ setLogger, [ "@logger" ]]
56 tags: 60 tags:
@@ -61,16 +65,29 @@ services:
61 arguments: 65 arguments:
62 - "@doctrine.orm.entity_manager" 66 - "@doctrine.orm.entity_manager"
63 - "@wallabag_core.content_proxy" 67 - "@wallabag_core.content_proxy"
68 - "@event_dispatcher"
64 calls: 69 calls:
65 - [ setLogger, [ "@logger" ]] 70 - [ setLogger, [ "@logger" ]]
66 tags: 71 tags:
67 - { name: wallabag_import.import, alias: instapaper } 72 - { name: wallabag_import.import, alias: instapaper }
68 73
74 wallabag_import.pinboard.import:
75 class: Wallabag\ImportBundle\Import\PinboardImport
76 arguments:
77 - "@doctrine.orm.entity_manager"
78 - "@wallabag_core.content_proxy"
79 - "@event_dispatcher"
80 calls:
81 - [ setLogger, [ "@logger" ]]
82 tags:
83 - { name: wallabag_import.import, alias: pinboard }
84
69 wallabag_import.firefox.import: 85 wallabag_import.firefox.import:
70 class: Wallabag\ImportBundle\Import\FirefoxImport 86 class: Wallabag\ImportBundle\Import\FirefoxImport
71 arguments: 87 arguments:
72 - "@doctrine.orm.entity_manager" 88 - "@doctrine.orm.entity_manager"
73 - "@wallabag_core.content_proxy" 89 - "@wallabag_core.content_proxy"
90 - "@event_dispatcher"
74 calls: 91 calls:
75 - [ setLogger, [ "@logger" ]] 92 - [ setLogger, [ "@logger" ]]
76 tags: 93 tags:
@@ -80,6 +97,7 @@ services:
80 arguments: 97 arguments:
81 - "@doctrine.orm.entity_manager" 98 - "@doctrine.orm.entity_manager"
82 - "@wallabag_core.content_proxy" 99 - "@wallabag_core.content_proxy"
100 - "@event_dispatcher"
83 calls: 101 calls:
84 - [ setLogger, [ "@logger" ]] 102 - [ setLogger, [ "@logger" ]]
85 tags: 103 tags:
diff --git a/src/Wallabag/ImportBundle/Resources/views/Chrome/index.html.twig b/src/Wallabag/ImportBundle/Resources/views/Chrome/index.html.twig
index ead828c6..93b08540 100644
--- a/src/Wallabag/ImportBundle/Resources/views/Chrome/index.html.twig
+++ b/src/Wallabag/ImportBundle/Resources/views/Chrome/index.html.twig
@@ -6,6 +6,8 @@
6<div class="row"> 6<div class="row">
7 <div class="col s12"> 7 <div class="col s12">
8 <div class="card-panel settings"> 8 <div class="card-panel settings">
9 {% include 'WallabagImportBundle:Import:_information.html.twig' %}
10
9 <div class="row"> 11 <div class="row">
10 <blockquote>{{ import.description|trans|raw }}</blockquote> 12 <blockquote>{{ import.description|trans|raw }}</blockquote>
11 <p>{{ 'import.chrome.how_to'|trans }}</p> 13 <p>{{ 'import.chrome.how_to'|trans }}</p>
diff --git a/src/Wallabag/ImportBundle/Resources/views/Firefox/index.html.twig b/src/Wallabag/ImportBundle/Resources/views/Firefox/index.html.twig
index f975da3f..ced3f008 100644
--- a/src/Wallabag/ImportBundle/Resources/views/Firefox/index.html.twig
+++ b/src/Wallabag/ImportBundle/Resources/views/Firefox/index.html.twig
@@ -6,6 +6,8 @@
6<div class="row"> 6<div class="row">
7 <div class="col s12"> 7 <div class="col s12">
8 <div class="card-panel settings"> 8 <div class="card-panel settings">
9 {% include 'WallabagImportBundle:Import:_information.html.twig' %}
10
9 <div class="row"> 11 <div class="row">
10 <blockquote>{{ import.description|trans|raw }}</blockquote> 12 <blockquote>{{ import.description|trans|raw }}</blockquote>
11 <p>{{ 'import.firefox.how_to'|trans }}</p> 13 <p>{{ 'import.firefox.how_to'|trans }}</p>
diff --git a/src/Wallabag/ImportBundle/Resources/views/Import/_workerEnabled.html.twig b/src/Wallabag/ImportBundle/Resources/views/Import/_information.html.twig
index 2390a41f..48bbcfe7 100644
--- a/src/Wallabag/ImportBundle/Resources/views/Import/_workerEnabled.html.twig
+++ b/src/Wallabag/ImportBundle/Resources/views/Import/_information.html.twig
@@ -1,8 +1,15 @@
1{% set redis = craue_setting('import_with_redis') %} 1{% set redis = craue_setting('import_with_redis') %}
2{% set rabbit = craue_setting('import_with_rabbitmq') %} 2{% set rabbit = craue_setting('import_with_rabbitmq') %}
3{% set downloadImages = craue_setting('download_images_enabled') %}
3 4
4{% if redis or rabbit %} 5{% if redis or rabbit %}
5 <div class="card-panel yellow darken-1 black-text"> 6 <div class="card-panel yellow darken-1 black-text">
6 {{ 'import.worker.enabled'|trans }} <strong>{% if rabbit %}RabbitMQ{% elseif redis %}Redis{% endif %}</strong> 7 {{ 'import.worker.enabled'|trans }} <strong>{% if rabbit %}RabbitMQ{% elseif redis %}Redis{% endif %}</strong>
7 </div> 8 </div>
8{% endif %} 9{% endif %}
10
11{% if not redis and not rabbit and downloadImages %}
12 <div class="card-panel orange darken-1 black-text">
13 {{ 'import.worker.download_images_warning'|trans|raw }}
14 </div>
15{% endif %}
diff --git a/src/Wallabag/ImportBundle/Resources/views/Import/index.html.twig b/src/Wallabag/ImportBundle/Resources/views/Import/index.html.twig
index 6ea5e0f4..b79a1470 100644
--- a/src/Wallabag/ImportBundle/Resources/views/Import/index.html.twig
+++ b/src/Wallabag/ImportBundle/Resources/views/Import/index.html.twig
@@ -2,10 +2,18 @@
2 2
3{% block title %}{{ 'import.page_title'|trans }}{% endblock %} 3{% block title %}{{ 'import.page_title'|trans }}{% endblock %}
4 4
5{% block messages %}
6 {{ render(controller("WallabagImportBundle:Import:checkQueue")) }}
7
8 {{ parent() }}
9{% endblock %}
10
5{% block content %} 11{% block content %}
6<div class="row"> 12<div class="row">
7 <div class="col s12"> 13 <div class="col s12">
8 <div class="card-panel settings"> 14 <div class="card-panel settings">
15 {% include 'WallabagImportBundle:Import:_information.html.twig' %}
16
9 {{ 'import.page_description'|trans }} 17 {{ 'import.page_description'|trans }}
10 <ul> 18 <ul>
11 {% for import in imports %} 19 {% for import in imports %}
diff --git a/src/Wallabag/ImportBundle/Resources/views/Instapaper/index.html.twig b/src/Wallabag/ImportBundle/Resources/views/Instapaper/index.html.twig
index 5789361f..28165d19 100644
--- a/src/Wallabag/ImportBundle/Resources/views/Instapaper/index.html.twig
+++ b/src/Wallabag/ImportBundle/Resources/views/Instapaper/index.html.twig
@@ -6,7 +6,7 @@
6<div class="row"> 6<div class="row">
7 <div class="col s12"> 7 <div class="col s12">
8 <div class="card-panel settings"> 8 <div class="card-panel settings">
9 {% include 'WallabagImportBundle:Import:_workerEnabled.html.twig' %} 9 {% include 'WallabagImportBundle:Import:_information.html.twig' %}
10 10
11 <div class="row"> 11 <div class="row">
12 <blockquote>{{ import.description|trans }}</blockquote> 12 <blockquote>{{ import.description|trans }}</blockquote>
diff --git a/src/Wallabag/ImportBundle/Resources/views/Pinboard/index.html.twig b/src/Wallabag/ImportBundle/Resources/views/Pinboard/index.html.twig
new file mode 100644
index 00000000..43f196ad
--- /dev/null
+++ b/src/Wallabag/ImportBundle/Resources/views/Pinboard/index.html.twig
@@ -0,0 +1,45 @@
1{% extends "WallabagCoreBundle::layout.html.twig" %}
2
3{% block title %}{{ 'import.pinboard.page_title'|trans }}{% endblock %}
4
5{% block content %}
6<div class="row">
7 <div class="col s12">
8 <div class="card-panel settings">
9 {% include 'WallabagImportBundle:Import:_information.html.twig' %}
10
11 <div class="row">
12 <blockquote>{{ import.description|trans }}</blockquote>
13 <p>{{ 'import.pinboard.how_to'|trans }}</p>
14
15 <div class="col s12">
16 {{ form_start(form, {'method': 'POST'}) }}
17 {{ form_errors(form) }}
18 <div class="row">
19 <div class="file-field input-field col s12">
20 {{ form_errors(form.file) }}
21 <div class="btn">
22 <span>{{ form.file.vars.label|trans }}</span>
23 {{ form_widget(form.file) }}
24 </div>
25 <div class="file-path-wrapper">
26 <input class="file-path validate" type="text">
27 </div>
28 </div>
29 <div class="input-field col s6 with-checkbox">
30 <h6>{{ 'import.form.mark_as_read_title'|trans }}</h6>
31 {{ form_widget(form.mark_as_read) }}
32 {{ form_label(form.mark_as_read) }}
33 </div>
34 </div>
35
36 {{ form_widget(form.save, { 'attr': {'class': 'btn waves-effect waves-light'} }) }}
37
38 {{ form_rest(form) }}
39 </form>
40 </div>
41 </div>
42 </div>
43 </div>
44</div>
45{% endblock %}
diff --git a/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig b/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig
index 6195fa07..536e3d1a 100644
--- a/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig
+++ b/src/Wallabag/ImportBundle/Resources/views/Pocket/index.html.twig
@@ -6,7 +6,7 @@
6<div class="row"> 6<div class="row">
7 <div class="col s12"> 7 <div class="col s12">
8 <div class="card-panel settings"> 8 <div class="card-panel settings">
9 {% include 'WallabagImportBundle:Import:_workerEnabled.html.twig' %} 9 {% include 'WallabagImportBundle:Import:_information.html.twig' %}
10 10
11 {% if not has_consumer_key %} 11 {% if not has_consumer_key %}
12 <div class="card-panel red white-text"> 12 <div class="card-panel red white-text">
diff --git a/src/Wallabag/ImportBundle/Resources/views/Readability/index.html.twig b/src/Wallabag/ImportBundle/Resources/views/Readability/index.html.twig
index 74653b0f..737b0adf 100644
--- a/src/Wallabag/ImportBundle/Resources/views/Readability/index.html.twig
+++ b/src/Wallabag/ImportBundle/Resources/views/Readability/index.html.twig
@@ -6,7 +6,7 @@
6<div class="row"> 6<div class="row">
7 <div class="col s12"> 7 <div class="col s12">
8 <div class="card-panel settings"> 8 <div class="card-panel settings">
9 {% include 'WallabagImportBundle:Import:_workerEnabled.html.twig' %} 9 {% include 'WallabagImportBundle:Import:_information.html.twig' %}
10 10
11 <div class="row"> 11 <div class="row">
12 <blockquote>{{ import.description|trans }}</blockquote> 12 <blockquote>{{ import.description|trans }}</blockquote>
diff --git a/src/Wallabag/ImportBundle/Resources/views/WallabagV1/index.html.twig b/src/Wallabag/ImportBundle/Resources/views/WallabagV1/index.html.twig
index 0b19bc34..974b2c73 100644
--- a/src/Wallabag/ImportBundle/Resources/views/WallabagV1/index.html.twig
+++ b/src/Wallabag/ImportBundle/Resources/views/WallabagV1/index.html.twig
@@ -6,7 +6,7 @@
6<div class="row"> 6<div class="row">
7 <div class="col s12"> 7 <div class="col s12">
8 <div class="card-panel settings"> 8 <div class="card-panel settings">
9 {% include 'WallabagImportBundle:Import:_workerEnabled.html.twig' %} 9 {% include 'WallabagImportBundle:Import:_information.html.twig' %}
10 10
11 <div class="row"> 11 <div class="row">
12 <blockquote>{{ import.description|trans }}</blockquote> 12 <blockquote>{{ import.description|trans }}</blockquote>