add search results RSS feed support

This commit is contained in:
ghost 2023-10-18 22:25:49 +03:00
parent b9111213b2
commit 3a14f29b38
16 changed files with 84 additions and 13 deletions

View File

@ -517,7 +517,7 @@ class TorrentController extends AbstractController
}
return $this->render('default/torrent/list.html.twig', [
'torrents' => $torrents,
'torrents' => $torrents,
'pagination' =>
[
'page' => $page,
@ -552,9 +552,13 @@ class TorrentController extends AbstractController
$activityService
);
// Init request
$query = $request->get('query') ? explode(' ', urldecode($request->get('query'))) : [];
$page = $request->get('page') ? (int) $request->get('page') : 1;
// Get total torrents
$total = $torrentService->findTorrentsTotal(
[],
$query,
$user->getLocales(),
!$user->isModerator() && $user->isSensitive() ? false : null, // hide on sensitive mode enabled or show all
!$user->isModerator() ? true : null // show approved content only for regular users
@ -563,12 +567,12 @@ class TorrentController extends AbstractController
// Create torrents list
$torrents = [];
foreach ($torrentService->findTorrents(
[],
$query,
$user->getLocales(),
!$user->isModerator() && $user->isSensitive() ? false : null, // hide on sensitive mode enabled or show all
!$user->isModerator() ? true : null, // show approved content only for regular users
$this->getParameter('app.pagination'),
0
($page - 1) * $this->getParameter('app.pagination')
) as $torrent)
{
// Read file

View File

@ -2,14 +2,25 @@
{% block title %}{% if query %}{{ query }} - {{ 'Search' | trans }} - {% endif %}{{ name }}{% endblock %}
{% block main_content %}
<div class="text-right">
<h2>{{ 'Recent uploads' | trans }}</h2>
<sub>
<a class="text-color-night margin-x-4-px" href="{{ path('rss_torrents_recent') }}" title="RSS">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
<path d="M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm1.5 2.5c5.523 0 10 4.477 10 10a1 1 0 1 1-2 0 8 8 0 0 0-8-8 1 1 0 0 1 0-2zm0 4a6 6 0 0 1 6 6 1 1 0 1 1-2 0 4 4 0 0 0-4-4 1 1 0 0 1 0-2zm.5 7a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3z"/>
</svg>
</a>
</sub>
{% if query %}
<h2>{{ 'Search results' | trans }}</h2>
<sub>
<a class="text-color-night margin-x-4-px" href="{{ path('rss_torrents_recent', { query : query | url_encode(true) }) }}" title="RSS">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
<path d="M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm1.5 2.5c5.523 0 10 4.477 10 10a1 1 0 1 1-2 0 8 8 0 0 0-8-8 1 1 0 0 1 0-2zm0 4a6 6 0 0 1 6 6 1 1 0 1 1-2 0 4 4 0 0 0-4-4 1 1 0 0 1 0-2zm.5 7a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3z"/>
</svg>
</a>
</sub>
{% else %}
<h2>{{ 'Recent uploads' | trans }}</h2>
<sub>
<a class="text-color-night margin-x-4-px" href="{{ path('rss_torrents_recent') }}" title="RSS">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
<path d="M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm1.5 2.5c5.523 0 10 4.477 10 10a1 1 0 1 1-2 0 8 8 0 0 0-8-8 1 1 0 0 1 0-2zm0 4a6 6 0 0 1 6 6 1 1 0 1 1-2 0 4 4 0 0 0-4-4 1 1 0 0 1 0-2zm.5 7a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3z"/>
</svg>
</a>
</sub>
{% endif %}
</div>
{% if torrents %}
{% for torrent in torrents %}

View File

@ -717,6 +717,10 @@
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
<trans-unit id="6XiwDeR" resname="Search results">
<source>Search results</source>
<target>Search results</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -717,6 +717,10 @@
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
<trans-unit id="6XiwDeR" resname="Search results">
<source>Search results</source>
<target>Search results</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -717,6 +717,10 @@
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
<trans-unit id="6XiwDeR" resname="Search results">
<source>Search results</source>
<target>Search results</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -717,6 +717,10 @@
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
<trans-unit id="6XiwDeR" resname="Search results">
<source>Search results</source>
<target>Search results</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -717,6 +717,10 @@
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
<trans-unit id="6XiwDeR" resname="Search results">
<source>Search results</source>
<target>Search results</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -717,6 +717,10 @@
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
<trans-unit id="6XiwDeR" resname="Search results">
<source>Search results</source>
<target>Search results</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -717,6 +717,10 @@
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
<trans-unit id="6XiwDeR" resname="Search results">
<source>Search results</source>
<target>Search results</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -717,6 +717,10 @@
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
<trans-unit id="6XiwDeR" resname="Search results">
<source>Search results</source>
<target>Search results</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -717,6 +717,10 @@
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
<trans-unit id="6XiwDeR" resname="Search results">
<source>Search results</source>
<target>Search results</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -717,6 +717,10 @@
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
<trans-unit id="6XiwDeR" resname="Search results">
<source>Search results</source>
<target>Search results</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -717,6 +717,10 @@
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
<trans-unit id="6XiwDeR" resname="Search results">
<source>Search results</source>
<target>Search results</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -717,6 +717,10 @@
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
<trans-unit id="6XiwDeR" resname="Search results">
<source>Search results</source>
<target>Search results</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -717,6 +717,10 @@
<source> seconds ago</source>
<target> секунд назад</target>
</trans-unit>
<trans-unit id="6XiwDeR" resname="Search results">
<source>Search results</source>
<target>Результаты поиска</target>
</trans-unit>
</body>
</file>
</xliff>

View File

@ -7,7 +7,7 @@
<body>
<trans-unit id="NSECGi6" resname="File not found">
<source>File not found</source>
<target>Файл не знайдений</target>
<target>Файл не знайдено</target>
</trans-unit>
<trans-unit id="awzJBNC" resname="Users">
<source>Users</source>
@ -717,6 +717,10 @@
<source> seconds ago</source>
<target> секунд тому</target>
</trans-unit>
<trans-unit id="6XiwDeR" resname="Search results">
<source>Search results</source>
<target>Результати пошуку</target>
</trans-unit>
</body>
</file>
</xliff>