master
Dave Winer 9 years ago
parent 1c0bff7e1b
commit d4d20f0954

@ -88,6 +88,14 @@ There will always be more work to do here. ;-)
#### Updates
##### v0.63 6/27/15 by DW
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 <a href="http://davewiner.com/">davewiner.com</a>.
I 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 <a href="https://gist.github.com/scripting/7b95bfea614245a47f38">gist</a> containing the code. And a <a href="http://pagepark.io/getjsonopml.js?url=http://hosting.opml.org/dave/states.opml">call</a> to that page.
In both cases, the CORS header allows access from anywhere.
##### v0.62 6/25/15 by DW
Code cleanup and factoring in <a href="https://github.com/scripting/pagepark/blob/master/lib/opml.js">opml.js</a>.

@ -1,4 +1,4 @@
var myVersion = "0.62d", myProductName = "PagePark";
var myVersion = "0.63a", myProductName = "PagePark";
//The MIT License (MIT)
@ -310,21 +310,30 @@ function handleHttpRequest (httpRequest, httpResponse) {
}
break;
case config.extOpmlFiles: //6/23/15 by DW
var flReturnHtml = (!hasAcceptHeader ("text/x-opml")) && (formatParam != "opml");
if (pageparkPrefs.flProcessOpmlFiles && config.flProcessOpmlFiles && flReturnHtml) { //6/24/15 by DW
getOpmlTemplate (function (theTemplate) {
var opmltext = data.toString (), pagetable = new Object ();
opmlLib.readOpmlString (opmltext, function (theOutline) {
pagetable.bodytext = utils.jsonStringify (theOutline);
pagetable.title = utils.stringLastField (f, "/");
var s = utils.multipleReplaceAll (theTemplate, pagetable, false, "[%", "%]");
httpResponse.writeHead (200, {"Content-Type": "text/html"});
httpResponse.end (s);
});
var opmltext = data.toString ();
if (formatParam == "json") {
opmlLib.readOpmlString (opmltext, function (theOutline) {
httpResponse.writeHead (200, {"Content-Type": "application/json", "Access-Control-Allow-Origin": "*"});
httpResponse.end (utils.jsonStringify (theOutline));
});
}
else {
defaultReturn ("text/xml", data);
var flReturnHtml = (!hasAcceptHeader ("text/x-opml")) && (formatParam != "opml");
if (pageparkPrefs.flProcessOpmlFiles && config.flProcessOpmlFiles && flReturnHtml) { //6/24/15 by DW
getOpmlTemplate (function (theTemplate) {
var pagetable = new Object ();
opmlLib.readOpmlString (opmltext, function (theOutline) {
pagetable.bodytext = utils.jsonStringify (theOutline);
pagetable.title = utils.stringLastField (f, "/");
var s = utils.multipleReplaceAll (theTemplate, pagetable, false, "[%", "%]");
httpResponse.writeHead (200, {"Content-Type": "text/html"});
httpResponse.end (s);
});
});
}
else {
defaultReturn ("text/xml", data);
}
}
break;
default:

Loading…
Cancel
Save