1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-07-17 17:08:37 +00:00

Improve pagination when user has lot of entries

Fix #1905
* Usage of whiteoctober/WhiteOctoberPagerfantaBundle
This commit is contained in:
Nicolas Lœuillet 2016-04-12 16:04:17 +02:00
parent 80bd17f00d
commit 624a7c6df1
No known key found for this signature in database
GPG key ID: 5656BE27E1E34D0A
9 changed files with 53 additions and 47 deletions

View file

@ -22,19 +22,22 @@ class AppKernel extends Kernel
new Nelmio\ApiDocBundle\NelmioApiDocBundle(), new Nelmio\ApiDocBundle\NelmioApiDocBundle(),
new Nelmio\CorsBundle\NelmioCorsBundle(), new Nelmio\CorsBundle\NelmioCorsBundle(),
new Liip\ThemeBundle\LiipThemeBundle(), new Liip\ThemeBundle\LiipThemeBundle(),
new Wallabag\CoreBundle\WallabagCoreBundle(),
new Wallabag\ApiBundle\WallabagApiBundle(),
new Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle(), new Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle(),
new Lexik\Bundle\FormFilterBundle\LexikFormFilterBundle(), new Lexik\Bundle\FormFilterBundle\LexikFormFilterBundle(),
new FOS\OAuthServerBundle\FOSOAuthServerBundle(), new FOS\OAuthServerBundle\FOSOAuthServerBundle(),
new Wallabag\UserBundle\WallabagUserBundle(),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(), new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new Scheb\TwoFactorBundle\SchebTwoFactorBundle(), new Scheb\TwoFactorBundle\SchebTwoFactorBundle(),
new KPhoen\RulerZBundle\KPhoenRulerZBundle(), new KPhoen\RulerZBundle\KPhoenRulerZBundle(),
new Wallabag\ImportBundle\WallabagImportBundle(),
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
new Craue\ConfigBundle\CraueConfigBundle(), new Craue\ConfigBundle\CraueConfigBundle(),
new Lexik\Bundle\MaintenanceBundle\LexikMaintenanceBundle(), 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(), new Wallabag\AnnotationBundle\WallabagAnnotationBundle(),
]; ];

View file

@ -81,7 +81,8 @@
"craue/config-bundle": "~1.4", "craue/config-bundle": "~1.4",
"mnapoli/piwik-twig-extension": "^1.0", "mnapoli/piwik-twig-extension": "^1.0",
"lexik/maintenance-bundle": "~2.1", "lexik/maintenance-bundle": "~2.1",
"ocramius/proxy-manager": "1.*" "ocramius/proxy-manager": "1.*",
"white-october/pagerfanta-bundle": "^1.0"
}, },
"require-dev": { "require-dev": {
"doctrine/doctrine-fixtures-bundle": "~2.2", "doctrine/doctrine-fixtures-bundle": "~2.2",

View file

@ -3,7 +3,6 @@
namespace Wallabag\CoreBundle\Controller; namespace Wallabag\CoreBundle\Controller;
use Pagerfanta\Adapter\DoctrineORMAdapter; use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Exception\OutOfRangeCurrentPageException;
use Pagerfanta\Pagerfanta; use Pagerfanta\Pagerfanta;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
@ -253,13 +252,7 @@ class EntryController extends Controller
$entries = new Pagerfanta($pagerAdapter); $entries = new Pagerfanta($pagerAdapter);
$entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage()); $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage());
try { $entries->setCurrentPage($page);
$entries->setCurrentPage($page);
} catch (OutOfRangeCurrentPageException $e) {
if ($page > 1) {
return $this->redirect($this->generateUrl($type, array('page' => $entries->getNbPages())), 302);
}
}
return $this->render( return $this->render(
'WallabagCoreBundle:Entry:entries.html.twig', 'WallabagCoreBundle:Entry:entries.html.twig',

View file

@ -3,14 +3,14 @@ services:
class: Wallabag\CoreBundle\Helper\DetectActiveTheme class: Wallabag\CoreBundle\Helper\DetectActiveTheme
arguments: arguments:
- "@security.token_storage" - "@security.token_storage"
- %wallabag_core.theme% - "%wallabag_core.theme%"
# custom form type # custom form type
wallabag_core.form.type.config: wallabag_core.form.type.config:
class: Wallabag\CoreBundle\Form\Type\ConfigType class: Wallabag\CoreBundle\Form\Type\ConfigType
arguments: arguments:
- %liip_theme.themes% - "%liip_theme.themes%"
- %wallabag_core.languages% - "%wallabag_core.languages%"
tags: tags:
- { name: form.type } - { name: form.type }
@ -32,7 +32,7 @@ services:
wallabag_core.table_prefix_subscriber: wallabag_core.table_prefix_subscriber:
class: Wallabag\CoreBundle\Subscriber\TablePrefixSubscriber class: Wallabag\CoreBundle\Subscriber\TablePrefixSubscriber
arguments: arguments:
- %database_table_prefix% - "%database_table_prefix%"
tags: tags:
- { name: doctrine.event_subscriber } - { name: doctrine.event_subscriber }
@ -92,10 +92,10 @@ services:
class: Wallabag\CoreBundle\EventListener\RegistrationConfirmedListener class: Wallabag\CoreBundle\EventListener\RegistrationConfirmedListener
arguments: arguments:
- "@doctrine.orm.entity_manager" - "@doctrine.orm.entity_manager"
- %wallabag_core.theme% - "%wallabag_core.theme%"
- %wallabag_core.items_on_page% - "%wallabag_core.items_on_page%"
- %wallabag_core.rss_limit% - "%wallabag_core.rss_limit%"
- %wallabag_core.language% - "%wallabag_core.language%"
tags: tags:
- { name: kernel.event_subscriber } - { name: kernel.event_subscriber }
@ -114,3 +114,11 @@ services:
class: Wallabag\CoreBundle\Operator\Doctrine\Matches class: Wallabag\CoreBundle\Operator\Doctrine\Matches
tags: tags:
- { name: rulerz.operator, executor: rulerz.executor.doctrine, operator: matches, inline: true } - { 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 }]

View file

@ -512,7 +512,7 @@ img.preview {
width: 50%; width: 50%;
} }
.pagination { div.pagination ul {
text-align: right; text-align: right;
margin-bottom:50px; margin-bottom:50px;
} }
@ -523,25 +523,25 @@ img.preview {
color: #999; color: #999;
} }
.pagination > * { div.pagination ul > * {
display: inline-block; display: inline-block;
margin-left: 0.5em; margin-left: 0.5em;
} }
.pagination a { div.pagination ul a {
color: #999; color: #999;
text-decoration: none; text-decoration: none;
} }
.pagination a:hover, .pagination a:focus { div.pagination ul a:hover, div.pagination ul a:focus {
text-decoration: underline; text-decoration: underline;
} }
.pagination .disabled { div.pagination ul .disabled {
display: none; display: none;
} }
.pagination .current { div.pagination ul .current {
height: 25px; height: 25px;
padding: 4px 8px; padding: 4px 8px;
border: 1px solid #d5d5d5; border: 1px solid #d5d5d5;

View file

@ -80,6 +80,14 @@ main, #content, .valign-wrapper {
margin-bottom: 0; margin-bottom: 0;
} }
.pagination {
float: right;
}
.pagination ul {
margin: 0 !important;
}
.pagination li { .pagination li {
padding: 0; padding: 0;
} }
@ -90,6 +98,13 @@ main, #content, .valign-wrapper {
display: block; display: block;
} }
.pagination li.active span {
padding: 0px 10px;
height: 30px;
display: block;
color: #fff;
}
.page-footer .footer-copyright p { .page-footer .footer-copyright p {
display: inline; display: inline;
} }

View file

@ -7,16 +7,9 @@
<div class="results"> <div class="results">
<div class="nb-results">{{ 'entry.list.number_on_the_page'|transchoice(entries.count) }}</div> <div class="nb-results">{{ 'entry.list.number_on_the_page'|transchoice(entries.count) }}</div>
<div class="pagination"> <div class="pagination">
<a href="#" id="filter">{{ 'entry.filters.title'|trans }}</a> <a href="#" id="filter">{{ 'entry.filters.title'|trans }}</a>
{% if entries is not empty %} {{ pagerfanta(entries, 'wallabag_view') }}
</div>
{% 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>
</div> </div>
{% endblock %} {% endblock %}

View file

@ -21,13 +21,7 @@
<div class="nb-results left"> <div class="nb-results left">
{{ 'entry.list.number_on_the_page'|transchoice(entries.count) }} {{ 'entry.list.number_on_the_page'|transchoice(entries.count) }}
</div> </div>
<ul class="pagination right"> {{ pagerfanta(entries, 'wallabag_view') }}
{% 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>
</div> </div>
{% endblock %} {% endblock %}
<br /> <br />

View file

@ -225,8 +225,7 @@ class EntryControllerTest extends WallabagCoreTestCase
$client->request('GET', '/all/list/900'); $client->request('GET', '/all/list/900');
$this->assertEquals(302, $client->getResponse()->getStatusCode()); $this->assertEquals(404, $client->getResponse()->getStatusCode());
$this->assertEquals('/all/list', $client->getResponse()->getTargetUrl());
} }
/** /**