master
Dave Winer 8 years ago
parent ba50a664bf
commit 2d4722a659

@ -0,0 +1,24 @@
### Programming your website
Websites evolve over time, and PagePark has features that help you adjust things so links keep working after the change. Almost all the features described on this page are here to help you prevent linkrot! That's how prevalent it is.
#### config.json
All the values described here are added to a config.json file that's stored at the top level of a domain folder. Any time a request comes in for that domain, we read the config.json file in its folder, if there is one, and the values are applied to the request.
#### flProcessScriptFiles
If you set this value false, none of the JavaScript files in the domain folder will be processed. They will be served as text, with the source code in the file.
This can be useful if you want to serve script code to be used in browser-based apps.
Example:
<pre>{
"flProcessScriptFiles": false
}
</pre>

@ -34,6 +34,11 @@ function sameDay (d1, d2) {
d2 = new Date (d2);
return ((d1.getFullYear () == d2.getFullYear ()) && (d1.getMonth () == d2.getMonth ()) && (d1.getDate () == d2.getDate ()));
}
function sameMonth (d1, d2) { //5/29/16 by DW -- return true if the two dates are in the same month
d1 = new Date (d1);
d2 = new Date (d2);
return ((d1.getFullYear () == d2.getFullYear ()) && (d1.getMonth () == d2.getMonth ()));
}
function dayGreaterThanOrEqual (d1, d2) { //9/2/14 by DW
d1 = new Date (d1);
d1.setHours (0);
@ -336,27 +341,32 @@ function stripMarkup (s) { //5/24/14 by DW
return (s.replace (/(<([^>]+)>)/ig, ""));
}
function maxStringLength (s, len, flWholeWordAtEnd, flAddElipses) {
if (flWholeWordAtEnd === undefined) {
flWholeWordAtEnd = true;
}
if (flAddElipses === undefined) { //6/2/14 by DW
flAddElipses = true;
if ((s === undefined) || (s === null)) {
return ("");
}
if (s.length > len) {
s = s.substr (0, len);
if (flWholeWordAtEnd) {
while (s.length > 0) {
if (s [s.length - 1] == " ") {
if (flAddElipses) {
s += "...";
else {
if (flWholeWordAtEnd === undefined) {
flWholeWordAtEnd = true;
}
if (flAddElipses === undefined) { //6/2/14 by DW
flAddElipses = true;
}
if (s.length > len) {
s = s.substr (0, len);
if (flWholeWordAtEnd) {
while (s.length > 0) {
if (s [s.length - 1] == " ") {
if (flAddElipses) {
s += "...";
}
break;
}
break;
s = s.substr (0, s.length - 1); //pop last char
}
s = s.substr (0, s.length - 1); //pop last char
}
}
return (s);
}
return (s);
}
function random (lower, upper) {
var range = upper - lower + 1;
@ -403,12 +413,13 @@ function readHttpFile (url, callback, timeoutInMilliseconds, headers) { //5/27/1
});
}
function readHttpFileThruProxy (url, type, callback) { //10/25/14 by DW
var urlReadFileApi = "http://pub2.fargo.io:5347/httpReadUrl";
var urlReadFileApi = "http://pub2.fargo.io/httpReadUrl"; //"http://pub2.fargo.io:5347/httpReadUrl";
if (type === undefined) {
type = "text/plain";
}
var urlAjax = urlReadFileApi + "?url=" + encodeURIComponent (url) + "&type=" + encodeURIComponent (type);
var jxhr = $.ajax ({
url: urlReadFileApi + "?url=" + encodeURIComponent (url) + "&type=" + encodeURIComponent (type),
url: urlAjax,
dataType: "text" ,
timeout: 30000
})
@ -455,18 +466,23 @@ function filledString (ch, ct) { //6/4/14 by DW
return (s);
}
function encodeXml (s) { //7/15/14 by DW
var charMap = {
'<': '&lt;',
'>': '&gt;',
'&': '&amp;',
'"': '&'+'quot;'
};
s = s.toString();
s = s.replace(/\u00A0/g, " ");
var escaped = s.replace(/[<>&"]/g, function(ch) {
return charMap [ch];
});
return escaped;
if (s === undefined) {
return ("");
}
else {
var charMap = {
'<': '&lt;',
'>': '&gt;',
'&': '&amp;',
'"': '&'+'quot;'
};
s = s.toString();
s = s.replace(/\u00A0/g, " ");
var escaped = s.replace(/[<>&"]/g, function(ch) {
return charMap [ch];
});
return escaped;
}
}
function decodeXml (s) { //11/7/14 by DW
return (s.replace (/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&amp;/g,'&'));
@ -596,7 +612,6 @@ function getRandomSnarkySlogan () { //8/15/14 by DW
"All baking done on premises.",
"Still diggin!",
"It's even worse than it appears.",
"Ask not what the Internet can do for you...",
"You should never argue with a crazy man.",
"Welcome back my friends to the show that never ends.",
"Greetings, citizen of Planet Earth. We are your overlords. :-)",
@ -611,7 +626,12 @@ function getRandomSnarkySlogan () { //8/15/14 by DW
"Shut up and eat your vegetables.",
"Don't slam the door on the way out.",
"Yeah well, that's just, you know, like, your opinion, man.",
"So, it has come to this."
"So, it has come to this.",
"We now return to our regularly scheduled program.",
"That rug really tied the room together.",
"It's a good time for a backup.",
"Takes a lickin, keeps on tickin.",
"People return to places that send them away."
]
return (snarkySlogans [random (0, snarkySlogans.length - 1)]);
}
@ -755,7 +775,13 @@ function copyScalars (source, dest) { //8/31/14 by DW
}
}
function linkToDomainFromUrl (url, flshort, maxlength) { //10/10/14 by DW
var splitUrl = urlSplitter (url), host = splitUrl.host.toLowerCase ();
var splitUrl = urlSplitter (url), host;
if (splitUrl.host === undefined) { //1/21/16 by DW
host = "";
}
else {
host = splitUrl.host.toLowerCase ();
}
if (flshort === undefined) {
flshort = false;
}
@ -966,6 +992,23 @@ function getFileModDate (f, callback) { //8/26/15 by DW
}
});
}
function getFileCreationDate (f, callback) { //12/15/15 by DW
fs.exists (f, function (flExists) {
if (flExists) {
fs.stat (f, function (err, stats) {
if (err) {
callback (undefined);
}
else {
callback (new Date (stats.birthtime).toString ());
}
});
}
else {
callback (undefined);
}
});
}
function getAppUrl () { //11/13/15 by DW
var url = stringNthField (window.location.href, "?", 1);
url = stringNthField (url, "#", 1);
@ -1024,4 +1067,18 @@ function upperCaseFirstChar (s) { //11/15/15 by DW
s = stringUpper (s [0]) + stringDelete (s, 1, 1);
return (s);
}
function cacheConfuse (url) { //3/1/16 by DW
return (url + "?x=" + random (0, 10000000));
}
function equalStrings (s1, s2, flUnicase) { //4/7/16 by DW
if (flUnicase === undefined) {
flUnicase = true;
}
if (flUnicase) {
return (s1.toLowerCase () == s2.toLowerCase ());
}
else {
return (s1 == s2);
}
}

@ -20,7 +20,7 @@ var myVersion = "0.70b", myProductName = "PagePark";
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
structured listing: http://scripting.com/listings/pagepark.html
*/

Loading…
Cancel
Save