mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-03-13 05:51:10 +00:00
implement sitemap
This commit is contained in:
parent
d3cdbc831c
commit
891868eccd
@ -1884,6 +1884,41 @@ class TorrentController extends AbstractController
|
|||||||
return new Response(); // @TODO
|
return new Response(); // @TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Route(
|
||||||
|
'/sitemap.xml',
|
||||||
|
methods:
|
||||||
|
[
|
||||||
|
'GET'
|
||||||
|
]
|
||||||
|
)]
|
||||||
|
public function sitemap(
|
||||||
|
TorrentService $torrentService
|
||||||
|
): Response
|
||||||
|
{
|
||||||
|
$locale = $this->getParameter('app.locale');
|
||||||
|
$locales = explode('|', $this->getParameter('app.locales'));
|
||||||
|
|
||||||
|
$response = new Response();
|
||||||
|
$response->headers->set('Content-Type', 'text/xml');
|
||||||
|
|
||||||
|
return $this->render(
|
||||||
|
'default/torrent/sitemap.xml.twig',
|
||||||
|
[
|
||||||
|
'locale' => $locale,
|
||||||
|
'locales' => $locales,
|
||||||
|
'torrents' => $torrentService->findTorrents(
|
||||||
|
[], // without keywords filter
|
||||||
|
$locales, // all sensitive levels
|
||||||
|
null, // all sensitive levels
|
||||||
|
true, // approved only
|
||||||
|
1000, // @TODO limit
|
||||||
|
0 // offset
|
||||||
|
)
|
||||||
|
],
|
||||||
|
$response
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private function initUser(
|
private function initUser(
|
||||||
Request $request,
|
Request $request,
|
||||||
UserService $userService,
|
UserService $userService,
|
||||||
|
15
templates/default/torrent/sitemap.xml.twig
Normal file
15
templates/default/torrent/sitemap.xml.twig
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
|
||||||
|
{% for torrent in torrents %}
|
||||||
|
<url>
|
||||||
|
<lastmod>{{ torrent.added | date('Y-m-d') }}</lastmod>
|
||||||
|
{% for code in locales %}
|
||||||
|
{% if code == locale %}
|
||||||
|
<loc>{{ url('torrent_info', { '_locale': code , torrentId : torrent.id }) }}</loc>
|
||||||
|
{% else %}
|
||||||
|
<xhtml:link rel="alternate" hreflang="{{ code }}" href="{{ url('torrent_info', { '_locale': code , torrentId : torrent.id }) }}" />
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</url>
|
||||||
|
{% endfor %}
|
||||||
|
</urlset>
|
Loading…
x
Reference in New Issue
Block a user