lib/ndd/url_checker/reporting_url_checker.html.erb
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
<style type="text/css">
.popover-title {
font-weight: bold;
}
.popover-content em {
font-style: normal;
font-weight: bold;
}
.popover-content ol {
margin-left: -20px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script language="JavaScript">
if (!window.ndd_url_checker) {
window.ndd_url_checker = {};
}
ndd_url_checker.STATES = ['direct', 'redirected', 'failed', 'too-many-redirects', 'unknown-host'];
ndd_url_checker.displayStates = function () {
var displayStates = {};
$.each(ndd_url_checker.STATES, function (_, state) {
var checked = $('.display-' + state).is(':checked');
displayStates[state] = checked;
});
return displayStates;
}
ndd_url_checker.filter = function () {
var displayStates = ndd_url_checker.displayStates();
$.each(displayStates, function (state, display) {
$('.result-' + state).toggle(display);
});
}
$(document).ready(function () {
// show or hide results depending on their state
$.each(ndd_url_checker.STATES, function (_, state) {
$('.display-' + state).change(function () {
ndd_url_checker.filter();
});
});
// activate all tooltips
$('[data-toggle="popover"]')
.popover()
.click(function (e) {
e.preventDefault();
});
});
</script>
</head>
<body>
<div class="container">
<div class="page-header">
<h1>
<span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span>
URL Checker Report
</h1>
</div>
<div class="row">
<div class="col-md-4">
<dl class="page-info dl-horizontal">
<dt>Number of URLs</dt>
<dd><%= urls.count %></dd>
<dt>Duration</dt>
<dd><%= benchmark.total_duration.round(3) %> s</dd>
<dt>Average duration</dt>
<dd><%= benchmark.average_duration.round(3) %> s/URL</dd>
<dt>Average throughput</dt>
<dd><%= benchmark.average_throughput.round(3) %> URL/s</dd>
</dl>
</div>
<div class="col-md-4">
<dl class="page-info dl-horizontal">
<dt>Valid URLS</dt>
<dd><%= urls.valid_count %></dd>
<dt>direct</dt>
<dd><%= urls.direct_count %></dd>
<dt>redirected</dt>
<dd><%= urls.redirected_count %></dd>
</dl>
</div>
<div class="col-md-4">
<dl class="page-info dl-horizontal">
<dt>Invalid URLS</dt>
<dd><%= urls.invalid_count %></dd>
<dt>failed</dt>
<dd><%= urls.failed_count %></dd>
<dt>too many redirects</dt>
<dd><%= urls.too_many_redirects_count %></dd>
<dt>unknown host</dt>
<dd><%= urls.unknown_host_count %></dd>
</dl>
</div>
</div>
<hr />
<div class="row page-controls hidden-print">
<div class="col-md-6">
<span>Valid URLs:</span>
<div class="btn-group page-display" data-toggle="buttons">
<label class="btn btn-default active">
<input type="checkbox" autocomplete="off" class="display-direct" checked="true" />
Direct (<%= urls.direct_count %>)
</label>
<label class="btn btn-default active">
<input type="checkbox" autocomplete="off" class="display-redirected" checked="true" />
Redirected (<%= urls.redirected_count %>)
</label>
</div>
</div>
<div class="col-md-6">
<span>Invalid URLs:</span>
<div class="btn-group page-display" data-toggle="buttons">
<label class="btn btn-default active">
<input type="checkbox" autocomplete="off" class="display-failed" checked="true" />
Failed (<%= urls.failed_count %>)
</label>
<label class="btn btn-default active">
<input type="checkbox" autocomplete="off" class="display-too-many-redirects" checked="true" />
Too many redirects (<%= urls.too_many_redirects_count %>)
</label>
<label class="btn btn-default active">
<input type="checkbox" autocomplete="off" class="display-unknown-host" checked="true" />
Unknown host (<%= urls.unknown_host_count %>)
</label>
</div>
</div>
</div>
<hr />
<table id="results" class="table table-condensed table-hover">
<thead>
<tr>
<th>#</th>
<th>URL</th>
<th>Code</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<% statuses.each_with_index do |status, index| %>
<tr class="result result-<%= status.code_as_css %> <%= status.invalid? ? 'danger' : '' %>">
<td><%= index+1 %></td>
<td><a href="<%= status.uri %>" target="_blank"><%= status.uri %></a></td>
<td><%= status.code %></td>
<td><%= status.details_title %></td>
<td>
<% if status.details_body %>
<a href="#" data-toggle="popover" data-placement="left" data-trigger="focus"
data-html="true" title="<%= status.uri %>" data-content="<%= status.details_body_as_html %>">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
</a>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</body>
</html>