Added button to show entries with the same domain

This commit is contained in:
Nicolas Lœuillet 2021-01-04 09:28:56 +01:00 committed by Jeremy Benoist
parent 84dcaaaea9
commit 890c7d0bfa
No known key found for this signature in database
GPG key ID: BCA73962457ACC3C
11 changed files with 64 additions and 5 deletions

View file

@ -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 {

View file

@ -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;

View file

@ -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

View file

@ -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()
)
);
}
/**

View file

@ -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

View file

@ -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 %}

View file

@ -9,6 +9,7 @@
<ul class="tools right">
<li>
<a title="{{ 'entry.list.show_same_domain'|trans }}" class="tool grey-text" href="{{ path('same_domain', { 'id': entry.id }) }}"><i class="material-icons">language</i></a>
<a title="{{ 'entry.list.toogle_as_read'|trans }}" class="tool grey-text" href="{{ path('archive_entry', { 'id': entry.id }) }}"><i class="material-icons">{% if entry.isArchived == 0 %}done{% else %}unarchive{% endif %}</i></a>
<a title="{{ 'entry.list.toogle_as_star'|trans }}" class="tool grey-text" href="{{ path('star_entry', { 'id': entry.id }) }}"><i class="material-icons">{% if entry.isStarred == 0 %}star_border{% else %}star{% endif %}</i></a>
<a title="{{ 'entry.list.delete'|trans }}" onclick="return confirm('{{ 'entry.confirm.delete'|trans|escape('js') }}')" class="tool grey-text delete" href="{{ path('delete_entry', { 'id': entry.id }) }}"><i class="material-icons">delete</i></a>

View file

@ -9,6 +9,7 @@
{% include "@WallabagCore/themes/material/Entry/Card/_content.html.twig" with {'entry': entry, 'withMetadata': true, 'subClass': 'metadata'} only %}
<ul class="tools-list hide-on-small-only">
<li>
<a title="{{ 'entry.list.show_same_domain'|trans }}" class="tool grey-text" href="{{ path('same_domain', { 'id': entry.id }) }}"><i class="material-icons">language</i></a>
<a title="{{ 'entry.list.toogle_as_read'|trans }}" class="tool grey-text" href="{{ path('archive_entry', { 'id': entry.id }) }}"><i class="material-icons">{% if entry.isArchived == 0 %}done{% else %}unarchive{% endif %}</i></a>
<a title="{{ 'entry.list.toogle_as_star'|trans }}" class="tool grey-text" href="{{ path('star_entry', { 'id': entry.id }) }}"><i class="material-icons">{% if entry.isStarred == 0 %}star_border{% else %}star{% endif %}</i></a>
<a title="{{ 'entry.list.delete'|trans }}" onclick="return confirm('{{ 'entry.confirm.delete'|trans|escape('js') }}')" class="tool grey-text delete" href="{{ path('delete_entry', { 'id': entry.id }) }}"><i class="material-icons">delete</i></a>

View file

@ -1675,4 +1675,13 @@ class EntryControllerTest extends WallabagCoreTestCase
$client->request('GET', '/delete/' . $entry2->getId());
$this->assertSame(404, $client->getResponse()->getStatusCode());
}
public function testGetSameDomainEntries()
{
$this->logInAs('admin');
$client = $this->getClient();
$crawler = $client->request('GET', '/domain/1');
$this->assertCount(4, $crawler->filter('li.entry'));
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long