daveappserver 0.5.40 → 0.5.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/appserver.js +64 -26
- package/package.json +1 -1
- package/readme.md +10 -0
- package/readme.opml +8 -1
package/appserver.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var myVersion = "0.5.
|
|
1
|
+
var myVersion = "0.5.45", myProductName = "daveAppServer";
|
|
2
2
|
|
|
3
3
|
exports.start = startup;
|
|
4
4
|
exports.notifySocketSubscribers = notifySocketSubscribers;
|
|
@@ -282,6 +282,18 @@ function cleanFileStats (stats) { //4/19/21 by DW
|
|
|
282
282
|
});
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
+
function kissOtherLogonsGoodnight (screenname, theNewConnection) { //12/14/21 by DW
|
|
286
|
+
theWsServer.connections.forEach (function (conn, ix) {
|
|
287
|
+
if (conn.appData !== undefined) { //it's one of ours
|
|
288
|
+
if (conn != theNewConnection) { //it's not the new one
|
|
289
|
+
if (conn.appData.screenname == screenname) {
|
|
290
|
+
conn.sendText ("goodnight");
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
|
|
285
297
|
conn.on ("text", function (s) {
|
|
286
298
|
var words = s.split (" ");
|
|
287
299
|
if (words.length > 1) { //new protocol as of 11/29/15 by DW
|
|
@@ -300,6 +312,7 @@ function cleanFileStats (stats) { //4/19/21 by DW
|
|
|
300
312
|
conn.appData.urlToWatch = "";
|
|
301
313
|
davetwitter.getScreenName (token, secret, function (screenname) {
|
|
302
314
|
conn.appData.screenname = screenname;
|
|
315
|
+
kissOtherLogonsGoodnight (screenname, conn); //12/14/21 by DW
|
|
303
316
|
logToConsole (conn, conn.appData.lastVerb, conn.appData.screenname);
|
|
304
317
|
});
|
|
305
318
|
break;
|
|
@@ -365,6 +378,9 @@ function cleanFileStats (stats) { //4/19/21 by DW
|
|
|
365
378
|
}
|
|
366
379
|
else {
|
|
367
380
|
var url = (flprivate) ? undefined : config.urlServerForClient + screenname + "/" + relpath;
|
|
381
|
+
if (config.publishFile !== undefined) { //3/18/22 by DW
|
|
382
|
+
config.publishFile (f, screenname, relpath, type, flprivate, filetext, url);
|
|
383
|
+
}
|
|
368
384
|
if (!flprivate) {
|
|
369
385
|
notifySocketSubscribers ("update", filetext, true, function (conn) { //3/6/2 by DW -- payload is a string
|
|
370
386
|
if (conn.appData.urlToWatch == url) {
|
|
@@ -606,6 +622,10 @@ function cleanFileStats (stats) { //4/19/21 by DW
|
|
|
606
622
|
callback (err);
|
|
607
623
|
}
|
|
608
624
|
else {
|
|
625
|
+
if (config.publishFile !== undefined) { //3/18/22 by DW
|
|
626
|
+
var url = (flprivate) ? undefined : config.urlServerForClient + screenname + "/" + relpath;
|
|
627
|
+
config.publishFile (f, screenname, relpath, type, flprivate, filetext, url);
|
|
628
|
+
}
|
|
609
629
|
callback (undefined);
|
|
610
630
|
}
|
|
611
631
|
});
|
|
@@ -985,32 +1005,48 @@ function startup (options, callback) {
|
|
|
985
1005
|
}
|
|
986
1006
|
});
|
|
987
1007
|
}
|
|
988
|
-
function returnServerHomePage () {
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
if (config.addMacroToPagetable !== undefined) {
|
|
1008
|
-
config.addMacroToPagetable (pagetable);
|
|
1008
|
+
function returnServerHomePage (screenname) {
|
|
1009
|
+
function servePage (templatetext) {
|
|
1010
|
+
var pagetable = {
|
|
1011
|
+
productName: config.productName,
|
|
1012
|
+
productNameForDisplay: config.productNameForDisplay,
|
|
1013
|
+
version: config.version,
|
|
1014
|
+
urlServerForClient: config.urlServerForClient,
|
|
1015
|
+
urlWebsocketServerForClient: config.urlWebsocketServerForClient,
|
|
1016
|
+
flEnableLogin: config.flEnableLogin,
|
|
1017
|
+
prefsPath: config.prefsPath,
|
|
1018
|
+
docsPath: config.docsPath,
|
|
1019
|
+
idGitHubClient: config.githubClientId, //11/9/21 by DW
|
|
1020
|
+
screenname //4/30/22 by DW
|
|
1021
|
+
};
|
|
1022
|
+
if (theRequest.addToPagetable !== undefined) { //3/9/21 by DW
|
|
1023
|
+
for (var x in theRequest.addToPagetable) {
|
|
1024
|
+
pagetable [x] = theRequest.addToPagetable [x];
|
|
1009
1025
|
}
|
|
1010
|
-
var pagetext = utils.multipleReplaceAll (templatetext, pagetable, false, "[%", "%]");
|
|
1011
|
-
returnHtml (pagetext);
|
|
1012
1026
|
}
|
|
1013
|
-
|
|
1027
|
+
if (config.addMacroToPagetable !== undefined) {
|
|
1028
|
+
config.addMacroToPagetable (pagetable);
|
|
1029
|
+
}
|
|
1030
|
+
var pagetext = utils.multipleReplaceAll (templatetext.toString (), pagetable, false, "[%", "%]");
|
|
1031
|
+
returnHtml (pagetext);
|
|
1032
|
+
}
|
|
1033
|
+
if (config.pathServerHomePageSource !== undefined) {
|
|
1034
|
+
fs.readFile (config.pathServerHomePageSource, function (err, templatetext) {
|
|
1035
|
+
if (err) {
|
|
1036
|
+
console.log ("returnServerHomePage: err.message == " + err.message + ", f == " + config.pathServerHomePageSource);
|
|
1037
|
+
}
|
|
1038
|
+
else {
|
|
1039
|
+
servePage (templatetext);
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
else {
|
|
1044
|
+
request (config.urlServerHomePageSource, function (err, response, templatetext) {
|
|
1045
|
+
if (!err && response.statusCode == 200) {
|
|
1046
|
+
servePage (templatetext);
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1014
1050
|
}
|
|
1015
1051
|
function callWithScreenname (callback) {
|
|
1016
1052
|
davetwitter.getScreenName (token, secret, function (screenname) {
|
|
@@ -1061,7 +1097,9 @@ function startup (options, callback) {
|
|
|
1061
1097
|
case "get":
|
|
1062
1098
|
switch (theRequest.lowerpath) {
|
|
1063
1099
|
case "/":
|
|
1064
|
-
|
|
1100
|
+
callWithScreenname (function (screenname) {
|
|
1101
|
+
returnServerHomePage (screenname);
|
|
1102
|
+
});
|
|
1065
1103
|
return (true);
|
|
1066
1104
|
case "/now":
|
|
1067
1105
|
returnPlainText (new Date ());
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -52,6 +52,16 @@ The second section configures the HTTP server and the connection to Twitter for
|
|
|
52
52
|
|
|
53
53
|
### Updates
|
|
54
54
|
|
|
55
|
+
#### v0.5.45 -- 4/30/22 by DW
|
|
56
|
+
|
|
57
|
+
pagetable now contains the user's screenname. It's important that the addMacroToPagetable callback have access to the screenname, we need it to construct the url for the user's RSS feed in littleFeedReader.
|
|
58
|
+
|
|
59
|
+
#### v0.5.44 -- 3/18/22 by DW
|
|
60
|
+
|
|
61
|
+
New callback, config.publishFile. If defined we call back with the file, screenname, relpath, flprivate, filetext and the url of the file if it's public.
|
|
62
|
+
|
|
63
|
+
It's called when we handle a /publishfile or /writewholefile message.
|
|
64
|
+
|
|
55
65
|
#### v0.5.32 -- 12/4/21 by DW
|
|
56
66
|
|
|
57
67
|
Added a new callback, publicFileSaved, which is called when the user updates a public file.
|
package/readme.opml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<opml version="2.0">
|
|
3
3
|
<head>
|
|
4
4
|
<title>readme.md</title>
|
|
5
|
-
<dateModified
|
|
5
|
+
<dateModified>Sat, 30 Apr 2022 14:19:31 GMT</dateModified>
|
|
6
6
|
<expansionState></expansionState>
|
|
7
7
|
<vertScrollState>1</vertScrollState>
|
|
8
8
|
<windowTop>300</windowTop>
|
|
@@ -45,6 +45,13 @@
|
|
|
45
45
|
</outline>
|
|
46
46
|
</outline>
|
|
47
47
|
<outline created="Wed, 15 Sep 2021 14:19:02 GMT" text="### Updates">
|
|
48
|
+
<outline created="Sat, 30 Apr 2022 14:17:59 GMT" text="#### v0.5.45 -- 4/30/22 by DW">
|
|
49
|
+
<outline created="Sat, 30 Apr 2022 14:16:10 GMT" text="pagetable now contains the user's screenname. It's important that the addMacroToPagetable callback have access to the screenname, we need it to construct the url for the user's RSS feed in littleFeedReader. "></outline>
|
|
50
|
+
</outline>
|
|
51
|
+
<outline created="Fri, 18 Mar 2022 14:21:28 GMT" text="#### v0.5.44 -- 3/18/22 by DW">
|
|
52
|
+
<outline created="Fri, 18 Mar 2022 14:21:59 GMT" text="New callback, config.publishFile. If defined we call back with the file, screenname, relpath, flprivate, filetext and the url of the file if it's public."></outline>
|
|
53
|
+
<outline created="Fri, 18 Mar 2022 14:22:36 GMT" text="It's called when we handle a /publishfile or /writewholefile message."></outline>
|
|
54
|
+
</outline>
|
|
48
55
|
<outline created="Sat, 04 Dec 2021 21:29:57 GMT" text="#### v0.5.32 -- 12/4/21 by DW">
|
|
49
56
|
<outline created="Sat, 04 Dec 2021 21:30:33 GMT" text="Added a new callback, publicFileSaved, which is called when the user updates a public file. "></outline>
|
|
50
57
|
<outline created="Sat, 04 Dec 2021 21:29:58 GMT" text="Fixed a bug where a user couldn't create a new file if their public files folder was empty. "></outline>
|