diff --git a/build.gradle b/build.gradle index 0cddde2..93715a3 100644 --- a/build.gradle +++ b/build.gradle @@ -16,8 +16,8 @@ dependencies { implementation "io.ktor:ktor-server-core:$ktor_version" implementation "io.ktor:ktor-server-netty:$ktor_version" implementation "io.ktor:ktor-html-builder:$ktor_version" - implementation "ch.qos.logback:logback-classic:$logback_version" implementation "io.ktor:ktor-freemarker:$ktor_version" + implementation "ch.qos.logback:logback-classic:$logback_version" } compileKotlin { diff --git a/gradle.properties b/gradle.properties index c378215..d2a4d18 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ ktor_version=1.3.2 kotlin.code.style=official -kotlin_version=1.3.70 -logback_version=1.2.1 +kotlin_version=1.3.72 +logback_version=1.2.3 diff --git a/src/main/kotlin/com/jetbrains/handson/website/Application.kt b/src/main/kotlin/com/jetbrains/handson/website/Application.kt index c7cc33c..fab81bf 100644 --- a/src/main/kotlin/com/jetbrains/handson/website/Application.kt +++ b/src/main/kotlin/com/jetbrains/handson/website/Application.kt @@ -1,10 +1,13 @@ package com.jetbrains.handson.website import freemarker.cache.* +import freemarker.core.HTMLOutputFormat import io.ktor.application.* import io.ktor.freemarker.* import io.ktor.html.respondHtml +import io.ktor.http.HttpStatusCode import io.ktor.http.content.* +import io.ktor.request.receiveParameters import io.ktor.response.* import io.ktor.routing.* import kotlinx.html.* @@ -13,41 +16,5 @@ import kotlinx.html.* fun main(args: Array): Unit = io.ktor.server.netty.EngineMain.main(args) fun Application.module() { - install(FreeMarker) { - templateLoader = ClassTemplateLoader(this::class.java.classLoader, "templates") - } - routing { - static("/static") { - resources("files") - } - get("/html") { - call.respondHtml { - head { - title { - +"Returning HTML using Kotlinx.HTML" - } - } - body { - h1 { - +"Kotlinx.Html" - } - p { - +"We're using a static HTML DSL" - } - val numbers = 1..10 - ul { - numbers.forEach { - li { - value = it.toString() - +"Item $it" - } - } - } - } - } - } - get("/freemarker") { - call.respond(FreeMarkerContent("index.ftl", mapOf("data" to IndexData(listOf(1, 2, 3))), "")) - } - } + } diff --git a/src/main/kotlin/com/jetbrains/handson/website/IndexData.kt b/src/main/kotlin/com/jetbrains/handson/website/IndexData.kt deleted file mode 100644 index 9bcff0e..0000000 --- a/src/main/kotlin/com/jetbrains/handson/website/IndexData.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.jetbrains.handson.website - -data class IndexData(val items: List) \ No newline at end of file diff --git a/src/main/resources/files/index.html b/src/main/resources/files/index.html deleted file mode 100644 index 053c139..0000000 --- a/src/main/resources/files/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - Static Page - - -

Static Page

-

- -

-

- This is a static page! -

-Ktor Logo - - \ No newline at end of file diff --git a/src/main/resources/files/ktor.png b/src/main/resources/files/ktor.png index 40c878c..862e4db 100644 Binary files a/src/main/resources/files/ktor.png and b/src/main/resources/files/ktor.png differ diff --git a/src/main/resources/templates/index.ftl b/src/main/resources/templates/index.ftl deleted file mode 100644 index 06bec5f..0000000 --- a/src/main/resources/templates/index.ftl +++ /dev/null @@ -1,17 +0,0 @@ -<#-- @ftlvariable name="data" type="com.jetbrains.handson.website.IndexData" --> - - - FreeMarker - - -

FreeMarker

-

- Using FreeMarker Template Engine -

- - - \ No newline at end of file