master
Dave Winer 9 years ago
parent 773bb9d56d
commit 234604ba0d

@ -16,6 +16,9 @@ exports.isAlpha = isAlpha;
exports.isNumeric = isNumeric;
exports.stringLastField = stringLastField;
exports.multipleReplaceAll = multipleReplaceAll;
exports.kilobyteString = kilobyteString;
exports.megabyteString = megabyteString;
exports.gigabyteString = gigabyteString;
function sameDay (d1, d2) {
//returns true if the two dates are on the same day
@ -37,6 +40,10 @@ function dayGreaterThanOrEqual (d1, d2) { //9/2/14 by DW
return (d1 >= d2);
}
function stringLower (s) {
if (s === undefined) { //1/26/15 by DW
return ("");
}
s = s.toString (); //1/26/15 by DW
return (s.toLowerCase ());
}
function secondsSince (when) {
@ -226,7 +233,6 @@ function getBoolean (val) { //12/5/13 by DW
break;
case "boolean":
return (val);
break;
case "number":
if (val == 1) {
return (true);
@ -456,11 +462,11 @@ function hotUpText (s, url) { //7/18/14 by DW
}
function getFavicon (url) { //7/18/14 by DW
function getDomain (url) {
if (( url != null ) && (url != "")) {
if ((url != null ) && (url != "")) {
url = url.replace("www.","").replace("www2.", "").replace("feedproxy.", "").replace("feeds.", "");
var root = url.split('?')[0]; // cleans urls of form http://domain.com?a=1&b=2
var url = root.split('/')[2];
}
}
return (url);
};
var domain = getDomain (url);
@ -887,4 +893,24 @@ function httpExt2MIME (ext) { //12/24/14 by DW
}
return ("text/plain");
}
function kilobyteString (num) { //1/24/15 by DW
num = Number (num) / 1024;
return (num.toFixed (2) + "K");
}
function megabyteString (num) { //1/24/15 by DW
var onemeg = 1024 * 1024;
if (num <= onemeg) {
return (kilobyteString (num));
}
num = Number (num) / onemeg;
return (num.toFixed (2) + "MB");
}
function gigabyteString (num) { //1/24/15 by DW
var onegig = 1024 * 1024 * 1024;
if (num <= onegig) {
return (megabyteString (num));
}
num = Number (num) / onegig;
return (num.toFixed (2) + "GB");
}

@ -1,4 +1,4 @@
var myVersion = "0.51", myProductName = "PagePark";
var myVersion = "0.53", myProductName = "PagePark";
//The MIT License (MIT)
@ -281,6 +281,9 @@ function handleHttpRequest (httpRequest, httpResponse) {
client = domains [0];
}
}
if (client == undefined) { //1/25/15 by DW
client = "";
}
console.log (now.toLocaleTimeString () + " " + httpRequest.method + " " + host + ":" + port + " " + lowerpath + " " + referrer + " " + client);
});
@ -406,11 +409,11 @@ function startup () {
readStats (fnameStats, pageparkStats, function () {
fsSureFilePath (getFullFilePath (domainsPath) + "x", function () { //make sure domains folder exists
var now = new Date ();
console.log (myProductName + " v" + myVersion + ".");
pageparkStats.ctStarts++;
pageparkStats.whenLastStart = now;
flStatsDirty = true;
http.createServer (handleHttpRequest).listen (pageparkPrefs.myPort);
console.log (""); console.log (myProductName + " v" + myVersion + " running on port " + pageparkPrefs.myPort + "."); console.log ("");
setInterval (everySecond, 1000);
});
});

Loading…
Cancel
Save