add ability to serve static roots as different prefixes
This commit is contained in:
parent
674bb48689
commit
0b8870f640
3 changed files with 27 additions and 6 deletions
|
|
@ -97,7 +97,9 @@ var gs_moto_db = exports;
|
||||||
}
|
}
|
||||||
storage.db = request.result;
|
storage.db = request.result;
|
||||||
storage.store = storage.db.createObjectStore(name);
|
storage.store = storage.db.createObjectStore(name);
|
||||||
setTimeout(function() { storage.runQueue() });
|
event.target.transaction.oncomplete = function(event) {
|
||||||
|
storage.runQueue();
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
request.onsuccess = function(event) {
|
request.onsuccess = function(event) {
|
||||||
|
|
|
||||||
|
|
@ -1018,7 +1018,7 @@ function initModule(file, dir) {
|
||||||
pre: arg => { modPaths.push(prepath(arg)) },
|
pre: arg => { modPaths.push(prepath(arg)) },
|
||||||
map: arg => { modPaths.push(fixedmap(arg)) },
|
map: arg => { modPaths.push(fixedmap(arg)) },
|
||||||
full: arg => { modPaths.push(fullpath(arg)) },
|
full: arg => { modPaths.push(fullpath(arg)) },
|
||||||
static: arg => { modPaths.push(serveStatic(arg)) },
|
static: (root, pre) => { modPaths.push(handleStatic(root, pre)) },
|
||||||
code: (endpoint, path) => {
|
code: (endpoint, path) => {
|
||||||
if (debug) {
|
if (debug) {
|
||||||
code[endpoint] = fs.readFileSync(path);
|
code[endpoint] = fs.readFileSync(path);
|
||||||
|
|
@ -1031,7 +1031,7 @@ function initModule(file, dir) {
|
||||||
},
|
},
|
||||||
handler: {
|
handler: {
|
||||||
addCORS: addCorsHeaders,
|
addCORS: addCorsHeaders,
|
||||||
static: serveStatic,
|
static: handleStatic,
|
||||||
redirect: redirect,
|
redirect: redirect,
|
||||||
reply404: reply404,
|
reply404: reply404,
|
||||||
reply: quickReply
|
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
|
// add static assets to be served
|
||||||
function addStatic(dir) {
|
function addStatic(dir, pre) {
|
||||||
helper.log({static:dir});
|
helper.log({static:dir});
|
||||||
modPaths.push(serveStatic(dir));
|
modPaths.push(handleStatic(dir, pre));
|
||||||
}
|
}
|
||||||
|
|
||||||
// either add module assets to path or require(init.js)
|
// either add module assets to path or require(init.js)
|
||||||
|
|
@ -1101,7 +1119,7 @@ handler.use(fullpath({
|
||||||
.use(fixedmap("/api/", api))
|
.use(fixedmap("/api/", api))
|
||||||
.use(rewriteHTML)
|
.use(rewriteHTML)
|
||||||
.use(compression)
|
.use(compression)
|
||||||
.use(serveStatic(currentDir + "/web/"))
|
.use(handleStatic(currentDir + "/web/"))
|
||||||
.listen(port);
|
.listen(port);
|
||||||
|
|
||||||
helper.log("------------------------------------------");
|
helper.log("------------------------------------------");
|
||||||
|
|
|
||||||
1
web/kiri/filter/FDM/GridBot.Two
Symbolic link
1
web/kiri/filter/FDM/GridBot.Two
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
GridBot.One
|
||||||
Loading…
Reference in a new issue