diff --git a/README.md b/README.md
index c2f1f71..c6ed674 100644
--- a/README.md
+++ b/README.md
@@ -1,24 +1,24 @@
#### PagePark
-I wrote this simple HTTP server to park domains I've bought but not yet used.
+ I wrote this simple HTTP server to park domains I've bought but not yet used.
-It's written in JavaScript and runs in Node.js.
+ It's written in JavaScript and runs in Node.js.
-Each domain is in its own folder. The content for that domain is in the folder. I went a little wild with content types, it can serve Markdown docs, or run JS code. And of course HTML, text files, images, movies, etc.
+ Each domain is in its own folder. The content for that domain is in the folder. I went a little wild with content types, it can serve Markdown docs, or run JS code. And of course HTML, text files, images, movies, etc.
-Yet it's still very simple. Which is the point. ;-)
+ Yet it's still very simple. Which is the point. ;-)
-It's 90 percent of what all web servers do, so if you learn how to run PagePark, you're learning how to run a web server. A real one you can use to host your sites. And it's easy to hack the code if you want to.
+ It's 90 percent of what all web servers do, so if you learn how to run PagePark, you're learning how to run a web server. A real one you can use to host your sites. And it's easy to hack the code if you want to.
#### How to
-1. Create a folder to host your website.
+ 1. Create a folder to host your website.
-2. Copy all the files from the downloaded folder into that folder.
+ 2. Copy all the files from the downloaded folder into that folder.
-3. npm install
+ 3. npm install
-4. node pagepark.js
+ 4. node pagepark.js
#### Screen shot
diff --git a/lib/opml.js b/lib/opml.js
index 516bcff..4da87ae 100644
--- a/lib/opml.js
+++ b/lib/opml.js
@@ -98,8 +98,8 @@ function copyScalars (source, dest) { //8/31/14 by DW
}
function readInclude (theIncludeNode, callback) {
console.log ("readInclude: url == " + theIncludeNode.url);
- readOpmlUrl (theIncludeNode.url, function (theOutline, err) {
- if (err) {
+ readOpmlUrl (theIncludeNode.url, function (theOutline) {
+ if (theOutline === undefined) {
callback (undefined);
}
else {
@@ -124,6 +124,9 @@ function outlineVisiter (theOutline, inlevelcallback, outlevelcallback, nodecall
doOneSub (head, ixsub +1);
});
}
+ else { //6/25/15 by DW -- don't let errors derail us
+ doOneSub (head, ixsub +1);
+ }
});
}
else {
@@ -208,7 +211,7 @@ function readOpmlString (s, callback) {
theStream.pipe (opmlparser);
opmlparser.on ("error", function (error) {
- console.log ("readOpml: opml parser error == " + error.message);
+ console.log ("readOpmlString: opml parser error == " + error.message);
if (callback != undefined) {
callback (undefined, error);
}
@@ -269,173 +272,34 @@ function readOpmlString (s, callback) {
});
});
}
-function readOpmlFile (f, callback) {
- var outlineArray = new Array ();
- var fstream = fs.createReadStream (f);
- var opmlparser = new opmlParser ();
- var metadata = undefined;
- flparseerror = false;
-
- fstream.pipe (opmlparser);
-
- opmlparser.on ("error", function (error) {
- console.log ("readOpml: opml parser error == " + error.message);
- if (callback != undefined) {
- callback (undefined, error);
- }
- flparseerror = true;
- });
- opmlparser.on ("readable", function () {
- var outline;
- while (outline = this.read ()) {
- var ix = Number (outline ["#id"]);
- outlineArray [ix] = outline;
- if (metadata === undefined) {
- metadata = this.meta;
- }
- }
- });
- opmlparser.on ("end", function () {
- if (flparseerror) {
- return;
+
+function readOpmlFile (f, callback) { //6/25/15 by DW
+ fs.readFile (f, function (err, data) {
+ if (err) {
+ console.log ("readOpmlFile: error reading file " + f + " == " + err.message)
+ callback (undefined);
}
- var theOutline = new Object ();
-
- //copy elements of the metadata object into the root of the outline
- function copyone (name) {
- var val = metadata [name];
- if ((val !== undefined) && (val != null)) {
- theOutline [name] = val;
- }
- }
- copyone ("title");
- copyone ("datecreated");
- copyone ("datemodified");
- copyone ("ownername");
- copyone ("owneremail");
- copyone ("description");
-
- for (var i = 0; i < outlineArray.length; i++) {
- var obj = outlineArray [i];
- if (obj != null) {
- var idparent = obj ["#parentid"], parent;
- if (idparent == 0) {
- parent = theOutline;
- }
- else {
- parent = outlineArray [idparent];
- }
- if (parent.subs === undefined) {
- parent.subs = new Array ();
- }
- parent.subs [parent.subs.length] = obj;
- delete obj ["#id"];
- delete obj ["#parentid"];
- }
+ else {
+ readOpmlString (data.toString (), callback);
}
-
- expandIncludes (theOutline, function (expandedOutline) {
- if (callback != undefined) {
- callback (expandedOutline, undefined);
- }
- });
-
});
}
+
function readOpmlUrl (urlOutline, callback) {
- if (opmlData.flUseOutlineCache && (opmlData.outlineCache [urlOutline] !== undefined)) {
- if (callback !== undefined) {
- callback (opmlData.outlineCache [urlOutline], undefined);
+ request (urlOutline, function (err, response, body) {
+ if (err !== null) {
+ console.log ("readOpmlUrl: error reading file " + urlOutline + " == " + err.message)
+ callback (undefined);
}
- }
- else {
- var outlineArray = new Array ();
- var opmlparser = new opmlParser ();
- var metadata = undefined;
- var flparseerror = false;
- var req;
- var theRequest = {
- url: urlOutline,
- headers: {
- "Accept": "text/x-opml, */*",
- }
- };
- req = request (theRequest);
-
- req.on ("response", function (res) {
- var stream = this;
- if (res.statusCode == 200) {
- stream.pipe (opmlparser);
- }
- });
- req.on ("error", function (res) {
- console.log ("readOpml: error reading outline. urlOutline == " + urlOutline);
- if (callback != undefined) {
- callback (undefined, res);
- }
- });
- opmlparser.on ("error", function (error) {
- console.log ("readOpml: opml parser error == " + error.message);
- if (callback != undefined) {
- callback (undefined, error);
- }
- flparseerror = true;
- });
- opmlparser.on ("readable", function () {
- var outline;
- while (outline = this.read ()) {
- var ix = Number (outline ["#id"]);
- outlineArray [ix] = outline;
- if (metadata === undefined) {
- metadata = this.meta;
- }
- }
- });
- opmlparser.on ("end", function () {
- if (flparseerror) {
- return;
- }
- var theOutline = new Object ();
-
- //copy elements of the metadata object into the root of the outline
- function copyone (name) {
- var val = metadata [name];
- if ((val !== undefined) && (val != null)) {
- theOutline [name] = val;
- }
- }
- copyone ("title");
- copyone ("datecreated");
- copyone ("datemodified");
- copyone ("ownername");
- copyone ("owneremail");
- copyone ("description");
-
- for (var i = 0; i < outlineArray.length; i++) {
- var obj = outlineArray [i];
- if (obj != null) {
- var idparent = obj ["#parentid"], parent;
- if (idparent == 0) {
- parent = theOutline;
- }
- else {
- parent = outlineArray [idparent];
- }
- if (parent.subs === undefined) {
- parent.subs = new Array ();
- }
- parent.subs [parent.subs.length] = obj;
- delete obj ["#id"];
- delete obj ["#parentid"];
- }
- }
- if (opmlData.flUseOutlineCache) {
- opmlData.outlineCache [urlOutline] = theOutline;
+ else {
+ if (response.statusCode != 200) {
+ console.log ("readOpmlUrl: error reading file, statusCode == " + response.statusCode + ", urlOutline == " + urlOutline)
+ callback (undefined);
}
- if (callback != undefined) {
- callback (theOutline, undefined);
+ else {
+ readOpmlString (body.toString (), callback);
}
- });
- }
+ }
+ });
}
diff --git a/pagepark.js b/pagepark.js
index 55f5e6b..827e934 100644
--- a/pagepark.js
+++ b/pagepark.js
@@ -1,4 +1,4 @@
-var myVersion = "0.61v", myProductName = "PagePark";
+var myVersion = "0.62d", myProductName = "PagePark";
//The MIT License (MIT)