summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Mehren2019-10-27 15:29:10 +0100
committerDavid Mehren2019-10-27 15:29:10 +0100
commit3c39d07723e20cbd7facb68253ef1aead8da753c (patch)
tree55728386ec63512aa61f035171b7a0dbe8534429 /lib
parentca9e6e49c9c80ecdd1f79635062f1cef4c931ffb (diff)
Inline responseCodiMD
Signed-off-by: David Mehren <dmehren1@gmail.com>
Diffstat (limited to '')
-rw-r--r--lib/web/note/controller.js32
1 files changed, 14 insertions, 18 deletions
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
- })
-}