mirror of https://github.com/requarks/wiki
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
891 B
49 lines
891 B
const express = require('express')
|
|
const router = express.Router()
|
|
const pageHelper = require('../helpers/page')
|
|
|
|
/* global WIKI */
|
|
|
|
/**
|
|
* Create/Edit document
|
|
*/
|
|
router.get(['/e', '/e/*'], (req, res, next) => {
|
|
res.render('editor')
|
|
})
|
|
|
|
/**
|
|
* Administration
|
|
*/
|
|
router.get(['/a', '/a/*'], (req, res, next) => {
|
|
res.render('admin')
|
|
})
|
|
|
|
/**
|
|
* Profile
|
|
*/
|
|
router.get(['/p', '/p/*'], (req, res, next) => {
|
|
res.render('profile')
|
|
})
|
|
|
|
/**
|
|
* View document
|
|
*/
|
|
router.get('/*', async (req, res, next) => {
|
|
const pageArgs = pageHelper.parsePath(req.path)
|
|
const page = await WIKI.models.pages.getPage({
|
|
path: pageArgs.path,
|
|
locale: pageArgs.locale,
|
|
userId: req.user.id,
|
|
isPrivate: false
|
|
})
|
|
if (page) {
|
|
res.render('page', { page })
|
|
} else if (pageArgs.path === 'home') {
|
|
res.render('welcome')
|
|
} else {
|
|
res.render('new')
|
|
}
|
|
})
|
|
|
|
module.exports = router
|