cloudcms-server 3.3.1-beta.0 → 3.3.1-beta.11

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.
Files changed (38) hide show
  1. package/.last_command +7 -0
  2. package/broadcast/providers/redis.js +32 -57
  3. package/clients/nrp.js +117 -0
  4. package/clients/redis.js +48 -0
  5. package/duster/helpers/sample/nyt.js +6 -7
  6. package/framework/controllers.js +0 -1
  7. package/index.js +23 -13
  8. package/insight/insight.js +6 -9
  9. package/locks/providers/redis.js +29 -58
  10. package/middleware/admin/admin.js +4 -4
  11. package/middleware/awareness/awareness.js +4 -1
  12. package/middleware/awareness/plugins/editorial.js +41 -66
  13. package/middleware/awareness/plugins/resources.js +74 -0
  14. package/middleware/awareness/providers/redis.js +263 -237
  15. package/middleware/cache/providers/redis.js +134 -92
  16. package/middleware/config/config.js +41 -2
  17. package/middleware/deployment/deployment.js +19 -27
  18. package/middleware/form/form.js +18 -33
  19. package/middleware/modules/modules.js +64 -11
  20. package/middleware/proxy/proxy.js +1 -2
  21. package/middleware/stores/engines/s3.js +0 -2
  22. package/middleware/stores/stores.js +50 -6
  23. package/middleware/themes/themes.js +49 -0
  24. package/middleware/virtual-config/virtual-config.js +35 -39
  25. package/notifications/notifications.js +75 -2
  26. package/package.json +18 -20
  27. package/server/index.js +105 -23
  28. package/server/standalone.js +2 -0
  29. package/util/auth.js +10 -14
  30. package/util/cloudcms.js +22 -37
  31. package/util/proxy-factory.js +20 -8
  32. package/util/redis.js +113 -0
  33. package/util/renditions.js +11 -17
  34. package/util/request.js +117 -0
  35. package/util/util.js +31 -40
  36. package/web/socket.io/socket.io.js +4240 -2
  37. package/web/cms/ice.js +0 -109
  38. package/web/cms/preview.js +0 -106
@@ -3,34 +3,31 @@ exports = module.exports = {};
3
3
  var util = require("../../../util/util");
4
4
  var socketUtil = require("../../../util/socket");
5
5
 
6
- var request = require("request");
7
-
8
- var http = require("http");
9
- var https = require("https");
6
+ var request = require("../../../util/request");
10
7
 
11
8
  exports.bindSocket = function(socket, provider)
12
9
  {
13
10
  socketUtil.bindGitana(socket, function() {
14
11
 
15
- socket.on("acquireEditorialSession", function(sessionKey, repositoryId, branchId, force, callback) {
16
- acquireEditorialSession(socket, provider, sessionKey, repositoryId, branchId, force, callback);
12
+ socket.on("acquireEditorialWorkspace", function(sessionKey, repositoryId, branchId, type, force, callback) {
13
+ acquireEditorialWorkspace(socket, provider, sessionKey, repositoryId, branchId, type, force, callback);
17
14
  });
18
15
 
19
- socket.on("releaseEditorialSession", function(sessionKey, repositoryId, branchId, callback) {
20
- releaseEditorialSession(socket, provider, sessionKey, repositoryId, branchId, callback);
16
+ socket.on("releaseEditorialWorkspace", function(sessionKey, repositoryId, branchId, callback) {
17
+ releaseEditorialWorkspace(socket, provider, sessionKey, repositoryId, branchId, callback);
21
18
  });
22
19
 
23
- socket.on("commitEditorialSession", function(sessionKey, repositoryId, branchId, callback) {
24
- commitEditorialSession(socket, provider, sessionKey, repositoryId, branchId, callback);
20
+ socket.on("commitEditorialWorkspace", function(sessionKey, repositoryId, branchId, callback) {
21
+ commitEditorialWorkspace(socket, provider, sessionKey, repositoryId, branchId, callback);
25
22
  });
26
23
 
27
- socket.on("editorialSessionInfo", function(sessionKey, repositoryId, branchId, callback) {
28
- editorialSessionInfo(socket, provider, sessionKey, repositoryId, branchId, callback);
24
+ socket.on("editorialWorkspaceInfo", function(sessionKey, repositoryId, branchId, callback) {
25
+ editorialWorkspaceInfo(socket, provider, sessionKey, repositoryId, branchId, callback);
29
26
  });
30
27
 
31
28
  /**
32
- * Acquires an editorial session. If a session doesn't already exists, it is created.
33
- * If a session already exists, it is reused unless `force` is set true.
29
+ * Acquires an editorial workspace. If a workspace doesn't already exists, it is created.
30
+ * If a workspace already exists, it is reused unless `force` is set true.
34
31
  *
35
32
  * @param socket
36
33
  * @param provider
@@ -38,12 +35,13 @@ exports.bindSocket = function(socket, provider)
38
35
  * @param repositoryId
39
36
  * @param branchId
40
37
  * @param force
38
+ * @param type (either "TEMPORARY" or "AUTOSAVE", assume "TEMPORARY" if not provided)
41
39
  * @param callback
42
40
  */
43
- var acquireEditorialSession = function(socket, provider, sessionKey, repositoryId, branchId, force, callback)
41
+ var acquireEditorialWorkspace = function(socket, provider, sessionKey, repositoryId, branchId, type, force, callback)
44
42
  {
45
- // send an HTTP command to acquire an editorial session for this repository and branch
46
- var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT) + "/oneteam/editorial/session/acquire";
43
+ // send an HTTP command to acquire an editorial workspace for this repository and branch
44
+ var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH) + "/oneteam/editorial/workspace/acquire";
47
45
 
48
46
  var headers = {};
49
47
  //headers["Authorization"] = socket.gitana.platform().getDriver().getHttpHeaders()["Authorization"];
@@ -57,39 +55,37 @@ exports.bindSocket = function(socket, provider)
57
55
  json.repositoryId = repositoryId;
58
56
  json.branchId = branchId;
59
57
  json.key = sessionKey;
58
+ json.type = type;
59
+
60
+ if (!json.type) {
61
+ json.type = "TEMPORARY";
62
+ }
60
63
 
61
64
  var qs = {};
62
65
  if (force) {
63
66
  qs["force"] = true;
64
67
  }
65
68
 
66
- var agent = http.globalAgent;
67
- if (process.env.GITANA_PROXY_SCHEME === "https")
68
- {
69
- agent = https.globalAgent;
70
- }
71
-
72
69
  request({
73
70
  "method": "POST",
74
71
  "url": URL,
75
72
  "qs": {},
76
73
  "json": json,
77
74
  "headers": headers,
78
- "agent": agent,
79
75
  "timeout": process.defaultHttpTimeoutMs
80
- }, function(err, response, body) {
76
+ }, function(err, response, json) {
81
77
 
82
- if (err || (response && response.body && response.body.error)) {
78
+ if (err || (json && json.error)) {
83
79
  return callback(err);
84
80
  }
85
81
 
86
- callback(null, body._doc, body.branchId);
82
+ callback(null, json._doc, json.branchId);
87
83
  });
88
84
  };
89
85
  });
90
86
 
91
87
  /**
92
- * Releases an editorial session, deleting the session branch and erasing any accumulated work.
88
+ * Releases an editorial workspace, deleting the workspace branch and erasing any accumulated work.
93
89
  *
94
90
  * @param socket
95
91
  * @param provider
@@ -98,10 +94,10 @@ exports.bindSocket = function(socket, provider)
98
94
  * @param branchId
99
95
  * @param callback
100
96
  */
101
- var releaseEditorialSession = function(socket, provider, sessionKey, repositoryId, branchId, callback)
97
+ var releaseEditorialWorkspace = function(socket, provider, sessionKey, repositoryId, branchId, callback)
102
98
  {
103
99
  // send an HTTP command to release the session
104
- var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT) + "/oneteam/editorial/session/release";
100
+ var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH) + "/oneteam/editorial/workspace/release";
105
101
 
106
102
  var json = {};
107
103
  json.repositoryId = repositoryId;
@@ -115,23 +111,16 @@ exports.bindSocket = function(socket, provider)
115
111
  headers["GITANA_TICKET"] = gitanaTicket;
116
112
  }
117
113
 
118
- var agent = http.globalAgent;
119
- if (process.env.GITANA_PROXY_SCHEME === "https")
120
- {
121
- agent = https.globalAgent;
122
- }
123
-
124
114
  request({
125
115
  "method": "POST",
126
116
  "url": URL,
127
117
  "qs": {},
128
118
  "json": json,
129
119
  "headers": headers,
130
- "agent": agent,
131
120
  "timeout": process.defaultHttpTimeoutMs
132
- }, function(err, response, body) {
121
+ }, function(err, response, json) {
133
122
 
134
- if (err || (response && response.body && response.body.error)) {
123
+ if (err || (json && json.error)) {
135
124
  return callback(err);
136
125
  }
137
126
 
@@ -140,7 +129,7 @@ exports.bindSocket = function(socket, provider)
140
129
  };
141
130
 
142
131
  /**
143
- * Sends an HTTP request back to the API to commit the contents of an editorial session branch back to its
132
+ * Sends an HTTP request back to the API to commit the contents of an editorial workspace branch back to its
144
133
  * parent branch.
145
134
  *
146
135
  * @param socket
@@ -150,9 +139,9 @@ exports.bindSocket = function(socket, provider)
150
139
  * @param branchId
151
140
  * @param callback
152
141
  */
153
- var commitEditorialSession = function(socket, provider, sessionKey, repositoryId, branchId, callback)
142
+ var commitEditorialWorkspace = function(socket, provider, sessionKey, repositoryId, branchId, callback)
154
143
  {
155
- var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT) + "/oneteam/editorial/session/commit";
144
+ var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH) + "/oneteam/editorial/workspace/commit";
156
145
 
157
146
  var json = {};
158
147
  json.repositoryId = repositoryId;
@@ -166,32 +155,25 @@ exports.bindSocket = function(socket, provider)
166
155
  headers["GITANA_TICKET"] = gitanaTicket;
167
156
  }
168
157
 
169
- var agent = http.globalAgent;
170
- if (process.env.GITANA_PROXY_SCHEME === "https")
171
- {
172
- agent = https.globalAgent;
173
- }
174
-
175
158
  request({
176
159
  "method": "POST",
177
160
  "url": URL,
178
161
  "qs": {},
179
162
  "json": json,
180
163
  "headers": headers,
181
- "agent": agent,
182
164
  "timeout": process.defaultHttpTimeoutMs
183
- }, function(err, response, body) {
165
+ }, function(err, response, json) {
184
166
 
185
- if (err || (response && response.body && response.body.error)) {
167
+ if (err || (json && json.error)) {
186
168
  return callback(err);
187
169
  }
188
170
 
189
- callback(null, body);
171
+ callback(null, json);
190
172
  });
191
173
  };
192
174
 
193
175
  /**
194
- * Sends an HTTP request back to the API to request information about an existing editorial session.
176
+ * Sends an HTTP request back to the API to request information about an existing editorial workspace.
195
177
  *
196
178
  * @param socket
197
179
  * @param provider
@@ -200,9 +182,9 @@ exports.bindSocket = function(socket, provider)
200
182
  * @param branchId
201
183
  * @param callback
202
184
  */
203
- var editorialSessionInfo = function(socket, provider, sessionKey, repositoryId, branchId, callback)
185
+ var editorialWorkspaceInfo = function(socket, provider, sessionKey, repositoryId, branchId, callback)
204
186
  {
205
- var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT) + "/oneteam/editorial/session/info";
187
+ var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH) + "/oneteam/editorial/workspace/info";
206
188
 
207
189
  var json = {};
208
190
  json.repositoryId = repositoryId;
@@ -216,31 +198,24 @@ exports.bindSocket = function(socket, provider)
216
198
  headers["GITANA_TICKET"] = gitanaTicket;
217
199
  }
218
200
 
219
- var agent = http.globalAgent;
220
- if (process.env.GITANA_PROXY_SCHEME === "https")
221
- {
222
- agent = https.globalAgent;
223
- }
224
-
225
201
  request({
226
202
  "method": "POST",
227
203
  "url": URL,
228
204
  "qs": {},
229
205
  "json": json,
230
206
  "headers": headers,
231
- "agent": agent,
232
207
  "timeout": process.defaultHttpTimeoutMs
233
- }, function(err, response, body) {
208
+ }, function(err, response, json) {
234
209
 
235
- if (err || (response && response.body && response.body.error)) {
210
+ if (err || (json && json.error)) {
236
211
  return callback(err);
237
212
  }
238
213
 
239
- if (!body.exists) {
214
+ if (!json.exists) {
240
215
  return callback(null, false);
241
216
  }
242
217
 
243
- callback(null, true, body.session);
218
+ callback(null, true, json.workspace);
244
219
  });
245
220
  };
246
221
 
@@ -0,0 +1,74 @@
1
+ exports = module.exports = {};
2
+
3
+ var util = require("../../../util/util");
4
+ var socketUtil = require("../../../util/socket");
5
+
6
+ var subscriptionsBound = false;
7
+
8
+ var bindSubscriptions = function()
9
+ {
10
+ if (subscriptionsBound) {
11
+ return;
12
+ }
13
+
14
+ subscriptionsBound = true;
15
+
16
+ // LISTEN: "deployment_synced"
17
+ process.broadcast.subscribe("deployment_synced", function (message, channel, done) {
18
+
19
+ if (!done) {
20
+ done = function () {};
21
+ }
22
+
23
+ var deployment = message.deployment;
24
+
25
+ var resources = deployment.resources;
26
+ for (var k in resources)
27
+ {
28
+ var resourceObject = resources[k]; // state, operation, reference, headReference
29
+
30
+ var reference = resourceObject.reference;
31
+ var headReference = resourceObject.headReference;
32
+
33
+ var deploymentObject = JSON.parse(JSON.stringify(deployment));
34
+ delete deploymentObject.reference;
35
+ delete deploymentObject.headReference;
36
+ delete deploymentObject.resources;
37
+ delete deploymentObject.targetSummaries;
38
+
39
+ var watchObject = {
40
+ "type": "deployment_synced",
41
+ "resource": resourceObject,
42
+ "deployment": deploymentObject
43
+ };
44
+
45
+ // fire to reference
46
+ process.IO.to(reference).emit("watchResource", reference, watchObject);
47
+
48
+ // fire to head reference
49
+ process.IO.to(headReference).emit("watchResource", headReference, watchObject);
50
+ }
51
+
52
+ done();
53
+ });
54
+ };
55
+
56
+ exports.bindSocket = function(socket, provider)
57
+ {
58
+ bindSubscriptions();
59
+
60
+ socketUtil.bindGitana(socket, function() {
61
+
62
+ socket.on("watchResource", function(reference, callback) {
63
+
64
+ if (reference)
65
+ {
66
+ // join room for this reference
67
+ //console.log("watchResource, room: " + reference);
68
+ socket.join(reference);
69
+ }
70
+
71
+ callback();
72
+ });
73
+ });
74
+ };