@nakedcreativity/cee-ms-node 0.2.3 → 0.2.5
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/index.js +40 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -21,6 +21,8 @@ function ceems(config) {
|
|
|
21
21
|
cache: true
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
+
this.config = config;
|
|
25
|
+
|
|
24
26
|
// register liquid engine
|
|
25
27
|
this.app.engine('liquid', this.engine.express({
|
|
26
28
|
strict_variables: false,
|
|
@@ -52,6 +54,32 @@ function ceems(config) {
|
|
|
52
54
|
}
|
|
53
55
|
});
|
|
54
56
|
|
|
57
|
+
this.engine.registerTag('navigation', {
|
|
58
|
+
parse: (tagToken, remainTokens)=> {
|
|
59
|
+
this.match = tagToken.args; // name // path[0] == navigation name
|
|
60
|
+
},
|
|
61
|
+
render: (scope, hash)=> {
|
|
62
|
+
var filepath = Liquid.evalValue('submenu.liquid', scope);
|
|
63
|
+
var page = scope.scopes[0]
|
|
64
|
+
|
|
65
|
+
if(page.path && this.site.navigation[page.path[0]]){
|
|
66
|
+
console.log('navigation exists for ', page.path[0])
|
|
67
|
+
}else {
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
// look for navigation that match the name of any part of the path?
|
|
71
|
+
|
|
72
|
+
return this.engine.handleCache('submenu.liquid')
|
|
73
|
+
.then((templates) => {
|
|
74
|
+
scope.push(this.site.navigation[page.path[0]]);
|
|
75
|
+
return this.engine.renderer.renderTemplates(templates, scope);
|
|
76
|
+
})
|
|
77
|
+
.then((html) => {
|
|
78
|
+
scope.pop();
|
|
79
|
+
return html;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
});
|
|
55
83
|
|
|
56
84
|
this.app.listen(config.port, function () {});
|
|
57
85
|
|
|
@@ -76,7 +104,7 @@ function ceems(config) {
|
|
|
76
104
|
|
|
77
105
|
// validate authorisation JWT here
|
|
78
106
|
this.site = JSON.parse(fs.readFileSync('./pages/site.json', 'utf8'));
|
|
79
|
-
console.log(req.body.page)
|
|
107
|
+
//console.log(req.body.page)
|
|
80
108
|
req.query.edit = true;
|
|
81
109
|
this.render(req,res, req.body.page);
|
|
82
110
|
|
|
@@ -127,6 +155,17 @@ ceems.prototype.render = function(req, res, page=null) {
|
|
|
127
155
|
})
|
|
128
156
|
}
|
|
129
157
|
|
|
158
|
+
// if there are whitelisted cookies, add these to the page so they can be rendered
|
|
159
|
+
if(this.config.whitelistedCookies){
|
|
160
|
+
page.cookies = []
|
|
161
|
+
_.each(this.config.whitelistedCookies, cookieName=>{
|
|
162
|
+
if(req.cookies[cookieName]){
|
|
163
|
+
page.cookies[cookieName] = req.cookies[cookieName]
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
|
|
130
169
|
var renderedRegions = {}
|
|
131
170
|
var jobs = []
|
|
132
171
|
|