SNRK-86: Assembly parts
This commit is contained in:
parent
363f63b8da
commit
667688d46d
@ -44,4 +44,5 @@ include(
|
||||
":snark-ktor",
|
||||
":snark-storage-driver",
|
||||
":snark-document-builder",
|
||||
":snark-main",
|
||||
)
|
@ -6,10 +6,12 @@ plugins {
|
||||
|
||||
val coroutinesVersion = space.kscience.gradle.KScienceVersions.coroutinesVersion
|
||||
val jacksonVersion = "2.14.2"
|
||||
val ktorVersion = space.kscience.gradle.KScienceVersions.ktorVersion
|
||||
|
||||
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
|
||||
api("io.ktor:ktor-server-html-builder:$ktorVersion")
|
||||
|
||||
implementation(project(":snark-storage-driver"))
|
||||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion")
|
||||
|
@ -4,10 +4,12 @@ import com.fasterxml.jackson.core.io.BigDecimalParser
|
||||
import space.kscience.snark.storage.*
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import kotlinx.html.*
|
||||
import kotlinx.html.dom.createHTMLDocument
|
||||
|
||||
private val DEFAULT_DOCUMENT_ROOT = "main.md"
|
||||
|
||||
public suspend fun buildDocument(documentDirectory: Directory) {
|
||||
public suspend fun buildDocument(documentDirectory: Directory): HTML {
|
||||
val dependencyGraph = buildDependencyGraph(documentDirectory)
|
||||
|
||||
TODO() /*resolving of dependencies*/
|
||||
|
@ -2,6 +2,7 @@ package documentBuilder
|
||||
|
||||
import org.junit.jupiter.api.Test
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import space.kscience.snark.storage.local.localStorage
|
||||
|
||||
class SomeTest {
|
||||
@Test
|
||||
|
@ -13,7 +13,7 @@ dependencies {
|
||||
api("io.ktor:ktor-server-html-builder:$ktorVersion")
|
||||
api("io.ktor:ktor-server-host-common:$ktorVersion")
|
||||
implementation("io.ktor:ktor-server-netty:2.3.0")
|
||||
implementation(project(mapOf("path" to ":snark-storage-driver")))
|
||||
implementation(project(":snark-storage-driver"))
|
||||
|
||||
testApi("io.ktor:ktor-server-tests:$ktorVersion")
|
||||
}
|
@ -11,7 +11,10 @@ import io.ktor.server.response.*
|
||||
import io.ktor.server.http.content.*
|
||||
import kotlinx.html.*
|
||||
import io.ktor.server.routing.*
|
||||
import kotlinx.css.h1
|
||||
import kotlinx.css.html
|
||||
import kotlinx.html.dom.create
|
||||
import kotlinx.html.dom.document
|
||||
import java.nio.file.Path
|
||||
import space.kscience.snark.storage.Directory
|
||||
import space.kscience.snark.storage.local.localStorage
|
||||
@ -22,9 +25,8 @@ import kotlin.io.path.name
|
||||
import space.kscience.snark.storage.unzip.unzip
|
||||
|
||||
public interface DataHolder {
|
||||
|
||||
fun init() : Directory
|
||||
fun represent(): String
|
||||
public fun init() : Directory
|
||||
public suspend fun represent(): String
|
||||
//will be HTML later
|
||||
}
|
||||
class LocalDataHolder: DataHolder {
|
||||
@ -44,7 +46,7 @@ class LocalDataHolder: DataHolder {
|
||||
}
|
||||
}
|
||||
}
|
||||
override fun represent() : String =
|
||||
override suspend fun represent(): String =
|
||||
if (source == null) {
|
||||
"No data was loaded!"
|
||||
} else {
|
||||
|
21
snark-main/build.gradle.kts
Normal file
21
snark-main/build.gradle.kts
Normal file
@ -0,0 +1,21 @@
|
||||
plugins {
|
||||
id("space.kscience.gradle.jvm")
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
val coroutinesVersion = space.kscience.gradle.KScienceVersions.coroutinesVersion
|
||||
|
||||
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
|
||||
implementation(project(":snark-ktor"))
|
||||
implementation(project(":snark-storage-driver"))
|
||||
implementation(project(":snark-document-builder"))
|
||||
|
||||
testImplementation(kotlin("test"))
|
||||
testImplementation("org.junit.jupiter:junit-jupiter:5.8.1")
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
useJUnitPlatform()
|
||||
}
|
17
snark-main/src/main/kotlin/space/kscience/snark/main/Main.kt
Normal file
17
snark-main/src/main/kotlin/space/kscience/snark/main/Main.kt
Normal file
@ -0,0 +1,17 @@
|
||||
package space.kscience.snark.main
|
||||
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import space.kscience.snark.ktor.SNARKServer
|
||||
import space.kscience.snark.storage.local.localStorage
|
||||
import kotlin.io.path.Path
|
||||
|
||||
fun main() = runBlocking {
|
||||
val port = 8080
|
||||
val directory = localStorage(Path("./rundata"))
|
||||
val server = SNARKServer(ServerDataHolder(directory), port)
|
||||
launch {
|
||||
server.run()
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package space.kscience.snark.main
|
||||
|
||||
import space.kscience.snark.ktor.DataHolder
|
||||
import space.kscience.snark.storage.Directory
|
||||
import documentBuilder.*
|
||||
import kotlinx.html.HTML
|
||||
|
||||
internal class ServerDataHolder(private val directory: Directory): DataHolder {
|
||||
override fun init(): Directory =
|
||||
directory
|
||||
|
||||
override suspend fun represent(): String {
|
||||
return buildDocument(directory).toString()
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package space.kscience.snark.main
|
||||
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.jupiter.api.Test
|
||||
import space.kscience.snark.ktor.SNARKServer
|
||||
import space.kscience.snark.storage.local.localStorage
|
||||
import kotlin.io.path.Path
|
||||
|
||||
class Acceptance {
|
||||
@Test
|
||||
fun justWorks() = runBlocking {
|
||||
main()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user