]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Improve pagination when user has lot of entries
authorNicolas Lœuillet <nicolas@loeuillet.org>
Tue, 12 Apr 2016 14:04:17 +0000 (16:04 +0200)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Tue, 12 Apr 2016 14:04:17 +0000 (16:04 +0200)
Fix #1905
* Usage of whiteoctober/WhiteOctoberPagerfantaBundle

app/AppKernel.php
composer.json
src/Wallabag/CoreBundle/Controller/EntryController.php
src/Wallabag/CoreBundle/Resources/config/services.yml
src/Wallabag/CoreBundle/Resources/public/themes/baggy/css/main.css
src/Wallabag/CoreBundle/Resources/public/themes/material/css/main.css
src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php

index 30ac7463ba742bb6bdda0b650b69c9c325f3c7a7..04f86eb76c829add567624c616038796e638cec2 100644 (file)
@@ -22,19 +22,22 @@ class AppKernel extends Kernel
             new Nelmio\ApiDocBundle\NelmioApiDocBundle(),
             new Nelmio\CorsBundle\NelmioCorsBundle(),
             new Liip\ThemeBundle\LiipThemeBundle(),
-            new Wallabag\CoreBundle\WallabagCoreBundle(),
-            new Wallabag\ApiBundle\WallabagApiBundle(),
             new Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle(),
             new Lexik\Bundle\FormFilterBundle\LexikFormFilterBundle(),
             new FOS\OAuthServerBundle\FOSOAuthServerBundle(),
-            new Wallabag\UserBundle\WallabagUserBundle(),
             new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
             new Scheb\TwoFactorBundle\SchebTwoFactorBundle(),
             new KPhoen\RulerZBundle\KPhoenRulerZBundle(),
-            new Wallabag\ImportBundle\WallabagImportBundle(),
             new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
             new Craue\ConfigBundle\CraueConfigBundle(),
             new Lexik\Bundle\MaintenanceBundle\LexikMaintenanceBundle(),
+            new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
+
+            // wallabag bundles
+            new Wallabag\CoreBundle\WallabagCoreBundle(),
+            new Wallabag\ApiBundle\WallabagApiBundle(),
+            new Wallabag\UserBundle\WallabagUserBundle(),
+            new Wallabag\ImportBundle\WallabagImportBundle(),
             new Wallabag\AnnotationBundle\WallabagAnnotationBundle(),
         ];
 
index 7dbc6772d41f9839faf46153cc4ef24a4b33a5c2..594a20456a5b5680bd96208fbf0e2a00a259b433 100644 (file)
@@ -81,7 +81,8 @@
         "craue/config-bundle": "~1.4",
         "mnapoli/piwik-twig-extension": "^1.0",
         "lexik/maintenance-bundle": "~2.1",
-        "ocramius/proxy-manager": "1.*"
+        "ocramius/proxy-manager": "1.*",
+        "white-october/pagerfanta-bundle": "^1.0"
     },
     "require-dev": {
         "doctrine/doctrine-fixtures-bundle": "~2.2",
index cba58858a16f68d868b5f09e8604e1c41cf4de3f..e60777070aa782bdff707e3f246d03ba96fcccb7 100644 (file)
@@ -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',
index a36f33922e8805ecd00d7727ddb13293f084c898..11d4d59b423f94e573c2bc543f10dcfd5bff431a 100644 (file)
@@ -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 }]
index 1cb2ddf34f039d7a224752f67bfd7e6e726b1aca..ba430cc4aa9e048f0297b76561471d6453c17231 100755 (executable)
@@ -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;
index 96c38822e4133b7f79ce541435bc862570d7e2b2..fb0f577607021f85fd20f4a7ff98dbdabc06f54e 100755 (executable)
@@ -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;
 }
index 29cb9584528c719ba513edcdedf2b40bf50cb3dc..8114c703c630233d447c95cd88c71c7280677691 100644 (file)
@@ -7,16 +7,9 @@
         <div class="results">
             <div class="nb-results">{{ 'entry.list.number_on_the_page'|transchoice(entries.count) }}</div>
                 <div class="pagination">
-                <a href="#" id="filter">{{ 'entry.filters.title'|trans }}</a>
-                {% if entries is not empty %}
-                    –
-                    {% for p in range(1, entries.nbPages) if entries.nbPages > 1 %}
-                        <li>
-                            <a href="{{ path(app.request.attributes.get('_route'), app.request.query.all|merge({'page': p})) }}" class="{{ currentPage == p ? 'current':''}}" >{{ p }}</a>
-                        </li>
-                    {% endfor %}
-                {% endif %}
-            </div>
+                    <a href="#" id="filter">{{ 'entry.filters.title'|trans }}</a>
+                    {{ pagerfanta(entries, 'wallabag_view') }}
+                </div>
         </div>
     {% endblock %}
 
index 74c2623e3c654b9bed2b35a3dbf45b979eb61fff..f637136c970606d370883b08e904a9f77060c6cb 100644 (file)
         <div class="nb-results left">
             {{ 'entry.list.number_on_the_page'|transchoice(entries.count) }}
         </div>
-        <ul class="pagination right">
-            {% for p in range(1, entries.nbPages) if entries.nbPages > 1 %}
-                <li class="{{ currentPage == p ? 'active':'waves-effect'}}">
-                    <a href="{{ path(app.request.attributes.get('_route'), app.request.query.all|merge({'page': p})) }}">{{ p }}</a>
-                </li>
-            {% endfor %}
-        </ul>
+        {{ pagerfanta(entries, 'wallabag_view') }}
     </div>
     {% endblock %}
     <br />
index 46fbaf918f6e936f9f5fd7a2e48ff8db1b10b262..f15aaab12731e8fd5a6d7feb31cdae2623dc2ab2 100644 (file)
@@ -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());
     }
 
     /**