From 2be6c7c819b35ade556279dc045c370f3d01da9b Mon Sep 17 00:00:00 2001 From: Lars Westermann Date: Fri, 24 May 2019 17:11:19 +0200 Subject: [PATCH] Make it ugly again --- src/jsMain/resources/style/style.scss | 20 ++++++++- .../kotlin/de/kif/backend/route/Overview.kt | 42 ++++++++++++++++++- 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/src/jsMain/resources/style/style.scss b/src/jsMain/resources/style/style.scss index d5052d1..afcfcd7 100644 --- a/src/jsMain/resources/style/style.scss +++ b/src/jsMain/resources/style/style.scss @@ -981,6 +981,7 @@ form { .post { position: relative; padding-top: 2rem; + width: 100%; } .post-name { @@ -1008,8 +1009,8 @@ form { } .post-content { - h1, h2, h3, h4, h5, h6 { - margin: 0; + h1, h2, h3, h4, h5, h6, p { + margin: 0.7rem 0; padding: 0; } h1 { @@ -1030,4 +1031,19 @@ form { h6 { font-size: 1rem; } +} + +.overview-post { + max-height: 20rem; + overflow: hidden; + + &::after { + content: ''; + position: absolute; + display: block; + height: 1.5rem; + top: 18.5rem; + width: 100%; + background: linear-gradient(0deg, $background-primary-color, transparent); + } } \ No newline at end of file diff --git a/src/jvmMain/kotlin/de/kif/backend/route/Overview.kt b/src/jvmMain/kotlin/de/kif/backend/route/Overview.kt index 59db722..8783387 100644 --- a/src/jvmMain/kotlin/de/kif/backend/route/Overview.kt +++ b/src/jvmMain/kotlin/de/kif/backend/route/Overview.kt @@ -10,7 +10,9 @@ import de.kif.common.model.Permission import de.kif.common.model.Post import io.ktor.application.call import io.ktor.html.respondHtmlTemplate +import io.ktor.http.HttpStatusCode import io.ktor.request.receiveParameters +import io.ktor.response.respond import io.ktor.response.respondRedirect import io.ktor.routing.Route import io.ktor.routing.get @@ -43,7 +45,7 @@ fun Route.overview() { for (post in postList) { div("overview-post post") { - span("post-name") { + a("/p/${post.url}", classes="post-name") { +post.name } if (editable) { @@ -89,6 +91,44 @@ fun Route.overview() { } } + get("/p/{url}") { + val user = isAuthenticated(Permission.POST) + val editable = user != null + + val post = PostRepository.getByUrl(call.parameters["url"] ?: "") + + if (post == null) { + call.respond(HttpStatusCode.NotFound, "Not found") + return@get + } + + call.respondHtmlTemplate(MainTemplate()) { + menuTemplate { + this.user = user + active = MenuTemplate.Tab.BOARD + } + content { + div("overview") { + div("post") { + span("post-name") { + +post.name + } + if (editable) { + a("/post/${post.id}", classes = "post-edit") { + i("material-icons") { +"edit" } + } + } + div("post-content") { + unsafe { + raw(markdownToHtml(post.content)) + } + } + } + } + } + } + } + get("/post/{id}") { authenticateOrRedirect(Permission.POST) { user ->