Skip to content

Commit 3149d96

Browse files
committed
v0.94
1 parent 76283db commit 3149d96

File tree

4 files changed

+195
-33
lines changed

4 files changed

+195
-33
lines changed

api.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,40 @@ function twGetComments (snAuthor, idPost, callback) {
824824
}
825825
});
826826
}
827+
828+
829+
function twGetMonthChatMessages (theMonth, nameChatLog, callback) { //5/31/16 by DW
830+
var paramtable = {
831+
oauth_token: localStorage.twOauthToken,
832+
oauth_token_secret: localStorage.twOauthTokenSecret,
833+
monthnum: theMonth.getMonth (),
834+
yearnum: theMonth.getFullYear (),
835+
chatLog: nameChatLog
836+
}
837+
var url = twGetDefaultServer () + "getmonthchatmessages?" + twBuildParamList (paramtable);
838+
$.ajax ({
839+
type: "GET",
840+
url: url,
841+
success: function (data) {
842+
if (callback != undefined) {
843+
callback (undefined, data);
844+
}
845+
},
846+
error: function (status, something, otherthing) {
847+
console.log ("twGetMonthChatMessages: error == " + JSON.stringify (status, undefined, 4));
848+
if (callback != undefined) {
849+
var err = {
850+
code: status.status,
851+
message: JSON.parse (status.responseText).message
852+
};
853+
callback (err, undefined);
854+
}
855+
},
856+
dataType: "json"
857+
});
858+
}
859+
860+
827861
function twChatLike (id, nameChatLog, callback) { //9/27/15 by DW
828862
var paramtable = {
829863
oauth_token: localStorage.twOauthToken,

opml/api.opml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,48 @@
12061206
</outline>
12071207
<outline text="}"></outline>
12081208
</outline>
1209+
<outline text=""></outline>
1210+
<outline text=""></outline>
1211+
<outline text="function twGetMonthChatMessages (theMonth, nameChatLog, callback) { //5/31/16 by DW">
1212+
<outline created="Sat, 09 Aug 2014 15:42:15 GMT" pgfnum="43199" text="var paramtable = {">
1213+
<outline created="Sat, 09 Aug 2014 15:42:28 GMT" pgfnum="43203" text="oauth_token: localStorage.twOauthToken,"></outline>
1214+
<outline created="Sat, 09 Aug 2014 15:42:43 GMT" pgfnum="43205" text="oauth_token_secret: localStorage.twOauthTokenSecret,"></outline>
1215+
<outline text="monthnum: theMonth.getMonth (),"></outline>
1216+
<outline text="yearnum: theMonth.getFullYear (),"></outline>
1217+
<outline text="chatLog: nameChatLog"></outline>
1218+
<outline created="Sat, 09 Aug 2014 15:42:23 GMT" pgfnum="43202" text="}"></outline>
1219+
</outline>
1220+
<outline created="Sat, 09 Aug 2014 16:02:57 GMT" pgfnum="43215" text="var url = twGetDefaultServer () + &quot;getmonthchatmessages?&quot; + twBuildParamList (paramtable);"></outline>
1221+
<outline text="$.ajax ({">
1222+
<outline text="type: &quot;GET&quot;,"></outline>
1223+
<outline text="url: url,"></outline>
1224+
<outline text="success: function (data) {">
1225+
<outline text="if (callback != undefined) {">
1226+
<outline text="callback (undefined, data);"></outline>
1227+
<outline text="}"></outline>
1228+
</outline>
1229+
<outline text="},"></outline>
1230+
</outline>
1231+
<outline text="error: function (status, something, otherthing) { ">
1232+
<outline created="Wed, 12 Jun 2013 13:14:10 GMT" pgfnum="25848" text="console.log (&quot;twGetMonthChatMessages: error == &quot; + JSON.stringify (status, undefined, 4));"></outline>
1233+
<outline text="if (callback != undefined) {">
1234+
<outline text="var err = {">
1235+
<outline text="code: status.status,"></outline>
1236+
<outline text="message: JSON.parse (status.responseText).message"></outline>
1237+
<outline text="};"></outline>
1238+
</outline>
1239+
<outline text="callback (err, undefined);"></outline>
1240+
<outline text="}"></outline>
1241+
</outline>
1242+
<outline text="},"></outline>
1243+
</outline>
1244+
<outline text="dataType: &quot;json&quot;"></outline>
1245+
<outline text="});"></outline>
1246+
</outline>
1247+
<outline text="}"></outline>
1248+
</outline>
1249+
<outline text=""></outline>
1250+
<outline text=""></outline>
12091251
<outline text="function twChatLike (id, nameChatLog, callback) { //9/27/15 by DW">
12101252
<outline created="Sat, 09 Aug 2014 15:42:15 GMT" pgfnum="43199" text="var paramtable = {">
12111253
<outline created="Sat, 09 Aug 2014 15:42:28 GMT" pgfnum="43203" text="oauth_token: localStorage.twOauthToken,"></outline>

opml/storage.opml

Lines changed: 68 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<outline text="*/"></outline>
3838
</outline>
3939
<outline text=""></outline>
40-
<outline created="Mon, 03 Feb 2014 03:21:03 GMT" pgfnum="36831" text="var myVersion = &quot;0.94t&quot;, myProductName = &quot;nodeStorage&quot;; "></outline>
40+
<outline created="Mon, 03 Feb 2014 03:21:03 GMT" pgfnum="36831" text="var myVersion = &quot;0.94u&quot;, myProductName = &quot;nodeStorage&quot;; "></outline>
4141
<outline created="Tue, 15 Apr 2014 20:31:53 GMT" pgfnum="40037" text=""></outline>
4242
<outline created="Thu, 26 Dec 2013 23:02:58 GMT" pgfnum="34549" text="var http = require (&quot;http&quot;); "></outline>
4343
<outline created="Tue, 21 Jan 2014 00:09:23 GMT" pgfnum="36074" text="var urlpack = require (&quot;url&quot;);"></outline>
@@ -582,13 +582,25 @@
582582
<outline text="}"></outline>
583583
</outline>
584584
<outline text="function loadStruct (fname, struct, callback) {">
585+
<outline isComment="true" text="Changes">
586+
<outline text="6/1/16; 10:06:14 AM by DW">
587+
<outline text="Make the JSON.parse call in a try so an error in the stats file doesn't kill the server at startup. This seems to happen when the disk got full somehow so there will quite possibly be other problems. "></outline>
588+
</outline>
589+
</outline>
585590
<outline created="Wed, 22 Jan 2014 23:07:46 GMT" pgfnum="36412" text="store.getObject (s3Path + fname, function (error, data) {">
586591
<outline text="if (!error) {">
587592
<outline created="Thu, 23 Jan 2014 18:37:27 GMT" pgfnum="36463" text="if (data != null) {">
588-
<outline created="Thu, 23 Jan 2014 16:59:39 GMT" pgfnum="36438" text="var oldStruct = JSON.parse (data.Body);"></outline>
589-
<outline created="Sun, 27 Apr 2014 18:34:38 GMT" pgfnum="40531" text="for (var x in oldStruct) { ">
590-
<outline created="Tue, 05 Nov 2013 16:12:39 GMT" pgfnum="30856" text="struct [x] = oldStruct [x];"></outline>
591-
<outline created="Sun, 27 Apr 2014 18:36:17 GMT" pgfnum="40538" text="}"></outline>
593+
<outline text="try {">
594+
<outline created="Thu, 23 Jan 2014 16:59:39 GMT" pgfnum="36438" text="var oldStruct = JSON.parse (data.Body);"></outline>
595+
<outline created="Sun, 27 Apr 2014 18:34:38 GMT" pgfnum="40531" text="for (var x in oldStruct) { ">
596+
<outline created="Tue, 05 Nov 2013 16:12:39 GMT" pgfnum="30856" text="struct [x] = oldStruct [x];"></outline>
597+
<outline created="Sun, 27 Apr 2014 18:36:17 GMT" pgfnum="40538" text="}"></outline>
598+
</outline>
599+
<outline text="}"></outline>
600+
</outline>
601+
<outline text="catch (err) {">
602+
<outline text="console.log (&quot;loadStruct: error reading file \&quot;&quot; + fname + &quot;\&quot;, err.message == &quot; + err.message + &quot;\n&quot;);"></outline>
603+
<outline text="}"></outline>
592604
</outline>
593605
<outline created="Thu, 23 Jan 2014 18:37:33 GMT" pgfnum="36464" text="}"></outline>
594606
</outline>
@@ -624,28 +636,6 @@
624636
</outline>
625637
<outline text="});"></outline>
626638
</outline>
627-
<outline created="Wed, 22 Jan 2014 23:07:46 GMT" isComment="true" pgfnum="36412" text="store.getObject (s3Path + fnameStats, function (error, data) { //5/18/14 by DW -- this changed, got a new &lt;i&gt;error&lt;/i&gt; parameter. ">
628-
<outline created="Thu, 23 Jan 2014 18:37:27 GMT" pgfnum="36463" text="if (data != null) {">
629-
<outline created="Thu, 23 Jan 2014 16:59:39 GMT" pgfnum="36438" text="var oldServerStats = JSON.parse (data.Body);"></outline>
630-
<outline created="Sun, 27 Apr 2014 18:34:38 GMT" pgfnum="40531" text="for (var x in oldServerStats) { ">
631-
<outline created="Sun, 27 Apr 2014 18:45:30 GMT" pgfnum="40540" text="if (x != &quot;httpLog&quot;) {">
632-
<outline created="Tue, 05 Nov 2013 16:12:39 GMT" pgfnum="30856" text="serverStats [x] = oldServerStats [x];"></outline>
633-
<outline created="Sun, 27 Apr 2014 18:45:38 GMT" pgfnum="40541" text="}"></outline>
634-
</outline>
635-
<outline created="Sun, 27 Apr 2014 18:36:17 GMT" pgfnum="40538" text="}"></outline>
636-
</outline>
637-
<outline created="Thu, 23 Jan 2014 18:37:33 GMT" pgfnum="36464" text="}"></outline>
638-
</outline>
639-
<outline created="Tue, 11 Feb 2014 22:44:56 GMT" pgfnum="37502" text="serverStats.ctHitsThisRun = 0;"></outline>
640-
<outline created="Tue, 11 Feb 2014 22:44:56 GMT" pgfnum="37502" text="serverStats.ctTweetsThisRun = 0;"></outline>
641-
<outline text="serverStats.whenServerStart = new Date ();"></outline>
642-
<outline created="Mon, 28 Apr 2014 16:36:47 GMT" pgfnum="40619" text="serverStats.ctServerStarts++;"></outline>
643-
<outline text="if (callback != undefined) {">
644-
<outline text="callback ();"></outline>
645-
<outline text="}"></outline>
646-
</outline>
647-
<outline created="Wed, 22 Jan 2014 23:07:55 GMT" pgfnum="36413" text="});"></outline>
648-
</outline>
649639
<outline created="Tue, 11 Feb 2014 22:39:47 GMT" pgfnum="37500" text="}"></outline>
650640
</outline>
651641
<outline created="Sun, 27 Apr 2014 18:57:52 GMT" pgfnum="40558" text="function saveServerStats () {">
@@ -1681,6 +1671,36 @@
16811671
<outline text="return (undefined); //didn't find the item"></outline>
16821672
<outline text="}"></outline>
16831673
</outline>
1674+
<outline text=""></outline>
1675+
<outline text=""></outline>
1676+
<outline text="function getMonthChatLogPosts (nameChatLog, monthnum, yearnum) { //5/31/16 by DW">
1677+
<outline text="var theLog = findChatLog (nameChatLog), jstruct = new Array ();"></outline>
1678+
<outline text="if (theLog === undefined) {">
1679+
<outline text="return (undefined);"></outline>
1680+
<outline text="}"></outline>
1681+
</outline>
1682+
<outline text=""></outline>
1683+
<outline text="var theMonth = new Date ();"></outline>
1684+
<outline text="theMonth.setSeconds (0);"></outline>
1685+
<outline text="theMonth.setMinutes (0);"></outline>
1686+
<outline text="theMonth.setHours (0);"></outline>
1687+
<outline text="theMonth.setDate (1);"></outline>
1688+
<outline text="theMonth.setMonth (monthnum);"></outline>
1689+
<outline text="theMonth.setFullYear (yearnum);"></outline>
1690+
<outline text=""></outline>
1691+
<outline text="for (var i = 0; i &lt; theLog.chatLog.length; i++) {">
1692+
<outline text="if (utils.sameMonth (new Date (theLog.chatLog [i].when), theMonth)) {">
1693+
<outline text="jstruct [jstruct.length] = theLog.chatLog [i];"></outline>
1694+
<outline text="}"></outline>
1695+
</outline>
1696+
<outline text="}"></outline>
1697+
</outline>
1698+
<outline text=""></outline>
1699+
<outline text="return (jstruct);"></outline>
1700+
<outline text="}"></outline>
1701+
</outline>
1702+
<outline text=""></outline>
1703+
<outline text=""></outline>
16841704
<outline text="function getChatLogIndex (nameChatLog) { //1/2/16 by DW">
16851705
<outline isComment="true" text="Changes">
16861706
<outline text="5/6/16; 11:16:50 AM by DW">
@@ -4671,7 +4691,7 @@
46714691
<outline text="break;"></outline>
46724692
</outline>
46734693
<outline text="case &quot;/getchatmessage&quot;: //9/20/15 by DW">
4674-
<outline text="var nameChatLog = parsedUrl.query.chatLog; //10/26/15 by DW -- yyy"></outline>
4694+
<outline text="var nameChatLog = parsedUrl.query.chatLog; //10/26/15 by DW"></outline>
46754695
<outline text="findChatMessage (nameChatLog, parsedUrl.query.id, function (flFound, item, subs, theTopItem) {">
46764696
<outline text="if (flFound) {">
46774697
<outline created="Sat, 21 Jun 2014 14:43:33 GMT" pgfnum="42366" text="dataResponse ({">
@@ -4914,6 +4934,26 @@
49144934
<outline created="Wed, 22 Jan 2014 15:18:30 GMT" pgfnum="36266" text="break;"></outline>
49154935
</outline>
49164936
<outline text=""></outline>
4937+
<outline text="case &quot;/getmonthchatmessages&quot;: //5/31/16 by DW">
4938+
<outline text="var monthnum = parsedUrl.query.monthnum;"></outline>
4939+
<outline text="var yearnum = parsedUrl.query.yearnum;"></outline>
4940+
<outline text="var nameChatLog = parsedUrl.query.chatLog; "></outline>
4941+
<outline isComment="true" text=""></outline>
4942+
<outline isComment="true" text="console.log (&quot;/getmonthchatmessages: monthnum == &quot; + monthnum + &quot;, yearnum == &quot; + yearnum + &quot;, nameChatLog == &quot; + nameChatLog);"></outline>
4943+
<outline text=""></outline>
4944+
<outline text="var jstruct = getMonthChatLogPosts (nameChatLog, monthnum, yearnum);"></outline>
4945+
<outline text="if (jstruct === undefined) {">
4946+
<outline text="errorResponse ({message: &quot;Can't get chatlog items for month # &quot; + monthnum + &quot; in &quot; + yearnum + &quot; because the chatlog doesn't exist or the posts don't.&quot;});"></outline>
4947+
<outline text="}"></outline>
4948+
</outline>
4949+
<outline text="else {">
4950+
<outline created="Thu, 26 Jun 2014 12:29:46 GMT" pgfnum="42486" text="dataResponse (jstruct);"></outline>
4951+
<outline text="}"></outline>
4952+
</outline>
4953+
<outline text=""></outline>
4954+
<outline text="break;"></outline>
4955+
</outline>
4956+
<outline text=""></outline>
49174957
<outline isComment="true" text="case &quot;/test1&quot;: //10/27/15 by DW">
49184958
<outline text="postChatMessage (&quot;davewiner&quot;, &quot;blork&quot;, &quot;Oh the buzzing of the bees&quot;, undefined, undefined, undefined, undefined, true, function (err, idMessage) {">
49194959
<outline text="if (err) {">

storage.js

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
structured listing: http://scripting.com/listings/storage.html
2424
*/
2525

26-
var myVersion = "0.94t", myProductName = "nodeStorage";
26+
var myVersion = "0.94u", myProductName = "nodeStorage";
2727

2828
var http = require ("http");
2929
var urlpack = require ("url");
@@ -362,9 +362,14 @@ function httpReadUrl (url, callback) {
362362
store.getObject (s3Path + fname, function (error, data) {
363363
if (!error) {
364364
if (data != null) {
365-
var oldStruct = JSON.parse (data.Body);
366-
for (var x in oldStruct) {
367-
struct [x] = oldStruct [x];
365+
try {
366+
var oldStruct = JSON.parse (data.Body);
367+
for (var x in oldStruct) {
368+
struct [x] = oldStruct [x];
369+
}
370+
}
371+
catch (err) {
372+
console.log ("loadStruct: error reading file \"" + fname + "\", err.message == " + err.message + "\n");
368373
}
369374
}
370375
}
@@ -956,6 +961,32 @@ function httpReadUrl (url, callback) {
956961
}
957962
return (undefined); //didn't find the item
958963
}
964+
965+
966+
function getMonthChatLogPosts (nameChatLog, monthnum, yearnum) { //5/31/16 by DW
967+
var theLog = findChatLog (nameChatLog), jstruct = new Array ();
968+
if (theLog === undefined) {
969+
return (undefined);
970+
}
971+
972+
var theMonth = new Date ();
973+
theMonth.setSeconds (0);
974+
theMonth.setMinutes (0);
975+
theMonth.setHours (0);
976+
theMonth.setDate (1);
977+
theMonth.setMonth (monthnum);
978+
theMonth.setFullYear (yearnum);
979+
980+
for (var i = 0; i < theLog.chatLog.length; i++) {
981+
if (utils.sameMonth (new Date (theLog.chatLog [i].when), theMonth)) {
982+
jstruct [jstruct.length] = theLog.chatLog [i];
983+
}
984+
}
985+
986+
return (jstruct);
987+
}
988+
989+
959990
function getChatLogIndex (nameChatLog) { //1/2/16 by DW
960991
var theLog = findChatLog (nameChatLog), jstruct = new Array (), ct = 0;
961992
if (theLog === undefined) {
@@ -2961,7 +2992,7 @@ function handleHttpRequest (httpRequest, httpResponse) {
29612992
dataResponse (getChatLogList ());
29622993
break;
29632994
case "/getchatmessage": //9/20/15 by DW
2964-
var nameChatLog = parsedUrl.query.chatLog; //10/26/15 by DW -- yyy
2995+
var nameChatLog = parsedUrl.query.chatLog; //10/26/15 by DW
29652996
findChatMessage (nameChatLog, parsedUrl.query.id, function (flFound, item, subs, theTopItem) {
29662997
if (flFound) {
29672998
dataResponse ({
@@ -3142,6 +3173,21 @@ function handleHttpRequest (httpRequest, httpResponse) {
31423173
});
31433174
break;
31443175

3176+
case "/getmonthchatmessages": //5/31/16 by DW
3177+
var monthnum = parsedUrl.query.monthnum;
3178+
var yearnum = parsedUrl.query.yearnum;
3179+
var nameChatLog = parsedUrl.query.chatLog;
3180+
3181+
var jstruct = getMonthChatLogPosts (nameChatLog, monthnum, yearnum);
3182+
if (jstruct === undefined) {
3183+
errorResponse ({message: "Can't get chatlog items for month # " + monthnum + " in " + yearnum + " because the chatlog doesn't exist or the posts don't."});
3184+
}
3185+
else {
3186+
dataResponse (jstruct);
3187+
}
3188+
3189+
break;
3190+
31453191
default:
31463192
var path = parsedUrl.pathname;
31473193

0 commit comments

Comments
 (0)