Skip to content

Commit efb97ec

Browse files
committed
v0.9.11
1 parent 28301ea commit efb97ec

File tree

8 files changed

+177
-32
lines changed

8 files changed

+177
-32
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ You can also access it in <a href="http://api.nodestorage.io/api.js">api.nodesto
6262

6363
#### Updates
6464

65+
##### v0.9.11 - 4/14/20 by DW
66+
67+
Add new /myfiles call, requires authentication, and returns a zip archive containing the user's files. Only works if the storage is local, not on S3.
68+
6569
##### v0.9.10 - 3/6/20 by DW
6670

6771
Add new /disconnect call, requires authentication, and removes the user from the screen name cache. The need for this came up in the <a href="http://scripting.com/2019/03/24.html#a164643">development</a> of feedBase. Little Outliner calls this endpoint.

api.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* The MIT License (MIT)
22
3-
Copyright (c) 2014-2019 Dave Winer
3+
Copyright (c) 2014-2020 Dave Winer
44
55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -529,7 +529,7 @@ function twShortenUrl (longUrl, callback) { //8/25/14 by DW
529529
dataType: "json"
530530
});
531531
}
532-
function twGetUserFiles (flPrivate, callback) { //12/21/14 by DW
532+
function twGetUserFiles (flPrivate, callback) { //12/21/14 by DW -- get a list of the user's files
533533
if (flPrivate == undefined) {
534534
flPrivate = false;
535535
}
@@ -549,6 +549,24 @@ function twGetUserFiles (flPrivate, callback) { //12/21/14 by DW
549549
dataType: "json"
550550
});
551551
}
552+
function twDownloadUserFiles (callback) { //4/14/20 by DW -- get a zip file containing the user's files
553+
var paramtable = {
554+
oauth_token: localStorage.twOauthToken,
555+
oauth_token_secret: localStorage.twOauthTokenSecret
556+
}
557+
var url = twGetDefaultServer () + "myfiles?" + twBuildParamList (paramtable);
558+
$.ajax ({
559+
type: "GET",
560+
url: url,
561+
success: function (data) {
562+
callback (undefined, data);
563+
},
564+
error: function (status, something, otherthing) {
565+
console.log ("twDownloadUserFiles: error == " + JSON.stringify (status, undefined, 4));
566+
callback (status, undefined);
567+
}
568+
});
569+
}
552570
function twAddComment (snAuthor, idPost, urlOpmlFile, callback) { //2/21/15 by DW
553571
var paramtable = {
554572
oauth_token: localStorage.twOauthToken,

opml/api.opml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<body text="api.js">
1414
<outline text="/* The MIT License (MIT) ">
1515
<outline text=""></outline>
16-
<outline text="Copyright (c) 2014-2019 Dave Winer "></outline>
16+
<outline text="Copyright (c) 2014-2020 Dave Winer "></outline>
1717
<outline text=""></outline>
1818
<outline text="Permission is hereby granted, free of charge, to any person obtaining a copy"></outline>
1919
<outline text="of this software and associated documentation files (the &quot;Software&quot;), to deal"></outline>
@@ -814,7 +814,7 @@
814814
</outline>
815815
<outline text="}"></outline>
816816
</outline>
817-
<outline text="function twGetUserFiles (flPrivate, callback) { //12/21/14 by DW">
817+
<outline text="function twGetUserFiles (flPrivate, callback) { //12/21/14 by DW -- get a list of the user's files">
818818
<outline text="if (flPrivate == undefined) {">
819819
<outline text="flPrivate = false;"></outline>
820820
<outline text="}"></outline>
@@ -841,6 +841,30 @@
841841
</outline>
842842
<outline text="}"></outline>
843843
</outline>
844+
<outline text="function twDownloadUserFiles (callback) { //4/14/20 by DW -- get a zip file containing the user's files">
845+
<outline created="Sat, 09 Aug 2014 15:42:15 GMT" pgfnum="43199" text="var paramtable = {">
846+
<outline created="Sat, 09 Aug 2014 15:42:28 GMT" pgfnum="43203" text="oauth_token: localStorage.twOauthToken,"></outline>
847+
<outline created="Sat, 09 Aug 2014 15:42:43 GMT" pgfnum="43205" text="oauth_token_secret: localStorage.twOauthTokenSecret"></outline>
848+
<outline created="Sat, 09 Aug 2014 15:42:23 GMT" pgfnum="43202" text="}"></outline>
849+
</outline>
850+
<outline created="Sat, 09 Aug 2014 16:02:57 GMT" pgfnum="43215" text="var url = twGetDefaultServer () + &quot;myfiles?&quot; + twBuildParamList (paramtable);"></outline>
851+
<outline text="$.ajax ({">
852+
<outline text="type: &quot;GET&quot;,"></outline>
853+
<outline text="url: url,"></outline>
854+
<outline text="success: function (data) {">
855+
<outline text="callback (undefined, data);"></outline>
856+
<outline text="},"></outline>
857+
</outline>
858+
<outline text="error: function (status, something, otherthing) { ">
859+
<outline created="Wed, 12 Jun 2013 13:14:10 GMT" pgfnum="25848" text="console.log (&quot;twDownloadUserFiles: error == &quot; + JSON.stringify (status, undefined, 4));"></outline>
860+
<outline text="callback (status, undefined);"></outline>
861+
<outline text="}"></outline>
862+
</outline>
863+
<outline isComment="true" text="dataType: &quot;json&quot;"></outline>
864+
<outline text="});"></outline>
865+
</outline>
866+
<outline text="}"></outline>
867+
</outline>
844868
<outline text="function twAddComment (snAuthor, idPost, urlOpmlFile, callback) { //2/21/15 by DW">
845869
<outline isComment="true" text="Changes">
846870
<outline text="2/21/15; 11:30:47 AM by DW">

opml/package.opml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<outline text="&quot;name&quot;: &quot;nodestorage&quot;, "></outline>
1616
<outline text="&quot;description&quot;: &quot;A simple storage system based on Twitter identity.&quot;,"></outline>
1717
<outline text="&quot;author&quot;: &quot;Dave Winer &lt;dave@smallpicture.com&gt;&quot;,"></outline>
18-
<outline text="&quot;version&quot;: &quot;0.9.10&quot;,"></outline>
18+
<outline text="&quot;version&quot;: &quot;0.9.11&quot;,"></outline>
1919
<outline text="&quot;scripts&quot;: {">
2020
<outline text="&quot;start&quot;: &quot;node storage.js&quot;"></outline>
2121
<outline text="},"></outline>
@@ -34,6 +34,7 @@
3434
<outline text="&quot;request&quot;: &quot;*&quot;,"></outline>
3535
<outline text="&quot;simple-git&quot;: &quot;*&quot;,"></outline>
3636
<outline text="&quot;davefilesystem&quot;: &quot;*&quot;,"></outline>
37+
<outline text="&quot;davezip&quot;: &quot;*&quot;,"></outline>
3738
<outline text="&quot;daveutils&quot;: &quot;*&quot;"></outline>
3839
<outline text="}, "></outline>
3940
</outline>

opml/readme.opml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@
7474
<outline text="1. You may see the product referred to in docs and comments as *storage*. That's what it was called while it was in development. It's still a good descriptive name for what the app does."></outline>
7575
</outline>
7676
<outline text="#### Updates">
77+
<outline text="##### v0.9.11 - 4/14/20 by DW">
78+
<outline text="Add new /myfiles call, requires authentication, and returns a zip archive containing the user's files. Only works if the storage is local, not on S3. "></outline>
79+
</outline>
7780
<outline text="##### v0.9.10 - 3/6/20 by DW">
7881
<outline text="Add new /disconnect call, requires authentication, and removes the user from the screen name cache. The need for this came up in the &lt;a href=&quot;http://scripting.com/2019/03/24.html#a164643&quot;&gt;development&lt;/a&gt; of feedBase. Little Outliner calls this endpoint. "></outline>
7982
</outline>

opml/storage.opml

Lines changed: 70 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<windowRight>1500</windowRight>
1212
</head>
1313
<body text="storage.js">
14-
<outline created="Mon, 03 Feb 2014 03:21:03 GMT" pgfnum="36831" text="var myVersion = &quot;0.9.10&quot;, myProductName = &quot;nodeStorage&quot;; "></outline>
14+
<outline created="Mon, 03 Feb 2014 03:21:03 GMT" pgfnum="36831" text="var myVersion = &quot;0.9.11&quot;, myProductName = &quot;nodeStorage&quot;; "></outline>
1515
<outline text=""></outline>
1616
<outline text="/* The MIT License (MIT) ">
1717
<outline text=""></outline>
@@ -58,6 +58,7 @@
5858
<outline text="var os = require (&quot;os&quot;);"></outline>
5959
<outline text="var qs = require (&quot;querystring&quot;); //4/28/16 by DW"></outline>
6060
<outline text="var filesystem = require (&quot;davefilesystem&quot;); //3/2/20 by DW"></outline>
61+
<outline text="var zip = require (&quot;davezip&quot;); //4/13/20 by DW"></outline>
6162
<outline created="Tue, 15 Apr 2014 20:32:04 GMT" pgfnum="40038" text=""></outline>
6263
<outline text="//environment variables">
6364
<outline created="Sat, 01 Feb 2014 18:42:45 GMT" pgfnum="36699" text="var myPort = process.env.PORT;"></outline>
@@ -697,7 +698,7 @@
697698
<outline text="var maxLogLengthForClient = 50; //we won't return more than this number of log items to the client"></outline>
698699
<outline text="var flChatLogDirty = false, nameDirtyChatLog;"></outline>
699700
<outline text="var chatLogArray = new Array (); //10/26/15 by DW"></outline>
700-
<outline text=""></outline>
701+
<outline isComment="true" text=""></outline>
701702
<outline isComment="true" text="what's in a chatLogArray element?">
702703
<outline text="chatLog: array (one element for each top-level item in the log)"></outline>
703704
<outline text="prefs: struct (info about the chatlog, including &lt;i&gt;serialNum&lt;/i&gt; for the ID of the next item added)"></outline>
@@ -807,7 +808,6 @@
807808
</outline>
808809
</outline>
809810
<outline text=""></outline>
810-
<outline text=""></outline>
811811
<outline text="function initChatLogStats (name) { //1/20/16 by DW">
812812
<outline text="if (serverStats.chatLogStats.logStats [name] === undefined) {">
813813
<outline text="serverStats.chatLogStats.logStats [name] = {">
@@ -1675,8 +1675,6 @@
16751675
<outline text="return (undefined); //didn't find the item"></outline>
16761676
<outline text="}"></outline>
16771677
</outline>
1678-
<outline text=""></outline>
1679-
<outline text=""></outline>
16801678
<outline text="function getMonthChatLogPosts (nameChatLog, monthnum, yearnum) { //5/31/16 by DW">
16811679
<outline text="var theLog = findChatLog (nameChatLog), jstruct = new Array ();"></outline>
16821680
<outline text="if (theLog === undefined) {">
@@ -1703,8 +1701,6 @@
17031701
<outline text="return (jstruct);"></outline>
17041702
<outline text="}"></outline>
17051703
</outline>
1706-
<outline text=""></outline>
1707-
<outline text=""></outline>
17081704
<outline text="function getChatLogIndex (nameChatLog) { //1/2/16 by DW">
17091705
<outline isComment="true" text="Changes">
17101706
<outline text="5/6/16; 11:16:50 AM by DW">
@@ -2327,8 +2323,6 @@
23272323
</outline>
23282324
<outline text="}"></outline>
23292325
</outline>
2330-
<outline text=""></outline>
2331-
<outline text=""></outline>
23322326
</outline>
23332327
<outline text="//webhooks -- 8/28/15 by DW">
23342328
<outline text="var webhooks = {">
@@ -3259,6 +3253,35 @@
32593253
<outline text="}"></outline>
32603254
</outline>
32613255
</outline>
3256+
<outline text="//zip archive of user data -- 4/13/20 by DW">
3257+
<outline text="function getUserData (screenName, callback) { //4/14/20 by DW">
3258+
<outline text="if (flLocalFilesystem) {">
3259+
<outline text="const tmpfolder = &quot;tmp/&quot;, archivefile = tmpfolder + screenName + &quot;.zip&quot;; "></outline>
3260+
<outline text="utils.sureFilePath (archivefile, function () {">
3261+
<outline text="var theArchive = zip.createArchive (archivefile, function (err, data) {">
3262+
<outline text="if (callback !== undefined) {">
3263+
<outline text="callback (err, archivefile);"></outline>
3264+
<outline text="}"></outline>
3265+
</outline>
3266+
<outline text="});"></outline>
3267+
</outline>
3268+
<outline text="var pathPublicFiles = s3Path + &quot;users/&quot; + screenName + &quot;/&quot;;"></outline>
3269+
<outline text="var pathPrivateFiles = s3PrivatePath + &quot;users/&quot; + screenName + &quot;/&quot;;"></outline>
3270+
<outline isComment="true" text="console.log (&quot;archiveUser: pathPublicFiles == &quot; + pathPublicFiles);"></outline>
3271+
<outline text="theArchive.addDirectoryToArchive (pathPublicFiles, &quot;Public Files&quot;);"></outline>
3272+
<outline text="theArchive.addDirectoryToArchive (pathPrivateFiles, &quot;Private Files&quot;);"></outline>
3273+
<outline text="theArchive.finalize ();"></outline>
3274+
<outline text="});"></outline>
3275+
</outline>
3276+
<outline text="}"></outline>
3277+
</outline>
3278+
<outline text="else {">
3279+
<outline text="callback ({message: &quot;Can't return the user's files because the server isn't using a local file system.&quot;});"></outline>
3280+
<outline text="}"></outline>
3281+
</outline>
3282+
<outline text="}"></outline>
3283+
</outline>
3284+
</outline>
32623285
<outline text=""></outline>
32633286
<outline text="function everyMinute () {">
32643287
<outline text="var now = new Date ();"></outline>
@@ -3499,7 +3522,20 @@
34993522
<outline text="httpResponse.end (utils.jsonStringify (data)); "></outline>
35003523
<outline created="Sat, 21 Jun 2014 14:43:44 GMT" pgfnum="42368" text="}"></outline>
35013524
</outline>
3502-
<outline text=""></outline>
3525+
<outline text="function returnZipFile (f) { //4/13/20 by DW">
3526+
<outline text="fs.readFile (f, function (err, data) {">
3527+
<outline text="if (err) {">
3528+
<outline text="errorResponse (err);"></outline>
3529+
<outline text="}"></outline>
3530+
</outline>
3531+
<outline text="else {">
3532+
<outline text="doHttpReturn (200, &quot;application/zip&quot;, data);"></outline>
3533+
<outline text="}"></outline>
3534+
</outline>
3535+
<outline text="});"></outline>
3536+
</outline>
3537+
<outline text="}"></outline>
3538+
</outline>
35033539
<outline text="function requestHomeFile (lowerpath, callback) { //3/19/16 by DW">
35043540
<outline text="if (urlHomePageContent === undefined) {">
35053541
<outline text="callback ({message: &quot;Can't get the file because the server isn't configured for it.&quot;});"></outline>
@@ -4967,7 +5003,6 @@
49675003
</outline>
49685004
<outline text="break;"></outline>
49695005
</outline>
4970-
<outline text=""></outline>
49715006
<outline text="case &quot;/chat.css&quot;: //3/19/16 by DW">
49725007
<outline text="requestHomeFile (lowerpath, function (err, data) {">
49735008
<outline created="Mon, 21 Apr 2014 23:12:55 GMT" pgfnum="40408" text="if (err) {">
@@ -5049,7 +5084,6 @@
50495084
</outline>
50505085
<outline created="Wed, 22 Jan 2014 15:18:30 GMT" pgfnum="36266" text="break;"></outline>
50515086
</outline>
5052-
<outline text=""></outline>
50535087
<outline text="case &quot;/getmonthchatmessages&quot;: //5/31/16 by DW">
50545088
<outline text="var monthnum = parsedUrl.query.monthnum;"></outline>
50555089
<outline text="var yearnum = parsedUrl.query.yearnum;"></outline>
@@ -5069,7 +5103,30 @@
50695103
<outline text=""></outline>
50705104
<outline text="break;"></outline>
50715105
</outline>
5072-
<outline text=""></outline>
5106+
<outline text="case &quot;/myfiles&quot;: //4/14/20 by DW">
5107+
<outline created="Wed, 09 Jul 2014 23:57:16 GMT" pgfnum="42784" text="getScreenName (parsedUrl.query.oauth_token, parsedUrl.query.oauth_token_secret, function (screenName) {">
5108+
<outline created="Thu, 10 Jul 2014 00:53:00 GMT" pgfnum="42793" text="if (screenName === undefined) {">
5109+
<outline text="errorResponse ({message: &quot;Can't get the user's data because the access token is not valid.&quot;}); "></outline>
5110+
<outline created="Thu, 10 Jul 2014 00:53:11 GMT" pgfnum="42797" text="}"></outline>
5111+
</outline>
5112+
<outline created="Thu, 10 Jul 2014 00:53:12 GMT" pgfnum="42798" text="else {">
5113+
<outline text="getUserData (screenName, function (err, zipfile) {">
5114+
<outline text="if (err) {">
5115+
<outline text="errorResponse (err);"></outline>
5116+
<outline text="}"></outline>
5117+
</outline>
5118+
<outline text="else {">
5119+
<outline text="returnZipFile (zipfile);"></outline>
5120+
<outline text="}"></outline>
5121+
</outline>
5122+
<outline text="});"></outline>
5123+
</outline>
5124+
<outline created="Thu, 10 Jul 2014 00:53:14 GMT" pgfnum="42799" text="}"></outline>
5125+
</outline>
5126+
<outline created="Wed, 09 Jul 2014 23:57:25 GMT" pgfnum="42785" text="});"></outline>
5127+
</outline>
5128+
<outline text="break;"></outline>
5129+
</outline>
50735130
<outline isComment="true" text="case &quot;/test1&quot;: //10/27/15 by DW">
50745131
<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) {">
50755132
<outline text="if (err) {">

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nodestorage",
33
"description": "A simple storage system based on Twitter identity.",
44
"author": "Dave Winer <dave@smallpicture.com>",
5-
"version": "0.9.10",
5+
"version": "0.9.11",
66
"scripts": {
77
"start": "node storage.js"
88
},
@@ -18,6 +18,7 @@
1818
"request": "*",
1919
"simple-git": "*",
2020
"davefilesystem": "*",
21+
"davezip": "*",
2122
"daveutils": "*"
2223
},
2324
"license": "MIT",

0 commit comments

Comments
 (0)