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; flex-basis: 5em;
align-self: flex-end; align-self: flex-end;
float: right; float: right;
max-width: 6em; max-width: 8em;
} }
.tags { .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 * Global method to retrieve entries depending on the given type
* It returns the response to be send. * It returns the response to be send.
@ -553,6 +567,9 @@ class EntryController extends Controller
$qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId()); $qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId());
$formOptions['filter_unread'] = true; $formOptions['filter_unread'] = true;
break; break;
case 'same-domain':
$qb = $repository->getBuilderForSameDomainByUser($this->getUser()->getId(), $request->get('id'));
break;
case 'all': case 'all':
$qb = $repository->getBuilderForAllByUser($this->getUser()->getId()); $qb = $repository->getBuilderForAllByUser($this->getUser()->getId());
break; break;

View File

@ -47,7 +47,7 @@ class ExportController extends Controller
* *
* @Route("/export/{category}.{format}", name="export_entries", requirements={ * @Route("/export/{category}.{format}", name="export_entries", requirements={
* "format": "epub|mobi|pdf|json|xml|txt|csv", * "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 * @return \Symfony\Component\HttpFoundation\Response

View File

@ -39,7 +39,34 @@ class EntryRepository extends EntityRepository
return $this return $this
->getSortedQueryBuilderByUser($userId) ->getSortedQueryBuilderByUser($userId)
->andWhere('e.isArchived = false') ->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:' filtered_search: 'Filtered by search:'
untagged: Untagged entries untagged: Untagged entries
all: All entries all: All entries
same_domain: Same domain
list: list:
number_on_the_page: '{0} There are no entries.|{1} There is one entry.|]1,Inf[ There are %count% entries.' 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 reading_time: estimated reading time
@ -237,6 +238,7 @@ entry:
toogle_as_star: Toggle starred toogle_as_star: Toggle starred
delete: Delete delete: Delete
export_title: Export export_title: Export
show_same_domain: Show articles with the same domain
filters: filters:
title: Filters title: Filters
status_label: Status status_label: Status

View File

@ -12,6 +12,8 @@
{{ 'entry.page_titles.filtered_tags'|trans }} {{ filter }} {{ 'entry.page_titles.filtered_tags'|trans }} {{ filter }}
{% elseif currentRoute == 'untagged' %} {% elseif currentRoute == 'untagged' %}
{{ 'entry.page_titles.untagged'|trans }} {{ 'entry.page_titles.untagged'|trans }}
{% elseif currentRoute == 'same_domain' %}
{{ 'entry.page_titles.same_domain'|trans }}
{% else %} {% else %}
{{ 'entry.page_titles.unread'|trans }} {{ 'entry.page_titles.unread'|trans }}
{% endif %} {% endif %}

View File

@ -9,6 +9,7 @@
<ul class="tools right"> <ul class="tools right">
<li> <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_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.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> <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 %} {% 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"> <ul class="tools-list hide-on-small-only">
<li> <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_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.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> <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()); $client->request('GET', '/delete/' . $entry2->getId());
$this->assertSame(404, $client->getResponse()->getStatusCode()); $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