initial commit

This commit is contained in:
2021-04-27 23:01:31 +02:00
commit 4f305b79f6
24 changed files with 2119 additions and 0 deletions

35
build/build.js Normal file
View File

@@ -0,0 +1,35 @@
const fs = require("fs")
const Mustache = require('mustache');
// Load template
const htmlTemplate = fs.readFileSync("build/template/editor.html.mustache").toString()
const nodes = fs.readdirSync("src/nodes")
nodes.forEach((e)=>{
// Load html parts
const helpHtml = fs.readFileSync(`src/nodes/${e}/ui/editor.html`)
const editorHtml = fs.readFileSync(`src/nodes/${e}/ui/editor.html`)
// Load complied editor index js/ts
let indexHtml = fs.readFileSync(`dist/nodes/${e}/ui/index.js`).toString()
// Cut first 2 lines because typescript inserts some stuff that the browser does not like
// TODO: is is ugly but it works
const tmp = indexHtml.split("\n")
tmp.splice(0,2)
indexHtml = tmp.join("\n")
// Prepare view object to be injected into render
const view = {
helpHtml,
editorHtml,
indexHtml,
nodeName: e
}
const html = Mustache.render(htmlTemplate, view);
// Write generated html into dist
fs.writeFileSync(`dist/nodes/${e}/${e}.html`,html)
})

View File

@@ -0,0 +1,11 @@
<script type="text/javascript">
{{{indexHtml}}}
</script>
<script type="text/html" data-template-name="{{nodeName}}">
{{{editorHtml}}}
</script>
<script type="text/html" data-help-name="{{nodeName}}">
{{{helpHtml}}}
</script>