master
Dave Winer 7 years ago
parent 3d6e454951
commit c9a2dcd6e6

@ -266,6 +266,10 @@ There will always be more work to do here. ;-)
### Updates
#### v0.7.9 11/8/17 by DW
A new top-level config.json option, `flUnicasePaths`. The feature is documented.
#### v0.7.8 10/3/17 by DW
New features supports logging over WebSockets. To enable, in config.json set <i>flWebsocketEnabled</i> true, and assign a port to the WS server in <i>websocketPort.</i> On every hit, PagePark will send back a JSON structure containing information about the request.

@ -64,3 +64,9 @@ Example:
<pre>{"flProcessScriptFiles": false} </pre>
#### Case-sensitive paths
If the filesystem on the server is case sensitive, as Ubuntu is, and you're porting a site from another system where file names are not case-sensitive, you will need to set `flUnicasePaths` to true. By default it's false.
This option was added in v0.7.9.

@ -2,7 +2,7 @@
"name": "PagePark",
"description": "A simple Node.js folder-based HTTP server that serves static and dynamic pages for domains.",
"author": "Dave Winer <dave@smallpicture.com>",
"version": "0.7.8",
"version": "0.7.9",
"scripts": {
"start": "node pagepark.js"
},

@ -1,4 +1,4 @@
var myVersion = "0.7.8", myProductName = "PagePark";
var myVersion = "0.7.9", myProductName = "PagePark";
/* The MIT License (MIT)
Copyright (c) 2014-2017 Dave Winer
@ -47,7 +47,8 @@ var pageparkPrefs = {
flCacheTemplatesLocally: true, //6/17/17 by DW -- preserve the original behavior
urlDefaultMarkdownTemplate: "http://fargo.io/code/pagepark/defaultmarkdowntemplate.txt", //6/17/17 by DW
urlDefaultOpmlTemplate: "http://fargo.io/code/pagepark/templates/opml/template.txt", //6/17/17 by DW
urlDefaultErrorPage: "http://fargo.io/code/pagepark/prefs/error.html" //6/17/17 by DW
urlDefaultErrorPage: "http://fargo.io/code/pagepark/prefs/error.html", //6/17/17 by DW
flUnicasePaths: false //11/7/17 by DW
};
var pageparkStats = {
ctStarts: 0,
@ -451,6 +452,60 @@ function handleHttpRequest (httpRequest, httpResponse) {
}
callback (undefined); //it's one of our domains, handle it here
}
function pathParse (domainfolder, path, callback) { //11/7/17 by DW
if (pageparkPrefs.flUnicasePaths) {
var nomad = domainfolder, steps, flSlashAtEnd = false;
if (utils.beginsWith (path, "/")) {
path = utils.stringDelete (path, 1, 1);
}
steps = path.split ("/");
if (steps [steps.length - 1].length == 0) {
steps.pop ();
flSlashAtEnd = true;
}
function doStep (ix) {
if (ix < steps.length) {
var lowerstep = utils.stringLower (steps [ix]), flfound = false;
if (!utils.endsWith (nomad, "/")) {
nomad += "/";
}
fs.readdir (nomad, function (err, list) {
if (err) {
callback (err);
}
else {
for (var i = 0; i < list.length; i++) {
var fname = utils.stringLower (list [i]);
if (fname == lowerstep) {
nomad += list [i];
doStep (ix + 1);
flfound = true;
break;
}
}
if (!flfound) {
var err = {
};
callback (err);
}
}
});
}
else {
if (flSlashAtEnd) {
nomad += "/";
}
callback (undefined, nomad);
}
}
doStep (0);
}
else {
callback (undefined, domainfolder + path);
}
}
try {
var parsedUrl = urlpack.parse (httpRequest.url, true), host, lowerhost, port, referrer;
@ -533,7 +588,10 @@ function handleHttpRequest (httpRequest, httpResponse) {
}
else { //no mapping, we handle the request
getDomainFolder (host, function (domainfolder, actualhost) { //might be a wildcard folder
var f = domainfolder + parsedUrl.pathname;
pathParse (domainfolder, parsedUrl.pathname, function (err, f) {
if (f === undefined) {
f = domainfolder + parsedUrl.pathname;
}
if (checkPathForIllegalChars (f)) {
utils.sureFilePath (domainsPath, function () { //make sure domains folder exists
getConfigFile (actualhost, function (config) { //get config.json, if it exists -- 1/18/15 by DW
@ -641,9 +699,10 @@ function handleHttpRequest (httpRequest, httpResponse) {
});
}
else {
httpRespond (500, "text/plain", "The file name contains illegal characters.");
httpRespond (400, "text/plain", "The file name contains illegal characters.");
}
});
});
}
});
}

Loading…
Cancel
Save