|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
const express = require('express')
|
|
|
|
|
const router = express.Router()
|
|
|
|
|
const pageHelper = require('../helpers/page')
|
|
|
|
|
const _ = require('lodash')
|
|
|
|
|
|
|
|
|
|
/* global WIKI */
|
|
|
|
|
|
|
|
|
@ -16,10 +17,13 @@ router.get(['/e', '/e/*'], async (req, res, next) => {
|
|
|
|
|
isPrivate: false
|
|
|
|
|
})
|
|
|
|
|
if (page) {
|
|
|
|
|
_.set(res.locals, 'pageMeta.title', `Edit ${page.title}`)
|
|
|
|
|
_.set(res.locals, 'pageMeta.description', page.description)
|
|
|
|
|
page.mode = 'update'
|
|
|
|
|
page.isPublished = (page.isPublished === true || page.isPublished === 1) ? 'true' : 'false'
|
|
|
|
|
page.content = Buffer.from(page.content).toString('base64')
|
|
|
|
|
} else {
|
|
|
|
|
_.set(res.locals, 'pageMeta.title', `New Page`)
|
|
|
|
|
page = {
|
|
|
|
|
path: pageArgs.path,
|
|
|
|
|
localeCode: pageArgs.locale,
|
|
|
|
@ -35,6 +39,7 @@ router.get(['/e', '/e/*'], async (req, res, next) => {
|
|
|
|
|
* Administration
|
|
|
|
|
*/
|
|
|
|
|
router.get(['/a', '/a/*'], (req, res, next) => {
|
|
|
|
|
_.set(res.locals, 'pageMeta.title', 'Admin')
|
|
|
|
|
res.render('admin')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
@ -42,6 +47,7 @@ router.get(['/a', '/a/*'], (req, res, next) => {
|
|
|
|
|
* Profile
|
|
|
|
|
*/
|
|
|
|
|
router.get(['/p', '/p/*'], (req, res, next) => {
|
|
|
|
|
_.set(res.locals, 'pageMeta.title', 'User Profile')
|
|
|
|
|
res.render('profile')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
@ -57,6 +63,8 @@ router.get(['/h', '/h/*'], async (req, res, next) => {
|
|
|
|
|
isPrivate: false
|
|
|
|
|
})
|
|
|
|
|
if (page) {
|
|
|
|
|
_.set(res.locals, 'pageMeta.title', page.title)
|
|
|
|
|
_.set(res.locals, 'pageMeta.description', page.description)
|
|
|
|
|
res.render('history', { page })
|
|
|
|
|
} else {
|
|
|
|
|
res.redirect(`/${pageArgs.path}`)
|
|
|
|
@ -75,6 +83,8 @@ router.get(['/s', '/s/*'], async (req, res, next) => {
|
|
|
|
|
isPrivate: false
|
|
|
|
|
})
|
|
|
|
|
if (page) {
|
|
|
|
|
_.set(res.locals, 'pageMeta.title', page.title)
|
|
|
|
|
_.set(res.locals, 'pageMeta.description', page.description)
|
|
|
|
|
res.render('source', { page })
|
|
|
|
|
} else {
|
|
|
|
|
res.redirect(`/${pageArgs.path}`)
|
|
|
|
@ -93,6 +103,8 @@ router.get('/*', async (req, res, next) => {
|
|
|
|
|
isPrivate: false
|
|
|
|
|
})
|
|
|
|
|
if (page) {
|
|
|
|
|
_.set(res.locals, 'pageMeta.title', page.title)
|
|
|
|
|
_.set(res.locals, 'pageMeta.description', page.description)
|
|
|
|
|
const sidebar = await WIKI.models.navigation.getTree({ cache: true })
|
|
|
|
|
res.render('page', { page, sidebar })
|
|
|
|
|
} else if (pageArgs.path === 'home') {
|
|
|
|
|