cloudcms-server 4.0.0-beta.11 → 4.0.0-beta.14
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/README.md +0 -5
- package/index.js +58 -32
- package/middleware/authentication/authentication.js +40 -12
- package/middleware/authentication/providers/saml.js +7 -3
- package/middleware/config/adapter.js +0 -44
- package/middleware/deployment/deployment.js +22 -24
- package/middleware/driver/driver.js +24 -1
- package/middleware/registration/registration.js +0 -5
- package/middleware/stores/engines/empty.js +0 -4
- package/middleware/stores/engines/fs-caching-adapter.js +0 -5
- package/middleware/stores/engines/fs.js +0 -9
- package/middleware/stores/engines/s3.js +0 -5
- package/middleware/stores/engines/s3fs.js +0 -5
- package/middleware/stores/multistore.js +0 -29
- package/middleware/stores/store.js +0 -9
- package/middleware/virtual-config/virtual-config.js +253 -203
- package/package.json +33 -48
- package/server/index.js +166 -111
- package/server/standalone.js +1 -6
- package/util/cloudcms.js +34 -7
- package/util/loaders.js +113 -0
- package/util/workqueue.js +100 -0
- package/duster/helpers/core/cloudcms/associations.js +0 -34
- package/duster/helpers/core/cloudcms/beta/markdown.js +0 -46
- package/duster/helpers/core/cloudcms/beta/nodeAttachmentText.js +0 -46
- package/duster/helpers/core/cloudcms/beta/params.js +0 -33
- package/duster/helpers/core/cloudcms/beta/processTemplate.js +0 -82
- package/duster/helpers/core/cloudcms/content.js +0 -34
- package/duster/helpers/core/cloudcms/expand.js +0 -38
- package/duster/helpers/core/cloudcms/form.js +0 -34
- package/duster/helpers/core/cloudcms/query.js +0 -34
- package/duster/helpers/core/cloudcms/queryOne.js +0 -34
- package/duster/helpers/core/cloudcms/relatives.js +0 -34
- package/duster/helpers/core/cloudcms/search.js +0 -34
- package/duster/helpers/core/cloudcms/searchOne.js +0 -34
- package/duster/helpers/core/cloudcms/wcm/dependency.js +0 -83
- package/duster/helpers/core/cloudcms/wcm/fragment.js +0 -34
- package/duster/helpers/core/dev/debug.js +0 -42
- package/duster/helpers/core/dom/block.js +0 -49
- package/duster/helpers/core/dom/include.js +0 -38
- package/duster/helpers/core/dom/layout.js +0 -49
- package/duster/helpers/core/dom/link.js +0 -81
- package/duster/helpers/core/dom/resource.js +0 -77
- package/duster/helpers/core/engine.js +0 -1580
- package/duster/helpers/core/ice/value.js +0 -65
- package/duster/helpers/core/index.js +0 -49
- package/duster/helpers/core/operators/if.js +0 -64
- package/duster/helpers/core/operators/iter.js +0 -45
- package/duster/helpers/core/operators/iterate.js +0 -129
- package/duster/helpers/sample/nyt.js +0 -114
- package/duster/index.js +0 -319
- package/duster/support.js +0 -436
- package/duster/tracker.js +0 -262
- package/middleware/authentication/providers/cas.js +0 -73
- package/middleware/authentication/providers/facebook.js +0 -120
- package/middleware/authentication/providers/github.js +0 -88
- package/middleware/authentication/providers/linkedin.js +0 -112
- package/middleware/authentication/providers/twitter.js +0 -120
- package/middleware/server-tags/server-tags.js +0 -113
- package/middleware/wcm/wcm.js +0 -1437
package/util/cloudcms.js
CHANGED
|
@@ -7,8 +7,13 @@ var https = require("https");
|
|
|
7
7
|
|
|
8
8
|
var request = require("./request");
|
|
9
9
|
|
|
10
|
+
var workQueueFactory = require("./workqueue");
|
|
11
|
+
|
|
10
12
|
exports = module.exports = function()
|
|
11
13
|
{
|
|
14
|
+
// ensures that we only load 3 preview icons at a time
|
|
15
|
+
var previewQueueFn = workQueueFactory(3);
|
|
16
|
+
|
|
12
17
|
var toCacheFilePath = function(filePath)
|
|
13
18
|
{
|
|
14
19
|
var filename = path.basename(filePath);
|
|
@@ -311,8 +316,13 @@ exports = module.exports = function()
|
|
|
311
316
|
* @param filePath
|
|
312
317
|
* @param callback
|
|
313
318
|
*/
|
|
314
|
-
var writeToDisk = function(contentStore, gitana, uri, filePath, callback)
|
|
319
|
+
var writeToDisk = function(contentStore, gitana, uri, filePath, queueFn, callback)
|
|
315
320
|
{
|
|
321
|
+
if (!callback) {
|
|
322
|
+
queueFn = callback;
|
|
323
|
+
queueFn = null;
|
|
324
|
+
}
|
|
325
|
+
|
|
316
326
|
var _refreshAccessTokenAndRetry = function(contentStore, gitana, uri, filePath, attemptCount, maxAttemptsAllowed, previousError, cb)
|
|
317
327
|
{
|
|
318
328
|
// tell gitana driver to refresh access token
|
|
@@ -532,10 +542,27 @@ exports = module.exports = function()
|
|
|
532
542
|
|
|
533
543
|
};
|
|
534
544
|
|
|
535
|
-
|
|
545
|
+
var workFn = function(contentStore, gitana, uri, filePath)
|
|
546
|
+
{
|
|
547
|
+
return function(done)
|
|
548
|
+
{
|
|
549
|
+
_writeToDisk(contentStore, gitana, uri, filePath, 0, 2, null, function(err, filePath, cacheInfo) {
|
|
550
|
+
done(err, filePath, cacheInfo);
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
}(contentStore, gitana, uri, filePath);
|
|
554
|
+
|
|
555
|
+
if (queueFn)
|
|
556
|
+
{
|
|
557
|
+
return queueFn(workFn, function(err, filePath, cacheInfo) {
|
|
558
|
+
callback(err, filePath, cacheInfo);
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// otherwise, invoke right away
|
|
563
|
+
workFn(function(err, filePath, cacheInfo) {
|
|
536
564
|
callback(err, filePath, cacheInfo);
|
|
537
565
|
});
|
|
538
|
-
|
|
539
566
|
};
|
|
540
567
|
|
|
541
568
|
/**
|
|
@@ -601,7 +628,7 @@ exports = module.exports = function()
|
|
|
601
628
|
}
|
|
602
629
|
|
|
603
630
|
// grab from Cloud CMS and write to disk
|
|
604
|
-
writeToDisk(contentStore, gitana, uri, filePath, function (err, filePath, cacheInfo) {
|
|
631
|
+
writeToDisk(contentStore, gitana, uri, filePath, null, function (err, filePath, cacheInfo) {
|
|
605
632
|
|
|
606
633
|
if (err) {
|
|
607
634
|
process.log("writeToDisk error, err: " + err.message + ", body: " + err.body);
|
|
@@ -719,7 +746,7 @@ exports = module.exports = function()
|
|
|
719
746
|
uri += "&mimetype=" + mimetype;
|
|
720
747
|
}
|
|
721
748
|
|
|
722
|
-
writeToDisk(contentStore, gitana, uri, filePath, function (err, filePath, responseHeaders) {
|
|
749
|
+
writeToDisk(contentStore, gitana, uri, filePath, previewQueueFn, function (err, filePath, responseHeaders) {
|
|
723
750
|
|
|
724
751
|
if (err) {
|
|
725
752
|
|
|
@@ -876,7 +903,7 @@ exports = module.exports = function()
|
|
|
876
903
|
uri += "?a=true";
|
|
877
904
|
|
|
878
905
|
// grab from Cloud CMS and write to disk
|
|
879
|
-
writeToDisk(contentStore, gitana, uri, filePath, function (err, filePath, cacheInfo) {
|
|
906
|
+
writeToDisk(contentStore, gitana, uri, filePath, null, function (err, filePath, cacheInfo) {
|
|
880
907
|
|
|
881
908
|
if (err) {
|
|
882
909
|
callback(err);
|
|
@@ -978,7 +1005,7 @@ exports = module.exports = function()
|
|
|
978
1005
|
uri += "&mimetype=" + mimetype;
|
|
979
1006
|
}
|
|
980
1007
|
|
|
981
|
-
writeToDisk(contentStore, gitana, uri, filePath, function (err, filePath, responseHeaders) {
|
|
1008
|
+
writeToDisk(contentStore, gitana, uri, filePath, previewQueueFn, function (err, filePath, responseHeaders) {
|
|
982
1009
|
|
|
983
1010
|
if (err) {
|
|
984
1011
|
callback(err);
|
package/util/loaders.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
var exports = module.exports;
|
|
2
|
+
|
|
3
|
+
var AsyncLock = require("async-lock");
|
|
4
|
+
|
|
5
|
+
var SENTINEL_NOT_FOUND_VALUE = "null";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Applies caching to a loader.
|
|
9
|
+
*
|
|
10
|
+
* A loader function is invoked like:
|
|
11
|
+
*
|
|
12
|
+
* loader(function(err, value) {
|
|
13
|
+
*
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* Its job is to load something from a remote place and then fire the callback.
|
|
17
|
+
*
|
|
18
|
+
* This method wraps caching around the loader for the given key. It returns a new loader
|
|
19
|
+
* that checks a given cache (key) for a value ahead of invoking the actual underlying loader.
|
|
20
|
+
*
|
|
21
|
+
* @param loader
|
|
22
|
+
* @param cache
|
|
23
|
+
* @param key
|
|
24
|
+
*/
|
|
25
|
+
var cached = exports.cached = function(loader, cache, key)
|
|
26
|
+
{
|
|
27
|
+
return function(callback)
|
|
28
|
+
{
|
|
29
|
+
cache.read(key, function(err, value) {
|
|
30
|
+
|
|
31
|
+
if (value === SENTINEL_NOT_FOUND_VALUE) {
|
|
32
|
+
return callback();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (value) {
|
|
36
|
+
return callback(null, value);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
loader(function(err, value) {
|
|
40
|
+
|
|
41
|
+
if (err) {
|
|
42
|
+
return callback(err);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!value) {
|
|
46
|
+
return cache.write(key, SENTINEL_NOT_FOUND_VALUE, function () {
|
|
47
|
+
callback();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// write to cache
|
|
52
|
+
return cache.write(key, value, function () {
|
|
53
|
+
callback.call(this, null, value);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
var lock = new AsyncLock();
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Applies caching to a loader.
|
|
64
|
+
*
|
|
65
|
+
* A loader function is invoked like:
|
|
66
|
+
*
|
|
67
|
+
* loader(function(err, value) {
|
|
68
|
+
*
|
|
69
|
+
* });
|
|
70
|
+
*
|
|
71
|
+
* Its job is to load something from a remote place and then fire the callback.
|
|
72
|
+
*
|
|
73
|
+
* This method wraps an exclusive mutex lock around the given loader. This makes it so that only one
|
|
74
|
+
* invocation of this loader may run per key within the event loop.
|
|
75
|
+
*
|
|
76
|
+
* @param loader
|
|
77
|
+
* @param key
|
|
78
|
+
*/
|
|
79
|
+
var exclusive = exports.exclusive = function(loader, key, timeout)
|
|
80
|
+
{
|
|
81
|
+
return function(callback)
|
|
82
|
+
{
|
|
83
|
+
var opts = {};
|
|
84
|
+
// up to 50000 tasks in the queue
|
|
85
|
+
opts.maxPending = 50000;
|
|
86
|
+
if (timeout) {
|
|
87
|
+
opts.timeout = timeout;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
lock.acquire(key, function(releaseFn) {
|
|
91
|
+
loader(function(err, value) {
|
|
92
|
+
setTimeout(function() {
|
|
93
|
+
releaseFn();
|
|
94
|
+
}, 0);
|
|
95
|
+
callback.call(this, err, value);
|
|
96
|
+
});
|
|
97
|
+
}, function(err, value) {
|
|
98
|
+
// lock was released
|
|
99
|
+
if (err) {
|
|
100
|
+
console.error("Failed to acquire lock for key: " + key + ", error: ", err, " return value: ", value);
|
|
101
|
+
}
|
|
102
|
+
}, opts);
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
var cachedExclusive = exports.cachedExclusive = function(loader, cache, key, timeout)
|
|
107
|
+
{
|
|
108
|
+
var cachedLoader1 = cached(loader, cache, key);
|
|
109
|
+
var exclusiveLoader = exclusive(cachedLoader1, key, timeout);
|
|
110
|
+
var cachedLoader2 = cached(exclusiveLoader, cache, key);
|
|
111
|
+
|
|
112
|
+
return cachedLoader2;
|
|
113
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
module.exports = function(maxSize)
|
|
2
|
+
{
|
|
3
|
+
if (!maxSize) {
|
|
4
|
+
maxSize = 3;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
var blockExecution = false;
|
|
8
|
+
|
|
9
|
+
var pendingWorkQueue = [];
|
|
10
|
+
var activeCount = 0;
|
|
11
|
+
|
|
12
|
+
var processWork = function () {
|
|
13
|
+
|
|
14
|
+
// if another "thread" is running the processor, don't bother
|
|
15
|
+
if (blockExecution)
|
|
16
|
+
{
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
blockExecution = true;
|
|
21
|
+
|
|
22
|
+
// add as many pending work items as we can, loop until full or no more pending
|
|
23
|
+
var process = true;
|
|
24
|
+
do
|
|
25
|
+
{
|
|
26
|
+
// if nothing to work on, bail
|
|
27
|
+
if (pendingWorkQueue.length === 0)
|
|
28
|
+
{
|
|
29
|
+
process = false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// if we're full, bail
|
|
33
|
+
if (activeCount >= maxSize)
|
|
34
|
+
{
|
|
35
|
+
process = false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (process)
|
|
39
|
+
{
|
|
40
|
+
// increment active count
|
|
41
|
+
activeCount++;
|
|
42
|
+
|
|
43
|
+
// console.log("Active work items: " + activeCount);
|
|
44
|
+
|
|
45
|
+
// define execution function and splice/bind to 0th element from pending list
|
|
46
|
+
var executionFn = function(work) {
|
|
47
|
+
return function() {
|
|
48
|
+
var workFn = work.workFn;
|
|
49
|
+
var callbackFn = work.callbackFn;
|
|
50
|
+
|
|
51
|
+
// console.log("[WORKQUEUE - queue: " + pendingWorkQueue.length + ", actives: " + activeCount + "] start work");
|
|
52
|
+
|
|
53
|
+
workFn(function(err, obj1, obj2) {
|
|
54
|
+
|
|
55
|
+
// decrement active count
|
|
56
|
+
activeCount--;
|
|
57
|
+
|
|
58
|
+
// console.log("[WORKQUEUE - queue: " + pendingWorkQueue.length + ", actives: " + activeCount + "] finish work");
|
|
59
|
+
|
|
60
|
+
// fire optional callback
|
|
61
|
+
if (callbackFn) {
|
|
62
|
+
// console.log("[WORKQUEUE - queue: " + pendingWorkQueue.length + ", actives: " + activeCount + "] fire work callback");
|
|
63
|
+
window.setTimeout(function() {
|
|
64
|
+
callbackFn(err, obj1, obj2);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// process more work on timeout
|
|
69
|
+
window.setTimeout(processWork);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
};
|
|
73
|
+
}(pendingWorkQueue.splice(0, 1)[0]);
|
|
74
|
+
|
|
75
|
+
// execute on timeout
|
|
76
|
+
window.setTimeout(executionFn);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
} while (process);
|
|
80
|
+
|
|
81
|
+
blockExecution = false;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
return function(workFn, callbackFn) {
|
|
85
|
+
|
|
86
|
+
var pendingWork = {
|
|
87
|
+
"workFn": workFn
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
if (callbackFn) {
|
|
91
|
+
pendingWork.callbackFn = callbackFn;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
pendingWorkQueue.push(pendingWork);
|
|
95
|
+
|
|
96
|
+
// execute on timeout
|
|
97
|
+
window.setTimeout(processWork);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @associations
|
|
3
|
-
*
|
|
4
|
-
* @param app
|
|
5
|
-
* @param dust
|
|
6
|
-
* @param callback
|
|
7
|
-
*/
|
|
8
|
-
module.exports = function(app, dust, callback)
|
|
9
|
-
{
|
|
10
|
-
var engine = require("../engine")(app, dust);
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* ASSOCIATIONS
|
|
14
|
-
*
|
|
15
|
-
* Finds associations around a node.
|
|
16
|
-
*
|
|
17
|
-
* Syntax:
|
|
18
|
-
*
|
|
19
|
-
* {@associations node="<nodeId>" type="<association_type>" limit="" skip="" as=""}
|
|
20
|
-
* {+templateIdentifier/}
|
|
21
|
-
* {/associations}
|
|
22
|
-
*
|
|
23
|
-
* @param chunk
|
|
24
|
-
* @param context
|
|
25
|
-
* @param bodies
|
|
26
|
-
* @param params
|
|
27
|
-
*/
|
|
28
|
-
dust.helpers.associations = function(chunk, context, bodies, params)
|
|
29
|
-
{
|
|
30
|
-
return engine.handleAssociations(chunk, context, bodies, params);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
callback();
|
|
34
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
var marked = require("marked");
|
|
2
|
-
marked.setOptions({
|
|
3
|
-
renderer: new marked.Renderer(),
|
|
4
|
-
gfm: true,
|
|
5
|
-
tables: true,
|
|
6
|
-
breaks: false,
|
|
7
|
-
pedantic: false,
|
|
8
|
-
sanitize: true,
|
|
9
|
-
smartLists: true,
|
|
10
|
-
smartypants: false
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @markdown
|
|
15
|
-
*
|
|
16
|
-
* @param app
|
|
17
|
-
* @param dust
|
|
18
|
-
* @param callback
|
|
19
|
-
*/
|
|
20
|
-
module.exports = function(app, dust, callback)
|
|
21
|
-
{
|
|
22
|
-
/**
|
|
23
|
-
* Renders markdown into the Dust template.
|
|
24
|
-
*
|
|
25
|
-
* @param chunk
|
|
26
|
-
* @param context
|
|
27
|
-
* @param bodies
|
|
28
|
-
* @param params
|
|
29
|
-
* @returns {*}
|
|
30
|
-
*/
|
|
31
|
-
dust.helpers.markdown = function(chunk, context, bodies, params) {
|
|
32
|
-
|
|
33
|
-
params = params || {};
|
|
34
|
-
|
|
35
|
-
var text = context.resolve(params.text);
|
|
36
|
-
if (!text) {
|
|
37
|
-
return chunk;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
text = marked(text);
|
|
41
|
-
|
|
42
|
-
return chunk.write(text);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
callback();
|
|
46
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @nodeAttachmentText
|
|
3
|
-
*
|
|
4
|
-
* @param app
|
|
5
|
-
* @param dust
|
|
6
|
-
* @param callback
|
|
7
|
-
*/
|
|
8
|
-
module.exports = function(app, dust, callback)
|
|
9
|
-
{
|
|
10
|
-
var engine = require("../../engine")(app, dust);
|
|
11
|
-
|
|
12
|
-
var map = engine.map;
|
|
13
|
-
var end = engine.end;
|
|
14
|
-
|
|
15
|
-
dust.helpers.nodeAttachmentText = dust.helpers.nodeAttachmentValue = function(chunk, context, bodies, params)
|
|
16
|
-
{
|
|
17
|
-
params = params || {};
|
|
18
|
-
|
|
19
|
-
var nodeId = context.resolve(params.node);
|
|
20
|
-
var attachmentId = context.resolve(params.attachment);
|
|
21
|
-
if (!attachmentId)
|
|
22
|
-
{
|
|
23
|
-
attachmentId = "default";
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return map(chunk, function(chunk) {
|
|
27
|
-
|
|
28
|
-
var req = context.get("req");
|
|
29
|
-
req.branch(function(err, branch) {
|
|
30
|
-
|
|
31
|
-
if (err) {
|
|
32
|
-
return end(chunk, context);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
branch.readNode(nodeId).attachment(attachmentId).download(function(text) {
|
|
36
|
-
|
|
37
|
-
chunk.write(text);
|
|
38
|
-
|
|
39
|
-
end(chunk, context);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
callback();
|
|
46
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @params
|
|
3
|
-
*
|
|
4
|
-
* @param app
|
|
5
|
-
* @param dust
|
|
6
|
-
* @param callback
|
|
7
|
-
*/
|
|
8
|
-
module.exports = function(app, dust, callback)
|
|
9
|
-
{
|
|
10
|
-
/**
|
|
11
|
-
* Allows parameters to be passed into blocks or partials
|
|
12
|
-
*/
|
|
13
|
-
dust.helpers.params = function( chunk, context, bodies, params ){
|
|
14
|
-
|
|
15
|
-
var partial = {};
|
|
16
|
-
if( params)
|
|
17
|
-
{
|
|
18
|
-
for (var key in params)
|
|
19
|
-
{
|
|
20
|
-
partial[key] = params[key];
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// render
|
|
25
|
-
var newContext = context.push(partial);
|
|
26
|
-
|
|
27
|
-
//return bodies.block(chunk, dust.makeBase(partial))
|
|
28
|
-
return bodies.block(chunk, newContext);
|
|
29
|
-
};
|
|
30
|
-
dust.helpers.parameters = dust.helpers.params;
|
|
31
|
-
|
|
32
|
-
callback();
|
|
33
|
-
};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @processTemplate
|
|
3
|
-
*
|
|
4
|
-
* @param app
|
|
5
|
-
* @param dust
|
|
6
|
-
* @param callback
|
|
7
|
-
*/
|
|
8
|
-
module.exports = function(app, dust, callback)
|
|
9
|
-
{
|
|
10
|
-
var engine = require("../../engine")(app, dust);
|
|
11
|
-
|
|
12
|
-
var map = engine.map;
|
|
13
|
-
var end = engine.end;
|
|
14
|
-
|
|
15
|
-
dust.helpers.processTemplate = function(chunk, context, bodies, params)
|
|
16
|
-
{
|
|
17
|
-
params = params || {};
|
|
18
|
-
|
|
19
|
-
var nodeId = context.resolve(params.node);
|
|
20
|
-
var attachmentId = context.resolve(params.attachment);
|
|
21
|
-
if (!attachmentId)
|
|
22
|
-
{
|
|
23
|
-
attachmentId = "default";
|
|
24
|
-
}
|
|
25
|
-
var propertyId = context.resolve(params.property);
|
|
26
|
-
var locale = context.resolve(params.locale);
|
|
27
|
-
|
|
28
|
-
return map(chunk, function(chunk) {
|
|
29
|
-
|
|
30
|
-
if (locale)
|
|
31
|
-
{
|
|
32
|
-
var gitana = context.get("gitana");
|
|
33
|
-
gitana.getDriver().setLocale(locale);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (propertyId)
|
|
37
|
-
{
|
|
38
|
-
var req = context.get("req");
|
|
39
|
-
req.branch(function(err, branch) {
|
|
40
|
-
|
|
41
|
-
if (err) {
|
|
42
|
-
return end(chunk, context);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
branch.readNode(nodeId).then(function() {
|
|
46
|
-
|
|
47
|
-
resolveVariables([this[propertyId]], context, function (err, resolutions) {
|
|
48
|
-
|
|
49
|
-
chunk.write(resolutions[0]);
|
|
50
|
-
|
|
51
|
-
end(chunk, context);
|
|
52
|
-
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
else
|
|
58
|
-
{
|
|
59
|
-
var req = context.get("req");
|
|
60
|
-
req.branch(function(err, branch) {
|
|
61
|
-
|
|
62
|
-
if (err) {
|
|
63
|
-
return end(chunk, context);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
branch.readNode(nodeId).attachment(attachmentId).download(function (text) {
|
|
67
|
-
|
|
68
|
-
resolveVariables([text], context, function (err, resolutions) {
|
|
69
|
-
|
|
70
|
-
chunk.write(resolutions[0]);
|
|
71
|
-
|
|
72
|
-
end(chunk, context);
|
|
73
|
-
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
callback();
|
|
82
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @content
|
|
3
|
-
*
|
|
4
|
-
* @param app
|
|
5
|
-
* @param dust
|
|
6
|
-
* @param callback
|
|
7
|
-
*/
|
|
8
|
-
module.exports = function(app, dust, callback)
|
|
9
|
-
{
|
|
10
|
-
var engine = require("../engine")(app, dust);
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* CONTENT
|
|
14
|
-
*
|
|
15
|
-
* Selects a single content item.
|
|
16
|
-
*
|
|
17
|
-
* Syntax:
|
|
18
|
-
*
|
|
19
|
-
* {@content id="GUID" path="/a/b/c" as=""}
|
|
20
|
-
* {+templateIdentifier/}
|
|
21
|
-
* {/content}
|
|
22
|
-
*
|
|
23
|
-
* @param chunk
|
|
24
|
-
* @param context
|
|
25
|
-
* @param bodies
|
|
26
|
-
* @param params
|
|
27
|
-
*/
|
|
28
|
-
dust.helpers.content = function(chunk, context, bodies, params)
|
|
29
|
-
{
|
|
30
|
-
return engine.handleContent(chunk, context, bodies, params);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
callback();
|
|
34
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @expand
|
|
3
|
-
*
|
|
4
|
-
* @param app
|
|
5
|
-
* @param dust
|
|
6
|
-
* @param callback
|
|
7
|
-
*/
|
|
8
|
-
module.exports = function(app, dust, callback)
|
|
9
|
-
{
|
|
10
|
-
var engine = require("../engine")(app, dust);
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* EXPAND
|
|
14
|
-
*
|
|
15
|
-
* Query for a list of nodes by their id (._doc).
|
|
16
|
-
* The list of id values can be supplied as an array of id values in
|
|
17
|
-
* the 'list' arg or as an array of node records in the 'list' arg
|
|
18
|
-
* along with a the name of a common key within each node that holds
|
|
19
|
-
* the id.
|
|
20
|
-
*
|
|
21
|
-
* Syntax:
|
|
22
|
-
* ex. 1
|
|
23
|
-
* {@expand list="components" key="editorialpage.components" as="components"}
|
|
24
|
-
* {+templateIdentifier/}
|
|
25
|
-
* {/expand}
|
|
26
|
-
*
|
|
27
|
-
* @param chunk
|
|
28
|
-
* @param context
|
|
29
|
-
* @param bodies
|
|
30
|
-
* @param params
|
|
31
|
-
*/
|
|
32
|
-
dust.helpers.expand = function(chunk, context, bodies, params)
|
|
33
|
-
{
|
|
34
|
-
return engine.handleExpand(chunk, context, bodies, params);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
callback();
|
|
38
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @form
|
|
3
|
-
*
|
|
4
|
-
* @param app
|
|
5
|
-
* @param dust
|
|
6
|
-
* @param callback
|
|
7
|
-
*/
|
|
8
|
-
module.exports = function(app, dust, callback)
|
|
9
|
-
{
|
|
10
|
-
var engine = require("../engine")(app, dust);
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* FORM
|
|
14
|
-
*
|
|
15
|
-
* Renders a form.
|
|
16
|
-
*
|
|
17
|
-
* Syntax:
|
|
18
|
-
*
|
|
19
|
-
* {@form definition="custom:type" form="formKey" list="listKeyOrId" successUrl="" errorUrl=""}
|
|
20
|
-
* {+templateIdentifier/}
|
|
21
|
-
* {/form}
|
|
22
|
-
*
|
|
23
|
-
* @param chunk
|
|
24
|
-
* @param context
|
|
25
|
-
* @param bodies
|
|
26
|
-
* @param params
|
|
27
|
-
*/
|
|
28
|
-
dust.helpers.form = function(chunk, context, bodies, params)
|
|
29
|
-
{
|
|
30
|
-
return engine.handleForm(chunk, context, bodies, params);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
callback();
|
|
34
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @query
|
|
3
|
-
*
|
|
4
|
-
* @param app
|
|
5
|
-
* @param dust
|
|
6
|
-
* @param callback
|
|
7
|
-
*/
|
|
8
|
-
module.exports = function(app, dust, callback)
|
|
9
|
-
{
|
|
10
|
-
var engine = require("../engine")(app, dust);
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* QUERY
|
|
14
|
-
*
|
|
15
|
-
* Queries for content from the content repository and renders.
|
|
16
|
-
*
|
|
17
|
-
* Syntax:
|
|
18
|
-
*
|
|
19
|
-
* {@query sort="title" scope="page" type="custom:type" limit="" skip="" as=""}
|
|
20
|
-
* {+templateIdentifier/}
|
|
21
|
-
* {/query}
|
|
22
|
-
*
|
|
23
|
-
* @param chunk
|
|
24
|
-
* @param context
|
|
25
|
-
* @param bodies
|
|
26
|
-
* @param params
|
|
27
|
-
*/
|
|
28
|
-
dust.helpers.query = function(chunk, context, bodies, params)
|
|
29
|
-
{
|
|
30
|
-
return engine.handleQuery(chunk, context, bodies, params, false);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
callback();
|
|
34
|
-
};
|