generated from rnentjes/kotlin-server-web-empty
Refactor package structure and add web components.
Reorganized Kotlin package structure under 'nl.astraeus' and removed 'gradle.properties' file. Updated '.gitignore' to exclude 'gradle.properties'. Added new web functionalities including ID generation, websocket and HTTP request handling to support dynamic web content delivery. Adjusted server configuration and modified build version.
This commit is contained in:
41
src/jvmMain/kotlin/nl/astraeus/tmpl/web/Index.kt
Normal file
41
src/jvmMain/kotlin/nl/astraeus/tmpl/web/Index.kt
Normal file
@@ -0,0 +1,41 @@
|
||||
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
|
||||
|
||||
fun generateIndex(patch: String?): String {
|
||||
val result = StringBuilder();
|
||||
|
||||
if (patch == null) {
|
||||
result.appendHTML(true).html {
|
||||
head {
|
||||
title("${REPO_NAME}")
|
||||
//link("/css/all.min.css", "stylesheet")
|
||||
}
|
||||
body {
|
||||
script(src = "/${REPO_NAME}.js") {}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result.appendHTML(true).html {
|
||||
head {
|
||||
title("${REPO_NAME}")
|
||||
meta {
|
||||
httpEquiv = "refresh"
|
||||
content = "0; url=/$itemUrl/$patch"
|
||||
}
|
||||
}
|
||||
body {
|
||||
+"Redirecting to $itemUrl $patch..."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result.toString()
|
||||
}
|
||||
Reference in New Issue
Block a user