mirror of
https://github.com/pa11y/pa11y-dashboard.git
synced 2025-09-24 22:31:15 +00:00
Add a readonly mode for demo/public-facing sites
This commit is contained in:
15
app.js
15
app.js
@@ -53,8 +53,10 @@ function initApp (config, callback) {
|
||||
version: pkg.version,
|
||||
repo: pkg.homepage,
|
||||
bugtracker: pkg.bugs,
|
||||
noindex: config.noindex
|
||||
noindex: config.noindex,
|
||||
readonly: config.readonly
|
||||
});
|
||||
|
||||
app.express.use(function (req, res, next) {
|
||||
res.locals.isHomePage = (req.path === '/');
|
||||
res.locals.host = req.host;
|
||||
@@ -63,12 +65,14 @@ function initApp (config, callback) {
|
||||
|
||||
// Load routes
|
||||
require('./route/index')(app);
|
||||
require('./route/new')(app);
|
||||
require('./route/task/index')(app);
|
||||
require('./route/task/delete')(app);
|
||||
require('./route/task/run')(app);
|
||||
require('./route/result/index')(app);
|
||||
require('./route/result/download')(app);
|
||||
if (!config.readonly) {
|
||||
require('./route/new')(app);
|
||||
require('./route/task/delete')(app);
|
||||
require('./route/task/run')(app);
|
||||
}
|
||||
|
||||
// Error handling
|
||||
app.express.get('*', function (req, res) {
|
||||
@@ -101,5 +105,8 @@ function defaultConfig (config) {
|
||||
if (typeof config.noindex !== 'boolean') {
|
||||
config.noindex = true;
|
||||
}
|
||||
if (typeof config.readonly !== 'boolean') {
|
||||
config.readonly = false;
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
Reference in New Issue
Block a user