2021-03-07 16:19:43 +03:00
|
|
|
package space.kscience.visionforge.examples
|
2021-01-12 12:52:22 +03:00
|
|
|
|
2022-01-20 11:13:17 +03:00
|
|
|
import space.kscience.dataforge.context.Global
|
|
|
|
import space.kscience.visionforge.html.HtmlVisionFragment
|
|
|
|
import space.kscience.visionforge.html.Page
|
2021-03-07 16:19:43 +03:00
|
|
|
import space.kscience.visionforge.html.ResourceLocation
|
2022-01-20 11:13:17 +03:00
|
|
|
import space.kscience.visionforge.html.importScriptHeader
|
2021-03-07 16:19:43 +03:00
|
|
|
import space.kscience.visionforge.makeFile
|
2021-01-12 12:52:22 +03:00
|
|
|
import java.awt.Desktop
|
|
|
|
import java.nio.file.Path
|
|
|
|
|
2022-01-20 11:13:17 +03:00
|
|
|
public fun makeVisionFile(
|
2021-01-12 12:52:22 +03:00
|
|
|
path: Path? = null,
|
|
|
|
title: String = "VisionForge page",
|
|
|
|
resourceLocation: ResourceLocation = ResourceLocation.SYSTEM,
|
|
|
|
show: Boolean = true,
|
2022-01-20 11:13:17 +03:00
|
|
|
content: HtmlVisionFragment,
|
2021-01-12 12:52:22 +03:00
|
|
|
): Unit {
|
2022-01-20 11:13:17 +03:00
|
|
|
val actualPath = Page(Global, content = content).makeFile(path) { actualPath ->
|
2022-01-07 12:29:43 +03:00
|
|
|
mapOf(
|
2022-01-20 11:13:17 +03:00
|
|
|
"title" to Page.title(title),
|
|
|
|
"playground" to Page.importScriptHeader("js/visionforge-playground.js", resourceLocation, actualPath),
|
2022-01-07 12:29:43 +03:00
|
|
|
)
|
2021-01-12 12:52:22 +03:00
|
|
|
}
|
|
|
|
if (show) Desktop.getDesktop().browse(actualPath.toFile().toURI())
|
|
|
|
}
|
2021-02-24 18:26:15 +03:00
|
|
|
|
2021-05-05 15:28:06 +03:00
|
|
|
//@DFExperimental
|
|
|
|
//public fun Context.makeVisionFile(
|
|
|
|
// vision: Vision,
|
|
|
|
// path: Path? = null,
|
|
|
|
// title: String = "VisionForge page",
|
|
|
|
// resourceLocation: ResourceLocation = ResourceLocation.SYSTEM,
|
|
|
|
// show: Boolean = true,
|
|
|
|
//): Unit = makeVisionFile({ vision(vision) }, path, title, resourceLocation, show)
|