diff options
Diffstat (limited to '')
-rw-r--r-- | app.js | 2 | ||||
-rw-r--r-- | lib/config/default.js | 7 | ||||
-rw-r--r-- | lib/config/index.js | 10 | ||||
-rw-r--r-- | lib/response.js | 12 | ||||
-rw-r--r-- | lib/web/statusRouter.js | 2 |
5 files changed, 11 insertions, 22 deletions
@@ -170,7 +170,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 diff --git a/lib/config/default.js b/lib/config/default.js index 6096bce4..5d10ad26 100644 --- a/lib/config/default.js +++ b/lib/config/default.js @@ -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', diff --git a/lib/config/index.js b/lib/config/index.js index 59db8612..7d059c5c 100644 --- a/lib/config/index.js +++ b/lib/config/index.js @@ -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) @@ -177,16 +177,10 @@ config.sslCAPath.forEach(function (capath, i, array) { config.sslCertPath = path.resolve(appRootPath, config.sslCertPath) config.sslKeyPath = path.resolve(appRootPath, config.sslKeyPath) config.dhParamPath = path.resolve(appRootPath, config.dhParamPath) - +config.viewPath = path.resolve(appRootPath, config.viewPath) config.tmpPath = path.resolve(appRootPath, config.tmpPath) config.defaultNotePath = path.resolve(appRootPath, config.defaultNotePath) 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) // make config readonly diff --git a/lib/response.js b/lib/response.js index 295f91d6..88623043 100644 --- a/lib/response.js +++ b/lib/response.js @@ -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, @@ -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) } } @@ -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, @@ -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) { @@ -657,7 +657,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 diff --git a/lib/web/statusRouter.js b/lib/web/statusRouter.js index 7ecf3839..fb2609ea 100644 --- a/lib/web/statusRouter.js +++ b/lib/web/statusRouter.js @@ -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) }) |