Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ app.use(require('./lib/web/middleware/codiMDVersion'))

// routes need sessions
// template files
app.set('views', path.join(__dirname, '/public/views'))
app.set('views', config.viewPath)
// set render engine
app.engine('ejs', ejs.renderFile)
// set view engine
Expand Down
7 changes: 1 addition & 6 deletions lib/config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,10 @@ module.exports = {
sslCAPath: '',
dhParamPath: '',
// other path
viewPath: './public/views',
tmpPath: './tmp',
defaultNotePath: './public/default.md',
docsPath: './public/docs',
indexPath: './public/views/index.ejs',
codimdPath: './public/views/codimd.ejs',
errorPath: './public/views/error.ejs',
prettyPath: './public/views/pretty.ejs',
slidePath: './public/views/slide.ejs',
constantsPath: './public/js/lib/common/constant.ejs',
uploadsPath: './public/uploads',
// session
sessionName: 'connect.sid',
Expand Down
9 changes: 2 additions & 7 deletions lib/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const deepFreeze = require('deep-freeze')
const {Environment, Permission} = require('./enum')
const logger = require('../logger')

const appRootPath = path.join(__dirname, '../../')
const appRootPath = path.resolve(__dirname, '../../')
const env = process.env.NODE_ENV || Environment.development
const debugConfig = {
debug: (env === Environment.development)
Expand Down Expand Up @@ -177,15 +177,10 @@ config.sslCertPath = path.join(appRootPath, config.sslCertPath)
config.sslKeyPath = path.join(appRootPath, config.sslKeyPath)
config.dhParamPath = path.join(appRootPath, config.dhParamPath)

config.viewPath = path.resolve(appRootPath, config.viewPath)
config.tmpPath = path.join(appRootPath, config.tmpPath)
config.defaultNotePath = path.join(appRootPath, config.defaultNotePath)
config.docsPath = path.join(appRootPath, config.docsPath)
config.indexPath = path.join(appRootPath, config.indexPath)
config.codimdPath = path.join(appRootPath, config.codimdPath)
config.errorPath = path.join(appRootPath, config.errorPath)
config.prettyPath = path.join(appRootPath, config.prettyPath)
config.slidePath = path.join(appRootPath, config.slidePath)
config.constantsPath = path.join(appRootPath, config.constantsPath)
config.uploadsPath = path.join(appRootPath, config.uploadsPath)

// make config readonly
Expand Down
12 changes: 6 additions & 6 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var response = {
}

function responseError (res, code, detail, msg) {
res.status(code).render(config.errorPath, {
res.status(code).render('error.ejs', {
url: config.serverURL,
title: code + ' ' + detail + ' ' + msg,
code: code,
Expand Down Expand Up @@ -101,11 +101,11 @@ function showIndex (req, res, next) {
}).then(function (user) {
if (user) {
data.deleteToken = user.deleteToken
res.render(config.indexPath, data)
res.render('index.ejs', data)
}
})
} else {
res.render(config.indexPath, data)
res.render('index.ejs', data)
}
}

Expand All @@ -119,7 +119,7 @@ function responseCodiMD (res, note) {
'Cache-Control': 'private', // only cache by client
'X-Robots-Tag': 'noindex, nofollow' // prevent crawling
})
res.render(config.codimdPath, {
res.render('codimd.ejs', {
url: config.serverURL,
title: title,
useCDN: config.useCDN,
Expand Down Expand Up @@ -275,7 +275,7 @@ function renderPublish (data, res) {
res.set({
'Cache-Control': 'private' // only cache by client
})
res.render(config.prettyPath, data)
res.render('pretty.ejs', data)
}

function actionPublish (req, res, note) {
Expand Down Expand Up @@ -653,7 +653,7 @@ function renderPublishSlide (data, res) {
res.set({
'Cache-Control': 'private' // only cache by client
})
res.render(config.slidePath, data)
res.render('slide.ejs', data)
}

module.exports = response
2 changes: 1 addition & 1 deletion lib/web/statusRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,5 @@ statusRouter.get('/config', function (req, res) {
'X-Robots-Tag': 'noindex, nofollow', // prevent crawling
'Content-Type': 'application/javascript'
})
res.render(config.constantsPath, data)
res.render('../js/lib/common/constant.ejs', data)
})