aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJeremy Benoist <j0k3r@users.noreply.github.com>2015-08-09 22:47:28 +0200
committerJeremy Benoist <j0k3r@users.noreply.github.com>2015-08-09 22:47:28 +0200
commit47cadf36c8f7c20ba1edf26e184637d33a52cf35 (patch)
treeb25f67a8d32c3d211e6d16dfe010805c3bdafc0e /src
parent20a69dffe7e1caf01c12b2c39dbb2f9cb8093925 (diff)
parentd0b90fbe18da72dc09a0ef748fa178314f6657b6 (diff)
downloadwallabag-47cadf36c8f7c20ba1edf26e184637d33a52cf35.tar.gz
wallabag-47cadf36c8f7c20ba1edf26e184637d33a52cf35.tar.zst
wallabag-47cadf36c8f7c20ba1edf26e184637d33a52cf35.zip
Merge pull request #1292 from wallabag/v2-tags-route
Add tags list display
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Controller/TagController.php31
-rw-r--r--src/Wallabag/CoreBundle/Repository/TagRepository.php18
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/Tag/tags.html.twig13
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/base.html.twig2
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/base.html.twig2
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php19
6 files changed, 83 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php
new file mode 100644
index 00000000..e448cea1
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Controller/TagController.php
@@ -0,0 +1,31 @@
1<?php
2
3namespace Wallabag\CoreBundle\Controller;
4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7
8class TagController extends Controller
9{
10 /**
11 * Shows tags for current user.
12 *
13 * @Route("/tag/list", name="tag")
14 *
15 * @return \Symfony\Component\HttpFoundation\Response
16 */
17 public function showTagAction()
18 {
19 $tags = $this->getDoctrine()
20 ->getRepository('WallabagCoreBundle:Tag')
21 ->findTags($this->getUser()->getId());
22
23 return $this->render(
24 'WallabagCoreBundle:Tag:tags.html.twig',
25 array(
26 'tags' => $tags
27 )
28 );
29 }
30
31}
diff --git a/src/Wallabag/CoreBundle/Repository/TagRepository.php b/src/Wallabag/CoreBundle/Repository/TagRepository.php
index 52f319f1..51f1cd42 100644
--- a/src/Wallabag/CoreBundle/Repository/TagRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/TagRepository.php
@@ -3,7 +3,25 @@
3namespace Wallabag\CoreBundle\Repository; 3namespace Wallabag\CoreBundle\Repository;
4 4
5use Doctrine\ORM\EntityRepository; 5use Doctrine\ORM\EntityRepository;
6use Pagerfanta\Adapter\DoctrineORMAdapter;
7use Pagerfanta\Pagerfanta;
6 8
7class TagRepository extends EntityRepository 9class TagRepository extends EntityRepository
8{ 10{
11 /**
12 * Find Tags.
13 *
14 * @param int $userId
15 *
16 * @return array
17 */
18 public function findTags($userId)
19 {
20 $qb = $this->createQueryBuilder('t')
21 ->where('t.user =:userId')->setParameter('userId', $userId);
22
23 $pagerAdapter = new DoctrineORMAdapter($qb);
24
25 return new Pagerfanta($pagerAdapter);
26 }
9} 27}
diff --git a/src/Wallabag/CoreBundle/Resources/views/Tag/tags.html.twig b/src/Wallabag/CoreBundle/Resources/views/Tag/tags.html.twig
new file mode 100644
index 00000000..c2a461b8
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Resources/views/Tag/tags.html.twig
@@ -0,0 +1,13 @@
1{% extends "WallabagCoreBundle::layout.html.twig" %}
2
3{% block title "Tags" %}
4
5{% block content %}
6 {% if tags is empty %}
7 <div class="messages warning"><p>{% trans %}No tags found.{% endtrans %}</p></div>
8 {% else %}
9 {% for tag in tags %}
10 {{tag.label}}
11 {% endfor %}
12 {% endif %}
13{% endblock %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/base.html.twig b/src/Wallabag/CoreBundle/Resources/views/base.html.twig
index 4f27f413..223e8433 100644
--- a/src/Wallabag/CoreBundle/Resources/views/base.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/base.html.twig
@@ -71,7 +71,7 @@
71 <li><a href="{{ path('unread') }}">{% trans %}unread{% endtrans %}</a></li> 71 <li><a href="{{ path('unread') }}">{% trans %}unread{% endtrans %}</a></li>
72 <li><a href="{{ path('starred') }}">{% trans %}favorites{% endtrans %}</a></li> 72 <li><a href="{{ path('starred') }}">{% trans %}favorites{% endtrans %}</a></li>
73 <li><a href="{{ path('archive') }}"}>{% trans %}archive{% endtrans %}</a></li> 73 <li><a href="{{ path('archive') }}"}>{% trans %}archive{% endtrans %}</a></li>
74 <li><a href="?view=tags">{% trans %}tags{% endtrans %}</a></li> 74 <li><a href="{{ path ('tag') }}">{% trans %}tags{% endtrans %}</a></li>
75 <li><a href="{{ path('new_entry') }}">{% trans %}save a link{% endtrans %}</a></li> 75 <li><a href="{{ path('new_entry') }}">{% trans %}save a link{% endtrans %}</a></li>
76 <li style="position: relative;"><a href="javascript: void(null);" id="search">{% trans %}search{% endtrans %}</a> 76 <li style="position: relative;"><a href="javascript: void(null);" id="search">{% trans %}search{% endtrans %}</a>
77 <div id="search-form" class="messages info popup-form"> 77 <div id="search-form" class="messages info popup-form">
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/base.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/base.html.twig
index a56f58f3..7070a399 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/base.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/base.html.twig
@@ -74,7 +74,7 @@
74 <li class="bold {% if currentRoute == 'unread' or currentRoute == 'homepage' %}active{% endif %}"><a class="waves-effect" href="{{ path('unread') }}">{% trans %}unread{% endtrans %}</a></li> 74 <li class="bold {% if currentRoute == 'unread' or currentRoute == 'homepage' %}active{% endif %}"><a class="waves-effect" href="{{ path('unread') }}">{% trans %}unread{% endtrans %}</a></li>
75 <li class="bold {% if currentRoute == 'starred' %}active{% endif %}"><a class="waves-effect" href="{{ path('starred') }}">{% trans %}starred{% endtrans %}</a></li> 75 <li class="bold {% if currentRoute == 'starred' %}active{% endif %}"><a class="waves-effect" href="{{ path('starred') }}">{% trans %}starred{% endtrans %}</a></li>
76 <li class="bold {% if currentRoute == 'archive' %}active{% endif %}"><a class="waves-effect" href="{{ path('archive') }}">{% trans %}archive{% endtrans %}</a></li> 76 <li class="bold {% if currentRoute == 'archive' %}active{% endif %}"><a class="waves-effect" href="{{ path('archive') }}">{% trans %}archive{% endtrans %}</a></li>
77 <li class="bold border-bottom {% if currentRoute == 'tags' %}active{% endif %}"><a class="waves-effect" href="?view=tags">{% trans %}tags{% endtrans %}</a></li> 77 <li class="bold border-bottom {% if currentRoute == 'tags' %}active{% endif %}"><a class="waves-effect" href="{{ path('tag') }}">{% trans %}tags{% endtrans %}</a></li>
78 <li class="bold {% if currentRoute == 'config' %}active{% endif %}"><a class="waves-effect" href="{{ path('config') }}">{% trans %}config{% endtrans %}</a></li> 78 <li class="bold {% if currentRoute == 'config' %}active{% endif %}"><a class="waves-effect" href="{{ path('config') }}">{% trans %}config{% endtrans %}</a></li>
79 <li class="bold"><a class="waves-effect" class="icon icon-power" href="{{ path('logout') }}" title="{% trans %}logout{% endtrans %}">{% trans %}logout{% endtrans %}</a></li> 79 <li class="bold"><a class="waves-effect" class="icon icon-power" href="{{ path('logout') }}" title="{% trans %}logout{% endtrans %}">{% trans %}logout{% endtrans %}</a></li>
80 </ul> 80 </ul>
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php
new file mode 100644
index 00000000..34faf709
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php
@@ -0,0 +1,19 @@
1<?php
2
3namespace Wallabag\CoreBundle\Tests\Controller;
4
5use Wallabag\CoreBundle\Tests\WallabagCoreTestCase;
6use Doctrine\ORM\AbstractQuery;
7
8class TagControllerTest extends WallabagCoreTestCase
9{
10 public function testList()
11 {
12 $this->logInAs('admin');
13 $client = $this->getClient();
14
15 $client->request('GET', '/tag/list');
16
17 $this->assertEquals(200, $client->getResponse()->getStatusCode());
18 }
19}