Fix local exports for temporary files.
This commit is contained in:
parent
651a875eee
commit
f4970955cb
@ -1,5 +1,6 @@
|
|||||||
package ru.mipt.npm.sat
|
package ru.mipt.npm.sat
|
||||||
|
|
||||||
|
import hep.dataforge.vision.ResourceLocation
|
||||||
import hep.dataforge.vision.VisionManager
|
import hep.dataforge.vision.VisionManager
|
||||||
import hep.dataforge.vision.html.fragment
|
import hep.dataforge.vision.html.fragment
|
||||||
import hep.dataforge.vision.solid.box
|
import hep.dataforge.vision.solid.box
|
||||||
@ -15,5 +16,5 @@ fun main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment.makeFile()
|
fragment.makeFile(resourceLocation = ResourceLocation.LOCAL)
|
||||||
}
|
}
|
@ -102,23 +102,21 @@ internal fun fileCssHeader(
|
|||||||
@DFExperimental
|
@DFExperimental
|
||||||
public fun Context.Companion.scriptHeader(
|
public fun Context.Companion.scriptHeader(
|
||||||
scriptResource: String,
|
scriptResource: String,
|
||||||
basePath: Path?,
|
basePath: Path,
|
||||||
resourceLocation: ResourceLocation,
|
resourceLocation: ResourceLocation,
|
||||||
): HtmlFragment {
|
): HtmlFragment {
|
||||||
val targetPath = if (basePath == null) null else {
|
val targetPath = when (resourceLocation) {
|
||||||
when (resourceLocation) {
|
ResourceLocation.LOCAL -> checkOrStoreFile(
|
||||||
ResourceLocation.LOCAL -> checkOrStoreFile(
|
basePath,
|
||||||
basePath,
|
Path.of(DATAFORGE_ASSETS_PATH),
|
||||||
Path.of(DATAFORGE_ASSETS_PATH),
|
scriptResource
|
||||||
scriptResource
|
)
|
||||||
)
|
ResourceLocation.SYSTEM -> checkOrStoreFile(
|
||||||
ResourceLocation.SYSTEM -> checkOrStoreFile(
|
Path.of("."),
|
||||||
Path.of("."),
|
Path.of(System.getProperty("user.home")).resolve(DATAFORGE_ASSETS_PATH),
|
||||||
Path.of(System.getProperty("user.home")).resolve(DATAFORGE_ASSETS_PATH),
|
scriptResource
|
||||||
scriptResource
|
)
|
||||||
)
|
ResourceLocation.EMBED -> null
|
||||||
ResourceLocation.EMBED -> null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return if (targetPath == null) {
|
return if (targetPath == null) {
|
||||||
embedScriptHeader(scriptResource)
|
embedScriptHeader(scriptResource)
|
||||||
|
@ -10,6 +10,7 @@ import hep.dataforge.vision.makeFile
|
|||||||
import hep.dataforge.vision.scriptHeader
|
import hep.dataforge.vision.scriptHeader
|
||||||
import hep.dataforge.vision.solid.SolidGroup
|
import hep.dataforge.vision.solid.SolidGroup
|
||||||
import hep.dataforge.vision.solid.SolidManager
|
import hep.dataforge.vision.solid.SolidManager
|
||||||
|
import java.nio.file.Files
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
|
||||||
public actual val visionContext: Context = Global.context("vision-server") {
|
public actual val visionContext: Context = Global.context("vision-server") {
|
||||||
@ -38,6 +39,7 @@ public fun HtmlVisionFragment.makeFile(
|
|||||||
resourceLocation: ResourceLocation = ResourceLocation.SYSTEM,
|
resourceLocation: ResourceLocation = ResourceLocation.SYSTEM,
|
||||||
show: Boolean = true,
|
show: Boolean = true,
|
||||||
) {
|
) {
|
||||||
val scriptHeader = Context.scriptHeader("/js/visionforge-three.js", path, resourceLocation)
|
val actualPath = path ?: Files.createTempFile("tempPlot", ".html")
|
||||||
|
val scriptHeader = Context.scriptHeader("/js/visionforge-three.js", actualPath, resourceLocation)
|
||||||
makeFile(visionManager, path = path, show = show, title = title, headers = arrayOf(scriptHeader))
|
makeFile(visionManager, path = path, show = show, title = title, headers = arrayOf(scriptHeader))
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user