kageru
726a25bed7
Most preview applications render this as html, which will strip repeated spaces. By instead emitting , we can retain the indentation. Groups of two spaces are replaced with two nbsp because single spaces (i.e. gaps between words) should still be breaking.
46 lines
1.6 KiB
Kotlin
46 lines
1.6 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 {
|
|
defaultHead("View paste $uri${type?.let { " (type $it)" } ?: ""}")
|
|
link(
|
|
rel = "stylesheet",
|
|
href = "/static/hljs.css",
|
|
type = "text/css"
|
|
)
|
|
script(src = "/static/hl.js") {}
|
|
// Show the first 3 lines in preview/embed for applications like discord, slack, or skype
|
|
meta(content = content.lines().take(3).joinToString("\n").replace(" ", " ")) {
|
|
attributes["property"] = "og:description"
|
|
}
|
|
unsafe {
|
|
+"<script>hljs.initHighlightingOnLoad();</script>"
|
|
// TODO: find out how CSSBuilder.fontFace is supposed to work and use that instead
|
|
+"""<style>html { scrollbar-color: transparent transparent; }::-webkit-scrollbar { display: none; }
|
|
@font-face {
|
|
font-family: 'Hack';
|
|
src: url('/static/hack.woff2') format('woff2'), url('/static/hack.woff') format('woff');
|
|
font-weight: 400;
|
|
font-style: normal;
|
|
}</style>""".trimIndent()
|
|
}
|
|
}
|
|
body {
|
|
pre {
|
|
code(classes = type) {
|
|
+content
|
|
}
|
|
}
|
|
a("/") {
|
|
div(Css.FLOATY_CLASS) {
|
|
+"New paste"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|