Files
kotlin-server-web-undertow/src/jvmMain/kotlin/nl/astraeus/tmpl/web/Index.kt
rnentjes 0eb853050b Refactor placeholder constants into dedicated file
Moved REPO_NAME and related constants into Placeholders.kt to improve code organization and maintainability. The code now dynamically references these constants where needed, simplifying updates and ensuring consistency across modules. Updated relevant imports and references to accommodate these changes.
2024-12-01 12:12:33 +01:00

44 lines
922 B
Kotlin

package nl.astraeus.tmpl.web
import kotlinx.html.body
import kotlinx.html.head
import kotlinx.html.html
import kotlinx.html.meta
import kotlinx.html.script
import kotlinx.html.stream.appendHTML
import kotlinx.html.title
import nl.astraeus.tmpl.REPO_NAME
import nl.astraeus.tmpl.pageTitle
import nl.astraeus.tmpl.repoName
fun generateIndex(patch: String?): String {
val result = StringBuilder();
if (patch == null) {
result.appendHTML(true).html {
head {
title(pageTitle)
//link("/css/all.min.css", "stylesheet")
}
body {
script(src = "/$repoName.js") {}
}
}
} else {
result.appendHTML(true).html {
head {
title(pageTitle)
meta {
httpEquiv = "refresh"
content = "0; url=/$itemUrl/$patch"
}
}
body {
+"Redirecting to $itemUrl $patch..."
}
}
}
return result.toString()
}