header and hide fields

This commit is contained in:
Laura Carvajal
2016-10-17 12:23:48 +01:00
committed by Rowan Manning
parent c562bb07f3
commit 39435f37e4
5 changed files with 50 additions and 12 deletions

View File

@@ -1,12 +0,0 @@
{
"port": 4000,
"noindex": true,
"readonly": false,
"webservice": {
"database": "mongodb://localhost/pa11y-webservice-test",
"host": "0.0.0.0",
"port": 3000,
"cron": "0 30 0 * * *"
}
}

View File

@@ -36,6 +36,15 @@ function route(app) {
});
app.express.post('/new', (req, res) => {
let parsedHeaders = '';
try {
parsedHeaders = JSON.parse(req.body.headers);
} catch (e) {
console.log(`error parsing headers object: ${req.body.headers}. Ignoring.`);
}
const newTask = {
name: req.body.name,
url: req.body.url,
@@ -45,7 +54,10 @@ function route(app) {
wait: req.body.wait || undefined,
username: req.body.username || undefined,
password: req.body.password || undefined
headers: parsedHeaders || undefined,
hideElements: req.body.hide || undefined
};
app.webservice.tasks.create(newTask, (err, task) => {
if (err) {
const standards = getStandards().map(standard => {

View File

@@ -69,6 +69,8 @@ function route(app) {
task.wait = req.body.wait;
task.username = req.body.username;
task.password = req.body.password;
task.headers = req.body.headers;
task.hideElements = req.body.hideElements;
const standards = getStandards().map(standard => {
if (standard.title === task.standard) {
standard.selected = true;

View File

@@ -102,6 +102,24 @@ along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
</div>
</div>
<div class="form-group clearfix">
<div class="row">
<div class="col-md-4 col-sm-4 col-xs-6">
<label class="control-label" for="new-task-headers">Headers Object (JSON)</label>
<input class="form-control" id="new-task-headers" type="text" name="headers" value="{{task.headers}}" placeholder='{headers: {"Cookie": "foo=bar"}}'/>
</div>
</div>
</div>
<div class="form-group clearfix">
<div class="row">
<div class="col-md-4 col-sm-4 col-xs-6">
<label class="control-label" for="new-task-hide-elements">Hide Elements</label>
<input class="form-control" id="new-task-hide-elements" type="text" name="hide-elements" value="{{task.hide-elements}}" placeholder=".advert, #modal, div[aria-role=presentation]"/> <em>(CSS selector)</em>
</div>
</div>
</div>
<p class="control-label"><b>Ignore these rules</b> <a target="_blank" href="https://github.com/pa11y/pa11y/wiki/HTML-CodeSniffer-Rules">(full list of rules here)</a></p>
<div class="standards-lists">

View File

@@ -114,6 +114,24 @@ along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
</div>
</div>
<div class="form-group clearfix">
<div class="row">
<div class="col-md-4 col-sm-4 col-xs-6">
<label class="control-label" for="new-task-headers">Headers Object (JSON)</label>
<input class="form-control" id="new-task-headers" type="text" name="headers" value="{{task.headers}}" placeholder='{headers: {"Cookie": "foo=bar"}}'/>
</div>
</div>
</div>
<div class="form-group clearfix">
<div class="row">
<div class="col-md-4 col-sm-4 col-xs-6">
<label class="control-label" for="new-task-hide-elements">Hide Elements</label>
<input class="form-control" id="new-task-hide-elements" type="text" name="hide-elements" value="{{task.hide-elements}}" placeholder=".advert, #modal, div[aria-role=presentation]"/> <em>(CSS selector)</em>
</div>
</div>
</div>
<p class="control-label"><b>Ignore these rules</b> <a target="_blank" href="https://github.com/pa11y/pa11y/wiki/HTML-CodeSniffer-Rules">(full list of rules here)</a></p>
<div class="standards-lists">