forked from SPC/spc-site
Complete refactor to new routing API
This commit is contained in:
parent
218e76a2a8
commit
072655ac51
@ -46,10 +46,13 @@ internal class KtorSiteBuilder(
|
|||||||
|
|
||||||
private fun resolveRef(baseUrl: String, ref: String) = if (baseUrl.isEmpty()) {
|
private fun resolveRef(baseUrl: String, ref: String) = if (baseUrl.isEmpty()) {
|
||||||
ref
|
ref
|
||||||
|
} else if (ref.isEmpty()) {
|
||||||
|
baseUrl
|
||||||
} else {
|
} else {
|
||||||
"${baseUrl.removeSuffix("/")}/$ref"
|
"${baseUrl.removeSuffix("/")}/$ref"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inner class KtorPageBuilder(
|
inner class KtorPageBuilder(
|
||||||
val pageBaseUrl: String,
|
val pageBaseUrl: String,
|
||||||
override val meta: Meta = this@KtorSiteBuilder.meta,
|
override val meta: Meta = this@KtorSiteBuilder.meta,
|
||||||
|
@ -5,10 +5,7 @@ import space.kscience.dataforge.data.*
|
|||||||
import space.kscience.dataforge.meta.Meta
|
import space.kscience.dataforge.meta.Meta
|
||||||
import space.kscience.dataforge.meta.get
|
import space.kscience.dataforge.meta.get
|
||||||
import space.kscience.dataforge.meta.string
|
import space.kscience.dataforge.meta.string
|
||||||
import space.kscience.dataforge.names.Name
|
import space.kscience.dataforge.names.*
|
||||||
import space.kscience.dataforge.names.parseAsName
|
|
||||||
import space.kscience.dataforge.names.plus
|
|
||||||
import space.kscience.dataforge.names.startsWith
|
|
||||||
|
|
||||||
internal fun Name.toWebPath() = tokens.joinToString(separator = "/")
|
internal fun Name.toWebPath() = tokens.joinToString(separator = "/")
|
||||||
|
|
||||||
@ -25,7 +22,7 @@ interface PageBuilder : ContextAware {
|
|||||||
|
|
||||||
fun PageBuilder.resolvePageRef(pageName: String) = resolvePageRef(pageName.parseAsName())
|
fun PageBuilder.resolvePageRef(pageName: String) = resolvePageRef(pageName.parseAsName())
|
||||||
|
|
||||||
val PageBuilder.homeRef get() = resolvePageRef(Name.EMPTY).removeSuffix("/")
|
val PageBuilder.homeRef get() = resolvePageRef(SiteBuilder.INDEX_PAGE_TOKEN.asName())
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve a Html builder by its full name
|
* Resolve a Html builder by its full name
|
||||||
|
@ -58,6 +58,8 @@ internal class StaticSiteBuilder(
|
|||||||
|
|
||||||
private fun resolveRef(baseUrl: String, ref: String) = if (baseUrl.isEmpty()) {
|
private fun resolveRef(baseUrl: String, ref: String) = if (baseUrl.isEmpty()) {
|
||||||
ref
|
ref
|
||||||
|
} else if (ref.isEmpty()) {
|
||||||
|
baseUrl
|
||||||
} else {
|
} else {
|
||||||
"${baseUrl.removeSuffix("/")}/$ref"
|
"${baseUrl.removeSuffix("/")}/$ref"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user