mirror of
https://github.com/wallabag/wallabag.git
synced 2025-06-27 16:36:00 +00:00
Merge branch '2.6'
# Conflicts: # src/Repository/EntryRepository.php # src/Twig/WallabagExtension.php # src/Wallabag/CoreBundle/Resources/views/Entry/_card_actions.html.twig # src/Wallabag/CoreBundle/Resources/views/Entry/_card_list.html.twig # tests/Twig/WallabagExtensionTest.php
This commit is contained in:
commit
2272d3da66
9 changed files with 68 additions and 32 deletions
|
@ -148,6 +148,12 @@ class AnnotationRepository extends ServiceEntityRepository
|
|||
->getResult();
|
||||
}
|
||||
|
||||
public function getCountBuilderByUser($userId = null)
|
||||
{
|
||||
return $this->createQueryBuilder('e')
|
||||
->andWhere('e.user = :userId')->setParameter('userId', $userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a query builder to used by other getBuilderFor* method.
|
||||
*
|
||||
|
|
|
@ -228,21 +228,6 @@ class EntryRepository extends ServiceEntityRepository
|
|||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve entries with annotations count for a user.
|
||||
*
|
||||
* @param int $userId
|
||||
*
|
||||
* @return QueryBuilder
|
||||
*/
|
||||
public function getCountBuilderForAnnotationsByUser($userId)
|
||||
{
|
||||
return $this
|
||||
->getQueryBuilderByUser($userId)
|
||||
->innerJoin('e.annotations', 'a')
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve untagged entries for a user.
|
||||
*
|
||||
|
|
|
@ -9,6 +9,7 @@ use Twig\Extension\GlobalsInterface;
|
|||
use Twig\TwigFilter;
|
||||
use Twig\TwigFunction;
|
||||
use Wallabag\Entity\User;
|
||||
use Wallabag\Repository\AnnotationRepository;
|
||||
use Wallabag\Repository\EntryRepository;
|
||||
use Wallabag\Repository\TagRepository;
|
||||
|
||||
|
@ -16,14 +17,16 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface
|
|||
{
|
||||
private $tokenStorage;
|
||||
private $entryRepository;
|
||||
private $annotationRepository;
|
||||
private $tagRepository;
|
||||
private $lifeTime;
|
||||
private $translator;
|
||||
private $projectDir;
|
||||
|
||||
public function __construct(EntryRepository $entryRepository, TagRepository $tagRepository, TokenStorageInterface $tokenStorage, $lifeTime, TranslatorInterface $translator, string $projectDir)
|
||||
public function __construct(EntryRepository $entryRepository, AnnotationRepository $annotationRepository, TagRepository $tagRepository, TokenStorageInterface $tokenStorage, $lifeTime, TranslatorInterface $translator, string $projectDir)
|
||||
{
|
||||
$this->entryRepository = $entryRepository;
|
||||
$this->annotationRepository = $annotationRepository;
|
||||
$this->tagRepository = $tagRepository;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->lifeTime = $lifeTime;
|
||||
|
@ -96,28 +99,25 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface
|
|||
|
||||
switch ($type) {
|
||||
case 'starred':
|
||||
$qb = $this->entryRepository->getCountBuilderForStarredByUser($user->getId());
|
||||
$qb = $this->entryRepository->getCountBuilderForStarredByUser($user->getId())->select('COUNT(e.id)');
|
||||
break;
|
||||
case 'archive':
|
||||
$qb = $this->entryRepository->getCountBuilderForArchiveByUser($user->getId());
|
||||
$qb = $this->entryRepository->getCountBuilderForArchiveByUser($user->getId())->select('COUNT(e.id)');
|
||||
break;
|
||||
case 'unread':
|
||||
$qb = $this->entryRepository->getCountBuilderForUnreadByUser($user->getId());
|
||||
$qb = $this->entryRepository->getCountBuilderForUnreadByUser($user->getId())->select('COUNT(e.id)');
|
||||
break;
|
||||
case 'annotated':
|
||||
$qb = $this->entryRepository->getCountBuilderForAnnotationsByUser($user->getId());
|
||||
$qb = $this->annotationRepository->getCountBuilderByUser($user->getId())->select('COUNT(DISTINCT e.entry)');
|
||||
break;
|
||||
case 'all':
|
||||
$qb = $this->entryRepository->getCountBuilderForAllByUser($user->getId());
|
||||
$qb = $this->entryRepository->getCountBuilderForAllByUser($user->getId())->select('COUNT(e.id)');
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException(\sprintf('Type "%s" is not implemented.', $type));
|
||||
}
|
||||
|
||||
$query = $qb
|
||||
->select('COUNT(e.id)')
|
||||
->getQuery();
|
||||
|
||||
$query = $qb->getQuery();
|
||||
$query->useQueryCache(true);
|
||||
$query->enableResultCache($this->lifeTime);
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{% set current_path = path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')) %}
|
||||
{% set current_path = app.request.requesturi %}
|
||||
|
||||
<ul class="tools right">
|
||||
{% if is_granted('LIST_ENTRIES') %}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
{% endif %}
|
||||
{% include "Entry/Card/_content.html.twig" with {'entry': entry, 'withMetadata': true, 'subClass': 'metadata'} only %}
|
||||
|
||||
{% set current_path = path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')) %}
|
||||
{% set current_path = app.request.requesturi %}
|
||||
|
||||
<ul class="tools-list hide-on-small-only">
|
||||
<li>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
{% elseif current_route == 'search' %}
|
||||
{{ 'entry.page_titles.filtered_search'|trans }} {{ filter }}
|
||||
{% elseif current_route == 'tag_entries' %}
|
||||
{{ 'entry.page_titles.filtered_tags'|trans }} {{ filter }}
|
||||
{{ 'entry.page_titles.filtered_tags'|trans }} {{ tag.label }}
|
||||
{% elseif current_route == 'untagged' %}
|
||||
{{ 'entry.page_titles.untagged'|trans }}
|
||||
{% elseif current_route == 'same_domain' %}
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% set current_path = path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')) %}
|
||||
{% set current_path = app.request.requesturi %}
|
||||
{% set list_mode = app.user.config.listMode %}
|
||||
{% set entries_with_archived_class_routes = ['tag_entries', 'search', 'all'] %}
|
||||
{% set current_route = app.request.attributes.get('_route') %}
|
||||
|
|
|
@ -1561,6 +1561,38 @@ class EntryControllerTest extends WallabagTestCase
|
|||
$this->assertCount(2, $crawler->filter($this->entryDataTestAttribute));
|
||||
}
|
||||
|
||||
public function testActionInSearchResults()
|
||||
{
|
||||
$this->logInAs('admin');
|
||||
$client = $this->getTestClient();
|
||||
|
||||
$config = $this->getLoggedInUser()->getConfig();
|
||||
$config->setActionMarkAsRead(ConfigEntity::REDIRECT_TO_CURRENT_PAGE);
|
||||
$this->getEntityManager()->persist($config);
|
||||
|
||||
$entry = new Entry($this->getLoggedInUser());
|
||||
$entry->setUrl($this->url);
|
||||
$entry->setTitle('ActionInSearchResults');
|
||||
$this->getEntityManager()->persist($entry);
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
// Search on unread list
|
||||
$crawler = $client->request('GET', '/unread/list');
|
||||
|
||||
$form = $crawler->filter('form[name=search]')->form();
|
||||
$data = [
|
||||
'search_entry[term]' => 'ActionInSearchResults',
|
||||
];
|
||||
|
||||
$crawler = $client->submit($form, $data);
|
||||
$currentUrl = $client->getRequest()->getUri();
|
||||
$element = $crawler->filter('a[data-action="delete"]')->link();
|
||||
$client->click($element);
|
||||
$client->followRedirect();
|
||||
$nextUrl = $client->getRequest()->getUri();
|
||||
$this->assertSame($currentUrl, $nextUrl);
|
||||
}
|
||||
|
||||
public function dataForLanguage()
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Tests\Wallabag\Twig;
|
|||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Wallabag\Repository\AnnotationRepository;
|
||||
use Wallabag\Repository\EntryRepository;
|
||||
use Wallabag\Repository\TagRepository;
|
||||
use Wallabag\Twig\WallabagExtension;
|
||||
|
@ -17,6 +18,10 @@ class WallabagExtensionTest extends TestCase
|
|||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$annotationRepository = $this->getMockBuilder(AnnotationRepository::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$tagRepository = $this->getMockBuilder(TagRepository::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
@ -29,7 +34,7 @@ class WallabagExtensionTest extends TestCase
|
|||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator, '');
|
||||
$extension = new WallabagExtension($entryRepository, $annotationRepository, $tagRepository, $tokenStorage, 0, $translator, '');
|
||||
|
||||
$this->assertSame('lemonde.fr', $extension->removeWww('www.lemonde.fr'));
|
||||
$this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr'));
|
||||
|
@ -42,6 +47,10 @@ class WallabagExtensionTest extends TestCase
|
|||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$annotationRepository = $this->getMockBuilder(AnnotationRepository::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$tagRepository = $this->getMockBuilder(TagRepository::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
@ -54,7 +63,7 @@ class WallabagExtensionTest extends TestCase
|
|||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator, '');
|
||||
$extension = new WallabagExtension($entryRepository, $annotationRepository, $tagRepository, $tokenStorage, 0, $translator, '');
|
||||
|
||||
$this->assertSame('lemonde.fr', $extension->removeScheme('lemonde.fr'));
|
||||
$this->assertSame('gist.github.com', $extension->removeScheme('gist.github.com'));
|
||||
|
@ -68,6 +77,10 @@ class WallabagExtensionTest extends TestCase
|
|||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$annotationRepository = $this->getMockBuilder(AnnotationRepository::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$tagRepository = $this->getMockBuilder(TagRepository::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
@ -80,7 +93,7 @@ class WallabagExtensionTest extends TestCase
|
|||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator, '');
|
||||
$extension = new WallabagExtension($entryRepository, $annotationRepository, $tagRepository, $tokenStorage, 0, $translator, '');
|
||||
|
||||
$this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('www.lemonde.fr'));
|
||||
$this->assertSame('lemonde.fr', $extension->removeSchemeAndWww('http://www.lemonde.fr'));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue