diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2019-06-26 22:31:47 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2019-07-08 09:38:32 +0200 |
commit | 34be2d5de44ade2a78be73decc0b90a2c1bca720 (patch) | |
tree | d635438784c4b02e1d182cfbc3d47b62e5032f1d /src/Wallabag/ApiBundle | |
parent | 92cd51aa2c29e23f137cde9b9732ced33ff38e59 (diff) | |
download | wallabag-34be2d5de44ade2a78be73decc0b90a2c1bca720.tar.gz wallabag-34be2d5de44ade2a78be73decc0b90a2c1bca720.tar.zst wallabag-34be2d5de44ade2a78be73decc0b90a2c1bca720.zip |
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)
Diffstat (limited to 'src/Wallabag/ApiBundle')
-rw-r--r-- | src/Wallabag/ApiBundle/Controller/TaggingRuleRestController.php | 39 | ||||
-rw-r--r-- | src/Wallabag/ApiBundle/Resources/config/routing_rest.yml | 5 |
2 files changed, 44 insertions, 0 deletions
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 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\ApiBundle\Controller; | ||
4 | |||
5 | use JMS\Serializer\SerializationContext; | ||
6 | use JMS\Serializer\SerializerBuilder; | ||
7 | use Nelmio\ApiDocBundle\Annotation\ApiDoc; | ||
8 | use Symfony\Component\HttpFoundation\Response; | ||
9 | |||
10 | class TaggingRuleRestController extends WallabagRestController | ||
11 | { | ||
12 | /** | ||
13 | * Export all tagging rules as a json file. | ||
14 | * | ||
15 | * @ApiDoc() | ||
16 | * | ||
17 | * @return Response | ||
18 | */ | ||
19 | public function getTaggingruleExportAction() | ||
20 | { | ||
21 | $this->validateAuthentication(); | ||
22 | |||
23 | $data = SerializerBuilder::create()->build()->serialize( | ||
24 | $this->getUser()->getConfig()->getTaggingRules(), | ||
25 | 'json', | ||
26 | SerializationContext::create()->setGroups(['export_tagging_rule']) | ||
27 | ); | ||
28 | |||
29 | return Response::create( | ||
30 | $data, | ||
31 | 200, | ||
32 | [ | ||
33 | 'Content-type' => 'application/json', | ||
34 | 'Content-Disposition' => 'attachment; filename="tagging_rules_' . $this->getUser()->getUsername() . '.json"', | ||
35 | 'Content-Transfer-Encoding' => 'UTF-8', | ||
36 | ] | ||
37 | ); | ||
38 | } | ||
39 | } | ||
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: | |||
13 | resource: "WallabagApiBundle:TagRest" | 13 | resource: "WallabagApiBundle:TagRest" |
14 | name_prefix: api_ | 14 | name_prefix: api_ |
15 | 15 | ||
16 | tagging_rule: | ||
17 | type: rest | ||
18 | resource: "WallabagApiBundle:TaggingRuleRest" | ||
19 | name_prefix: api_ | ||
20 | |||
16 | annotation: | 21 | annotation: |
17 | type: rest | 22 | type: rest |
18 | resource: "WallabagApiBundle:AnnotationRest" | 23 | resource: "WallabagApiBundle:AnnotationRest" |