More embed stuff

This commit is contained in:
kageru 2020-03-12 10:57:28 +01:00
parent 8e5becc777
commit dfe048bac2
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2
4 changed files with 16 additions and 13 deletions

@ -132,7 +132,7 @@ object Routes {
if (raw) {
respondText(paste.content, ContentType.Text.Plain)
} else {
respond(HttpStatusCode.OK, PastePage.build(paste.content, ext))
respond(HttpStatusCode.OK, PastePage.build(paste.content, paste.uri, ext))
}
} ?: respond(HttpStatusCode.NotFound, "nothing found for id $uri")
}

@ -10,10 +10,7 @@ object AboutPage {
private val domain = "${config[ServerSpec.domain]}"
val content = HtmlContent(HttpStatusCode.OK) {
head {
link(rel = "stylesheet", href = "/style.css", type = "text/css")
meta(content = "About Kodeshare – a FOSS [ph]astebin alternative") {
attributes["property"] = "og:title"
}
defaultHead("About kodeshare")
}
body {
div("wrapper") {

@ -7,10 +7,7 @@ import kotlinx.html.*
object Homepage {
val content = HtmlContent(HttpStatusCode.OK) {
head {
link(rel = "stylesheet", href = "/style.css", type = "text/css")
meta(content = "Kodeshare – a FOSS [ph]astebin alternative") {
attributes["property"] = "og:title"
}
defaultHead("Create new paste")
}
body {
a("/about") { div(Css.FLOATY_CLASS) { +"About" } }
@ -29,3 +26,14 @@ object Homepage {
}
}
}
fun HEAD.defaultHead(title: String) {
link(rel = "stylesheet", href = "/style.css", type = "text/css")
meta(content = title) {
attributes["property"] = "og:title"
}
meta(content = "kodeshare – a FOSS pastebin alternative") {
attributes["property"] = "og:site_name"
}
meta(name = "theme-color", content = "#66D9EF")
}

@ -4,7 +4,7 @@ import io.ktor.html.HtmlContent
import kotlinx.html.*
object PastePage {
fun build(content: String, type: String?) = HtmlContent {
fun build(content: String, uri: String, type: String?) = HtmlContent {
head {
link(rel = "stylesheet", href = "/style.css", type = "text/css")
link(
@ -13,9 +13,7 @@ object PastePage {
type = "text/css"
)
script(src = "https://p.kageru.moe/static/hl.js") {}
meta(content = "Kodeshare – a FOSS [ph]astebin alternative") {
attributes["property"] = "og:title"
}
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"