From 34be2d5de44ade2a78be73decc0b90a2c1bca720 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 26 Jun 2019 22:31:47 +0200 Subject: Add ability to import/export tagging rules - Add missing translations - Add some tests - Add `/api/taggingrule/export` API endpoint - Add baggy theme - Add error message when importing tagging rules failed - Also fix all translations (I think we are good now) --- .../Controller/TaggingRuleRestController.php | 39 ++++++++++++++++++++++ .../ApiBundle/Resources/config/routing_rest.yml | 5 +++ 2 files changed, 44 insertions(+) create mode 100644 src/Wallabag/ApiBundle/Controller/TaggingRuleRestController.php (limited to 'src/Wallabag/ApiBundle') diff --git a/src/Wallabag/ApiBundle/Controller/TaggingRuleRestController.php b/src/Wallabag/ApiBundle/Controller/TaggingRuleRestController.php new file mode 100644 index 00000000..2496298a --- /dev/null +++ b/src/Wallabag/ApiBundle/Controller/TaggingRuleRestController.php @@ -0,0 +1,39 @@ +validateAuthentication(); + + $data = SerializerBuilder::create()->build()->serialize( + $this->getUser()->getConfig()->getTaggingRules(), + 'json', + SerializationContext::create()->setGroups(['export_tagging_rule']) + ); + + return Response::create( + $data, + 200, + [ + 'Content-type' => 'application/json', + 'Content-Disposition' => 'attachment; filename="tagging_rules_' . $this->getUser()->getUsername() . '.json"', + 'Content-Transfer-Encoding' => 'UTF-8', + ] + ); + } +} diff --git a/src/Wallabag/ApiBundle/Resources/config/routing_rest.yml b/src/Wallabag/ApiBundle/Resources/config/routing_rest.yml index 06e62c37..98efeeb1 100644 --- a/src/Wallabag/ApiBundle/Resources/config/routing_rest.yml +++ b/src/Wallabag/ApiBundle/Resources/config/routing_rest.yml @@ -13,6 +13,11 @@ tag: resource: "WallabagApiBundle:TagRest" name_prefix: api_ +tagging_rule: + type: rest + resource: "WallabagApiBundle:TaggingRuleRest" + name_prefix: api_ + annotation: type: rest resource: "WallabagApiBundle:AnnotationRest" -- cgit v1.2.3