mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-01 15:48:32 -04:00
Move showNote to note controller
Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
parent
181d5646cf
commit
dee62ce571
3 changed files with 19 additions and 133 deletions
lib
|
@ -14,7 +14,6 @@ const errors = require('./errors')
|
|||
|
||||
// public
|
||||
var response = {
|
||||
showNote: showNote,
|
||||
showPublishNote: showPublishNote,
|
||||
showIndex: showIndex,
|
||||
publishNoteActions: publishNoteActions,
|
||||
|
@ -52,33 +51,6 @@ function showIndex (req, res, next) {
|
|||
}
|
||||
}
|
||||
|
||||
function responseCodiMD (res, note) {
|
||||
var body = note.content
|
||||
var extracted = models.Note.extractMeta(body)
|
||||
var meta = models.Note.parseMeta(extracted.meta)
|
||||
var title = models.Note.decodeTitle(note.title)
|
||||
title = models.Note.generateWebTitle(meta.title || title)
|
||||
var 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
|
||||
})
|
||||
}
|
||||
|
||||
function showNote (req, res, next) {
|
||||
noteUtil.findNote(req, res, function (note) {
|
||||
// force to use note id
|
||||
var noteId = req.params.noteId
|
||||
var id = models.Note.encodeNoteId(note.id)
|
||||
if ((note.alias && noteId !== note.alias) || (!note.alias && noteId !== id)) { return res.redirect(config.serverURL + '/' + (note.alias || id)) }
|
||||
return responseCodiMD(res, note)
|
||||
})
|
||||
}
|
||||
|
||||
function showPublishNote (req, res, next) {
|
||||
var include = [{
|
||||
model: models.User,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue