From 38f7c4590362e4657402eb1b58ad29b44ec763a6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 18 Nov 2019 17:26:41 +0100 Subject: [PATCH] Added button to show entries with the same domain --- .../CoreBundle/Controller/EntryController.php | 21 +++++++++++++++++++ .../CoreBundle/Repository/EntryRepository.php | 20 ++++++++++++++++++ .../material/Entry/Card/_content.html.twig | 2 +- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index 9b2954e7..fad2b51c 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php @@ -517,6 +517,24 @@ class EntryController extends Controller ); } + /** + * List the entries with the same domain as the current one. + * + * @param int $page + * + * @Route("/same-domain/{id}/{page}", requirements={"id" = ".+"}, defaults={"page" = 1}, name="same_domain") + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function getSameDomainEntries(Request $request, $page = 1) + { + if (!$this->get('craue_config')->get('share_public')) { + throw $this->createAccessDeniedException('Sharing an entry is disabled for this user.'); + } + + return $this->showEntries('same-domain', $request, $page); + } + /** * Global method to retrieve entries depending on the given type * It returns the response to be send. @@ -548,6 +566,9 @@ class EntryController extends Controller case 'unread': $qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId()); break; + case 'same-domain': + $qb = $repository->getBuilderForSameDomainByUser($this->getUser()->getId(), $request->get('id')); + break; case 'all': $qb = $repository->getBuilderForAllByUser($this->getUser()->getId()); break; diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index bfd07937..f2c73bbf 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -36,6 +36,26 @@ class EntryRepository extends EntityRepository */ public function getBuilderForUnreadByUser($userId) { + return $this + ->getSortedQueryBuilderByUser($userId) + ->andWhere('e.isArchived = false') + ; + } + + /** + * Retrieves entries with the same domain. + * + * @param int $userId + * @param int $entryId + * + * @return QueryBuilder + */ + public function getBuilderForSameDomainByUser($userId, $entryId) + { + dump($entryId);die; + + $ + return $this ->getSortedQueryBuilderByUser($userId) ->andWhere('e.isArchived = false') diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/Card/_content.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/Card/_content.html.twig index 1102a0bd..e66cdf2c 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/Card/_content.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/Card/_content.html.twig @@ -7,7 +7,7 @@
- {{ entry.domainName|removeWww }} + {{ entry.domainName|removeWww }} language {% if withMetadata is defined %} {% include "@WallabagCore/themes/material/Entry/_tags.html.twig" with {'tags': entry.tags | slice(0, 3), 'entryId': entry.id, 'listClass': ' hide-on-med-and-down'} only %}
-- 2.41.0