diff --git a/src/main/kotlin/fr/shikkanime/controllers/site/SiteController.kt b/src/main/kotlin/fr/shikkanime/controllers/site/SiteController.kt index 99a46b5a..87d10d91 100644 --- a/src/main/kotlin/fr/shikkanime/controllers/site/SiteController.kt +++ b/src/main/kotlin/fr/shikkanime/controllers/site/SiteController.kt @@ -2,7 +2,6 @@ package fr.shikkanime.controllers.site import com.google.inject.Inject import fr.shikkanime.entities.SortParameter -import fr.shikkanime.entities.enums.ConfigPropertyKey import fr.shikkanime.entities.enums.CountryCode import fr.shikkanime.entities.enums.Link import fr.shikkanime.services.caches.AnimeCacheService @@ -37,7 +36,6 @@ class SiteController { return Response.template( Link.HOME, mutableMapOf( - "description" to configCacheService.getValueAsString(ConfigPropertyKey.SEO_DESCRIPTION), "animes" to animeCacheService.findAllBy( CountryCode.FR, null, @@ -99,7 +97,6 @@ class SiteController { return Response.template( Link.CATALOG, mutableMapOf( - "description" to configCacheService.getValueAsString(ConfigPropertyKey.SEO_DESCRIPTION), "simulcasts" to findAll, "currentSimulcast" to currentSimulcast, "animes" to animeCacheService.findAllBy( @@ -118,7 +115,7 @@ class SiteController { private fun error404(): Response { return Response.template( "/site/404.ftl", - "Page introuvable", + "Page introuvable" ) } @@ -131,7 +128,6 @@ class SiteController { "/site/anime.ftl", anime.shortName, mutableMapOf( - "description" to configCacheService.getValueAsString(ConfigPropertyKey.SEO_DESCRIPTION), "anime" to anime, "episodes" to episodeCacheService.findAllBy( CountryCode.FR, diff --git a/src/main/kotlin/fr/shikkanime/plugins/Routing.kt b/src/main/kotlin/fr/shikkanime/plugins/Routing.kt index 50128531..7bbf8342 100644 --- a/src/main/kotlin/fr/shikkanime/plugins/Routing.kt +++ b/src/main/kotlin/fr/shikkanime/plugins/Routing.kt @@ -2,8 +2,10 @@ package fr.shikkanime.plugins import fr.shikkanime.dtos.TokenDto import fr.shikkanime.entities.LinkObject +import fr.shikkanime.entities.enums.ConfigPropertyKey import fr.shikkanime.entities.enums.CountryCode import fr.shikkanime.entities.enums.Platform +import fr.shikkanime.services.caches.ConfigCacheService import fr.shikkanime.utils.Constant import fr.shikkanime.utils.LoggerFactory import fr.shikkanime.utils.routes.* @@ -216,6 +218,11 @@ private suspend fun handleRequest( try { val response = callMethodWithParameters(method, controller, call, parameters) + if (method.hasAnnotation()) { + val cached = method.findAnnotation()!!.maxAgeSeconds + call.caching = CachingOptions(CacheControl.MaxAge(maxAgeSeconds = cached)) + } + response.session?.let { call.sessions.set(it) } when (response.type) { @@ -236,6 +243,7 @@ private suspend fun handleMultipartResponse(call: ApplicationCall, response: Res } private suspend fun handleTemplateResponse(call: ApplicationCall, controller: Any, replacedPath: String, response: Response) { + val configCacheService = Constant.injector.getInstance(ConfigCacheService::class.java) val map = response.data as Map val modelMap = (map["model"] as Map).toMutableMap() @@ -251,6 +259,7 @@ private suspend fun handleTemplateResponse(call: ApplicationCall, controller: An val title = map["title"] as String? modelMap["title"] = if (title?.contains(Constant.NAME) == true) title else (if (!title.isNullOrBlank()) "$title - " else "") + Constant.NAME + modelMap["description"] = configCacheService.getValueAsString(ConfigPropertyKey.SEO_DESCRIPTION) ?: "" call.respond(FreeMarkerContent(map["template"] as String, modelMap, "", response.contentType)) } diff --git a/src/main/resources/templates/site/anime.ftl b/src/main/resources/templates/site/anime.ftl index 9b79dae5..15302056 100644 --- a/src/main/resources/templates/site/anime.ftl +++ b/src/main/resources/templates/site/anime.ftl @@ -5,7 +5,7 @@
- ${anime.shortName?replace(
diff --git a/src/main/resources/templates/site/components/anime.ftl b/src/main/resources/templates/site/components/anime.ftl index cc74da05..32f89b2e 100644 --- a/src/main/resources/templates/site/components/anime.ftl +++ b/src/main/resources/templates/site/components/anime.ftl @@ -3,7 +3,7 @@