mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-14 17:35:17 +01:00
Display entries number for each category
This commit is contained in:
parent
79efca1e6f
commit
8315130a75
@ -303,6 +303,10 @@ nav input {
|
||||
margin: 0 1rem;
|
||||
}
|
||||
|
||||
span.numberItems {
|
||||
float: right;
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
* 3 = Filters slider
|
||||
* ========================================================================== */
|
||||
|
@ -16,6 +16,9 @@ services:
|
||||
wallabag.twig_extension:
|
||||
class: Wallabag\CoreBundle\Twig\WallabagExtension
|
||||
public: false
|
||||
arguments:
|
||||
- "@wallabag_core.entry_repository"
|
||||
- "@security.token_storage"
|
||||
tags:
|
||||
- { name: twig.extension }
|
||||
|
||||
|
@ -35,16 +35,16 @@
|
||||
{% set currentRoute = app.request.attributes.get('_route') %}
|
||||
|
||||
<li class="bold {% if currentRoute == 'unread' or currentRoute == 'homepage' %}active{% endif %}">
|
||||
<a class="waves-effect" href="{{ path('unread') }}">{{ 'menu.left.unread'|trans }}</a>
|
||||
<a class="waves-effect" href="{{ path('unread') }}">{{ 'menu.left.unread'|trans }} <span class="numberItems grey-text">{{ unreadEntries }}</span></a>
|
||||
</li>
|
||||
<li class="bold {% if currentRoute == 'starred' %}active{% endif %}">
|
||||
<a class="waves-effect" href="{{ path('starred') }}">{{ 'menu.left.starred'|trans }}</a>
|
||||
<a class="waves-effect" href="{{ path('starred') }}">{{ 'menu.left.starred'|trans }} <span class="numberItems grey-text">{{ starredEntries }}</span></a>
|
||||
</li>
|
||||
<li class="bold {% if currentRoute == 'archive' %}active{% endif %}">
|
||||
<a class="waves-effect" href="{{ path('archive') }}">{{ 'menu.left.archive'|trans }}</a>
|
||||
<a class="waves-effect" href="{{ path('archive') }}">{{ 'menu.left.archive'|trans }} <span class="numberItems grey-text">{{ archivedEntries }}</span></a>
|
||||
</li>
|
||||
<li class="bold border-bottom {% if currentRoute == 'all' %}active{% endif %}">
|
||||
<a class="waves-effect" href="{{ path('all') }}">{{ 'menu.left.all_articles'|trans }}</a>
|
||||
<a class="waves-effect" href="{{ path('all') }}">{{ 'menu.left.all_articles'|trans }} <span class="numberItems grey-text">{{ allEntries }}</span></a>
|
||||
</li>
|
||||
<li class="bold border-bottom {% if currentRoute == 'tags' %}active{% endif %}">
|
||||
<a class="waves-effect" href="{{ path('tag') }}">{{ 'menu.left.tags'|trans }}</a>
|
||||
|
@ -2,8 +2,20 @@
|
||||
|
||||
namespace Wallabag\CoreBundle\Twig;
|
||||
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Wallabag\CoreBundle\Repository\EntryRepository;
|
||||
|
||||
class WallabagExtension extends \Twig_Extension
|
||||
{
|
||||
private $tokenStorage;
|
||||
private $repository;
|
||||
|
||||
public function __construct(EntryRepository $repository = null, TokenStorageInterface $tokenStorage = null)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
}
|
||||
|
||||
public function getFilters()
|
||||
{
|
||||
return [
|
||||
@ -16,6 +28,27 @@ class WallabagExtension extends \Twig_Extension
|
||||
return preg_replace('/^www\./i', '', $url);
|
||||
}
|
||||
|
||||
public function getGlobals()
|
||||
{
|
||||
$user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
|
||||
|
||||
if (null === $user || !is_object($user)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$unreadEntries = $this->repository->getBuilderForUnreadByUser($user->getId())->getQuery()->getResult();
|
||||
$starredEntries = $this->repository->getBuilderForStarredByUser($user->getId())->getQuery()->getResult();
|
||||
$archivedEntries = $this->repository->getBuilderForArchiveByUser($user->getId())->getQuery()->getResult();
|
||||
$allEntries = $this->repository->getBuilderForAllByUser($user->getId())->getQuery()->getResult();
|
||||
|
||||
return array(
|
||||
'unreadEntries' => count($unreadEntries),
|
||||
'starredEntries' => count($starredEntries),
|
||||
'archivedEntries' => count($archivedEntries),
|
||||
'allEntries' => count($allEntries),
|
||||
);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'wallabag_extension';
|
||||
|
Loading…
Reference in New Issue
Block a user