From 3fad6c74fe72b50bceb5f1c67c3f81370660634e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolas=20L=C5=93uillet?= Date: Wed, 27 Apr 2016 20:30:24 +0200 Subject: [PATCH] Add CLI import for wallabag v2 files --- docs/en/user/migration.rst | 36 ++++++++++--------- docs/fr/user/migration.rst | 36 ++++++++++--------- .../ImportBundle/Command/ImportCommand.php | 13 ++++++- 3 files changed, 52 insertions(+), 33 deletions(-) diff --git a/docs/en/user/migration.rst b/docs/en/user/migration.rst index e141ae40..cfbca922 100644 --- a/docs/en/user/migration.rst +++ b/docs/en/user/migration.rst @@ -24,20 +24,38 @@ After creating an user account on your new wallabag v2 instance, you must head o :alt: Import from wallabag v1 :align: center +From wallabag 2.x +----------------- + +From the previous wallabag instance on which you were before, go to `All articles`, then export these articles as json. + +.. image:: ../../img/user/export_v2.png + :alt: Export depuis wallabag v2 + :align: center + +From your new wallabag instance, create your user account and click on the link in the menu to proceed to import. Choose import from wallabag v2 and select your json file to upload it. + +.. note:: + If you encounter issues during the export or the import, don't hesitate to `ask for support `__. + Import via command-line interface (CLI) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +--------------------------------------- If you have a CLI access on your web server, you can execute this command to import your wallabag v1 export: :: - bin/console wallabag:import-v1 1 ~/Downloads/wallabag-export-1-2016-04-05.json --env=prod + bin/console wallabag:import 1 ~/Downloads/wallabag-export-1-2016-04-05.json --env=prod Please replace values: * ``1`` is the user identifier in database (The ID of the first user created on wallabag is 1) * ``~/Downloads/wallabag-export-1-2016-04-05.json`` is the path of your wallabag v1 export +If you want to mark all these entries as read, you can add the ``--markAsRead=yes`` option. + +To import a wallabag v2 file, you need to add the option ``--importer=v2``. + You'll have this in return: :: @@ -46,17 +64,3 @@ You'll have this in return: 403 imported 0 already saved End : 05-04-2016 11:36:09 --- - -From wallabag 2.x ------------------ - -From the previous wallabag instance on which you were before, go to `All articles`, then export these articles as json. - -.. image:: ../../img/user/export_v2.png - :alt: Export depuis wallabag v2 - :align: center - -From your new wallabag instance, create your user account and click on the link in the menu to proceed to import. Choose import from wallabag v2 and select your json file to upload it. - -.. note:: - If you encounter issues during the export or the import, don't hesitate to `ask for support `__. diff --git a/docs/fr/user/migration.rst b/docs/fr/user/migration.rst index 66024572..a69df295 100644 --- a/docs/fr/user/migration.rst +++ b/docs/fr/user/migration.rst @@ -24,20 +24,38 @@ Une fois que vous avez créé un compte utilisateur sur votre nouvelle instance :alt: Import depuis wallabag v1 :align: center +Depuis wallabag 2.x +------------------- + +Depuis l'instance sur laquelle vous étiez, rendez-vous dans la section `Tous les articles`, puis exportez ces articles au format json. + +.. image:: ../../img/user/export_v2.png + :alt: Export depuis wallabag v2 + :align: center + +Depuis votre nouvelle instance de wallabag, créez votre compte utilisateur puis cliquez sur le lien dans le menu pour accéder à l'import. Choisissez l'import depuis wallabag v2 puis sélectionnez votre fichier json pour l'uploader. + +.. note:: + S'il vous arrive des problèmes durant l'export ou l'import, n'hésitez pas à `demander de l'aide `__. + Import via via la ligne de commande (CLI) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +----------------------------------------- Si vous avez accès à la ligne de commandes de votre serveur web, vous pouvez exécuter cette commande pour import votre fichier wallabag v1 : :: - bin/console wallabag:import-v1 1 ~/Downloads/wallabag-export-1-2016-04-05.json --env=prod + bin/console wallabag:import 1 ~/Downloads/wallabag-export-1-2016-04-05.json --env=prod Remplacez les valeurs : * ``1`` est l'identifiant de votre utilisateur en base (l'ID de votre premier utilisateur créé sur wallabag est 1) * ``~/Downloads/wallabag-export-1-2016-04-05.json`` est le chemin de votre export wallabag v1 +Si vous voulez marquer tous ces articles comme lus, vous pouvez ajouter l'option ``--markAsRead=yes``. + +Pour importer un fichier wallabag v2, vous devez ajouter l'option ``--importer=v2``. + Vous obtiendrez : :: @@ -46,17 +64,3 @@ Vous obtiendrez : 403 imported 0 already saved End : 05-04-2016 11:36:09 --- - -Depuis wallabag 2.x -------------------- - -Depuis l'instance sur laquelle vous étiez, rendez-vous dans la section `Tous les articles`, puis exportez ces articles au format json. - -.. image:: ../../img/user/export_v2.png - :alt: Export depuis wallabag v2 - :align: center - -Depuis votre nouvelle instance de wallabag, créez votre compte utilisateur puis cliquez sur le lien dans le menu pour accéder à l'import. Choisissez l'import depuis wallabag v2 puis sélectionnez votre fichier json pour l'uploader. - -.. note:: - S'il vous arrive des problèmes durant l'export ou l'import, n'hésitez pas à `demander de l'aide `__. diff --git a/src/Wallabag/ImportBundle/Command/ImportCommand.php b/src/Wallabag/ImportBundle/Command/ImportCommand.php index dfbfc2f7..f62176fc 100644 --- a/src/Wallabag/ImportBundle/Command/ImportCommand.php +++ b/src/Wallabag/ImportBundle/Command/ImportCommand.php @@ -13,10 +13,12 @@ class ImportCommand extends ContainerAwareCommand protected function configure() { $this - ->setName('wallabag:import-v1') + ->setName('wallabag:import') ->setDescription('Import entries from a JSON export from a wallabag v1 instance') ->addArgument('userId', InputArgument::REQUIRED, 'User ID to populate') ->addArgument('filepath', InputArgument::REQUIRED, 'Path to the JSON file') + ->addOption('importer', null, InputArgument::OPTIONAL, 'The importer to use: v1 or v2', 'v1') + ->addOption('markAsRead', null, InputArgument::OPTIONAL, 'Mark all entries as read: true/false', false) ; } @@ -35,6 +37,15 @@ class ImportCommand extends ContainerAwareCommand } $wallabag = $this->getContainer()->get('wallabag_import.wallabag_v1.import'); + + if ('v2' === $input->getOption('importer')) { + $wallabag = $this->getContainer()->get('wallabag_import.wallabag_v2.import'); + } + + if ('yes' === $input->getOption('markAsRead')) { + $wallabag->setMarkAsRead(true); + } + $res = $wallabag ->setUser($user) ->setFilepath($input->getArgument('filepath')) -- 2.41.0