Add a readonly mode for demo/public-facing sites

This commit is contained in:
Rowan Manning
2013-11-15 16:19:12 +00:00
parent 55d44685e9
commit 98bd9ed208
6 changed files with 38 additions and 14 deletions

View File

@@ -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
-----------

15
app.js
View File

@@ -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;
}

View File

@@ -1,5 +1,6 @@
{
"webservice": "http://localhost:3000/",
"port": 4000,
"noindex": true
"noindex": true,
"readonly": false
}

View File

@@ -1,5 +1,6 @@
{
"webservice": "http://localhost:3000/",
"port": 4000,
"noindex": true
"noindex": true,
"readonly": false
}

View File

@@ -6,7 +6,9 @@
<p class="h4">{{simplify-url task.url}}<span class="h5"> ({{task.standard}})</span></p>
</div>
<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}}
<div class="date">Last run : {{date-format mainResult.date format="DD MMM YYYY"}}</div>
{{else}}

View File

@@ -1,12 +1,20 @@
<ul class="list-unstyled clearfix crunch-bottom">
<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">
<p class="h3 crunch">Add new URL</p>
<p class="supersize-me crunch">+</p>
</a>
{{#if readonly}}
{{! TODO PERRY: make this look disabled }}
<span class="well task-card-link crunch-bottom">
<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>
{{#tasks}}
{{#each tasks}}
<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}}">
<p class="h3">{{name}}</p>
@@ -24,7 +32,9 @@
<p class="no-results">No results</p>
{{/if}}
</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>
{{/tasks}}
{{/each}}
</ul>