forked from external-repos/pa11y-dashboard
Add a readonly mode for demo/public-facing sites
This commit is contained in:
@@ -51,6 +51,9 @@ The boot configurations for pa11y-dashboard are as follows. Look at the sample J
|
|||||||
### noindex
|
### noindex
|
||||||
*(boolean)* If set to `true` (default), the dashboard will not be indexed by search engines. Set to `false` to allow indexing.
|
*(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
|
Development
|
||||||
-----------
|
-----------
|
||||||
|
15
app.js
15
app.js
@@ -53,8 +53,10 @@ function initApp (config, callback) {
|
|||||||
version: pkg.version,
|
version: pkg.version,
|
||||||
repo: pkg.homepage,
|
repo: pkg.homepage,
|
||||||
bugtracker: pkg.bugs,
|
bugtracker: pkg.bugs,
|
||||||
noindex: config.noindex
|
noindex: config.noindex,
|
||||||
|
readonly: config.readonly
|
||||||
});
|
});
|
||||||
|
|
||||||
app.express.use(function (req, res, next) {
|
app.express.use(function (req, res, next) {
|
||||||
res.locals.isHomePage = (req.path === '/');
|
res.locals.isHomePage = (req.path === '/');
|
||||||
res.locals.host = req.host;
|
res.locals.host = req.host;
|
||||||
@@ -63,12 +65,14 @@ function initApp (config, callback) {
|
|||||||
|
|
||||||
// Load routes
|
// Load routes
|
||||||
require('./route/index')(app);
|
require('./route/index')(app);
|
||||||
require('./route/new')(app);
|
|
||||||
require('./route/task/index')(app);
|
require('./route/task/index')(app);
|
||||||
require('./route/task/delete')(app);
|
|
||||||
require('./route/task/run')(app);
|
|
||||||
require('./route/result/index')(app);
|
require('./route/result/index')(app);
|
||||||
require('./route/result/download')(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
|
// Error handling
|
||||||
app.express.get('*', function (req, res) {
|
app.express.get('*', function (req, res) {
|
||||||
@@ -101,5 +105,8 @@ function defaultConfig (config) {
|
|||||||
if (typeof config.noindex !== 'boolean') {
|
if (typeof config.noindex !== 'boolean') {
|
||||||
config.noindex = true;
|
config.noindex = true;
|
||||||
}
|
}
|
||||||
|
if (typeof config.readonly !== 'boolean') {
|
||||||
|
config.readonly = false;
|
||||||
|
}
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"webservice": "http://localhost:3000/",
|
"webservice": "http://localhost:3000/",
|
||||||
"port": 4000,
|
"port": 4000,
|
||||||
"noindex": true
|
"noindex": true,
|
||||||
|
"readonly": false
|
||||||
}
|
}
|
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"webservice": "http://localhost:3000/",
|
"webservice": "http://localhost:3000/",
|
||||||
"port": 4000,
|
"port": 4000,
|
||||||
"noindex": true
|
"noindex": true,
|
||||||
|
"readonly": false
|
||||||
}
|
}
|
@@ -6,7 +6,9 @@
|
|||||||
<p class="h4">{{simplify-url task.url}}<span class="h5"> ({{task.standard}})</span></p>
|
<p class="h4">{{simplify-url task.url}}<span class="h5"> ({{task.standard}})</span></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3 col-sm-3 text-right run-details">
|
<div class="col-md-3 col-sm-3 text-right run-details">
|
||||||
<a href="{{task.hrefRun}}" class="btn btn-success">Run <span class="glyphicon glyphicon-play"></span></a>
|
{{#unless readonly}}
|
||||||
|
<a href="{{task.hrefRun}}" class="btn btn-success">Run <span class="glyphicon glyphicon-play"></span></a>
|
||||||
|
{{/unless}}
|
||||||
{{#if mainResult}}
|
{{#if mainResult}}
|
||||||
<div class="date">Last run : {{date-format mainResult.date format="DD MMM YYYY"}}</div>
|
<div class="date">Last run : {{date-format mainResult.date format="DD MMM YYYY"}}</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
@@ -1,12 +1,20 @@
|
|||||||
|
|
||||||
<ul class="list-unstyled clearfix crunch-bottom">
|
<ul class="list-unstyled clearfix crunch-bottom">
|
||||||
<li class="col-md-4 col-sm-6 task-card add-task">
|
<li class="col-md-4 col-sm-6 task-card add-task">
|
||||||
<a class="well task-card-link crunch-bottom" data-role="add-task" href="/new">
|
{{#if readonly}}
|
||||||
<p class="h3 crunch">Add new URL</p>
|
{{! TODO PERRY: make this look disabled }}
|
||||||
<p class="supersize-me crunch">+</p>
|
<span class="well task-card-link crunch-bottom">
|
||||||
</a>
|
<p class="h3 crunch">Add new URL</p>
|
||||||
|
<p class="supersize-me crunch">+</p>
|
||||||
|
</span>
|
||||||
|
{{else}}
|
||||||
|
<a class="well task-card-link crunch-bottom" data-role="add-task" href="/new">
|
||||||
|
<p class="h3 crunch">Add new URL</p>
|
||||||
|
<p class="supersize-me crunch">+</p>
|
||||||
|
</a>
|
||||||
|
{{/if}}
|
||||||
</li>
|
</li>
|
||||||
{{#tasks}}
|
{{#each tasks}}
|
||||||
<li class="col-md-4 col-sm-6 task-card">
|
<li class="col-md-4 col-sm-6 task-card">
|
||||||
<a class="well task-card-link crunch-bottom" title="Details for URL {{simplify-url url}}" href="{{href}}">
|
<a class="well task-card-link crunch-bottom" title="Details for URL {{simplify-url url}}" href="{{href}}">
|
||||||
<p class="h3">{{name}}</p>
|
<p class="h3">{{name}}</p>
|
||||||
@@ -24,7 +32,9 @@
|
|||||||
<p class="no-results">No results</p>
|
<p class="no-results">No results</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</a>
|
</a>
|
||||||
<a title="Delete this URL" class="delete-button" href="{{hrefDelete}}"><span class="sr-only">Delete </span><span class="glyphicon glyphicon-remove"></span></a>
|
{{#unless ../readonly}}
|
||||||
|
<a title="Delete this URL" class="delete-button" href="{{hrefDelete}}"><span class="sr-only">Delete </span><span class="glyphicon glyphicon-remove"></span></a>
|
||||||
|
{{/unless}}
|
||||||
</li>
|
</li>
|
||||||
{{/tasks}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
|
Reference in New Issue
Block a user