2022-05-13 17:21:06 +03:00
|
|
|
package ru.mipt.spc
|
|
|
|
|
|
|
|
import html5up.forty.fortyScripts
|
|
|
|
import io.ktor.server.application.Application
|
|
|
|
import io.ktor.server.application.call
|
|
|
|
import io.ktor.server.application.log
|
|
|
|
import io.ktor.server.html.respondHtml
|
|
|
|
import io.ktor.server.http.content.files
|
|
|
|
import io.ktor.server.http.content.static
|
|
|
|
import io.ktor.server.routing.*
|
|
|
|
import kotlinx.html.*
|
|
|
|
import space.kscience.dataforge.context.Context
|
|
|
|
import space.kscience.dataforge.context.fetch
|
2022-05-21 13:38:15 +03:00
|
|
|
import space.kscience.dataforge.meta.Meta
|
2022-05-13 17:21:06 +03:00
|
|
|
import space.kscience.dataforge.meta.get
|
|
|
|
import space.kscience.dataforge.meta.string
|
2022-05-21 13:38:15 +03:00
|
|
|
import space.kscience.dataforge.names.Name
|
2022-05-13 17:21:06 +03:00
|
|
|
import space.kscience.dataforge.names.parseAsName
|
2022-05-21 19:21:21 +03:00
|
|
|
import space.kscience.dataforge.values.string
|
2022-05-13 17:21:06 +03:00
|
|
|
import space.kscience.snark.*
|
|
|
|
import java.nio.file.Path
|
|
|
|
|
|
|
|
|
2022-05-21 13:38:15 +03:00
|
|
|
context(PageContext) internal fun HTML.spcPageContent(
|
|
|
|
meta: Meta,
|
|
|
|
title: String = meta["title"].string ?: SPC_TITLE,
|
|
|
|
fragment: FlowContent.() -> Unit,
|
|
|
|
) {
|
2022-05-13 17:21:06 +03:00
|
|
|
spcHead(title)
|
|
|
|
body("is-preload") {
|
|
|
|
wrapper {
|
|
|
|
div("alt") {
|
|
|
|
id = "main"
|
|
|
|
// One
|
|
|
|
section {
|
|
|
|
div("inner") {
|
|
|
|
header("major") {
|
|
|
|
h1 { +title }
|
|
|
|
}
|
2022-05-21 19:21:21 +03:00
|
|
|
meta["image"]?.let { imageMeta ->
|
|
|
|
val imagePath = imageMeta.value?.string ?: imageMeta["path"].string ?: error("Image path not provided")
|
|
|
|
val imageClass = imageMeta["position"].string ?: "main"
|
|
|
|
span("image $imageClass") {
|
2022-05-13 17:21:06 +03:00
|
|
|
img {
|
|
|
|
src = resolveRef(imagePath)
|
|
|
|
alt = imagePath
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-05-21 13:38:15 +03:00
|
|
|
fragment()
|
2022-05-13 17:21:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fortyScripts()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-21 13:38:15 +03:00
|
|
|
|
|
|
|
context(PageContext) internal fun Route.spcPage(subRoute: String, meta: Meta, fragment: FlowContent.() -> Unit) {
|
2022-05-13 17:21:06 +03:00
|
|
|
get(subRoute) {
|
|
|
|
withRequest(call.request) {
|
|
|
|
call.respondHtml {
|
2022-05-21 13:38:15 +03:00
|
|
|
spcPageContent(meta, fragment = fragment)
|
2022-05-13 17:21:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-21 13:38:15 +03:00
|
|
|
context(PageContext) internal fun Route.spcPage(
|
|
|
|
subRoute: String,
|
|
|
|
dataPath: Name = subRoute.parseAsName(),
|
|
|
|
more: FlowContent.() -> Unit = {},
|
|
|
|
) {
|
|
|
|
val data = resolveHtml(dataPath)
|
2022-05-13 17:21:06 +03:00
|
|
|
if (data != null) {
|
2022-05-21 13:38:15 +03:00
|
|
|
spcPage(subRoute, data.meta) {
|
|
|
|
htmlData(data)
|
|
|
|
more()
|
|
|
|
}
|
2022-05-13 17:21:06 +03:00
|
|
|
} else {
|
|
|
|
application.log.error("Content for page with path $dataPath not found")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-05-21 13:38:15 +03:00
|
|
|
context(PageContext) internal fun Route.spcPage(
|
|
|
|
name: Name,
|
|
|
|
more: FlowContent.() -> Unit = {},
|
|
|
|
) {
|
|
|
|
spcPage(name.tokens.joinToString("/"), name, more)
|
|
|
|
}
|
|
|
|
|
2022-05-13 17:21:06 +03:00
|
|
|
context(PageContext) private fun HTML.spcHome() {
|
|
|
|
spcHead()
|
|
|
|
body("is-preload") {
|
|
|
|
wrapper {
|
|
|
|
// Banner
|
|
|
|
section("major") {
|
|
|
|
id = "banner"
|
|
|
|
div("inner") {
|
|
|
|
header("major") {
|
|
|
|
h1 { +"""Scientific Programming Centre""" }
|
|
|
|
}
|
|
|
|
div("content") {
|
|
|
|
p {
|
|
|
|
+"""Programming in Science"""
|
|
|
|
br {
|
|
|
|
}
|
|
|
|
+"""and Science in Programming"""
|
|
|
|
}
|
|
|
|
ul("actions") {
|
|
|
|
li {
|
|
|
|
a(classes = "button next scrolly") {
|
|
|
|
href = "#master"
|
|
|
|
+"""Activities"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Main
|
|
|
|
div {
|
|
|
|
id = "main"
|
|
|
|
// One
|
|
|
|
section("tiles") {
|
|
|
|
id = "master"
|
|
|
|
article {
|
|
|
|
span("image") {
|
|
|
|
img {
|
|
|
|
src = resolveRef("images/pic01.jpg")
|
|
|
|
alt = ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
header("major") {
|
|
|
|
h3 {
|
|
|
|
a(classes = "link") {
|
|
|
|
href = resolveRef("magprog")
|
|
|
|
+"""Master program"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
p { +"""Master program: "Scientific programming" """ }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
article {
|
|
|
|
span("image") {
|
|
|
|
img {
|
|
|
|
src = resolveRef("images/pic02.jpg")
|
|
|
|
alt = ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
header("major") {
|
|
|
|
h3 {
|
|
|
|
a(classes = "link") {
|
|
|
|
href = resolveRef("research")
|
|
|
|
+"""Research"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
p {
|
2022-05-21 19:21:21 +03:00
|
|
|
+"""Fundamental and applied research in analysis, scientific software design and data acquisition and control systems."""
|
2022-05-13 17:21:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
article {
|
|
|
|
span("image") {
|
|
|
|
img {
|
|
|
|
src = resolveRef("images/pic03.jpg")
|
|
|
|
alt = ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
header("major") {
|
|
|
|
h3 {
|
|
|
|
a(classes = "link") {
|
|
|
|
href = resolveRef("consulting")
|
|
|
|
+"""Consulting"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
p { +"""Consultations, review and support of scientific software systems.""" }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
article {
|
|
|
|
span("image") {
|
|
|
|
img {
|
|
|
|
src = resolveRef("images/pic04.jpg")
|
|
|
|
alt = ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
header("major") {
|
|
|
|
h3 {
|
|
|
|
a(classes = "link") {
|
|
|
|
href = resolveRef("team")
|
|
|
|
+"""Team"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// article {
|
|
|
|
// span("image") {
|
|
|
|
// img {
|
|
|
|
// src = "images/pic05.jpg"
|
|
|
|
// alt = ""
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// header("major") {
|
|
|
|
// h3 {
|
|
|
|
// a(classes = "link") {
|
|
|
|
// href = "landing.html"
|
|
|
|
// +"""Consequat"""
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// p { +"""Ipsum dolor sit amet""" }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// article {
|
|
|
|
// span("image") {
|
|
|
|
// img {
|
|
|
|
// src = "images/pic06.jpg"
|
|
|
|
// alt = ""
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// header("major") {
|
|
|
|
// h3 {
|
|
|
|
// a(classes = "link") {
|
|
|
|
// href = "landing.html"
|
|
|
|
// +"""Etiam"""
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// p { +"""Feugiat amet tempus""" }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// Two
|
|
|
|
section {
|
|
|
|
div("inner") {
|
|
|
|
header("major") {
|
2022-05-21 19:21:21 +03:00
|
|
|
h2 { +"Science + education + industry" }
|
2022-05-13 17:21:06 +03:00
|
|
|
}
|
|
|
|
p {
|
|
|
|
+"""
|
|
|
|
Our mission is to bring together science, education and industry and
|
|
|
|
work on better software solutions for science and better science in
|
|
|
|
software development.
|
|
|
|
""".trimIndent()
|
|
|
|
}
|
|
|
|
// ul("actions") {
|
|
|
|
// li {
|
|
|
|
// a(classes = "button next") {
|
|
|
|
// href = "landing.html"
|
|
|
|
// +"""Get Started"""
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fortyScripts()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal fun Application.spcHome(context: Context, rootPath: Path, prefix: String = "") {
|
|
|
|
|
|
|
|
val snark = context.fetch(SnarkPlugin)
|
|
|
|
|
2022-05-14 11:08:28 +03:00
|
|
|
val homePageContext = snark.parse(prefix, rootPath.resolve("content"))
|
2022-05-13 17:21:06 +03:00
|
|
|
|
|
|
|
routing {
|
|
|
|
route(prefix) {
|
|
|
|
with(homePageContext) {
|
|
|
|
static("assets") {
|
|
|
|
files(rootPath.resolve("assets").toFile())
|
|
|
|
}
|
|
|
|
|
|
|
|
static("images") {
|
|
|
|
files(rootPath.resolve("images").toFile())
|
|
|
|
}
|
|
|
|
|
|
|
|
get {
|
|
|
|
withRequest(call.request) {
|
|
|
|
call.respondHtml {
|
|
|
|
spcHome()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
spcPage("consulting")
|
2022-05-21 13:38:15 +03:00
|
|
|
|
2022-05-21 19:21:21 +03:00
|
|
|
spcSpotlight("team") { _, m -> m["type"].string == "team" }
|
|
|
|
spcSpotlight("research") { _, m -> m["type"].string == "project" }
|
2022-05-13 17:21:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|