2019-09-29 08:17:31 +02:00
package moe.kageru.kodeshare.pages
import io.ktor.html.HtmlContent
import kotlinx.html.*
object PastePage {
2020-03-12 10:57:28 +01:00
fun build ( content : String , uri : String , type : String ? ) = HtmlContent {
2019-09-29 08:17:31 +02:00
head {
2020-03-12 11:14:36 +01:00
defaultHead ( " View paste $uri ${type?.let { " (type $it)" } ?: " " } " )
2019-09-29 08:17:31 +02:00
link (
rel = " stylesheet " ,
2020-05-03 20:11:01 +02:00
href = " /static/hljs.css " ,
2019-09-29 08:17:31 +02:00
type = " text/css "
)
2020-05-03 20:11:01 +02:00
script ( src = " /static/hl.js " ) { }
2020-03-12 10:40:25 +01:00
// 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 "
}
2019-10-31 13:01:18 +01:00
unsafe {
+ " <script>hljs.initHighlightingOnLoad();</script> "
2020-05-03 20:11:01 +02:00
// 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 ' ;
2020-05-03 20:18:13 +02:00
src : url ( ' / static / hack . woff2 ' ) format ( ' woff2 ' ) , url ( ' / static / hack . woff ' ) format ( ' woff ' ) ;
2020-05-03 20:11:01 +02:00
font - weight : 400 ;
font - style : normal ;
} < / style > """ .trimIndent()
2019-10-31 13:01:18 +01:00
}
2019-09-29 08:17:31 +02:00
}
body {
pre {
2019-09-29 09:51:15 +02:00
code ( classes = type ) {
2019-09-29 08:17:31 +02:00
+ content
}
}
2019-09-29 11:50:14 +02:00
a ( " / " ) {
div ( Css . FLOATY _CLASS ) {
2019-09-29 10:15:42 +02:00
+ " New paste "
}
}
2019-09-29 08:17:31 +02:00
}
}
}