feat: source + history (wip)

This commit is contained in:
Nicolas Giard
2018-11-25 01:28:20 -05:00
parent 076aeaf749
commit 78ba895eee
17 changed files with 374 additions and 81 deletions

View File

@@ -46,11 +46,11 @@ router.get(['/p', '/p/*'], (req, res, next) => {
})
/**
* View document
* History
*/
router.get(['/h', '/h/*'], async (req, res, next) => {
const pageArgs = pageHelper.parsePath(req.path)
const page = await WIKI.models.pages.getPage({
const page = await WIKI.models.pages.getPageFromDb({
path: pageArgs.path,
locale: pageArgs.locale,
userId: req.user.id,
@@ -63,6 +63,24 @@ router.get(['/h', '/h/*'], async (req, res, next) => {
}
})
/**
* Source
*/
router.get(['/s', '/s/*'], async (req, res, next) => {
const pageArgs = pageHelper.parsePath(req.path)
const page = await WIKI.models.pages.getPageFromDb({
path: pageArgs.path,
locale: pageArgs.locale,
userId: req.user.id,
isPrivate: false
})
if (page) {
res.render('source', { page })
} else {
res.redirect(`/${pageArgs.path}`)
}
})
/**
* View document
*/