diff --git a/src/main/kotlin/center/sciprog/Application.kt b/src/main/kotlin/center/sciprog/Application.kt index 9926172..d268bba 100644 --- a/src/main/kotlin/center/sciprog/Application.kt +++ b/src/main/kotlin/center/sciprog/Application.kt @@ -3,7 +3,6 @@ package center.sciprog import io.ktor.server.application.Application import io.ktor.server.application.call import io.ktor.server.application.install -import io.ktor.server.config.tryGetString import io.ktor.server.plugins.forwardedheaders.ForwardedHeaders import io.ktor.server.plugins.forwardedheaders.XForwardedHeaders import io.ktor.server.response.respondRedirect @@ -15,44 +14,6 @@ import space.kscience.dataforge.workspace.resources import space.kscience.snark.html.SnarkHtml import space.kscience.snark.html.readSiteData import space.kscience.snark.ktor.site -import java.nio.file.Path - - -//private fun Application.copyResource(resource: String, dataDirectory: Path) { -// val uri = javaClass.getResource("/$resource")?.toURI() -// ?: error("Resource $resource not found") -// val targetPath = dataDirectory.resolve(resource) -// -// if (Files.isDirectory(targetPath)) { -// log.info("Using existing data directory at $targetPath.") -// } else { -// log.info("Copying data from $uri into $targetPath.") -// targetPath.createDirectories() -// //Copy everything into a temporary directory -// -// fun copyFromPath(rootPath: Path) { -// Files.walk(rootPath).forEach { source: Path -> -// if (source.isRegularFile()) { -// val relative = source.relativeTo(rootPath).toString() -// val destination: Path = targetPath.resolve(relative) -// destination.parent.createDirectories() -// Files.copy(source, destination) -// } -// } -// } -// -// if ("jar" == uri.scheme) { -// FileSystems.newFileSystem(uri, emptyMap()).use { fs -> -// val rootPath: Path = fs.provider().getPath(uri) -// copyFromPath(rootPath) -// } -// } else { -// val rootPath = uri.toPath() -// copyFromPath(rootPath) -// } -// } -//} - @Suppress("unused") fun Application.spcModule() { @@ -66,9 +27,9 @@ fun Application.spcModule() { val snark = context.request(SnarkHtml) - val dataDirectory = Path.of( - environment.config.tryGetString("ktor.environment.dataDirectory") ?: "data" - ) +// val dataDirectory = Path.of( +// environment.config.tryGetString("ktor.environment.dataDirectory") ?: "data" +// ) val siteData = snark.readSiteData(context) { resources(snark.io, "common", "home", "magprog") diff --git a/src/main/kotlin/center/sciprog/spcCollection.kt b/src/main/kotlin/center/sciprog/spcCollection.kt index 08f32da..e72d7e5 100644 --- a/src/main/kotlin/center/sciprog/spcCollection.kt +++ b/src/main/kotlin/center/sciprog/spcCollection.kt @@ -17,8 +17,7 @@ import kotlin.collections.component2 import kotlin.collections.set -context(PageContextWithData) -private fun FlowContent.spcSpotlightContent( +context(PageContextWithData, FlowContent) private fun spcSpotlightContent( landing: Data, content: Map>, ) { diff --git a/src/main/kotlin/center/sciprog/spcMisc.kt b/src/main/kotlin/center/sciprog/spcMisc.kt index 7cf4260..7981751 100644 --- a/src/main/kotlin/center/sciprog/spcMisc.kt +++ b/src/main/kotlin/center/sciprog/spcMisc.kt @@ -50,8 +50,7 @@ internal fun HTML.spcHead(title: String = SPC_TITLE) { } } -context(PageContext) -internal fun FlowContent.spcHomeMenu() { +context(PageContext, FlowContent) internal fun spcHomeMenu() { nav { id = "menu" ul("links") { @@ -103,8 +102,8 @@ internal fun FlowContent.spcHomeMenu() { } } -context(PageContext) -internal fun FlowContent.spcFooter() { +context(PageContext, FlowContent) +internal fun spcFooter() { footer { id = "footer" div("inner") { @@ -155,8 +154,8 @@ internal fun FlowContent.spcFooter() { } } -context(PageContext) -internal fun FlowContent.wrapper(contentBody: FlowContent.() -> Unit) = postprocess{ +context(PageContextWithData, FlowContent) +internal fun wrapper(contentBody: FlowContent.() -> Unit) = postprocess { div { id = "wrapper" // Header @@ -169,7 +168,7 @@ internal fun FlowContent.wrapper(contentBody: FlowContent.() -> Unit) = postpro } - getLanguageMap().takeIf { it.isNotEmpty() }?.let { languageMap-> + languageMap.takeIf { it.isNotEmpty() }?.let { languageMap -> div { languageMap.forEach { (key, meta) -> a(classes = "button primary small") {