From 0b8870f64000388f182c17b79974f19a67f617c9 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Thu, 13 Feb 2020 20:24:35 -0500 Subject: [PATCH 1/3] add ability to serve static roots as different prefixes --- js/moto-db.js | 4 +++- js/web-server.js | 28 +++++++++++++++++++++++----- web/kiri/filter/FDM/GridBot.Two | 1 + 3 files changed, 27 insertions(+), 6 deletions(-) create mode 120000 web/kiri/filter/FDM/GridBot.Two diff --git a/js/moto-db.js b/js/moto-db.js index 95feaa71..e5e2acfd 100644 --- a/js/moto-db.js +++ b/js/moto-db.js @@ -97,7 +97,9 @@ var gs_moto_db = exports; } storage.db = request.result; storage.store = storage.db.createObjectStore(name); - setTimeout(function() { storage.runQueue() }); + event.target.transaction.oncomplete = function(event) { + storage.runQueue(); + }; }; request.onsuccess = function(event) { diff --git a/js/web-server.js b/js/web-server.js index d56cdcd0..9f51d0c2 100644 --- a/js/web-server.js +++ b/js/web-server.js @@ -1018,7 +1018,7 @@ function initModule(file, dir) { pre: arg => { modPaths.push(prepath(arg)) }, map: arg => { modPaths.push(fixedmap(arg)) }, full: arg => { modPaths.push(fullpath(arg)) }, - static: arg => { modPaths.push(serveStatic(arg)) }, + static: (root, pre) => { modPaths.push(handleStatic(root, pre)) }, code: (endpoint, path) => { if (debug) { code[endpoint] = fs.readFileSync(path); @@ -1031,7 +1031,7 @@ function initModule(file, dir) { }, handler: { addCORS: addCorsHeaders, - static: serveStatic, + static: handleStatic, redirect: redirect, reply404: reply404, reply: quickReply @@ -1039,10 +1039,28 @@ function initModule(file, dir) { }) } +function handleStatic(root, pre) { + let statServe = serveStatic(root); + return function(req, res, next) { + if (pre) { + if (req.url.indexOf(pre) === 0) { + if (req.url === pre) { + req.url = "/"; + } else { + req.url = req.url.substring(pre.length); + } + return statServe(req, res, next); + } + return next(); + } + statServe(req, res, next); + }; +} + // add static assets to be served -function addStatic(dir) { +function addStatic(dir, pre) { helper.log({static:dir}); - modPaths.push(serveStatic(dir)); + modPaths.push(handleStatic(dir, pre)); } // either add module assets to path or require(init.js) @@ -1101,7 +1119,7 @@ handler.use(fullpath({ .use(fixedmap("/api/", api)) .use(rewriteHTML) .use(compression) - .use(serveStatic(currentDir + "/web/")) + .use(handleStatic(currentDir + "/web/")) .listen(port); helper.log("------------------------------------------"); diff --git a/web/kiri/filter/FDM/GridBot.Two b/web/kiri/filter/FDM/GridBot.Two new file mode 120000 index 00000000..b188c4a2 --- /dev/null +++ b/web/kiri/filter/FDM/GridBot.Two @@ -0,0 +1 @@ +GridBot.One \ No newline at end of file From acc621ecb8cf90edeab7a88b49761432b1e50197 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Fri, 14 Feb 2020 00:05:19 -0500 Subject: [PATCH 2/3] changed cloud to browser --- web/kiri/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/kiri/index.html b/web/kiri/index.html index 01d71089..1270066e 100644 --- a/web/kiri/index.html +++ b/web/kiri/index.html @@ -8,7 +8,7 @@ - + From 56436fc4edb2a7e7857c36ed485d3aa283a33e91 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Fri, 14 Feb 2020 09:28:51 -0500 Subject: [PATCH 3/3] add loading of raw vertices --- js/kiri.js | 4 ++++ js/license.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/js/kiri.js b/js/kiri.js index 6ff4afcc..1449e4c0 100644 --- a/js/kiri.js +++ b/js/kiri.js @@ -1967,11 +1967,15 @@ self.kiri.license = exports.LICENSE; for (var i=0; i 0, isstl = lower.indexOf(".stl") > 0, issvg = lower.indexOf(".svg") > 0, isgcode = lower.indexOf(".gcode") > 0 || lower.indexOf(".nc") > 0; reader.file = files[i]; reader.onloadend = function (e) { + if (israw) platformAdd( + newWidget().loadVertices(JSON.parse(e.target.result).toFloat32()) + ); if (isstl) platformAdd( newWidget() .loadVertices(new MOTO.STL().parse(e.target.result)) diff --git a/js/license.js b/js/license.js index 438d7570..0c46ec48 100644 --- a/js/license.js +++ b/js/license.js @@ -1,7 +1,7 @@ var exports = { COPYRIGHT:"Copyright (C) 2014-2019 Stewart Allen - All Rights Reserved", LICENSE:"See the license.md file included with the source distribution", - VERSION:"1.5.9" + VERSION:"1.6.0" }; if (!module) var module = {}; module.exports = exports;