diff --git a/kodeshare.properties b/kodeshare.properties index f77f2d1..fd35db0 100644 --- a/kodeshare.properties +++ b/kodeshare.properties @@ -1,2 +1,4 @@ database.password=12345 -server.domain=localhost +server.domain=http://localhost/ +# this does nothing because the domain is used if we leave this unspecified +server.pasteurl=http://localhost/ diff --git a/src/main/kotlin/moe/kageru/kodeshare/Routes.kt b/src/main/kotlin/moe/kageru/kodeshare/Routes.kt index 5a3eed8..ca4bb40 100644 --- a/src/main/kotlin/moe/kageru/kodeshare/Routes.kt +++ b/src/main/kotlin/moe/kageru/kodeshare/Routes.kt @@ -121,7 +121,7 @@ object Routes { // while also redirecting browser uploads to the newly created paste. // May seem odd to return code 302, but it seems to be the only way. response.headers.append(HttpHeaders.Location, uri) - respond(HttpStatusCode.Found, "${config[ServerSpec.domain]}/$uri") + respond(HttpStatusCode.Found, "${config[ServerSpec.pasteurl].ifBlank { config[ServerSpec.domain] }}$uri") return uri } diff --git a/src/main/kotlin/moe/kageru/kodeshare/config/Config.kt b/src/main/kotlin/moe/kageru/kodeshare/config/Config.kt index d3e2790..8df7576 100644 --- a/src/main/kotlin/moe/kageru/kodeshare/config/Config.kt +++ b/src/main/kotlin/moe/kageru/kodeshare/config/Config.kt @@ -18,6 +18,10 @@ object DatabaseSpec : ConfigSpec() { object ServerSpec : ConfigSpec() { val port by optional(9092) - // this is needed to return full URLs when uploading via curl and for the AboutPage + // For the AboutPage. + // No protocol or trailing slash is added. val domain by required() + // This is needed to return full URLs when uploading via curl. + // Will use the domain above if unspecified. + val pasteurl by optional("") } diff --git a/src/main/kotlin/moe/kageru/kodeshare/pages/AboutPage.kt b/src/main/kotlin/moe/kageru/kodeshare/pages/AboutPage.kt index e8efa0d..f590f1a 100644 --- a/src/main/kotlin/moe/kageru/kodeshare/pages/AboutPage.kt +++ b/src/main/kotlin/moe/kageru/kodeshare/pages/AboutPage.kt @@ -7,7 +7,7 @@ import moe.kageru.kodeshare.config.ServerSpec import moe.kageru.kodeshare.config.config object AboutPage { - private val domain = "https://${config[ServerSpec.domain]}" + private val domain = "${config[ServerSpec.domain]}" val content = HtmlContent(HttpStatusCode.OK) { head { link(rel = "stylesheet", href = "/style.css", type = "text/css")