From 890c7d0bfae3698e595dffc27c7027766d041776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 4 Jan 2021 09:28:56 +0100 Subject: [PATCH 01/14] Added button to show entries with the same domain --- .../static/themes/material/css/cards.scss | 2 +- .../CoreBundle/Controller/EntryController.php | 17 +++++++++++ .../Controller/ExportController.php | 2 +- .../CoreBundle/Repository/EntryRepository.php | 29 ++++++++++++++++++- .../Resources/translations/messages.en.yml | 2 ++ .../themes/common/Entry/_title.html.twig | 2 ++ .../material/Entry/_card_actions.html.twig | 1 + .../material/Entry/_card_list.html.twig | 1 + .../Controller/EntryControllerTest.php | 9 ++++++ web/wallassets/material.css | 2 +- web/wallassets/material.css.map | 2 +- 11 files changed, 64 insertions(+), 5 deletions(-) diff --git a/app/Resources/static/themes/material/css/cards.scss b/app/Resources/static/themes/material/css/cards.scss index 966510185..838a585a0 100644 --- a/app/Resources/static/themes/material/css/cards.scss +++ b/app/Resources/static/themes/material/css/cards.scss @@ -285,7 +285,7 @@ a.original:not(.waves-effect) { flex-basis: 5em; align-self: flex-end; float: right; - max-width: 6em; + max-width: 8em; } .tags { diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index 510dca956..588572a1d 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php @@ -517,6 +517,20 @@ class EntryController extends Controller ); } + /** + * List the entries with the same domain as the current one. + * + * @param int $page + * + * @Route("/domain/{id}/{page}", requirements={"id" = ".+"}, defaults={"page" = 1}, name="same_domain") + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function getSameDomainEntries(Request $request, $page = 1) + { + return $this->showEntries('same-domain', $request, $page); + } + /** * Global method to retrieve entries depending on the given type * It returns the response to be send. @@ -553,6 +567,9 @@ class EntryController extends Controller $qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId()); $formOptions['filter_unread'] = true; 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/Controller/ExportController.php b/src/Wallabag/CoreBundle/Controller/ExportController.php index cec8d4999..824d21bb9 100644 --- a/src/Wallabag/CoreBundle/Controller/ExportController.php +++ b/src/Wallabag/CoreBundle/Controller/ExportController.php @@ -47,7 +47,7 @@ class ExportController extends Controller * * @Route("/export/{category}.{format}", name="export_entries", requirements={ * "format": "epub|mobi|pdf|json|xml|txt|csv", - * "category": "all|unread|starred|archive|tag_entries|untagged|search" + * "category": "all|unread|starred|archive|tag_entries|untagged|search|same_domain" * }) * * @return \Symfony\Component\HttpFoundation\Response diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 3beda9251..fa516eafd 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -39,7 +39,34 @@ class EntryRepository extends EntityRepository 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) + { + $queryBuilder = $this->createQueryBuilder('e'); + + return $this + ->getSortedQueryBuilderByUser($userId) + ->andWhere('e.id <> :entryId')->setParameter('entryId', $entryId) + ->andWhere( + $queryBuilder->expr()->in( + 'e.domainName', + $this + ->createQueryBuilder('e2') + ->select('e2.domainName') + ->where('e2.id = :entryId')->setParameter('entryId', $entryId) + ->getDQL() + ) + ); } /** diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index a0d5fb23b..973949a96 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@ -224,6 +224,7 @@ entry: filtered_search: 'Filtered by search:' untagged: Untagged entries all: All entries + same_domain: Same domain list: number_on_the_page: '{0} There are no entries.|{1} There is one entry.|]1,Inf[ There are %count% entries.' reading_time: estimated reading time @@ -237,6 +238,7 @@ entry: toogle_as_star: Toggle starred delete: Delete export_title: Export + show_same_domain: Show articles with the same domain filters: title: Filters status_label: Status diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/common/Entry/_title.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/common/Entry/_title.html.twig index 5c17e9f7b..95fdd640e 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/common/Entry/_title.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/common/Entry/_title.html.twig @@ -12,6 +12,8 @@ {{ 'entry.page_titles.filtered_tags'|trans }} {{ filter }} {% elseif currentRoute == 'untagged' %} {{ 'entry.page_titles.untagged'|trans }} +{% elseif currentRoute == 'same_domain' %} + {{ 'entry.page_titles.same_domain'|trans }} {% else %} {{ 'entry.page_titles.unread'|trans }} {% endif %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_actions.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_actions.html.twig index be764e108..58d1bfc14 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_actions.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_actions.html.twig @@ -9,6 +9,7 @@