40 lines
1.3 KiB
Kotlin
40 lines
1.3 KiB
Kotlin
package moe.kageru.kodeshare.pages
|
|
|
|
import io.ktor.html.HtmlContent
|
|
import kotlinx.html.*
|
|
|
|
object PastePage {
|
|
fun build(content: String, uri: String, type: String?) = HtmlContent {
|
|
head {
|
|
link(rel = "stylesheet", href = "/style.css", type = "text/css")
|
|
link(
|
|
rel = "stylesheet",
|
|
href = "https://p.kageru.moe/static/hljs.css",
|
|
type = "text/css"
|
|
)
|
|
script(src = "https://p.kageru.moe/static/hl.js") {}
|
|
defaultHead("View paste $uri${type?.let { " (type $it)" } ?: ""}")
|
|
// Show the first 3 lines in preview/embed for applications like discord, slack, or skype
|
|
meta(content = content.lines().take(3).joinToString("\n")) {
|
|
attributes["property"] = "og:description"
|
|
}
|
|
unsafe {
|
|
+"<script>hljs.initHighlightingOnLoad();</script>"
|
|
+"<style>html{scrollbar-color: transparent transparent;}::-webkit-scrollbar{display: none;}</style>"
|
|
}
|
|
}
|
|
body {
|
|
pre {
|
|
code(classes = type) {
|
|
+content
|
|
}
|
|
}
|
|
a("/") {
|
|
div(Css.FLOATY_CLASS) {
|
|
+"New paste"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|