forked from SPC/spc-site
Move data out of resources. Deliver as separate directory.
This commit is contained in:
parent
7053c866f9
commit
5e207a1a64
@ -10,10 +10,16 @@ import io.ktor.server.routing.get
|
|||||||
import io.ktor.server.routing.routing
|
import io.ktor.server.routing.routing
|
||||||
import space.kscience.dataforge.context.Context
|
import space.kscience.dataforge.context.Context
|
||||||
import space.kscience.dataforge.context.request
|
import space.kscience.dataforge.context.request
|
||||||
import space.kscience.dataforge.workspace.resources
|
import space.kscience.dataforge.data.forEach
|
||||||
|
import space.kscience.dataforge.names.Name
|
||||||
|
import space.kscience.dataforge.workspace.FileData
|
||||||
|
import space.kscience.dataforge.workspace.directory
|
||||||
import space.kscience.snark.html.SnarkHtml
|
import space.kscience.snark.html.SnarkHtml
|
||||||
import space.kscience.snark.html.readSiteData
|
import space.kscience.snark.html.readSiteData
|
||||||
import space.kscience.snark.ktor.site
|
import space.kscience.snark.ktor.site
|
||||||
|
import kotlin.io.path.Path
|
||||||
|
import kotlin.io.path.exists
|
||||||
|
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
fun Application.spcModule() {
|
fun Application.spcModule() {
|
||||||
@ -27,12 +33,20 @@ fun Application.spcModule() {
|
|||||||
|
|
||||||
val snark = context.request(SnarkHtml)
|
val snark = context.request(SnarkHtml)
|
||||||
|
|
||||||
// val dataDirectory = Path.of(
|
val dataDirectoryString = environment.config.propertyOrNull("snark.dataDirectory")?.getString() ?: "data"
|
||||||
// environment.config.tryGetString("ktor.environment.dataDirectory") ?: "data"
|
|
||||||
// )
|
val dataDirectory = Path(dataDirectoryString)
|
||||||
|
|
||||||
|
if(!dataDirectory.exists()){
|
||||||
|
error("Data directory at $dataDirectory is not resolved")
|
||||||
|
}
|
||||||
|
|
||||||
val siteData = snark.readSiteData(context) {
|
val siteData = snark.readSiteData(context) {
|
||||||
resources(snark.io, "common", "home", "magprog")
|
directory(snark.io, Name.EMPTY, dataDirectory)
|
||||||
|
}
|
||||||
|
|
||||||
|
siteData.forEach { namedData ->
|
||||||
|
println("${namedData.name}: ${namedData.meta[FileData.FILE_PATH_KEY]}")
|
||||||
}
|
}
|
||||||
|
|
||||||
routing {
|
routing {
|
||||||
|
Loading…
Reference in New Issue
Block a user