From f58e51d3d3aa789d1f1cf6768415d6c9bd25c0f0 Mon Sep 17 00:00:00 2001 From: Dave Winer Date: Mon, 29 Jun 2015 08:08:04 -0400 Subject: [PATCH] v0.64 --- README.md | 2 +- lib/opml.js | 28 +++++++++++++++++----------- pagepark.js | 2 +- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 7e47254..e17c39d 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ There will always be more work to do here. ;-) If you add ?format=json to a request for an OPML file, you'll get a JSON representation of the outline. This is useful for single-page JavaScript apps that want to use the outlineBrowser toolkit to diplay the contents. An example of this is davewiner.com. -I also figured out how to write a JS page that's served by PagePark that returns the JSON representation of any OPML file. Here's a gist containing the code. And a call to that page. It's extra-nice that this feature could be added without modifying PagePark. It's starting to become a real platform! :-) +To do this I needed to write a JS page that's served by PagePark that returns the JSON representation of a specific OPML file. Here's a gist containing the code. And a call to that page. It's extra-nice that this feature could be added without modifying PagePark. It's starting to become a real platform! :-) In both cases, the CORS header allows access from anywhere. diff --git a/lib/opml.js b/lib/opml.js index 19b3577..ab9d478 100644 --- a/lib/opml.js +++ b/lib/opml.js @@ -286,20 +286,26 @@ function readOpmlFile (f, callback) { //6/25/15 by DW } function readOpmlUrl (urlOutline, callback) { - request (urlOutline, function (err, response, body) { - if (err !== null) { - console.log ("readOpmlUrl: error reading file " + urlOutline + " == " + err.message) - callback (undefined); - } - else { - if (response.statusCode != 200) { - console.log ("readOpmlUrl: error reading file, statusCode == " + response.statusCode + ", urlOutline == " + urlOutline) + if (urlOutline === undefined) { //6/28/15 by DW + console.log ("readOpmlUrl: urlOutline is undefined.") + callback (undefined); + } + else { + request (urlOutline, function (err, response, body) { + if (err !== null) { + console.log ("readOpmlUrl: error reading file " + urlOutline + " == " + err.message) callback (undefined); } else { - readOpmlString (body.toString (), callback); + if (response.statusCode != 200) { + console.log ("readOpmlUrl: error reading file, statusCode == " + response.statusCode + ", urlOutline == " + urlOutline) + callback (undefined); + } + else { + readOpmlString (body.toString (), callback); + } } - } - }); + }); + } } diff --git a/pagepark.js b/pagepark.js index 21945f2..28ff4f6 100644 --- a/pagepark.js +++ b/pagepark.js @@ -1,4 +1,4 @@ -var myVersion = "0.63a", myProductName = "PagePark"; +var myVersion = "0.64a", myProductName = "PagePark"; //The MIT License (MIT)