Browse Source

Add separate parameter for URL template

master
kageru 1 year ago
parent
commit
e7014cb654
Signed by: kageru GPG Key ID: 8282A2BEA4ADA3D2
4 changed files with 10 additions and 4 deletions
  1. 4
      kodeshare.properties
  2. 2
      src/main/kotlin/moe/kageru/kodeshare/Routes.kt
  3. 6
      src/main/kotlin/moe/kageru/kodeshare/config/Config.kt
  4. 2
      src/main/kotlin/moe/kageru/kodeshare/pages/AboutPage.kt

4
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/

2
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
}

6
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<String>()
// This is needed to return full URLs when uploading via curl.
// Will use the domain above if unspecified.
val pasteurl by optional<String>("")
}

2
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")
Loading…
Cancel
Save