Inline responseCodiMD

Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
David Mehren 2019-10-27 15:29:10 +01:00
parent ca9e6e49c9
commit 3c39d07723
No known key found for this signature in database
GPG key ID: 6017AF117F9756CB

View file

@ -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
})
}