@nakedcreativity/cee-ms-node 0.3.1 → 0.3.2
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 +2 -13
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -104,17 +104,14 @@ function ceems(config) {
|
|
|
104
104
|
|
|
105
105
|
this.app.post(/draft\/(.*)/, (req, res)=>{
|
|
106
106
|
|
|
107
|
-
console.log('received a POST')
|
|
108
107
|
// validate authorisation JWT here
|
|
109
108
|
this.site = JSON.parse(fs.readFileSync('./pages/site.json', 'utf8'));
|
|
110
109
|
|
|
111
110
|
//console.log(req.body.page)
|
|
112
111
|
req.query.edit = true;
|
|
113
112
|
|
|
114
|
-
// this was sent by the iframe, handle it differently
|
|
115
|
-
console.log(req.query)
|
|
113
|
+
// if this was sent by the iframe, handle it differently
|
|
116
114
|
if(req.query.iframe != null){
|
|
117
|
-
console.log('using parsed body')
|
|
118
115
|
this.render(req, res, JSON.parse(decodeURIComponent(req.body.page)));
|
|
119
116
|
}else {
|
|
120
117
|
this.render(req, res, req.body.page);
|
|
@@ -126,8 +123,7 @@ function ceems(config) {
|
|
|
126
123
|
|
|
127
124
|
ceems.prototype.load = function(req, res){
|
|
128
125
|
|
|
129
|
-
var path = req._parsedUrl.pathname
|
|
130
|
-
console.log(path)
|
|
126
|
+
var path = req._parsedUrl.pathname.substring(1)
|
|
131
127
|
this.site = JSON.parse(fs.readFileSync('./pages/site.json', 'utf8'));
|
|
132
128
|
//this.pages_map = _.indexBy(this.site.pages, 'url');
|
|
133
129
|
|
|
@@ -154,16 +150,9 @@ ceems.prototype.load = function(req, res){
|
|
|
154
150
|
|
|
155
151
|
ceems.prototype.render = function(req, res, page=null) {
|
|
156
152
|
|
|
157
|
-
if(req.query.initial != null){
|
|
158
|
-
// validate JWT here
|
|
159
|
-
res.send('Waiting...')
|
|
160
|
-
return
|
|
161
|
-
}
|
|
162
|
-
|
|
163
153
|
if(!page){
|
|
164
154
|
page = this.load(req, res)
|
|
165
155
|
}
|
|
166
|
-
console.log(page)
|
|
167
156
|
// get any external data, and save this into the page
|
|
168
157
|
if(page.external){
|
|
169
158
|
_.each(page.external, function(ext, key){
|