Collapsed /configs into /devices (or in some cases, /apps or /disks), simplifying the structure a bit
This commit is contained in:
parent
c226edd53a
commit
0e8e11d2d8
159 changed files with 1498 additions and 1472 deletions
|
|
@ -520,7 +520,7 @@ HTMLOut.filter = function(req, res, next)
|
|||
* crack at the URL and redirect with a trailing slash as appropriate.
|
||||
*
|
||||
* This isn't just a cosmetic issue, because without "strict routing" and the "express-slash" module,
|
||||
* URLs like "http://localhost:9126/configs/pc/machines/5150/mda/64kb/debugger" will cause problems for
|
||||
* URLs like "http://localhost:8088/devices/pc/machine/5150/mda/64kb/debugger" will cause problems for
|
||||
* client-side JavaScript when it tries to do an XMLHttpRequest with a relative filename (eg, "machine.xml");
|
||||
* that request will fetch the "machine.xml" in the parent directory instead of the "debugger" directory.
|
||||
*
|
||||
|
|
@ -1392,7 +1392,7 @@ HTMLOut.prototype.getMachineXML = function(sToken, sIndent, aParms, sXMLFile, sS
|
|||
*
|
||||
* But, instead of displaying a cryptic error message inside our beautiful HTML template, eg:
|
||||
*
|
||||
* htmlout error: ENOENT, open '/Users/Jeff/Sites/pcjs/configs/pc/machines/5160/cga/256kb/win101/debugger/machine.xml'
|
||||
* htmlout error: ENOENT, open '/Users/Jeff/Sites/pcjs/devices/pc/machine/5160/cga/256kb/win101/debugger/machine.xml'
|
||||
*
|
||||
* we have one more fallback: a random string! Less useful, but more entertaining. Well, maybe not even that.
|
||||
*
|
||||
|
|
@ -1623,7 +1623,7 @@ HTMLOut.prototype.getReadMe = function(sToken, sIndent, aParms, sPrevious)
|
|||
/*
|
||||
* Instead of displaying a cryptic error message inside our beautiful HTML template, eg:
|
||||
*
|
||||
* htmlout error: ENOENT, open '/Users/Jeff/Sites/pcjs/configs/pc/machines/5160/cga/256kb/win101/debugger/README.md'
|
||||
* htmlout error: ENOENT, open '/Users/Jeff/Sites/pcjs/devices/pc/machine/5160/cga/256kb/win101/debugger/README.md'
|
||||
*
|
||||
* which is all this will give us:
|
||||
*
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ var logFile = null;
|
|||
* Redirect permanent /videos/pcjs/ /disks/pc/dos/microsoft/4.0M/
|
||||
* RedirectMatch permanent /demos/pc/.* /configs/pc/machines/
|
||||
*/
|
||||
var externalRedirects = {
|
||||
var aExternalRedirects = {
|
||||
"/c1p": "/docs/c1pjs/",
|
||||
"/c1pjs": "/docs/c1pjs/",
|
||||
"/pc": "/docs/about/pcjs/",
|
||||
|
|
@ -118,20 +118,21 @@ var externalRedirects = {
|
|||
"/videos/pcjs": "/configs/pc/machines/5160/cga/640kb/dos400m/"
|
||||
};
|
||||
|
||||
var aExternalRedirectPatterns = {
|
||||
"^/configs/pc/machines/(.*)": "/devices/pc/machine/$1"
|
||||
};
|
||||
|
||||
/*
|
||||
* Entries in this table are matched next, using a RegExp comparison; comparisons start with the first entry
|
||||
* and continue until a match is found, at which point the replacement is performed and comparisons stop;
|
||||
* we could make the replacement process "additive", by continuing comparisons/replacements until the
|
||||
* end is reached, but let's not, unless there's an actual need.
|
||||
*
|
||||
* In fact, until I find a compelling need for any of these redirects, I'm going to disable them, so that we
|
||||
* don't waste time running RegExp tests on every server request.
|
||||
*
|
||||
* Feel free to use subgroups on the left-hand side, and references to them (eg, $1, $2, etc) on the right.
|
||||
*/
|
||||
var internalRedirects = {
|
||||
// "^/apps/pc/visicalc/": "/apps/pc/1981/visicalc/",
|
||||
// "^/demos/pc/.*": "/configs/pc/machines/"
|
||||
var aInternalRedirectPatterns = {
|
||||
// "^/apps/pc/visicalc/": "/apps/pc/1981/visicalc/",
|
||||
// "^/demos/pc/.*": "/configs/pc/machines/"
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -181,6 +182,7 @@ var userVolumes = {};
|
|||
*/
|
||||
HTTPAPI.redirect = function(req, res, next)
|
||||
{
|
||||
var re;
|
||||
var sPath = req.path;
|
||||
if (sPath.slice(-1) == '/') sPath = sPath.slice(0, -1);
|
||||
|
||||
|
|
@ -190,15 +192,23 @@ HTTPAPI.redirect = function(req, res, next)
|
|||
return true;
|
||||
}
|
||||
|
||||
if (externalRedirects[sPath] !== undefined) {
|
||||
res.redirect(301, externalRedirects[sPath]);
|
||||
if (aExternalRedirects[sPath] !== undefined) {
|
||||
res.redirect(301, aExternalRedirects[sPath]);
|
||||
return true;
|
||||
}
|
||||
|
||||
for (sPath in internalRedirects) {
|
||||
for (sPath in aExternalRedirectPatterns) {
|
||||
re = new RegExp(sPath);
|
||||
if (re.exec(req.url)) {
|
||||
res.redirect(301, req.url.replace(re, aExternalRedirectPatterns[sPath]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (sPath in aInternalRedirectPatterns) {
|
||||
var re = new RegExp(sPath);
|
||||
if (re.exec(req.url)) {
|
||||
req.url = req.url.replace(re, internalRedirects[sPath]);
|
||||
req.url = req.url.replace(re, aInternalRedirectPatterns[sPath]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue