From 7fcce3d55b19cc51e88dba2d3f2e2c6b54f7ec71 Mon Sep 17 00:00:00 2001 From: Dave Winer Date: Sun, 26 Apr 2015 10:27:19 -0400 Subject: [PATCH] v0.55 --- README.md | 22 ++++++++++++++++++++++ lib/utils.js | 2 +- pagepark.js | 12 ++++++++++-- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 003beea..b65b3b3 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,28 @@ There will always be more work to do here. ;-) #### Updates +##### v0.55 4/26/15 by DW + +With this release you can serve domains whose content is stored elsewhere on the web. + +There's a new optional element of config.json, urlSiteContents. Its value is the URL of a directory on the web that stores the content of the domain. + +As an experiment, I mapped the domain my.this.how to point to a folder in my public Dropbox folder. Here's how I did it. + +1. First I created a new sub-folder of my public Dropbox folder called pageParkDemo. I put one file in that folder, index.html. + +2. I used the web interface of my domain registrar to point my.this.how at the IP address of my PagePark server. + +3. On my PagePark server, I created a sub-folder of the domains folder called my.this.how. + +4. I created a config.json file in that folder, pointing to the pageParkDemo folder in my Dropbox folder. + +To test the setup, I just went to http://my.this.how/, where I saw "this is just a demo". + +Just for fun I put a picture in that folder, to see if it works. + +Obviously it can get a lot more elaborate, and you can host the content anywhere, not just in a public Dropbox folder. The key is that the content be accessible over the web. + ##### v0.54 2/18/15 by DW A new feature for pages implemented as scripts. If the script returns the value undefined PagePark will not return a value to the HTTP client, it assumes that the script will do this. diff --git a/lib/utils.js b/lib/utils.js index 261a4b9..5740e88 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -541,7 +541,7 @@ function hitCounter (counterGroup, counterServer) { //8/12/14 by DW timeout: 30000 }) .success (function (data, status, xhr) { - console.log ("hitCounter: counter ping accepted by server."); + console.log ("hitCounter: counter ping accepted by server, group == " + counterGroup + ", page url == " + thispageurl); }) .error (function (status, textStatus, errorThrown) { console.log ("hitCounter: counter ping error: " + textStatus); diff --git a/pagepark.js b/pagepark.js index 7682dd3..f8623cd 100644 --- a/pagepark.js +++ b/pagepark.js @@ -1,4 +1,4 @@ -var myVersion = "0.54", myProductName = "PagePark"; +var myVersion = "0.55", myProductName = "PagePark"; //The MIT License (MIT) @@ -317,13 +317,21 @@ function handleHttpRequest (httpRequest, httpResponse) { fsSureFilePath (domainsPath, function () { //make sure domains folder exists getConfigFile (host, function (config) { //get config.json, if it exists -- 1/18/15 by DW if (config != undefined) { - console.log ("handleHttpRequest: config == " + utils.jsonStringify (config)); if (config.urlSiteRedirect != undefined) { var urlRedirect = config.urlSiteRedirect + parsedUrl.pathname; httpResponse.writeHead (302, {"Location": urlRedirect, "Content-Type": "text/plain"}); httpResponse.end ("Temporary redirect to " + urlRedirect + "."); return; } + if (config.urlSiteContents != undefined) { //4/26/15 by DW -- v0.55 + var path = parsedUrl.pathname; + if (path == "/") { + path += pageparkPrefs.indexFilename + ".html"; + } + var url = config.urlSiteContents + path; + httpRequest.pipe (request (url)).pipe (httpResponse); + return; + } } fs.stat (f, function (err, stats) { if (err) {