aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2016-09-21 17:47:47 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-09-25 12:29:18 +0200
commit59201088b4fc13fd361238396f630dabd9bd1990 (patch)
tree2d4d5c2fbe7f007214c41f0c4ccba2f8d3d7ec8b /src/Wallabag
parentf7c55b38122cc593c2b58bb6425fca9d243b055e (diff)
downloadwallabag-59201088b4fc13fd361238396f630dabd9bd1990.tar.gz
wallabag-59201088b4fc13fd361238396f630dabd9bd1990.tar.zst
wallabag-59201088b4fc13fd361238396f630dabd9bd1990.zip
bring chrome and firefox as separate imports
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.da.yml12
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.de.yml12
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.en.yml10
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.es.yml12
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml12
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml10
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.it.yml12
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml12
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml12
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml12
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml12
-rw-r--r--src/Wallabag/ImportBundle/Command/ImportCommand.php9
-rw-r--r--src/Wallabag/ImportBundle/Controller/BrowserController.php23
-rw-r--r--src/Wallabag/ImportBundle/Controller/ChromeController.php41
-rw-r--r--src/Wallabag/ImportBundle/Controller/FirefoxController.php41
-rw-r--r--src/Wallabag/ImportBundle/Import/BrowserImport.php247
-rw-r--r--src/Wallabag/ImportBundle/Import/ChromeImport.php71
-rw-r--r--src/Wallabag/ImportBundle/Import/FirefoxImport.php71
-rw-r--r--src/Wallabag/ImportBundle/Resources/config/rabbit.yml14
-rw-r--r--src/Wallabag/ImportBundle/Resources/config/redis.yml40
-rw-r--r--src/Wallabag/ImportBundle/Resources/config/services.yml15
-rw-r--r--src/Wallabag/ImportBundle/Resources/views/Chrome/index.html.twig43
-rw-r--r--src/Wallabag/ImportBundle/Resources/views/Firefox/index.html.twig (renamed from src/Wallabag/ImportBundle/Resources/views/Browser/index.html.twig)4
23 files changed, 558 insertions, 189 deletions
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
index e1170b75..9eeb210b 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
@@ -349,10 +349,14 @@ import:
349 # how_to: 'Please select your Readability export and click on the below button to upload and import it.' 349 # how_to: 'Please select your Readability export and click on the below button to upload and import it.'
350 worker: 350 worker:
351 # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" 351 # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:"
352 # browser: 352 # firefox:
353 # page_title: 'Import > Browser' 353 # page_title: 'Import > Firefox'
354 # description: "This importer will import all your Firefox or Chrome bookmarks. <p>For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file. </p>For Chrome, the location of the file depends on your operating system : <ul><li>On Linux, go into the <code>~/.config/chromium/Default/</code> directory</li><li>On Windows, it should be at <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>On OS X, it should be at <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Once you got there, copy the Bookmarks file someplace you'll find.<em><br>Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.</em></p>" 354 # description: "This importer will import all your Firefox bookmarks. <p>For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file."
355 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." 355 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
356 #chrome:
357 # page_title: 'Import > Chrome'
358 # description: "This importer will import all your Chrome bookmarks. The location of the file depends on your operating system : <ul><li>On Linux, go into the <code>~/.config/chromium/Default/</code> directory</li><li>On Windows, it should be at <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>On OS X, it should be at <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Once you got there, copy the Bookmarks file someplace you'll find.<em><br>Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.</em></p>"
359 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
356 360
357developer: 361developer:
358 # page_title: 'Developer' 362 # page_title: 'Developer'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
index b066cd88..a9ec2519 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
@@ -349,10 +349,14 @@ import:
349 # how_to: 'Please select your Readability export and click on the below button to upload and import it.' 349 # how_to: 'Please select your Readability export and click on the below button to upload and import it.'
350 worker: 350 worker:
351 # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" 351 # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:"
352 # browser: 352 # firefox:
353 # page_title: 'Import > Browser' 353 # page_title: 'Import > Firefox'
354 # description: "This importer will import all your Firefox or Chrome bookmarks. <p>For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file. </p>For Chrome, the location of the file depends on your operating system : <ul><li>On Linux, go into the <code>~/.config/chromium/Default/</code> directory</li><li>On Windows, it should be at <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>On OS X, it should be at <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Once you got there, copy the Bookmarks file someplace you'll find.<em><br>Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.</em></p>" 354 # description: "This importer will import all your Firefox bookmarks. <p>For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file."
355 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." 355 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
356 # chrome:
357 # page_title: 'Import > Chrome'
358 # description: "This importer will import all your Chrome bookmarks. The location of the file depends on your operating system : <ul><li>On Linux, go into the <code>~/.config/chromium/Default/</code> directory</li><li>On Windows, it should be at <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>On OS X, it should be at <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Once you got there, copy the Bookmarks file someplace you'll find.<em><br>Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.</em></p>"
359 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
356 360
357developer: 361developer:
358 page_title: 'Entwickler' 362 page_title: 'Entwickler'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
index afc28776..c0d8656d 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
@@ -349,9 +349,13 @@ import:
349 how_to: 'Please select your Readability export and click on the below button to upload and import it.' 349 how_to: 'Please select your Readability export and click on the below button to upload and import it.'
350 worker: 350 worker:
351 enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" 351 enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:"
352 browser: 352 firefox:
353 page_title: 'Import > Browser' 353 page_title: 'Import > Firefox'
354 description: "This importer will import all your Firefox or Chrome bookmarks. <p>For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file. </p>For Chrome, the location of the file depends on your operating system : <ul><li>On Linux, go into the <code>~/.config/chromium/Default/</code> directory</li><li>On Windows, it should be at <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>On OS X, it should be at <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Once you got there, copy the Bookmarks file someplace you'll find.<em><br>Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.</em></p>" 354 description: "This importer will import all your Firefox bookmarks. <p>For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file."
355 how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
356 chrome:
357 page_title: 'Import > Chrome'
358 description: "This importer will import all your Chrome bookmarks. The location of the file depends on your operating system : <ul><li>On Linux, go into the <code>~/.config/chromium/Default/</code> directory</li><li>On Windows, it should be at <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>On OS X, it should be at <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Once you got there, copy the Bookmarks file someplace you'll find.<em><br>Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.</em></p>"
355 how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." 359 how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
356 360
357developer: 361developer:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
index 429e5fed..1d6993db 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
@@ -349,10 +349,14 @@ import:
349 # how_to: 'Please select your Readability export and click on the below button to upload and import it.' 349 # how_to: 'Please select your Readability export and click on the below button to upload and import it.'
350 worker: 350 worker:
351 # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" 351 # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:"
352 # browser: 352 # firefox:
353 # page_title: 'Import > Browser' 353 # page_title: 'Import > Firefox'
354 # description: "This importer will import all your Firefox or Chrome bookmarks. <p>For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file. </p>For Chrome, the location of the file depends on your operating system : <ul><li>On Linux, go into the <code>~/.config/chromium/Default/</code> directory</li><li>On Windows, it should be at <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>On OS X, it should be at <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Once you got there, copy the Bookmarks file someplace you'll find.<em><br>Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.</em></p>" 354 # description: "This importer will import all your Firefox bookmarks. <p>For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file."
355 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." 355 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
356 # chrome:
357 # page_title: 'Import > Chrome'
358 # description: "This importer will import all your Chrome bookmarks. The location of the file depends on your operating system : <ul><li>On Linux, go into the <code>~/.config/chromium/Default/</code> directory</li><li>On Windows, it should be at <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>On OS X, it should be at <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Once you got there, copy the Bookmarks file someplace you'll find.<em><br>Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.</em></p>"
359 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
356 360
357developer: 361developer:
358 page_title: 'Promotor' 362 page_title: 'Promotor'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
index 8ee6c135..68272f99 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
@@ -349,10 +349,14 @@ import:
349 # how_to: 'Please select your Readability export and click on the below button to upload and import it.' 349 # how_to: 'Please select your Readability export and click on the below button to upload and import it.'
350 worker: 350 worker:
351 # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" 351 # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:"
352 # browser: 352 # firefox:
353 # page_title: 'Import > Browser' 353 # page_title: 'Import > Firefox'
354 # description: "This importer will import all your Firefox or Chrome bookmarks. <p>For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file. </p>For Chrome, the location of the file depends on your operating system : <ul><li>On Linux, go into the <code>~/.config/chromium/Default/</code> directory</li><li>On Windows, it should be at <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>On OS X, it should be at <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Once you got there, copy the Bookmarks file someplace you'll find.<em><br>Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.</em></p>" 354 # description: "This importer will import all your Firefox bookmarks. <p>For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file."
355 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." 355 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
356 # chrome:
357 # page_title: 'Import > Chrome'
358 # description: "This importer will import all your Chrome bookmarks. The location of the file depends on your operating system : <ul><li>On Linux, go into the <code>~/.config/chromium/Default/</code> directory</li><li>On Windows, it should be at <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>On OS X, it should be at <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Once you got there, copy the Bookmarks file someplace you'll find.<em><br>Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.</em></p>"
359 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
356 360
357developer: 361developer:
358 # page_title: 'Developer' 362 # page_title: 'Developer'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
index 5af03e61..b28068b6 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
@@ -349,9 +349,13 @@ import:
349 how_to: "Choisissez le fichier de votre export Readability et cliquez sur le bouton ci-dessous pour l'importer." 349 how_to: "Choisissez le fichier de votre export Readability et cliquez sur le bouton ci-dessous pour l'importer."
350 worker: 350 worker:
351 enabled: "Les imports sont asynchrones. Une fois l'import commencé un worker externe traitera les messages un par un. Le service activé est :" 351 enabled: "Les imports sont asynchrones. Une fois l'import commencé un worker externe traitera les messages un par un. Le service activé est :"
352 browser: 352 firefox:
353 page_title: 'Import > Navigateur' 353 page_title: 'Import > Firefox'
354 description: "Cet outil va vous permettre d'importer tous vos marques-pages de Firefox ou de Google Chrome/Chromium. <p>Pour Firefox, ouvrez le panneau des marques-pages (Ctrl+Maj+O), puis dans « Importation et sauvegarde », choisissez « Sauvegarde... ». Vous allez récupérer un fichier .json. </p>Pour Google Chrome, la situation du fichier dépend de votre système d'exploitation : <ul><li>Sur GNU/Linux, allez dans le répertoire <code>~/.config/google-chrome/Default/</code></li><li>Sous Windows, il devrait se trouver à <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>Sur OS X, il devrait se trouver dans le fichier <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Une fois que vous y êtes, copiez le fichier Bookmarks à un endroit où vous le retrouverez.<em><br>Notez que si vous utilisez Chromium à la place de Chrome, vous devez corriger les chemins en conséquence.</em></p>" 354 description: "Cet outil va vous permettre d'importer tous vos marques-pages de Firefox. <p>Pour Firefox, ouvrez le panneau des marques-pages (Ctrl+Maj+O), puis dans « Importation et sauvegarde », choisissez « Sauvegarde... ». Vous allez récupérer un fichier .json. </p>"
355 how_to: "Choisissez le fichier de sauvegarde de vos marques-page et cliquez sur le bouton pour l'importer. Soyez avertis que le processus peut prendre un temps assez long car tous les articles doivent être récupérés en ligne."
356 chrome:
357 page_title: 'Import > Chrome'
358 description: "Cet outil va vous permettre d'importer tous vos marques-pages de Google Chrome/Chromium. Pour Google Chrome, la situation du fichier dépend de votre système d'exploitation : <ul><li>Sur GNU/Linux, allez dans le répertoire <code>~/.config/google-chrome/Default/</code></li><li>Sous Windows, il devrait se trouver à <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>Sur OS X, il devrait se trouver dans le fichier <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Une fois que vous y êtes, copiez le fichier Bookmarks à un endroit où vous le retrouverez.<em><br>Notez que si vous utilisez Chromium à la place de Chrome, vous devez corriger les chemins en conséquence.</em></p>"
355 how_to: "Choisissez le fichier de sauvegarde de vos marques-page et cliquez sur le bouton pour l'importer. Soyez avertis que le processus peut prendre un temps assez long car tous les articles doivent être récupérés en ligne." 359 how_to: "Choisissez le fichier de sauvegarde de vos marques-page et cliquez sur le bouton pour l'importer. Soyez avertis que le processus peut prendre un temps assez long car tous les articles doivent être récupérés en ligne."
356 360
357developer: 361developer:
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
index dbf4517c..bd98c8c0 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
@@ -348,10 +348,14 @@ import:
348 # how_to: 'Please select your Readability export and click on the below button to upload and import it.' 348 # how_to: 'Please select your Readability export and click on the below button to upload and import it.'
349 worker: 349 worker:
350 # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" 350 # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:"
351 # browser: 351 # firefox:
352 # page_title: 'Import > Browser' 352 # page_title: 'Import > Firefox'
353 # description: "This importer will import all your Firefox or Chrome bookmarks. <p>For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file. </p>For Chrome, the location of the file depends on your operating system : <ul><li>On Linux, go into the <code>~/.config/chromium/Default/</code> directory</li><li>On Windows, it should be at <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>On OS X, it should be at <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Once you got there, copy the Bookmarks file someplace you'll find.<em><br>Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.</em></p>" 353 # description: "This importer will import all your Firefox bookmarks. <p>For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file."
354 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched" 354 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
355 # chrome:
356 # page_title: 'Import > Chrome'
357 # description: "This importer will import all your Chrome bookmarks. The location of the file depends on your operating system : <ul><li>On Linux, go into the <code>~/.config/chromium/Default/</code> directory</li><li>On Windows, it should be at <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>On OS X, it should be at <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Once you got there, copy the Bookmarks file someplace you'll find.<em><br>Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.</em></p>"
358 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
355 359
356developer: 360developer:
357 page_title: 'Sviluppatori' 361 page_title: 'Sviluppatori'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
index fa72dff4..6da9ff18 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
@@ -349,10 +349,14 @@ import:
349 how_to: "Mercés de seleccionar vòstre Readability fichièr e de clicar sul boton dejós per lo telecargar e l'importar." 349 how_to: "Mercés de seleccionar vòstre Readability fichièr e de clicar sul boton dejós per lo telecargar e l'importar."
350 worker: 350 worker:
351 # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" 351 # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:"
352 # browser: 352 # firefox:
353 # page_title: 'Import > Browser' 353 # page_title: 'Import > Firefox'
354 # description: "This importer will import all your Firefox or Chrome bookmarks. <p>For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file. </p>For Chrome, the location of the file depends on your operating system : <ul><li>On Linux, go into the <code>~/.config/chromium/Default/</code> directory</li><li>On Windows, it should be at <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>On OS X, it should be at <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Once you got there, copy the Bookmarks file someplace you'll find.<em><br>Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.</em></p>" 354 # description: "This importer will import all your Firefox bookmarks. <p>For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file."
355 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." 355 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
356 # chrome:
357 # page_title: 'Import > Chrome'
358 # description: "This importer will import all your Chrome bookmarks. The location of the file depends on your operating system : <ul><li>On Linux, go into the <code>~/.config/chromium/Default/</code> directory</li><li>On Windows, it should be at <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>On OS X, it should be at <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Once you got there, copy the Bookmarks file someplace you'll find.<em><br>Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.</em></p>"
359 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
356 360
357developer: 361developer:
358 page_title: 'Desvolopador' 362 page_title: 'Desvolopador'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
index a477ec67..daa34bc0 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
@@ -349,10 +349,14 @@ import:
349 how_to: 'Wybierz swój plik eksportu z Readability i kliknij poniższy przycisk, aby go załadować.' 349 how_to: 'Wybierz swój plik eksportu z Readability i kliknij poniższy przycisk, aby go załadować.'
350 worker: 350 worker:
351 enabled: "Import jest wykonywany asynchronicznie. Od momentu rozpoczęcia importu, zewnętrzna usługa może zajmować się na raz tylko jednym zadaniem. Bieżącą usługą jest:" 351 enabled: "Import jest wykonywany asynchronicznie. Od momentu rozpoczęcia importu, zewnętrzna usługa może zajmować się na raz tylko jednym zadaniem. Bieżącą usługą jest:"
352 # browser: 352 # firefox:
353 # page_title: 'Import > Browser' 353 # page_title: 'Import > Firefox'
354 # description: "This importer will import all your Firefox or Chrome bookmarks. <p>For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file. </p>For Chrome, the location of the file depends on your operating system : <ul><li>On Linux, go into the <code>~/.config/chromium/Default/</code> directory</li><li>On Windows, it should be at <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>On OS X, it should be at <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Once you got there, copy the Bookmarks file someplace you'll find.<em><br>Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.</em></p>" 354 # description: "This importer will import all your Firefox bookmarks. <p>For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file."
355 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." 355 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
356 # chrome:
357 # page_title: 'Import > Chrome'
358 # description: "This importer will import all your Chrome bookmarks. The location of the file depends on your operating system : <ul><li>On Linux, go into the <code>~/.config/chromium/Default/</code> directory</li><li>On Windows, it should be at <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>On OS X, it should be at <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Once you got there, copy the Bookmarks file someplace you'll find.<em><br>Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.</em></p>"
359 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
356 360
357developer: 361developer:
358 page_title: 'Deweloper' 362 page_title: 'Deweloper'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
index 5d848c2e..067f7878 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
@@ -349,10 +349,14 @@ import:
349 # how_to: 'Please select your Readability export and click on the below button to upload and import it.' 349 # how_to: 'Please select your Readability export and click on the below button to upload and import it.'
350 worker: 350 worker:
351 # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" 351 # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:"
352 # browser: 352 # firefox:
353 # page_title: 'Import > Browser' 353 # page_title: 'Import > Firefox'
354 # description: "This importer will import all your Firefox or Chrome bookmarks. <p>For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file. </p>For Chrome, the location of the file depends on your operating system : <ul><li>On Linux, go into the <code>~/.config/chromium/Default/</code> directory</li><li>On Windows, it should be at <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>On OS X, it should be at <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Once you got there, copy the Bookmarks file someplace you'll find.<em><br>Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.</em></p>" 354 # description: "This importer will import all your Firefox bookmarks. <p>For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file."
355 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." 355 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
356 # chrome:
357 # page_title: 'Import > Chrome'
358 # description: "This importer will import all your Chrome bookmarks. The location of the file depends on your operating system : <ul><li>On Linux, go into the <code>~/.config/chromium/Default/</code> directory</li><li>On Windows, it should be at <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>On OS X, it should be at <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Once you got there, copy the Bookmarks file someplace you'll find.<em><br>Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.</em></p>"
359 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
356 360
357developer: 361developer:
358 # page_title: 'Developer' 362 # page_title: 'Developer'
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
index 41d169d1..62c69510 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml
@@ -349,10 +349,14 @@ import:
349 # how_to: 'Please select your Readability export and click on the below button to upload and import it.' 349 # how_to: 'Please select your Readability export and click on the below button to upload and import it.'
350 worker: 350 worker:
351 # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:" 351 # enabled: "Import is made asynchronously. Once the import task is started, an external worker will handle jobs one at a time. The current service is:"
352 # browser: 352 # firefox:
353 # page_title: 'Import > Browser' 353 # page_title: 'Import > Firefox'
354 # description: "This importer will import all your Firefox or Chrome bookmarks. <p>For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file. </p>For Chrome, the location of the file depends on your operating system : <ul><li>On Linux, go into the <code>~/.config/chromium/Default/</code> directory</li><li>On Windows, it should be at <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>On OS X, it should be at <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Once you got there, copy the Bookmarks file someplace you'll find.<em><br>Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.</em></p>" 354 # description: "This importer will import all your Firefox bookmarks. <p>For Firefox, just go to your bookmarks (Ctrl+Maj+O), then into \"Import and backup\", choose \"Backup...\". You will obtain a .json file."
355 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched." 355 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
356 # chrome:
357 # page_title: 'Import > Chrome'
358 # description: "This importer will import all your Chrome bookmarks. The location of the file depends on your operating system : <ul><li>On Linux, go into the <code>~/.config/chromium/Default/</code> directory</li><li>On Windows, it should be at <code>%LOCALAPPDATA%\\Google\\Chrome\\User Data\\Default</code></li><li>On OS X, it should be at <code>~/Library/Application Support/Google/Chrome/Default/Bookmarks</code></li></ul>Once you got there, copy the Bookmarks file someplace you'll find.<em><br>Note that if you have Chromium instead of Chrome, you'll have to correct paths accordingly.</em></p>"
359 # how_to: "Please choose the bookmark backup file and click on the button below to import it. Note that the process may take a long time since all articles have to be fetched."
356 360
357developer: 361developer:
358 # page_title: 'Developer' 362 # page_title: 'Developer'
diff --git a/src/Wallabag/ImportBundle/Command/ImportCommand.php b/src/Wallabag/ImportBundle/Command/ImportCommand.php
index ac3d1d92..1df38295 100644
--- a/src/Wallabag/ImportBundle/Command/ImportCommand.php
+++ b/src/Wallabag/ImportBundle/Command/ImportCommand.php
@@ -17,7 +17,7 @@ class ImportCommand extends ContainerAwareCommand
17 ->setDescription('Import entries from a JSON export from a wallabag v1 instance') 17 ->setDescription('Import entries from a JSON export from a wallabag v1 instance')
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 or browser', 'v1') 20 ->addOption('importer', null, InputArgument::OPTIONAL, 'The importer to use: wallabag v1, v2, 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 }
@@ -44,8 +44,11 @@ class ImportCommand extends ContainerAwareCommand
44 case 'v2': 44 case 'v2':
45 $wallabag = $this->getContainer()->get('wallabag_import.wallabag_v2.import'); 45 $wallabag = $this->getContainer()->get('wallabag_import.wallabag_v2.import');
46 break; 46 break;
47 case 'browser': 47 case 'firefox':
48 $wallabag = $this->getContainer()->get('wallabag_import.browser.import'); 48 $wallabag = $this->getContainer()->get('wallabag_import.firefox.import');
49 break;
50 case 'chrome':
51 $wallabag = $this->getContainer()->get('wallabag_import.chrome.import');
49 break; 52 break;
50 case 'v1': 53 case 'v1':
51 default: 54 default:
diff --git a/src/Wallabag/ImportBundle/Controller/BrowserController.php b/src/Wallabag/ImportBundle/Controller/BrowserController.php
index 3b54a72e..144a4880 100644
--- a/src/Wallabag/ImportBundle/Controller/BrowserController.php
+++ b/src/Wallabag/ImportBundle/Controller/BrowserController.php
@@ -8,27 +8,21 @@ use Symfony\Component\HttpFoundation\Request;
8use Symfony\Component\HttpFoundation\Response; 8use Symfony\Component\HttpFoundation\Response;
9use Wallabag\ImportBundle\Form\Type\UploadImportType; 9use Wallabag\ImportBundle\Form\Type\UploadImportType;
10 10
11class BrowserController extends Controller 11abstract class BrowserController extends Controller
12{ 12{
13 /** 13 /**
14 * Return the service to handle the import. 14 * Return the service to handle the import.
15 * 15 *
16 * @return \Wallabag\ImportBundle\Import\ImportInterface 16 * @return \Wallabag\ImportBundle\Import\ImportInterface
17 */ 17 */
18 protected function getImportService() 18 abstract protected function getImportService();
19 {
20 return $this->get('wallabag_import.browser.import');
21 }
22 19
23 /** 20 /**
24 * Return the template used for the form. 21 * Return the template used for the form.
25 * 22 *
26 * @return string 23 * @return string
27 */ 24 */
28 protected function getImportTemplate() 25 abstract protected function getImportTemplate();
29 {
30 return 'WallabagImportBundle:Browser:index.html.twig';
31 }
32 26
33 /** 27 /**
34 * @Route("/browser", name="import_browser") 28 * @Route("/browser", name="import_browser")
@@ -43,15 +37,15 @@ class BrowserController extends Controller
43 $form->handleRequest($request); 37 $form->handleRequest($request);
44 38
45 $wallabag = $this->getImportService(); 39 $wallabag = $this->getImportService();
40 $wallabag->setUser($this->getUser());
46 41
47 if ($form->isValid()) { 42 if ($form->isValid()) {
48 $file = $form->get('file')->getData(); 43 $file = $form->get('file')->getData();
49 $markAsRead = $form->get('mark_as_read')->getData(); 44 $markAsRead = $form->get('mark_as_read')->getData();
50 $name = $this->getUser()->getId().'.json'; 45 $name = $this->getUser()->getId().'.json';
51 46
52 if (in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { 47 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
53 $res = $wallabag 48 $res = $wallabag
54 ->setUser($this->getUser())
55 ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) 49 ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name)
56 ->setMarkAsRead($markAsRead) 50 ->setMarkAsRead($markAsRead)
57 ->import(); 51 ->import();
@@ -60,12 +54,17 @@ class BrowserController extends Controller
60 54
61 if (true === $res) { 55 if (true === $res) {
62 $summary = $wallabag->getSummary(); 56 $summary = $wallabag->getSummary();
63 // TODO : Pluralize these messages
64 $message = $this->get('translator')->trans('flashes.import.notice.summary', [ 57 $message = $this->get('translator')->trans('flashes.import.notice.summary', [
65 '%imported%' => $summary['imported'], 58 '%imported%' => $summary['imported'],
66 '%skipped%' => $summary['skipped'], 59 '%skipped%' => $summary['skipped'],
67 ]); 60 ]);
68 61
62 if (0 < $summary['queued']) {
63 $message = $this->get('translator')->trans('flashes.import.notice.summary_with_queue', [
64 '%queued%' => $summary['queued'],
65 ]);
66 }
67
69 unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); 68 unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name);
70 } 69 }
71 70
diff --git a/src/Wallabag/ImportBundle/Controller/ChromeController.php b/src/Wallabag/ImportBundle/Controller/ChromeController.php
new file mode 100644
index 00000000..e4cc322a
--- /dev/null
+++ b/src/Wallabag/ImportBundle/Controller/ChromeController.php
@@ -0,0 +1,41 @@
1<?php
2
3namespace Wallabag\ImportBundle\Controller;
4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Component\HttpFoundation\Request;
7
8class ChromeController extends BrowserController
9{
10 /**
11 * {@inheritdoc}
12 */
13 protected function getImportService()
14 {
15 $service = $this->get('wallabag_import.chrome.import');
16
17 if ($this->get('craue_config')->get('import_with_rabbitmq')) {
18 $service->setProducer($this->get('old_sound_rabbit_mq.import_wallabag_v1_producer'));
19 } elseif ($this->get('craue_config')->get('import_with_redis')) {
20 $service->setProducer($this->get('wallabag_import.producer.redis.wallabag_v1'));
21 }
22
23 return $service;
24 }
25
26 /**
27 * {@inheritdoc}
28 */
29 protected function getImportTemplate()
30 {
31 return 'WallabagImportBundle:Chrome:index.html.twig';
32 }
33
34 /**
35 * @Route("/chrome", name="import_chrome")
36 */
37 public function indexAction(Request $request)
38 {
39 return parent::indexAction($request);
40 }
41}
diff --git a/src/Wallabag/ImportBundle/Controller/FirefoxController.php b/src/Wallabag/ImportBundle/Controller/FirefoxController.php
new file mode 100644
index 00000000..e0dd8214
--- /dev/null
+++ b/src/Wallabag/ImportBundle/Controller/FirefoxController.php
@@ -0,0 +1,41 @@
1<?php
2
3namespace Wallabag\ImportBundle\Controller;
4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Component\HttpFoundation\Request;
7
8class FirefoxController extends BrowserController
9{
10 /**
11 * {@inheritdoc}
12 */
13 protected function getImportService()
14 {
15 $service = $this->get('wallabag_import.firefox.import');
16
17 if ($this->get('craue_config')->get('import_with_rabbitmq')) {
18 $service->setProducer($this->get('old_sound_rabbit_mq.import_wallabag_v1_producer'));
19 } elseif ($this->get('craue_config')->get('import_with_redis')) {
20 $service->setProducer($this->get('wallabag_import.producer.redis.wallabag_v1'));
21 }
22
23 return $service;
24 }
25
26 /**
27 * {@inheritdoc}
28 */
29 protected function getImportTemplate()
30 {
31 return 'WallabagImportBundle:Firefox:index.html.twig';
32 }
33
34 /**
35 * @Route("/firefox", name="import_firefox")
36 */
37 public function indexAction(Request $request)
38 {
39 return parent::indexAction($request);
40 }
41}
diff --git a/src/Wallabag/ImportBundle/Import/BrowserImport.php b/src/Wallabag/ImportBundle/Import/BrowserImport.php
index e3457196..ef7d6d95 100644
--- a/src/Wallabag/ImportBundle/Import/BrowserImport.php
+++ b/src/Wallabag/ImportBundle/Import/BrowserImport.php
@@ -9,69 +9,24 @@ use Wallabag\CoreBundle\Entity\Entry;
9use Wallabag\UserBundle\Entity\User; 9use Wallabag\UserBundle\Entity\User;
10use Wallabag\CoreBundle\Helper\ContentProxy; 10use Wallabag\CoreBundle\Helper\ContentProxy;
11 11
12class BrowserImport implements ImportInterface 12abstract class BrowserImport extends AbstractImport
13{ 13{
14 protected $user;
15 protected $em;
16 protected $logger;
17 protected $contentProxy;
18 protected $skippedEntries = 0;
19 protected $importedEntries = 0;
20 protected $totalEntries = 0;
21 protected $filepath; 14 protected $filepath;
22 protected $markAsRead;
23 private $nbEntries;
24
25 public function __construct(EntityManager $em, ContentProxy $contentProxy)
26 {
27 $this->em = $em;
28 $this->logger = new NullLogger();
29 $this->contentProxy = $contentProxy;
30 }
31
32 public function setLogger(LoggerInterface $logger)
33 {
34 $this->logger = $logger;
35 }
36
37 /**
38 * We define the user in a custom call because on the import command there is no logged in user.
39 * So we can't retrieve user from the `security.token_storage` service.
40 *
41 * @param User $user
42 *
43 * @return $this
44 */
45 public function setUser(User $user)
46 {
47 $this->user = $user;
48
49 return $this;
50 }
51 15
52 /** 16 /**
53 * {@inheritdoc} 17 * {@inheritdoc}
54 */ 18 */
55 public function getName() 19 abstract public function getName();
56 {
57 return 'Firefox & Google Chrome';
58 }
59 20
60 /** 21 /**
61 * {@inheritdoc} 22 * {@inheritdoc}
62 */ 23 */
63 public function getUrl() 24 abstract public function getUrl();
64 {
65 return 'import_browser';
66 }
67 25
68 /** 26 /**
69 * {@inheritdoc} 27 * {@inheritdoc}
70 */ 28 */
71 public function getDescription() 29 abstract public function getDescription();
72 {
73 return 'import.browser.description';
74 }
75 30
76 /** 31 /**
77 * {@inheritdoc} 32 * {@inheritdoc}
@@ -96,124 +51,162 @@ class BrowserImport implements ImportInterface
96 return false; 51 return false;
97 } 52 }
98 53
99 $this->nbEntries = 1; 54 if ($this->producer) {
55 $this->parseEntriesForProducer($data);
56
57 return true;
58 }
59
100 $this->parseEntries($data); 60 $this->parseEntries($data);
101 $this->em->flush();
102 61
103 return true; 62 return true;
104 } 63 }
105 64
106 private function parseEntries($data) 65 /**
66 * Set file path to the json file.
67 *
68 * @param string $filepath
69 */
70 public function setFilepath($filepath)
71 {
72 $this->filepath = $filepath;
73
74 return $this;
75 }
76
77 /**
78 * Parse and insert all given entries.
79 *
80 * @param $entries
81 */
82 protected function parseEntries($entries)
107 { 83 {
108 foreach ($data as $importedEntry) { 84 $i = 1;
109 $this->parseEntry($importedEntry); 85
86 foreach ($entries as $importedEntry) {
87 if ((array) $importedEntry !== $importedEntry) {
88 continue;
89 }
90
91 $entry = $this->parseEntry($importedEntry);
92
93 if (null === $entry) {
94 continue;
95 }
96
97 // flush every 20 entries
98 if (($i % 20) === 0) {
99 $this->em->flush();
100
101 // clear only affected entities
102 $this->em->clear(Entry::class);
103 $this->em->clear(Tag::class);
104 }
105 ++$i;
110 } 106 }
111 $this->totalEntries += count($data); 107
108 $this->em->flush();
112 } 109 }
113 110
114 private function parseEntry($importedEntry) 111 /**
112 * Parse entries and send them to the queue.
113 * It should just be a simple loop on all item, no call to the database should be done
114 * to speedup queuing.
115 *
116 * Faster parse entries for Producer.
117 * We don't care to make check at this time. They'll be done by the consumer.
118 *
119 * @param array $entries
120 */
121 protected function parseEntriesForProducer(array $entries)
115 { 122 {
116 if (!is_array($importedEntry)) { 123 foreach ($entries as $importedEntry) {
117 return; 124
125 if ((array) $importedEntry !== $importedEntry) {
126 continue;
127 }
128
129 // set userId for the producer (it won't know which user is connected)
130 $importedEntry['userId'] = $this->user->getId();
131
132 if ($this->markAsRead) {
133 $importedEntry = $this->setEntryAsRead($importedEntry);
134 }
135
136 ++$this->queuedEntries;
137
138 $this->producer->publish(json_encode($importedEntry));
118 } 139 }
140 }
119 141
120 /* Firefox uses guid while Chrome uses id */ 142 /**
143 * {@inheritdoc}
144 */
145 public function parseEntry(array $importedEntry)
146 {
121 147
122 if ((!key_exists('guid', $importedEntry) || (!key_exists('id', $importedEntry))) && is_array(reset($importedEntry))) { 148 if ((!key_exists('guid', $importedEntry) || (!key_exists('id', $importedEntry))) && is_array(reset($importedEntry))) {
123 $this->parseEntries($importedEntry); 149 $this->parseEntries($importedEntry);
124
125 return; 150 return;
126 } 151 }
152
127 if (key_exists('children', $importedEntry)) { 153 if (key_exists('children', $importedEntry)) {
128 $this->parseEntries($importedEntry['children']); 154 $this->parseEntries($importedEntry['children']);
129
130 return; 155 return;
131 } 156 }
132 if (key_exists('uri', $importedEntry) || key_exists('url', $importedEntry)) {
133
134 /* Firefox uses uri while Chrome uses url */
135 157
136 $firefox = key_exists('uri', $importedEntry); 158 if (!key_exists('uri', $importedEntry) && !key_exists('url', $importedEntry)) {
137 159 return;
138 $existingEntry = $this->em 160 }
139 ->getRepository('WallabagCoreBundle:Entry')
140 ->findByUrlAndUserId(($firefox) ? $importedEntry['uri'] : $importedEntry['url'], $this->user->getId());
141
142 if (false !== $existingEntry) {
143 ++$this->skippedEntries;
144 161
145 return; 162 $firefox = key_exists('uri', $importedEntry);
146 }
147 163
148 if (false === parse_url(($firefox) ? $importedEntry['uri'] : $importedEntry['url']) || false === filter_var(($firefox) ? $importedEntry['uri'] : $importedEntry['url'], FILTER_VALIDATE_URL)) { 164 $existingEntry = $this->em
149 $this->logger->warning('Imported URL '.($firefox) ? $importedEntry['uri'] : $importedEntry['url'].' is not valid'); 165 ->getRepository('WallabagCoreBundle:Entry')
150 ++$this->skippedEntries; 166 ->findByUrlAndUserId(($firefox) ? $importedEntry['uri'] : $importedEntry['url'], $this->user->getId());
151 167
152 return; 168 if (false !== $existingEntry) {
153 } 169 ++$this->skippedEntries;
154 170
155 try { 171 return;
156 $entry = $this->contentProxy->updateEntry( 172 }
157 new Entry($this->user),
158 ($firefox) ? $importedEntry['uri'] : $importedEntry['url']
159 );
160 } catch (\Exception $e) {
161 $this->logger->warning('Error while saving '.($firefox) ? $importedEntry['uri'] : $importedEntry['url']);
162 ++$this->skippedEntries;
163 173
164 return; 174 $data = $this->prepareEntry($importedEntry);
165 }
166 175
167 $entry->setArchived($this->markAsRead); 176 $entry = new Entry($this->user);
177 $entry->setUrl($data['url']);
178 $entry->setTitle($data['title']);
168 179
169 $this->em->persist($entry); 180 // update entry with content (in case fetching failed, the given entry will be return)
170 ++$this->importedEntries; 181 $entry = $this->fetchContent($entry, $data['url'], $data);
171 182
172 // flush every 20 entries 183 if (array_key_exists('tags', $data)) {
173 if (($this->nbEntries % 20) === 0) { 184 $this->contentProxy->assignTagsToEntry(
174 $this->em->flush(); 185 $entry,
175 $this->em->clear($entry); 186 $data['tags']
176 } 187 );
177 ++$this->nbEntries;
178 } 188 }
179 }
180 189
181 /** 190 $entry->setArchived($data['is_archived']);
182 * Set whether articles must be all marked as read.
183 *
184 * @param bool $markAsRead
185 *
186 * @return $this
187 */
188 public function setMarkAsRead($markAsRead)
189 {
190 $this->markAsRead = $markAsRead;
191 191
192 return $this; 192 if (!empty($data['created_at'])) {
193 } 193 $dt = new \DateTime();
194 $entry->setCreatedAt($dt->setTimestamp($data['created_at']/1000));
195 }
194 196
195 /** 197 $this->em->persist($entry);
196 * Set file path to the json file. 198 ++$this->importedEntries;
197 *
198 * @param string $filepath
199 *
200 * @return $this
201 */
202 public function setFilepath($filepath)
203 {
204 $this->filepath = $filepath;
205 199
206 return $this; 200 return $entry;
207 } 201 }
208 202
209 /** 203 /**
210 * {@inheritdoc} 204 * {@inheritdoc}
211 */ 205 */
212 public function getSummary() 206 protected function setEntryAsRead(array $importedEntry)
213 { 207 {
214 return [ 208 $importedEntry['is_archived'] = 1;
215 'skipped' => $this->skippedEntries, 209
216 'imported' => $this->importedEntries, 210 return $importedEntry;
217 ];
218 } 211 }
219} 212}
diff --git a/src/Wallabag/ImportBundle/Import/ChromeImport.php b/src/Wallabag/ImportBundle/Import/ChromeImport.php
new file mode 100644
index 00000000..7936ee2f
--- /dev/null
+++ b/src/Wallabag/ImportBundle/Import/ChromeImport.php
@@ -0,0 +1,71 @@
1<?php
2
3namespace Wallabag\ImportBundle\Import;
4
5use Psr\Log\LoggerInterface;
6use Psr\Log\NullLogger;
7use Doctrine\ORM\EntityManager;
8use Wallabag\CoreBundle\Entity\Entry;
9use Wallabag\UserBundle\Entity\User;
10use Wallabag\CoreBundle\Helper\ContentProxy;
11
12class ChromeImport extends BrowserImport
13{
14 protected $filepath;
15
16 /**
17 * {@inheritdoc}
18 */
19 public function getName()
20 {
21 return 'Chrome';
22 }
23
24 /**
25 * {@inheritdoc}
26 */
27 public function getUrl()
28 {
29 return 'import_chrome';
30 }
31
32 /**
33 * {@inheritdoc}
34 */
35 public function getDescription()
36 {
37 return 'import.chrome.description';
38 }
39
40 /**
41 * {@inheritdoc}
42 */
43 protected function prepareEntry($entry = [])
44 {
45 $data = [
46 'title' => $entry['name'],
47 'html' => '',
48 'url' => $entry['url'],
49 'is_archived' => $this->markAsRead,
50 'tags' => '',
51 'created_at' => $entry['date_added'],
52 ];
53
54 if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
55 $data['tags'] = $entry['tags'];
56 }
57
58 return $data;
59 }
60
61
62 /**
63 * {@inheritdoc}
64 */
65 protected function setEntryAsRead(array $importedEntry)
66 {
67 $importedEntry['is_archived'] = 1;
68
69 return $importedEntry;
70 }
71}
diff --git a/src/Wallabag/ImportBundle/Import/FirefoxImport.php b/src/Wallabag/ImportBundle/Import/FirefoxImport.php
new file mode 100644
index 00000000..cbf10b87
--- /dev/null
+++ b/src/Wallabag/ImportBundle/Import/FirefoxImport.php
@@ -0,0 +1,71 @@
1<?php
2
3namespace Wallabag\ImportBundle\Import;
4
5use Psr\Log\LoggerInterface;
6use Psr\Log\NullLogger;
7use Doctrine\ORM\EntityManager;
8use Wallabag\CoreBundle\Entity\Entry;
9use Wallabag\UserBundle\Entity\User;
10use Wallabag\CoreBundle\Helper\ContentProxy;
11
12class FirefoxImport extends BrowserImport
13{
14 protected $filepath;
15
16 /**
17 * {@inheritdoc}
18 */
19 public function getName()
20 {
21 return 'Firefox';
22 }
23
24 /**
25 * {@inheritdoc}
26 */
27 public function getUrl()
28 {
29 return 'import_firefox';
30 }
31
32 /**
33 * {@inheritdoc}
34 */
35 public function getDescription()
36 {
37 return 'import.firefox.description';
38 }
39
40 /**
41 * {@inheritdoc}
42 */
43 protected function prepareEntry($entry = [])
44 {
45 $data = [
46 'title' => $entry['name'],
47 'html' => '',
48 'url' => $entry['url'],
49 'is_archived' => $this->markAsRead,
50 'tags' => '',
51 'created_at' => $entry['date_added'],
52 ];
53
54 if (array_key_exists('tags', $entry) && $entry['tags'] != '') {
55 $data['tags'] = $entry['tags'];
56 }
57
58 return $data;
59 }
60
61
62 /**
63 * {@inheritdoc}
64 */
65 protected function setEntryAsRead(array $importedEntry)
66 {
67 $importedEntry['is_archived'] = 1;
68
69 return $importedEntry;
70 }
71}
diff --git a/src/Wallabag/ImportBundle/Resources/config/rabbit.yml b/src/Wallabag/ImportBundle/Resources/config/rabbit.yml
index aa049749..6ada6302 100644
--- a/src/Wallabag/ImportBundle/Resources/config/rabbit.yml
+++ b/src/Wallabag/ImportBundle/Resources/config/rabbit.yml
@@ -28,3 +28,17 @@ services:
28 - "@wallabag_user.user_repository" 28 - "@wallabag_user.user_repository"
29 - "@wallabag_import.wallabag_v2.import" 29 - "@wallabag_import.wallabag_v2.import"
30 - "@logger" 30 - "@logger"
31 wallabag_import.consumer.amqp.firefox:
32 class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
33 arguments:
34 - "@doctrine.orm.entity_manager"
35 - "@wallabag_user.user_repository"
36 - "@wallabag_import.firefox.import"
37 - "@logger"
38 wallabag_import.consumer.amqp.chrome:
39 class: Wallabag\ImportBundle\Consumer\AMQPEntryConsumer
40 arguments:
41 - "@doctrine.orm.entity_manager"
42 - "@wallabag_user.user_repository"
43 - "@wallabag_import.chrome.import"
44 - "@logger"
diff --git a/src/Wallabag/ImportBundle/Resources/config/redis.yml b/src/Wallabag/ImportBundle/Resources/config/redis.yml
index 7d3248e5..c47778b8 100644
--- a/src/Wallabag/ImportBundle/Resources/config/redis.yml
+++ b/src/Wallabag/ImportBundle/Resources/config/redis.yml
@@ -79,3 +79,43 @@ services:
79 - "@wallabag_user.user_repository" 79 - "@wallabag_user.user_repository"
80 - "@wallabag_import.wallabag_v2.import" 80 - "@wallabag_import.wallabag_v2.import"
81 - "@logger" 81 - "@logger"
82
83 # firefox
84 wallabag_import.queue.redis.firefox:
85 class: Simpleue\Queue\RedisQueue
86 arguments:
87 - "@wallabag_core.redis.client"
88 - "wallabag.import.firefox"
89
90 wallabag_import.producer.redis.firefox:
91 class: Wallabag\ImportBundle\Redis\Producer
92 arguments:
93 - "@wallabag_import.queue.redis.firefox"
94
95 wallabag_import.consumer.redis.firefox:
96 class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer
97 arguments:
98 - "@doctrine.orm.entity_manager"
99 - "@wallabag_user.user_repository"
100 - "@wallabag_import.firefox.import"
101 - "@logger"
102
103 # chrome
104 wallabag_import.queue.redis.chrome:
105 class: Simpleue\Queue\RedisQueue
106 arguments:
107 - "@wallabag_core.redis.client"
108 - "wallabag.import.chrome"
109
110 wallabag_import.producer.redis.firefox:
111 class: Wallabag\ImportBundle\Redis\Producer
112 arguments:
113 - "@wallabag_import.queue.redis.chrome"
114
115 wallabag_import.consumer.redis.firefox:
116 class: Wallabag\ImportBundle\Consumer\RedisEntryConsumer
117 arguments:
118 - "@doctrine.orm.entity_manager"
119 - "@wallabag_user.user_repository"
120 - "@wallabag_import.chrome.import"
121 - "@logger"
diff --git a/src/Wallabag/ImportBundle/Resources/config/services.yml b/src/Wallabag/ImportBundle/Resources/config/services.yml
index d8be5c28..990f336d 100644
--- a/src/Wallabag/ImportBundle/Resources/config/services.yml
+++ b/src/Wallabag/ImportBundle/Resources/config/services.yml
@@ -57,12 +57,21 @@ services:
57 tags: 57 tags:
58 - { name: wallabag_import.import, alias: readability } 58 - { name: wallabag_import.import, alias: readability }
59 59
60 wallabag_import.browser.import: 60 wallabag_import.firefox.import:
61 class: Wallabag\ImportBundle\Import\BrowserImport 61 class: Wallabag\ImportBundle\Import\FirefoxImport
62 arguments: 62 arguments:
63 - "@doctrine.orm.entity_manager" 63 - "@doctrine.orm.entity_manager"
64 - "@wallabag_core.content_proxy" 64 - "@wallabag_core.content_proxy"
65 calls: 65 calls:
66 - [ setLogger, [ "@logger" ]] 66 - [ setLogger, [ "@logger" ]]
67 tags: 67 tags:
68 - { name: wallabag_import.import, alias: browser } 68 - { name: wallabag_import.import, alias: firefox }
69 wallabag_import.chrome.import:
70 class: Wallabag\ImportBundle\Import\ChromeImport
71 arguments:
72 - "@doctrine.orm.entity_manager"
73 - "@wallabag_core.content_proxy"
74 calls:
75 - [ setLogger, [ "@logger" ]]
76 tags:
77 - { name: wallabag_import.import, alias: chrome }
diff --git a/src/Wallabag/ImportBundle/Resources/views/Chrome/index.html.twig b/src/Wallabag/ImportBundle/Resources/views/Chrome/index.html.twig
new file mode 100644
index 00000000..ead828c6
--- /dev/null
+++ b/src/Wallabag/ImportBundle/Resources/views/Chrome/index.html.twig
@@ -0,0 +1,43 @@
1{% extends "WallabagCoreBundle::layout.html.twig" %}
2
3{% block title %}{{ 'import.chrome.page_title'|trans }}{% endblock %}
4
5{% block content %}
6<div class="row">
7 <div class="col s12">
8 <div class="card-panel settings">
9 <div class="row">
10 <blockquote>{{ import.description|trans|raw }}</blockquote>
11 <p>{{ 'import.chrome.how_to'|trans }}</p>
12
13 <div class="col s12">
14 {{ form_start(form, {'method': 'POST'}) }}
15 {{ form_errors(form) }}
16 <div class="row">
17 <div class="file-field input-field col s12">
18 {{ form_errors(form.file) }}
19 <div class="btn">
20 <span>{{ form.file.vars.label|trans }}</span>
21 {{ form_widget(form.file) }}
22 </div>
23 <div class="file-path-wrapper">
24 <input class="file-path validate" type="text">
25 </div>
26 </div>
27 <div class="input-field col s6 with-checkbox">
28 <h6>{{ 'import.form.mark_as_read_title'|trans }}</h6>
29 {{ form_widget(form.mark_as_read) }}
30 {{ form_label(form.mark_as_read) }}
31 </div>
32 </div>
33
34 {{ form_widget(form.save, { 'attr': {'class': 'btn waves-effect waves-light'} }) }}
35
36 {{ form_rest(form) }}
37 </form>
38 </div>
39 </div>
40 </div>
41 </div>
42</div>
43{% endblock %}
diff --git a/src/Wallabag/ImportBundle/Resources/views/Browser/index.html.twig b/src/Wallabag/ImportBundle/Resources/views/Firefox/index.html.twig
index bfc74e9d..f975da3f 100644
--- a/src/Wallabag/ImportBundle/Resources/views/Browser/index.html.twig
+++ b/src/Wallabag/ImportBundle/Resources/views/Firefox/index.html.twig
@@ -1,6 +1,6 @@
1{% extends "WallabagCoreBundle::layout.html.twig" %} 1{% extends "WallabagCoreBundle::layout.html.twig" %}
2 2
3{% block title %}{{ 'import.browser.page_title'|trans }}{% endblock %} 3{% block title %}{{ 'import.firefox.page_title'|trans }}{% endblock %}
4 4
5{% block content %} 5{% block content %}
6<div class="row"> 6<div class="row">
@@ -8,7 +8,7 @@
8 <div class="card-panel settings"> 8 <div class="card-panel settings">
9 <div class="row"> 9 <div class="row">
10 <blockquote>{{ import.description|trans|raw }}</blockquote> 10 <blockquote>{{ import.description|trans|raw }}</blockquote>
11 <p>{{ 'import.browser.how_to'|trans }}</p> 11 <p>{{ 'import.firefox.how_to'|trans }}</p>
12 12
13 <div class="col s12"> 13 <div class="col s12">
14 {{ form_start(form, {'method': 'POST'}) }} 14 {{ form_start(form, {'method': 'POST'}) }}