Add Https redirect
This commit is contained in:
parent
846c02020b
commit
43bf8e8e96
@ -33,6 +33,7 @@ dependencies {
|
|||||||
implementation("io.ktor:ktor-server-host-common:$ktorVersion")
|
implementation("io.ktor:ktor-server-host-common:$ktorVersion")
|
||||||
implementation("io.ktor:ktor-server-status-pages:$ktorVersion")
|
implementation("io.ktor:ktor-server-status-pages:$ktorVersion")
|
||||||
implementation("io.ktor:ktor-server-netty:$ktorVersion")
|
implementation("io.ktor:ktor-server-netty:$ktorVersion")
|
||||||
|
implementation("io.ktor:ktor-server-http-redirect:$ktorVersion")
|
||||||
implementation("ch.qos.logback:logback-classic:1.2.11")
|
implementation("ch.qos.logback:logback-classic:1.2.11")
|
||||||
implementation("space.kscience:dataforge-workspace:$dataforgeVersion")
|
implementation("space.kscience:dataforge-workspace:$dataforgeVersion")
|
||||||
implementation("space.kscience:dataforge-io-yaml:$dataforgeVersion")
|
implementation("space.kscience:dataforge-io-yaml:$dataforgeVersion")
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package ru.mipt.spc
|
package ru.mipt.spc
|
||||||
|
|
||||||
import io.ktor.server.application.Application
|
import io.ktor.server.application.Application
|
||||||
|
import io.ktor.server.application.install
|
||||||
import io.ktor.server.application.log
|
import io.ktor.server.application.log
|
||||||
|
import io.ktor.server.plugins.httpsredirect.HttpsRedirect
|
||||||
import kotlinx.css.CssBuilder
|
import kotlinx.css.CssBuilder
|
||||||
import kotlinx.html.CommonAttributeGroupFacade
|
import kotlinx.html.CommonAttributeGroupFacade
|
||||||
import kotlinx.html.style
|
import kotlinx.html.style
|
||||||
@ -47,6 +49,8 @@ const val BUILD_DATE_FILE = "/buildDate"
|
|||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
fun Application.spcModule() {
|
fun Application.spcModule() {
|
||||||
|
install(HttpsRedirect)
|
||||||
|
|
||||||
val context = Context("spc-site") {
|
val context = Context("spc-site") {
|
||||||
plugin(SnarkPlugin)
|
plugin(SnarkPlugin)
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ data class SiteData(
|
|||||||
return SiteData(snark, emptyData, baseUrlPath, meta)
|
return SiteData(snark, emptyData, baseUrlPath, meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
const val INDEX_PAGE_TOKEN: String = "index"
|
val INDEX_PAGE_TOKEN: NameToken = NameToken("index")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,8 +53,9 @@ fun SiteData.resolveRef(name: String): String = if (baseUrlPath.isEmpty()) {
|
|||||||
/**
|
/**
|
||||||
* Resolve a page designated by given name. Depending on rendering specifics, some prefixes or suffixes could be added.
|
* Resolve a page designated by given name. Depending on rendering specifics, some prefixes or suffixes could be added.
|
||||||
*/
|
*/
|
||||||
fun SiteData.resolvePage(name: Name): String =
|
fun SiteData.resolvePage(name: Name): String {
|
||||||
resolveRef(name.tokens.joinToString("/")) + (meta["pageSuffix"].string ?: "")
|
return resolveRef(name.tokens.joinToString("/")) + (meta["pageSuffix"].string ?: "")
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -73,7 +73,7 @@ fun SnarkPlugin.static(path: Path, block: SiteBuilder.() -> Unit) {
|
|||||||
this,
|
this,
|
||||||
baseUrlPath = path.absolutePathString(),
|
baseUrlPath = path.absolutePathString(),
|
||||||
meta = Meta {
|
meta = Meta {
|
||||||
"pageSuffix" put "/index.html"
|
"pageSuffix" put ".html"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
StaticSiteBuilder(base, path).block()
|
StaticSiteBuilder(base, path).block()
|
||||||
|
Loading…
Reference in New Issue
Block a user