From 3c39d07723e20cbd7facb68253ef1aead8da753c Mon Sep 17 00:00:00 2001 From: David Mehren Date: Sun, 27 Oct 2019 15:29:10 +0100 Subject: Inline responseCodiMD Signed-off-by: David Mehren --- lib/web/note/controller.js | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'lib/web/note/controller.js') diff --git a/lib/web/note/controller.js b/lib/web/note/controller.js index 3641f6b1..e537fe08 100644 --- a/lib/web/note/controller.js +++ b/lib/web/note/controller.js @@ -64,7 +64,20 @@ exports.showNote = function (req, res, next) { if ((note.alias && noteId !== note.alias) || (!note.alias && noteId !== id)) { return res.redirect(config.serverURL + '/' + (note.alias || id)) } - return responseCodiMD(res, note) + const body = note.content + const extracted = models.Note.extractMeta(body) + const meta = models.Note.parseMeta(extracted.meta) + let title = models.Note.decodeTitle(note.title) + title = models.Note.generateWebTitle(meta.title || title) + const opengraph = models.Note.parseOpengraph(meta, title) + res.set({ + 'Cache-Control': 'private', // only cache by client + 'X-Robots-Tag': 'noindex, nofollow' // prevent crawling + }) + return res.render('codimd.ejs', { + title: title, + opengraph: opengraph + }) }) } @@ -132,20 +145,3 @@ exports.downloadMarkdown = function (req, res, note) { }) res.send(body) } - -function responseCodiMD (res, note) { - const body = note.content - const extracted = models.Note.extractMeta(body) - const meta = models.Note.parseMeta(extracted.meta) - let title = models.Note.decodeTitle(note.title) - title = models.Note.generateWebTitle(meta.title || title) - const opengraph = models.Note.parseOpengraph(meta, title) - res.set({ - 'Cache-Control': 'private', // only cache by client - 'X-Robots-Tag': 'noindex, nofollow' // prevent crawling - }) - res.render('codimd.ejs', { - title: title, - opengraph: opengraph - }) -} -- cgit v1.2.3