From 3f3fbef11f86968a991426c2a052ad42e0c16d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 7 Aug 2015 18:17:23 +0200 Subject: [PATCH 1/5] Add tags list display --- .../CoreBundle/Controller/TagController.php | 33 +++++++++++++++++++ .../CoreBundle/Repository/TagRepository.php | 18 ++++++++++ .../Resources/views/Tag/tags.html.twig | 27 +++++++++++++++ .../CoreBundle/Resources/views/base.html.twig | 2 +- .../views/themes/material/base.html.twig | 2 +- 5 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 src/Wallabag/CoreBundle/Controller/TagController.php create mode 100644 src/Wallabag/CoreBundle/Resources/views/Tag/tags.html.twig diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php new file mode 100644 index 000000000..892842315 --- /dev/null +++ b/src/Wallabag/CoreBundle/Controller/TagController.php @@ -0,0 +1,33 @@ +getDoctrine() + ->getRepository('WallabagCoreBundle:Tag') + ->findTags($this->getUser()->getId()); + + return $this->render( + 'WallabagCoreBundle:Tag:tags.html.twig', + array( + 'tags' => $tags + ) + ); + } + +} diff --git a/src/Wallabag/CoreBundle/Repository/TagRepository.php b/src/Wallabag/CoreBundle/Repository/TagRepository.php index 52f319f11..51f1cd429 100644 --- a/src/Wallabag/CoreBundle/Repository/TagRepository.php +++ b/src/Wallabag/CoreBundle/Repository/TagRepository.php @@ -3,7 +3,25 @@ namespace Wallabag\CoreBundle\Repository; use Doctrine\ORM\EntityRepository; +use Pagerfanta\Adapter\DoctrineORMAdapter; +use Pagerfanta\Pagerfanta; class TagRepository extends EntityRepository { + /** + * Find Tags. + * + * @param int $userId + * + * @return array + */ + public function findTags($userId) + { + $qb = $this->createQueryBuilder('t') + ->where('t.user =:userId')->setParameter('userId', $userId); + + $pagerAdapter = new DoctrineORMAdapter($qb); + + return new Pagerfanta($pagerAdapter); + } } 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 000000000..7c2a9f45f --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/Tag/tags.html.twig @@ -0,0 +1,27 @@ +{% extends "WallabagCoreBundle::layout.html.twig" %} + +{% block title "Tags" %} + +{% block content %} + {% block pager %} + {% if tags is not empty %} +
+
{{ tags.count }} {% trans %}tags{% endtrans %}
+ +
+ {% endif %} + {% endblock %} + + {% if tags is empty %} +

{% trans %}No tags found.{% endtrans %}

+ {% else %} + {% for tag in tags %}{{tag.title}} + {% endfor %} + {% endif %} +{% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/base.html.twig b/src/Wallabag/CoreBundle/Resources/views/base.html.twig index 4f27f413f..223e8433c 100644 --- a/src/Wallabag/CoreBundle/Resources/views/base.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/base.html.twig @@ -71,7 +71,7 @@
  • {% trans %}unread{% endtrans %}
  • {% trans %}favorites{% endtrans %}
  • {% trans %}archive{% endtrans %}
  • -
  • {% trans %}tags{% endtrans %}
  • +
  • {% trans %}tags{% endtrans %}
  • {% trans %}save a link{% endtrans %}
  • {% trans %}search{% endtrans %}
  • {% trans %}unread{% endtrans %}
  • {% trans %}favorites{% endtrans %}
  • {% trans %}archive{% endtrans %}
  • -
  • {% trans %}tags{% endtrans %}
  • +
  • {% trans %}tags{% endtrans %}
  • {% trans %}config{% endtrans %}
  • {% trans %}logout{% endtrans %}
  • From 47e12c36776b21184267521ecbfd90f714ca9b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 7 Aug 2015 20:07:39 +0200 Subject: [PATCH 2/5] fix display --- .../Resources/views/Tag/tags.html.twig | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/Wallabag/CoreBundle/Resources/views/Tag/tags.html.twig b/src/Wallabag/CoreBundle/Resources/views/Tag/tags.html.twig index 7c2a9f45f..c2a461b83 100644 --- a/src/Wallabag/CoreBundle/Resources/views/Tag/tags.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/Tag/tags.html.twig @@ -3,25 +3,11 @@ {% block title "Tags" %} {% block content %} - {% block pager %} - {% if tags is not empty %} -
    -
    {{ tags.count }} {% trans %}tags{% endtrans %}
    - -
    - {% endif %} - {% endblock %} - {% if tags is empty %}

    {% trans %}No tags found.{% endtrans %}

    {% else %} - {% for tag in tags %}{{tag.title}} + {% for tag in tags %} + {{tag.label}} {% endfor %} {% endif %} {% endblock %} From d0b90fbe18da72dc09a0ef748fa178314f6657b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 7 Aug 2015 20:29:03 +0200 Subject: [PATCH 3/5] unit test --- .../CoreBundle/Controller/TagController.php | 2 -- .../Tests/Controller/TagControllerTest.php | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php index 892842315..e448cea1e 100644 --- a/src/Wallabag/CoreBundle/Controller/TagController.php +++ b/src/Wallabag/CoreBundle/Controller/TagController.php @@ -4,8 +4,6 @@ namespace Wallabag\CoreBundle\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; -use Symfony\Component\HttpFoundation\Request; -use Wallabag\CoreBundle\Entity\Tag; class TagController extends Controller { diff --git a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php new file mode 100644 index 000000000..34faf7097 --- /dev/null +++ b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php @@ -0,0 +1,19 @@ +logInAs('admin'); + $client = $this->getClient(); + + $client->request('GET', '/tag/list'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + } +} From 0bc2baa65cad31bcd353e82480ec3f6dc2e792a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 7 Aug 2015 21:57:53 +0200 Subject: [PATCH 4/5] fix #564: replace Untitled by the domain name --- src/Wallabag/CoreBundle/Service/Extractor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Wallabag/CoreBundle/Service/Extractor.php b/src/Wallabag/CoreBundle/Service/Extractor.php index 6d43a1da5..961ac20ad 100644 --- a/src/Wallabag/CoreBundle/Service/Extractor.php +++ b/src/Wallabag/CoreBundle/Service/Extractor.php @@ -10,7 +10,7 @@ final class Extractor public static function extract($url) { $pageContent = self::getPageContent(new Url(base64_encode($url))); - $title = $pageContent['rss']['channel']['item']['title'] ?: 'Untitled'; + $title = $pageContent['rss']['channel']['item']['title'] ?: parse_url($url, PHP_URL_HOST); $body = $pageContent['rss']['channel']['item']['description']; $content = new Content(); From 009696d0a80aa691fb65593c8c37fe578c8c867a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sun, 9 Aug 2015 20:31:53 +0200 Subject: [PATCH 5/5] rename favorite in starred --- .../CoreBundle/Resources/views/themes/material/base.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a767f8cfd..a56f58f35 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/base.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/base.html.twig @@ -72,7 +72,7 @@ {% set currentRoute = app.request.attributes.get('_route') %}
  • {% trans %}unread{% endtrans %}
  • -
  • {% trans %}favorites{% endtrans %}
  • +
  • {% trans %}starred{% endtrans %}
  • {% trans %}archive{% endtrans %}
  • {% trans %}tags{% endtrans %}
  • {% trans %}config{% endtrans %}