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: Add tags list display --- .../CoreBundle/Controller/TagController.php | 33 ++++++++++++++++++++++ .../CoreBundle/Repository/TagRepository.php | 18 ++++++++++++ .../CoreBundle/Resources/views/Tag/tags.html.twig | 27 ++++++++++++++++++ .../CoreBundle/Resources/views/base.html.twig | 2 +- .../Resources/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 00000000..89284231 --- /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 52f319f1..51f1cd42 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 00000000..7c2a9f45 --- /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 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 @@
  • {% 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 %}
  • -- cgit v1.2.3 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: fix display --- .../CoreBundle/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 7c2a9f45..c2a461b8 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 %} -- cgit v1.2.3 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: unit test --- src/Wallabag/CoreBundle/Controller/TagController.php | 2 -- .../CoreBundle/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 89284231..e448cea1 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 00000000..34faf709 --- /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()); + } +} -- cgit v1.2.3 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: 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 6d43a1da..961ac20a 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(); -- cgit v1.2.3 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: rename favorite in starred --- src/Wallabag/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 a767f8cf..a56f58f3 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 %}
  • -- cgit v1.2.3