From 891456ba9a592a200d8b23029e8f4514d9803080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 14 Apr 2016 15:03:22 +0200 Subject: Links on each tag in Tags view --- .../CoreBundle/Controller/EntryController.php | 6 ++-- .../CoreBundle/Controller/ExportController.php | 2 +- .../CoreBundle/Controller/TagController.php | 40 ++++++++++++++++++++++ .../CoreBundle/Helper/PreparePagerForEntries.php | 34 ++++++++++++++++++ .../CoreBundle/Resources/config/services.yml | 6 ++++ .../views/themes/material/Entry/entries.html.twig | 4 ++- .../views/themes/material/Tag/tags.html.twig | 2 +- 7 files changed, 88 insertions(+), 6 deletions(-) create mode 100644 src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index ccdf9406..93db0d6c 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php @@ -4,7 +4,6 @@ namespace Wallabag\CoreBundle\Controller; use Pagerfanta\Adapter\DoctrineORMAdapter; use Pagerfanta\Exception\OutOfRangeCurrentPageException; -use Pagerfanta\Pagerfanta; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; @@ -257,9 +256,10 @@ class EntryController extends Controller } $pagerAdapter = new DoctrineORMAdapter($qb->getQuery()); - $entries = new Pagerfanta($pagerAdapter); - $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage()); + $entries = $this->get('wallabag_core.helper.prepare_pager_for_entries') + ->prepare($pagerAdapter, $page); + try { $entries->setCurrentPage($page); } catch (OutOfRangeCurrentPageException $e) { diff --git a/src/Wallabag/CoreBundle/Controller/ExportController.php b/src/Wallabag/CoreBundle/Controller/ExportController.php index 944c755d..959b308d 100644 --- a/src/Wallabag/CoreBundle/Controller/ExportController.php +++ b/src/Wallabag/CoreBundle/Controller/ExportController.php @@ -46,7 +46,7 @@ class ExportController extends Controller * * @Route("/export/{category}.{format}", name="export_entries", requirements={ * "format": "epub|mobi|pdf|json|xml|txt|csv", - * "category": "all|unread|starred|archive" + * "category": "all|unread|starred|archive|tag_entries" * }) * * @return \Symfony\Component\HttpFoundation\Response diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php index 8645fb44..b6514ea6 100644 --- a/src/Wallabag/CoreBundle/Controller/TagController.php +++ b/src/Wallabag/CoreBundle/Controller/TagController.php @@ -2,12 +2,15 @@ namespace Wallabag\CoreBundle\Controller; +use Pagerfanta\Adapter\ArrayAdapter; +use Pagerfanta\Exception\OutOfRangeCurrentPageException; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Form\Type\NewTagType; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; class TagController extends Controller { @@ -90,4 +93,41 @@ class TagController extends Controller ] ); } + + /** + * @param Tag $tag + * @param int $page + * + * @Route("/tag/list/{slug}/{page}", name="tag_entries", defaults={"page" = "1"}) + * @ParamConverter("tag", options={"mapping": {"slug": "slug"}}) + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function showEntriesForTagAction(Tag $tag, $page, Request $request) + { + $pagerAdapter = new ArrayAdapter($tag->getEntries()->toArray()); + + $entries = $this->get('wallabag_core.helper.prepare_pager_for_entries') + ->prepare($pagerAdapter, $page); + + try { + $entries->setCurrentPage($page); + } catch (OutOfRangeCurrentPageException $e) { + if ($page > 1) { + return $this->redirect($this->generateUrl($request->get('_route'), [ + 'slug' => $tag->getSlug(), + 'page' => $entries->getNbPages(), + ]), 302); + } + } + + return $this->render( + 'WallabagCoreBundle:Entry:entries.html.twig', + [ + 'form' => null, + 'entries' => $entries, + 'currentPage' => $page, + ] + ); + } } diff --git a/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php b/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php new file mode 100644 index 00000000..f9066bee --- /dev/null +++ b/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php @@ -0,0 +1,34 @@ +user = $token->getToken()->getUser(); + $this->router = $router; + } + + /** + * @param AdapterInterface $adapter + * @param int $page + * + * @return null|Pagerfanta + */ + public function prepare(AdapterInterface $adapter, $page = 1) + { + $entries = new Pagerfanta($adapter); + $entries->setMaxPerPage($this->user->getConfig()->getItemsPerPage()); + + return $entries; + } +} diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml index f8835198..e95ef452 100644 --- a/src/Wallabag/CoreBundle/Resources/config/services.yml +++ b/src/Wallabag/CoreBundle/Resources/config/services.yml @@ -119,3 +119,9 @@ services: class: Wallabag\CoreBundle\Helper\Redirect arguments: - "@router" + + wallabag_core.helper.prepare_pager_for_entries: + class: Wallabag\CoreBundle\Helper\PreparePagerForEntries + arguments: + - "@security.token_storage" + - "@router" diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig index eca8924e..a0a0b02f 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig @@ -122,6 +122,7 @@ + {% if form is not null %}
@@ -205,5 +206,6 @@
- {% include "WallabagCoreBundle:Entry:pager.html.twig" with {'entries': entries} %} + {% endif %} + {% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/tags.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/tags.html.twig index d958c4b8..9495f543 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/tags.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/tags.html.twig @@ -9,7 +9,7 @@
{% endblock %} -- cgit v1.2.3 From 371bcca0f6b18951a15e56daae5bca2558c01851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Wed, 20 Apr 2016 10:04:32 +0200 Subject: Translations and baggy view for tags --- .../Resources/translations/messages.da.yml | 1 + .../Resources/translations/messages.de.yml | 1 + .../Resources/translations/messages.en.yml | 1 + .../Resources/translations/messages.es.yml | 1 + .../Resources/translations/messages.fa.yml | 1 + .../Resources/translations/messages.fr.yml | 1 + .../Resources/translations/messages.oc.yml | 1 + .../Resources/translations/messages.pl.yml | 1 + .../Resources/translations/messages.ro.yml | 1 + .../Resources/translations/messages.tr.yml | 1 + .../views/themes/baggy/Entry/entries.html.twig | 34 ++++++++++++++++++++-- .../views/themes/baggy/Tag/tags.html.twig | 2 +- .../views/themes/material/Entry/entries.html.twig | 3 +- 13 files changed, 44 insertions(+), 5 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index c24475d2..87988539 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml @@ -139,6 +139,7 @@ entry: # starred: 'Starred entries' # archived: 'Archived entries' # filtered: 'Filtered entries' + # filtered_tags: 'Filtered by tags' list: # number_on_the_page: '{0} There is no entry.|{1} There is one entry.|]1,Inf[ There are %count% entries.' reading_time: 'estimeret læsetid' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index 384ec09a..461967d6 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml @@ -139,6 +139,7 @@ entry: starred: 'Favorisierte Einträge' archived: 'Archivierte Einträge' filtered: 'Gefilterte Einträge' + # filtered_tags: 'Filtered by tags' list: number_on_the_page: '{0} Es gibt keine Einträge.|{1} Es gibt einen Eintrag.|]1,Inf[ Es gibt %count% Einträge.' reading_time: 'geschätzte Lesezeit' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index ea860564..600b7472 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@ -139,6 +139,7 @@ entry: starred: 'Starred entries' archived: 'Archived entries' filtered: 'Filtered entries' + filtered_tags: 'Filtered by tags' list: number_on_the_page: '{0} There are no entries.|{1} There is one entry.|]1,Inf[ There are %count% entries.' reading_time: 'estimated reading time' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index f64e95d5..6da8a593 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml @@ -139,6 +139,7 @@ entry: starred: 'Artículos favoritos' archived: 'Artículos archivados' filtered: 'Artículos filtrados' + # filtered_tags: 'Filtered by tags' list: number_on_the_page: '{0} No hay artículos.|{1} Hay un artículo.|]1,Inf[ Hay %count% artículos.' reading_time: 'tiempo estimado de lectura' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index e3592a78..4684b08b 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml @@ -139,6 +139,7 @@ entry: starred: 'مقاله‌های برگزیده' archived: 'مقاله‌های بایگانی‌شده' filtered: 'مقاله‌های فیلترشده' + # filtered_tags: 'Filtered by tags' list: number_on_the_page: '{0} هیج مقاله‌ای نیست.|{1} یک مقاله هست.|]1,Inf[ %count% مقاله هست.' reading_time: 'زمان تخمینی برای خواندن' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 9e47d600..2b6e4194 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -139,6 +139,7 @@ entry: starred: 'Articles favoris' archived: 'Articles lus' filtered: 'Articles filtrés' + filtered_tags: 'Articles filtrés par tags' list: number_on_the_page: "{0} Il n'y a pas d'articles.|{1} Il y a un article.|]1,Inf[ Il y a %count% articles." reading_time: 'durée de lecture' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index 1e23168b..95435606 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml @@ -139,6 +139,7 @@ entry: starred: 'Articles favorits' archived: 'Articles legits' filtered: 'Articles filtrats' + # filtered_tags: 'Filtered by tags' list: number_on_the_page: "{0} I a pas cap d'article.|{1} I a un article.|]1,Inf[ I a %count% articles." reading_time: 'durada de lectura' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index 0a325c57..b0b7e49b 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml @@ -139,6 +139,7 @@ entry: starred: 'Wpisy oznaczone gwiazdką' archived: 'Zarchiwizowane wpisy' filtered: 'Odfiltrowane wpisy' + # filtered_tags: 'Filtered by tags' list: number_on_the_page: '{0} Nie ma wpisów.|{1} Jest jeden wpis.|]1,Inf[ Są %count% wpisy.' reading_time: 'szacunkowy czas czytania' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index 42ad28ee..d735df4c 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml @@ -139,6 +139,7 @@ entry: # starred: 'Starred entries' # archived: 'Archived entries' # filtered: 'Filtered entries' + # filtered_tags: 'Filtered by tags' list: # number_on_the_page: '{0} There is no entry.|{1} There is one entry.|]1,Inf[ There are %count% entries.' reading_time: 'timp estimat de citire' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index a60dfc86..77bfa0f0 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml @@ -139,6 +139,7 @@ entry: # starred: 'Starred entries' # archived: 'Archived entries' # filtered: 'Filtered entries' + # filtered_tags: 'Filtered by tags' list: number_on_the_page: '{0} Herhangi bir makale yok.|{1} Burada bir adet makale var.|]1,Inf[ Burada %count% adet makale var.' reading_time: 'tahmini okuma süresi' diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig index 92eecb9b..a07285bd 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig @@ -1,10 +1,36 @@ {% extends "WallabagCoreBundle::layout.html.twig" %} -{% block title %}{{ 'entry.page_titles.unread'|trans }}{% endblock %} +{% block title %} + {% set currentRoute = app.request.attributes.get('_route') %} + + {% if currentRoute == 'starred' %} + {{ 'entry.page_titles.starred'|trans }} + {% elseif currentRoute == 'archive' %} + {{ 'entry.page_titles.archived'|trans }} + {% elseif currentRoute == 'all' %} + {{ 'entry.page_titles.filtered'|trans }} + {% elseif currentRoute == 'tag_entries' %} + {{ 'entry.page_titles.filtered_tags'|trans }} + {% else %} + {{ 'entry.page_titles.unread'|trans }} + {% endif %} +{% endblock %} {% block content %} {% include "WallabagCoreBundle:Entry:pager.html.twig" with {'entries': entries} %} + {% block pager %} +
+
{{ 'entry.list.number_on_the_page'|transchoice(entries.count) }}
+ +
+ {% endblock %} + {% for entry in entries %}

{{ entry.title|raw }}

@@ -44,7 +70,6 @@
{% endfor %} - + - {% endif %} - - {% include "WallabagCoreBundle:Entry:pager.html.twig" with {'entries': entries} %} {% endblock %} -- cgit v1.2.3