From 624a7c6df1142048cc73770e2c7b7377acd30a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 12 Apr 2016 16:04:17 +0200 Subject: Improve pagination when user has lot of entries Fix #1905 * Usage of whiteoctober/WhiteOctoberPagerfantaBundle --- .../CoreBundle/Controller/EntryController.php | 9 +------- .../CoreBundle/Resources/config/services.yml | 24 ++++++++++++++-------- .../Resources/public/themes/baggy/css/main.css | 14 ++++++------- .../Resources/public/themes/material/css/main.css | 15 ++++++++++++++ .../views/themes/baggy/Entry/entries.html.twig | 13 +++--------- .../views/themes/material/Entry/entries.html.twig | 8 +------- .../Tests/Controller/EntryControllerTest.php | 3 +-- 7 files changed, 44 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index cba58858..e6077707 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php @@ -3,7 +3,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; @@ -253,13 +252,7 @@ class EntryController extends Controller $entries = new Pagerfanta($pagerAdapter); $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage()); - try { - $entries->setCurrentPage($page); - } catch (OutOfRangeCurrentPageException $e) { - if ($page > 1) { - return $this->redirect($this->generateUrl($type, array('page' => $entries->getNbPages())), 302); - } - } + $entries->setCurrentPage($page); return $this->render( 'WallabagCoreBundle:Entry:entries.html.twig', diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml index a36f3392..11d4d59b 100644 --- a/src/Wallabag/CoreBundle/Resources/config/services.yml +++ b/src/Wallabag/CoreBundle/Resources/config/services.yml @@ -3,14 +3,14 @@ services: class: Wallabag\CoreBundle\Helper\DetectActiveTheme arguments: - "@security.token_storage" - - %wallabag_core.theme% + - "%wallabag_core.theme%" # custom form type wallabag_core.form.type.config: class: Wallabag\CoreBundle\Form\Type\ConfigType arguments: - - %liip_theme.themes% - - %wallabag_core.languages% + - "%liip_theme.themes%" + - "%wallabag_core.languages%" tags: - { name: form.type } @@ -32,7 +32,7 @@ services: wallabag_core.table_prefix_subscriber: class: Wallabag\CoreBundle\Subscriber\TablePrefixSubscriber arguments: - - %database_table_prefix% + - "%database_table_prefix%" tags: - { name: doctrine.event_subscriber } @@ -92,10 +92,10 @@ services: class: Wallabag\CoreBundle\EventListener\RegistrationConfirmedListener arguments: - "@doctrine.orm.entity_manager" - - %wallabag_core.theme% - - %wallabag_core.items_on_page% - - %wallabag_core.rss_limit% - - %wallabag_core.language% + - "%wallabag_core.theme%" + - "%wallabag_core.items_on_page%" + - "%wallabag_core.rss_limit%" + - "%wallabag_core.language%" tags: - { name: kernel.event_subscriber } @@ -114,3 +114,11 @@ services: class: Wallabag\CoreBundle\Operator\Doctrine\Matches tags: - { name: rulerz.operator, executor: rulerz.executor.doctrine, operator: matches, inline: true } + + pagerfanta.view.wallabag_view: + class: Pagerfanta\View\OptionableView + arguments: + - "@pagerfanta.view.twitter_bootstrap" + - { proximity: 1 } + public: false + tags: [{ name: pagerfanta.view, alias: wallabag_view }] diff --git a/src/Wallabag/CoreBundle/Resources/public/themes/baggy/css/main.css b/src/Wallabag/CoreBundle/Resources/public/themes/baggy/css/main.css index 1cb2ddf3..ba430cc4 100755 --- a/src/Wallabag/CoreBundle/Resources/public/themes/baggy/css/main.css +++ b/src/Wallabag/CoreBundle/Resources/public/themes/baggy/css/main.css @@ -512,7 +512,7 @@ img.preview { width: 50%; } -.pagination { +div.pagination ul { text-align: right; margin-bottom:50px; } @@ -523,25 +523,25 @@ img.preview { color: #999; } -.pagination > * { +div.pagination ul > * { display: inline-block; margin-left: 0.5em; } -.pagination a { +div.pagination ul a { color: #999; text-decoration: none; } - .pagination a:hover, .pagination a:focus { +div.pagination ul a:hover, div.pagination ul a:focus { text-decoration: underline; - } +} -.pagination .disabled { +div.pagination ul .disabled { display: none; } -.pagination .current { +div.pagination ul .current { height: 25px; padding: 4px 8px; border: 1px solid #d5d5d5; diff --git a/src/Wallabag/CoreBundle/Resources/public/themes/material/css/main.css b/src/Wallabag/CoreBundle/Resources/public/themes/material/css/main.css index 96c38822..fb0f5776 100755 --- a/src/Wallabag/CoreBundle/Resources/public/themes/material/css/main.css +++ b/src/Wallabag/CoreBundle/Resources/public/themes/material/css/main.css @@ -80,6 +80,14 @@ main, #content, .valign-wrapper { margin-bottom: 0; } +.pagination { + float: right; +} + +.pagination ul { + margin: 0 !important; +} + .pagination li { padding: 0; } @@ -90,6 +98,13 @@ main, #content, .valign-wrapper { display: block; } +.pagination li.active span { + padding: 0px 10px; + height: 30px; + display: block; + color: #fff; +} + .page-footer .footer-copyright p { display: inline; } 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 29cb9584..8114c703 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 @@ -7,16 +7,9 @@
{{ 'entry.list.number_on_the_page'|transchoice(entries.count) }}
+ {{ 'entry.filters.title'|trans }} + {{ pagerfanta(entries, 'wallabag_view') }} +
{% endblock %} 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 74c2623e..f637136c 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 @@ -21,13 +21,7 @@
{{ 'entry.list.number_on_the_page'|transchoice(entries.count) }}
- + {{ pagerfanta(entries, 'wallabag_view') }} {% endblock %}
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 46fbaf91..f15aaab1 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php @@ -225,8 +225,7 @@ class EntryControllerTest extends WallabagCoreTestCase $client->request('GET', '/all/list/900'); - $this->assertEquals(302, $client->getResponse()->getStatusCode()); - $this->assertEquals('/all/list', $client->getResponse()->getTargetUrl()); + $this->assertEquals(404, $client->getResponse()->getStatusCode()); } /** -- cgit v1.2.3 From 76cd8dbb059ebec2d0650089424681afc9bd6b0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 12 Apr 2016 16:32:01 +0200 Subject: Fix tests --- src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index f15aaab1..2d846454 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php @@ -521,7 +521,7 @@ class EntryControllerTest extends WallabagCoreTestCase $client->submit($form, $data); - $parameters = '?entry_filter%5BreadingTime%5D%5Bleft_number%5D=&entry_filter%5BreadingTime%5D%5Bright_number%5D='; + $parameters = '?entry_filter%5BreadingTime%5D%5Bleft_number%5D=&entry_filter%5BreadingTime%5D%5Bright_number%5D='; $client->request('GET', 'unread/list'.$parameters); -- cgit v1.2.3 From 1880da742027ec08f73e116143f2f514155ab7fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 12 Apr 2016 16:40:18 +0200 Subject: Restore old behavior for OutOfRangeCurrentPageException --- src/Wallabag/CoreBundle/Controller/EntryController.php | 9 ++++++++- src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index e6077707..cba58858 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php @@ -3,6 +3,7 @@ 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; @@ -252,7 +253,13 @@ class EntryController extends Controller $entries = new Pagerfanta($pagerAdapter); $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage()); - $entries->setCurrentPage($page); + try { + $entries->setCurrentPage($page); + } catch (OutOfRangeCurrentPageException $e) { + if ($page > 1) { + return $this->redirect($this->generateUrl($type, array('page' => $entries->getNbPages())), 302); + } + } return $this->render( 'WallabagCoreBundle:Entry:entries.html.twig', diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 2d846454..a3527898 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php @@ -225,7 +225,8 @@ class EntryControllerTest extends WallabagCoreTestCase $client->request('GET', '/all/list/900'); - $this->assertEquals(404, $client->getResponse()->getStatusCode()); + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + $this->assertEquals('/all/list', $client->getResponse()->getTargetUrl()); } /** -- cgit v1.2.3 From 63995be5ee248af5cb9381183afd8810202d7799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 12 Apr 2016 18:03:40 +0200 Subject: Fix display for Next/Previous link when they are disabled --- .../CoreBundle/Resources/public/themes/material/css/main.css | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/Wallabag/CoreBundle/Resources/public/themes/material/css/main.css b/src/Wallabag/CoreBundle/Resources/public/themes/material/css/main.css index fb0f5776..a3915b1d 100755 --- a/src/Wallabag/CoreBundle/Resources/public/themes/material/css/main.css +++ b/src/Wallabag/CoreBundle/Resources/public/themes/material/css/main.css @@ -105,6 +105,11 @@ main, #content, .valign-wrapper { color: #fff; } +.pagination .disabled { + margin-right: 10px; + margin-left: 10px; +} + .page-footer .footer-copyright p { display: inline; } -- cgit v1.2.3 From c95e39c51ae914c89321371018642dbb69a3b851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 12 Apr 2016 20:38:56 +0200 Subject: Lost in translation pager --- src/Wallabag/CoreBundle/Resources/config/services.yml | 8 -------- .../Resources/views/themes/baggy/Entry/entries.html.twig | 2 +- .../Resources/views/themes/material/Entry/entries.html.twig | 2 +- 3 files changed, 2 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml index 11d4d59b..6dc1f1d7 100644 --- a/src/Wallabag/CoreBundle/Resources/config/services.yml +++ b/src/Wallabag/CoreBundle/Resources/config/services.yml @@ -114,11 +114,3 @@ services: class: Wallabag\CoreBundle\Operator\Doctrine\Matches tags: - { name: rulerz.operator, executor: rulerz.executor.doctrine, operator: matches, inline: true } - - pagerfanta.view.wallabag_view: - class: Pagerfanta\View\OptionableView - arguments: - - "@pagerfanta.view.twitter_bootstrap" - - { proximity: 1 } - public: false - tags: [{ name: pagerfanta.view, alias: wallabag_view }] 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 8114c703..f00ade4e 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 @@ -8,7 +8,7 @@
{{ 'entry.list.number_on_the_page'|transchoice(entries.count) }}
{% endblock %} 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 f637136c..05cab954 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 @@ -21,7 +21,7 @@
{{ 'entry.list.number_on_the_page'|transchoice(entries.count) }}
- {{ pagerfanta(entries, 'wallabag_view') }} + {{ pagerfanta(entries, 'twitter_bootstrap_translated', {'proximity': 1}) }} {% endblock %}
-- cgit v1.2.3 From 18078ded1278af4d8352a0b71efbc48369a0da72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Wed, 13 Apr 2016 09:20:01 +0200 Subject: Fix indentation --- .../Resources/views/themes/baggy/Entry/entries.html.twig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') 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 f00ade4e..04e51955 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 @@ -6,10 +6,10 @@ {% block pager %}
{{ 'entry.list.number_on_the_page'|transchoice(entries.count) }}
- +
{% endblock %} -- cgit v1.2.3