removing superfluous config parameters for template files

Signed-off-by: Claudius <opensource@amenthes.de>
This commit is contained in:
Claudius 2018-09-10 22:35:38 +02:00 committed by WilliButz
parent 825ee4e66e
commit bb80bc2292
No known key found for this signature in database
GPG key ID: 92582A10F1179CB2
5 changed files with 11 additions and 22 deletions

2
app.js
View file

@ -170,7 +170,7 @@ app.use(require('./lib/web/middleware/codiMDVersion'))
// routes need sessions // routes need sessions
// template files // template files
app.set('views', path.join(__dirname, '/public/views')) app.set('views', config.viewPath)
// set render engine // set render engine
app.engine('ejs', ejs.renderFile) app.engine('ejs', ejs.renderFile)
// set view engine // set view engine

View file

@ -38,15 +38,10 @@ module.exports = {
sslCAPath: '', sslCAPath: '',
dhParamPath: '', dhParamPath: '',
// other path // other path
viewPath: './public/views',
tmpPath: './tmp', tmpPath: './tmp',
defaultNotePath: './public/default.md', defaultNotePath: './public/default.md',
docsPath: './public/docs', 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', uploadsPath: './public/uploads',
// session // session
sessionName: 'connect.sid', sessionName: 'connect.sid',

View file

@ -9,7 +9,7 @@ const deepFreeze = require('deep-freeze')
const {Environment, Permission} = require('./enum') const {Environment, Permission} = require('./enum')
const logger = require('../logger') const logger = require('../logger')
const appRootPath = path.join(__dirname, '../../') const appRootPath = path.resolve(__dirname, '../../')
const env = process.env.NODE_ENV || Environment.development const env = process.env.NODE_ENV || Environment.development
const debugConfig = { const debugConfig = {
debug: (env === Environment.development) debug: (env === Environment.development)
@ -177,16 +177,10 @@ config.sslCAPath.forEach(function (capath, i, array) {
config.sslCertPath = path.resolve(appRootPath, config.sslCertPath) config.sslCertPath = path.resolve(appRootPath, config.sslCertPath)
config.sslKeyPath = path.resolve(appRootPath, config.sslKeyPath) config.sslKeyPath = path.resolve(appRootPath, config.sslKeyPath)
config.dhParamPath = path.resolve(appRootPath, config.dhParamPath) config.dhParamPath = path.resolve(appRootPath, config.dhParamPath)
config.viewPath = path.resolve(appRootPath, config.viewPath)
config.tmpPath = path.resolve(appRootPath, config.tmpPath) config.tmpPath = path.resolve(appRootPath, config.tmpPath)
config.defaultNotePath = path.resolve(appRootPath, config.defaultNotePath) config.defaultNotePath = path.resolve(appRootPath, config.defaultNotePath)
config.docsPath = path.resolve(appRootPath, config.docsPath) config.docsPath = path.resolve(appRootPath, config.docsPath)
config.indexPath = path.resolve(appRootPath, config.indexPath)
config.codimdPath = path.resolve(appRootPath, config.codimdPath)
config.errorPath = path.resolve(appRootPath, config.errorPath)
config.prettyPath = path.resolve(appRootPath, config.prettyPath)
config.slidePath = path.resolve(appRootPath, config.slidePath)
config.constantsPath = path.resolve(appRootPath, config.constantsPath)
config.uploadsPath = path.resolve(appRootPath, config.uploadsPath) config.uploadsPath = path.resolve(appRootPath, config.uploadsPath)
// make config readonly // make config readonly

View file

@ -51,7 +51,7 @@ var response = {
} }
function responseError (res, code, detail, msg) { function responseError (res, code, detail, msg) {
res.status(code).render(config.errorPath, { res.status(code).render('error.ejs', {
url: config.serverURL, url: config.serverURL,
title: code + ' ' + detail + ' ' + msg, title: code + ' ' + detail + ' ' + msg,
code: code, code: code,
@ -101,11 +101,11 @@ function showIndex (req, res, next) {
}).then(function (user) { }).then(function (user) {
if (user) { if (user) {
data.deleteToken = user.deleteToken data.deleteToken = user.deleteToken
res.render(config.indexPath, data) res.render('index.ejs', data)
} }
}) })
} else { } else {
res.render(config.indexPath, data) res.render('index.ejs', data)
} }
} }
@ -119,7 +119,7 @@ function responseCodiMD (res, note) {
'Cache-Control': 'private', // only cache by client 'Cache-Control': 'private', // only cache by client
'X-Robots-Tag': 'noindex, nofollow' // prevent crawling 'X-Robots-Tag': 'noindex, nofollow' // prevent crawling
}) })
res.render(config.codimdPath, { res.render('codimd.ejs', {
url: config.serverURL, url: config.serverURL,
title: title, title: title,
useCDN: config.useCDN, useCDN: config.useCDN,
@ -275,7 +275,7 @@ function renderPublish (data, res) {
res.set({ res.set({
'Cache-Control': 'private' // only cache by client 'Cache-Control': 'private' // only cache by client
}) })
res.render(config.prettyPath, data) res.render('pretty.ejs', data)
} }
function actionPublish (req, res, note) { function actionPublish (req, res, note) {
@ -657,7 +657,7 @@ function renderPublishSlide (data, res) {
res.set({ res.set({
'Cache-Control': 'private' // only cache by client 'Cache-Control': 'private' // only cache by client
}) })
res.render(config.slidePath, data) res.render('slide.ejs', data)
} }
module.exports = response module.exports = response

View file

@ -105,5 +105,5 @@ statusRouter.get('/config', function (req, res) {
'X-Robots-Tag': 'noindex, nofollow', // prevent crawling 'X-Robots-Tag': 'noindex, nofollow', // prevent crawling
'Content-Type': 'application/javascript' 'Content-Type': 'application/javascript'
}) })
res.render(config.constantsPath, data) res.render('../js/lib/common/constant.ejs', data)
}) })