Skip to content

Commit bb80bc2

Browse files
ccoenenWilliButz
authored andcommitted
removing superfluous config parameters for template files
Signed-off-by: Claudius <[email protected]>
1 parent 825ee4e commit bb80bc2

File tree

5 files changed

+11
-22
lines changed

5 files changed

+11
-22
lines changed

app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ app.use(require('./lib/web/middleware/codiMDVersion'))
170170

171171
// routes need sessions
172172
// template files
173-
app.set('views', path.join(__dirname, '/public/views'))
173+
app.set('views', config.viewPath)
174174
// set render engine
175175
app.engine('ejs', ejs.renderFile)
176176
// set view engine

lib/config/default.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,10 @@ module.exports = {
3838
sslCAPath: '',
3939
dhParamPath: '',
4040
// other path
41+
viewPath: './public/views',
4142
tmpPath: './tmp',
4243
defaultNotePath: './public/default.md',
4344
docsPath: './public/docs',
44-
indexPath: './public/views/index.ejs',
45-
codimdPath: './public/views/codimd.ejs',
46-
errorPath: './public/views/error.ejs',
47-
prettyPath: './public/views/pretty.ejs',
48-
slidePath: './public/views/slide.ejs',
49-
constantsPath: './public/js/lib/common/constant.ejs',
5045
uploadsPath: './public/uploads',
5146
// session
5247
sessionName: 'connect.sid',

lib/config/index.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const deepFreeze = require('deep-freeze')
99
const {Environment, Permission} = require('./enum')
1010
const logger = require('../logger')
1111

12-
const appRootPath = path.join(__dirname, '../../')
12+
const appRootPath = path.resolve(__dirname, '../../')
1313
const env = process.env.NODE_ENV || Environment.development
1414
const debugConfig = {
1515
debug: (env === Environment.development)
@@ -177,16 +177,10 @@ config.sslCAPath.forEach(function (capath, i, array) {
177177
config.sslCertPath = path.resolve(appRootPath, config.sslCertPath)
178178
config.sslKeyPath = path.resolve(appRootPath, config.sslKeyPath)
179179
config.dhParamPath = path.resolve(appRootPath, config.dhParamPath)
180-
180+
config.viewPath = path.resolve(appRootPath, config.viewPath)
181181
config.tmpPath = path.resolve(appRootPath, config.tmpPath)
182182
config.defaultNotePath = path.resolve(appRootPath, config.defaultNotePath)
183183
config.docsPath = path.resolve(appRootPath, config.docsPath)
184-
config.indexPath = path.resolve(appRootPath, config.indexPath)
185-
config.codimdPath = path.resolve(appRootPath, config.codimdPath)
186-
config.errorPath = path.resolve(appRootPath, config.errorPath)
187-
config.prettyPath = path.resolve(appRootPath, config.prettyPath)
188-
config.slidePath = path.resolve(appRootPath, config.slidePath)
189-
config.constantsPath = path.resolve(appRootPath, config.constantsPath)
190184
config.uploadsPath = path.resolve(appRootPath, config.uploadsPath)
191185

192186
// make config readonly

lib/response.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var response = {
5151
}
5252

5353
function responseError (res, code, detail, msg) {
54-
res.status(code).render(config.errorPath, {
54+
res.status(code).render('error.ejs', {
5555
url: config.serverURL,
5656
title: code + ' ' + detail + ' ' + msg,
5757
code: code,
@@ -101,11 +101,11 @@ function showIndex (req, res, next) {
101101
}).then(function (user) {
102102
if (user) {
103103
data.deleteToken = user.deleteToken
104-
res.render(config.indexPath, data)
104+
res.render('index.ejs', data)
105105
}
106106
})
107107
} else {
108-
res.render(config.indexPath, data)
108+
res.render('index.ejs', data)
109109
}
110110
}
111111

@@ -119,7 +119,7 @@ function responseCodiMD (res, note) {
119119
'Cache-Control': 'private', // only cache by client
120120
'X-Robots-Tag': 'noindex, nofollow' // prevent crawling
121121
})
122-
res.render(config.codimdPath, {
122+
res.render('codimd.ejs', {
123123
url: config.serverURL,
124124
title: title,
125125
useCDN: config.useCDN,
@@ -275,7 +275,7 @@ function renderPublish (data, res) {
275275
res.set({
276276
'Cache-Control': 'private' // only cache by client
277277
})
278-
res.render(config.prettyPath, data)
278+
res.render('pretty.ejs', data)
279279
}
280280

281281
function actionPublish (req, res, note) {
@@ -657,7 +657,7 @@ function renderPublishSlide (data, res) {
657657
res.set({
658658
'Cache-Control': 'private' // only cache by client
659659
})
660-
res.render(config.slidePath, data)
660+
res.render('slide.ejs', data)
661661
}
662662

663663
module.exports = response

lib/web/statusRouter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,5 @@ statusRouter.get('/config', function (req, res) {
105105
'X-Robots-Tag': 'noindex, nofollow', // prevent crawling
106106
'Content-Type': 'application/javascript'
107107
})
108-
res.render(config.constantsPath, data)
108+
res.render('../js/lib/common/constant.ejs', data)
109109
})

0 commit comments

Comments
 (0)