diff --git a/src/jvmMain/kotlin/de/kif/backend/view/MainTemplate.kt b/src/jvmMain/kotlin/de/kif/backend/view/MainTemplate.kt index a80117b..8babe11 100644 --- a/src/jvmMain/kotlin/de/kif/backend/view/MainTemplate.kt +++ b/src/jvmMain/kotlin/de/kif/backend/view/MainTemplate.kt @@ -62,7 +62,7 @@ class MainTemplate(private val theme: Theme) : Template { div("footer-theme") { for (it in Theme.values()) { val name = it.name.toLowerCase() - a("?theme=$name", classes = if (theme == it) "selected" else "") { + a("?theme=${it.name}", classes = if (theme == it) "selected" else "") { id = "theme-$name" +name.capitalize() } @@ -78,7 +78,7 @@ enum class Theme { LIGHT, DARK } -private fun String?.toTheme() = this?.toUpperCase()?.let { str -> +private fun String?.toTheme() = this?.let { str -> Theme.values().find { str == it.name } } ?: Theme.LIGHT @@ -86,7 +86,12 @@ suspend fun PipelineContext.respondMain(body: MainTemplat val param = call.request.queryParameters["theme"] if (param != null) { - call.response.cookies.append("theme", param.toTheme().name.toLowerCase()) + call.response.cookies.append( + name = "theme", + value = param.toTheme().name, + maxAge = Int.MAX_VALUE, + path = "/" + ) call.respondRedirect(call.request.path()) } else { call.respondHtmlTemplate(