diff --git a/build.gradle.kts b/build.gradle.kts index f7b8ab04..ea9168ec 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ val ktorVersion = "2.3.9" -val ktorSwaggerUiVersion = "2.7.4" +val ktorSwaggerUiVersion = "2.7.5" val hibernateCoreVersion = "6.4.4.Final" val ehcacheVersion = "3.10.8" val glassfishJaxbVersion = "4.0.5" diff --git a/src/main/kotlin/fr/shikkanime/controllers/site/SiteController.kt b/src/main/kotlin/fr/shikkanime/controllers/site/SiteController.kt index dbefdd9a..b188c155 100644 --- a/src/main/kotlin/fr/shikkanime/controllers/site/SiteController.kt +++ b/src/main/kotlin/fr/shikkanime/controllers/site/SiteController.kt @@ -1,6 +1,7 @@ package fr.shikkanime.controllers.site import com.google.inject.Inject +import fr.shikkanime.dtos.AnimeDto import fr.shikkanime.entities.SortParameter import fr.shikkanime.entities.enums.CountryCode import fr.shikkanime.entities.enums.Link @@ -36,19 +37,41 @@ class SiteController { ) } + private fun getFullAnimesSimulcast(): MutableList { + val animeSimulcastLimit = 6 + + val animes = animeCacheService.findAllBy( + CountryCode.FR, + simulcastCacheService.currentSimulcast?.uuid, + listOf(SortParameter("name", SortParameter.Order.ASC)), + 1, + animeSimulcastLimit + )!!.data.toMutableList() + + val simulcasts = simulcastCacheService.findAll() + + if (animes.size in 1.. 1) { + val previousSimulcastAnimes = animeCacheService.findAllBy( + CountryCode.FR, + simulcasts[1].uuid, + listOf(SortParameter("name", SortParameter.Order.ASC)), + 1, + animeSimulcastLimit - animes.size + )!!.data + + animes.addAll(previousSimulcastAnimes) + } + + return animes + } + @Path @Get private fun home(): Response { return Response.template( Link.HOME, mutableMapOf( - "animes" to animeCacheService.findAllBy( - CountryCode.FR, - simulcastCacheService.currentSimulcast?.uuid, - listOf(SortParameter("name", SortParameter.Order.ASC)), - 1, - 6 - )!!.data, + "animes" to getFullAnimesSimulcast(), "episodes" to episodeCacheService.findAllBy( CountryCode.FR, null, diff --git a/src/main/resources/templates/site/_navigation.ftl b/src/main/resources/templates/site/_navigation.ftl index 8f9862f8..9481bb10 100644 --- a/src/main/resources/templates/site/_navigation.ftl +++ b/src/main/resources/templates/site/_navigation.ftl @@ -38,7 +38,7 @@ -
+