aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/ApiBundle/Controller/EntryRestController.php103
-rw-r--r--src/Wallabag/ApiBundle/Controller/TagRestController.php4
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.en.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig10
4 files changed, 111 insertions, 8 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
index af5f7603..7590efbb 100644
--- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
@@ -438,4 +438,107 @@ class EntryRestController extends WallabagRestController
438 438
439 return (new JsonResponse())->setJson($json); 439 return (new JsonResponse())->setJson($json);
440 } 440 }
441
442 /**
443 * Handles an entries list delete tags from them.
444 *
445 * @ApiDoc(
446 * parameters={
447 * {"name"="list", "dataType"="string", "required"=true, "format"="A JSON array of urls [{'url': 'http://...','tags': 'tag1, tag2'}, {'url': 'http://...','tags': 'tag1, tag2'}]", "description"="Urls (as an array) to handle."}
448 * }
449 * )
450 *
451 * @return JsonResponse
452 */
453 public function deleteEntriesTagsListAction(Request $request)
454 {
455 $this->validateAuthentication();
456
457 $list = json_decode($request->query->get('list', []));
458 $results = [];
459
460 // handle multiple urls
461 if (!empty($list)) {
462 foreach ($list as $key => $element) {
463 $entry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId(
464 $element->url,
465 $this->getUser()->getId()
466 );
467
468 $results[$key]['url'] = $element->url;
469 $results[$key]['entry'] = $entry instanceof Entry ? $entry->getId() : false;
470
471 $tags = $element->tags;
472
473 if (false !== $entry && !(empty($tags))) {
474 $tags = explode(',', $tags);
475 foreach ($tags as $label) {
476 $label = trim($label);
477
478 $tag = $this->getDoctrine()
479 ->getRepository('WallabagCoreBundle:Tag')
480 ->findOneByLabel($label);
481
482 if (false !== $tag) {
483 $entry->removeTag($tag);
484 }
485 }
486
487 $em = $this->getDoctrine()->getManager();
488 $em->persist($entry);
489 $em->flush();
490 }
491 }
492 }
493
494 $json = $this->get('serializer')->serialize($results, 'json');
495
496 return (new JsonResponse())->setJson($json);
497 }
498
499 /**
500 * Handles an entries list and add tags to them.
501 *
502 * @ApiDoc(
503 * parameters={
504 * {"name"="list", "dataType"="string", "required"=true, "format"="A JSON array of urls [{'url': 'http://...','tags': 'tag1, tag2'}, {'url': 'http://...','tags': 'tag1, tag2'}]", "description"="Urls (as an array) to handle."}
505 * }
506 * )
507 *
508 * @return JsonResponse
509 */
510 public function postEntriesTagsListAction(Request $request)
511 {
512 $this->validateAuthentication();
513
514 $list = json_decode($request->query->get('list', []));
515 $results = [];
516
517 // handle multiple urls
518 if (!empty($list)) {
519 foreach ($list as $key => $element) {
520 $entry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId(
521 $element->url,
522 $this->getUser()->getId()
523 );
524
525 $results[$key]['url'] = $element->url;
526 $results[$key]['entry'] = $entry instanceof Entry ? $entry->getId() : false;
527
528 $tags = $element->tags;
529
530 if (false !== $entry && !(empty($tags))) {
531 $this->get('wallabag_core.content_proxy')->assignTagsToEntry($entry, $tags);
532
533 $em = $this->getDoctrine()->getManager();
534 $em->persist($entry);
535 $em->flush();
536 }
537 }
538 }
539
540 $json = $this->get('serializer')->serialize($results, 'json');
541
542 return (new JsonResponse())->setJson($json);
543 }
441} 544}
diff --git a/src/Wallabag/ApiBundle/Controller/TagRestController.php b/src/Wallabag/ApiBundle/Controller/TagRestController.php
index bc6d4e64..47298d7e 100644
--- a/src/Wallabag/ApiBundle/Controller/TagRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/TagRestController.php
@@ -31,7 +31,7 @@ class TagRestController extends WallabagRestController
31 } 31 }
32 32
33 /** 33 /**
34 * Permanently remove one tag from **every** entry. 34 * Permanently remove one tag from **every** entry by passing the Tag label.
35 * 35 *
36 * @ApiDoc( 36 * @ApiDoc(
37 * requirements={ 37 * requirements={
@@ -106,7 +106,7 @@ class TagRestController extends WallabagRestController
106 } 106 }
107 107
108 /** 108 /**
109 * Permanently remove one tag from **every** entry. 109 * Permanently remove one tag from **every** entry by passing the Tag ID.
110 * 110 *
111 * @ApiDoc( 111 * @ApiDoc(
112 * requirements={ 112 * requirements={
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
index 29f9938c..4b745683 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
@@ -362,7 +362,7 @@ quickstart:
362 developer: 362 developer:
363 title: 'Developers' 363 title: 'Developers'
364 description: 'We also thought to the developers: Docker, API, translations, etc.' 364 description: 'We also thought to the developers: Docker, API, translations, etc.'
365 create_application: 'Create your third application' 365 create_application: 'Create your third-party application'
366 use_docker: 'Use Docker to install wallabag' 366 use_docker: 'Use Docker to install wallabag'
367 docs: 367 docs:
368 title: 'Full documentation' 368 title: 'Full documentation'
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
index 8be5fd0d..3c4ad024 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
@@ -12,6 +12,11 @@
12 <div class="nav-wrapper cyan darken-1"> 12 <div class="nav-wrapper cyan darken-1">
13 <ul> 13 <ul>
14 <li> 14 <li>
15 <a href="#" data-activates="slide-out" class="button-collapse">
16 <i class="material-icons">menu</i>
17 </a>
18 </li>
19 <li>
15 <a class="waves-effect" href="{{ path('homepage') }}"> 20 <a class="waves-effect" href="{{ path('homepage') }}">
16 <i class="material-icons">exit_to_app</i> 21 <i class="material-icons">exit_to_app</i>
17 </a> 22 </a>
@@ -28,11 +33,6 @@
28 <i class="material-icons small">{% if entry.isStarred == 0 %}star_outline{% else %}star{% endif %}</i> 33 <i class="material-icons small">{% if entry.isStarred == 0 %}star_outline{% else %}star{% endif %}</i>
29 </a> 34 </a>
30 </li> 35 </li>
31 <li>
32 <a href="#" data-activates="slide-out" class="button-collapse right">
33 <i class="material-icons">menu</i>
34 </a>
35 </li>
36 </ul> 36 </ul>
37 </div> 37 </div>
38 </nav> 38 </nav>