diff --git a/README.md b/README.md index ae36a45..dacf03c 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,9 @@ The boot configurations for pa11y-dashboard are as follows. Look at the sample J ### noindex *(boolean)* If set to `true` (default), the dashboard will not be indexed by search engines. Set to `false` to allow indexing. +### readonly +*(boolean)* If set to `true`, users will not be able to add, delete or run URLs (defaults to `false`). + Development ----------- diff --git a/app.js b/app.js index 004178c..b271c00 100644 --- a/app.js +++ b/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; } diff --git a/config/development.sample.json b/config/development.sample.json index 14a708c..4986cb4 100644 --- a/config/development.sample.json +++ b/config/development.sample.json @@ -1,5 +1,6 @@ { "webservice": "http://localhost:3000/", "port": 4000, - "noindex": true + "noindex": true, + "readonly": false } \ No newline at end of file diff --git a/config/production.sample.json b/config/production.sample.json index 14a708c..4986cb4 100644 --- a/config/production.sample.json +++ b/config/production.sample.json @@ -1,5 +1,6 @@ { "webservice": "http://localhost:3000/", "port": 4000, - "noindex": true + "noindex": true, + "readonly": false } \ No newline at end of file diff --git a/view/partial/task-header.html b/view/partial/task-header.html index b141f8b..409d6f1 100644 --- a/view/partial/task-header.html +++ b/view/partial/task-header.html @@ -6,7 +6,9 @@

{{simplify-url task.url}} ({{task.standard}})

- Run + {{#unless readonly}} + Run + {{/unless}} {{#if mainResult}}
Last run : {{date-format mainResult.date format="DD MMM YYYY"}}
{{else}} diff --git a/view/partial/tasks.html b/view/partial/tasks.html index cb4c49b..bb6de38 100644 --- a/view/partial/tasks.html +++ b/view/partial/tasks.html @@ -1,12 +1,20 @@