generated from rnentjes/kotlin-server-web-empty
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.
44 lines
922 B
Kotlin
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()
|
|
}
|