diff options
Diffstat (limited to 'lib/response.js')
-rwxr-xr-x | lib/response.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/response.js b/lib/response.js index 796f951f..fa97f157 100755 --- a/lib/response.js +++ b/lib/response.js @@ -33,6 +33,9 @@ var response = { errorNotFound: function (res) { responseError(res, "404", "Not Found", "oops."); }, + errorBadRequest: function (res) { + responseError(res, "400", "Bad Request", "something not right."); + }, errorInternalError: function (res) { responseError(res, "500", "Internal Error", "wtf."); }, @@ -205,6 +208,9 @@ function showPublishNote(req, res, next) { url: origin, body: text, useCDN: config.usecdn, + owner: note.owner ? note.owner.id : null, + ownerprofile: note.owner ? models.User.parseProfile(note.owner.profile) : null, + lastchangeuser: note.lastchangeuser ? note.lastchangeuser.id : null, lastchangeuserprofile: note.lastchangeuser ? models.User.parseProfile(note.lastchangeuser.profile) : null, robots: meta.robots || false, //default allow robots GA: meta.GA, @@ -332,6 +338,13 @@ function actionRevision(req, res, note) { if (!content) { return response.errorNotFound(res); } + res.set({ + 'Access-Control-Allow-Origin': '*', //allow CORS as API + 'Access-Control-Allow-Headers': 'Range', + 'Access-Control-Expose-Headers': 'Cache-Control, Content-Encoding, Content-Range', + 'Cache-Control': 'private', // only cache by client + 'X-Robots-Tag': 'noindex, nofollow' // prevent crawling + }); res.send(content); }); } else { @@ -346,6 +359,13 @@ function actionRevision(req, res, note) { var out = { revision: data }; + res.set({ + 'Access-Control-Allow-Origin': '*', //allow CORS as API + 'Access-Control-Allow-Headers': 'Range', + 'Access-Control-Expose-Headers': 'Cache-Control, Content-Encoding, Content-Range', + 'Cache-Control': 'private', // only cache by client + 'X-Robots-Tag': 'noindex, nofollow' // prevent crawling + }); res.send(out); }); } @@ -576,6 +596,9 @@ function showPublishSlide(req, res, next) { slides: slides, meta: JSON.stringify(obj.meta || {}), useCDN: config.usecdn, + owner: note.owner ? note.owner.id : null, + ownerprofile: note.owner ? models.User.parseProfile(note.owner.profile) : null, + lastchangeuser: note.lastchangeuser ? note.lastchangeuser.id : null, lastchangeuserprofile: note.lastchangeuser ? models.User.parseProfile(note.lastchangeuser.profile) : null, robots: meta.robots || false, //default allow robots GA: meta.GA, |