diff --git a/README.md b/README.md index a1740b8..b8e1115 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,10 @@ There will always be more work to do here. ;-) #### Updates +##### v0.70 12/8/15 by DW + +It used to be that a file had to exist in order for you to redirect from it in config.redirects. Now it doesn't have to exist. + ##### v0.68 8/31/15 by DW Small change in error handling when we delegate a request. The previous method would cause PagePark to crash if the app we're trying to delegate to isn't running. Thanks to Dan MacTough for the help fixing this. ;-) diff --git a/lib/utils.js b/lib/utils.js index 7588185..c3eec82 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -966,4 +966,62 @@ function getFileModDate (f, callback) { //8/26/15 by DW } }); } +function getAppUrl () { //11/13/15 by DW + var url = stringNthField (window.location.href, "?", 1); + url = stringNthField (url, "#", 1); + return (url); + } +function getFacebookTimeString (when) { //11/13/15 by DW + when = new Date (when); //make sure it's a date + var ctsecs = secondsSince (when), ct, s; + if (ctsecs < 60) { + return ("Just now"); + } + + var ctminutes = ctsecs / 60; + if (ctminutes < 60) { + ct = Math.floor (ctminutes); + s = ct + " min"; + if (ct != 1) { + s += "s"; + } + return (s); + } + + var cthours = ctminutes / 60; + if (cthours < 24) { + ct = Math.floor (cthours); + s = ct + " hr"; + if (ct != 1) { + s += "s"; + } + return (s); + } + + var now = new Date (); + if (sameDay (when, dateYesterday (now))) { + return ("Yesterday at " + formatDate (when, "%l:%M %p")); + } + + var formatstring = "%b %e"; + if (when.getFullYear () != now.getFullYear ()) { + formatstring += ", %Y"; + } + return (formatDate (when, formatstring)); + } +function stringUpper (s) { //11/15/15 by DW + if (s === undefined) { + return (""); + } + s = s.toString (); + return (s.toUpperCase ()); + } + +function upperCaseFirstChar (s) { //11/15/15 by DW + if ((s === undefined) || (s.length == 0)) { + return (""); + } + s = stringUpper (s [0]) + stringDelete (s, 1, 1); + return (s); + } diff --git a/pagepark.js b/pagepark.js index 50cb09f..3cd8232 100644 --- a/pagepark.js +++ b/pagepark.js @@ -1,4 +1,4 @@ -var myVersion = "0.68b", myProductName = "PagePark"; +var myVersion = "0.70a", myProductName = "PagePark"; /* The MIT License (MIT) Copyright (c) 2014-2015 Dave Winer @@ -521,7 +521,9 @@ function handleHttpRequest (httpRequest, httpResponse) { httpResponse.end (utils.jsonStringify (status)); break; default: - return404 (); + if (!serveRedirect (lowerpath, config)) { //12/8/15 by DW -- it wasn't a redirect + return404 (); + } break; } }