Skip to content

Commit 86ef0a6

Browse files
committed
cleaned up CGI output, added attribution, example
1 parent 9c98fd1 commit 86ef0a6

File tree

5 files changed

+48
-37
lines changed

5 files changed

+48
-37
lines changed

example/report_cgi.png

368 KB
Loading

lib/Mail/DMARC/Report/View/CLI.pm

-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ sub list {
1717
my $reports = $self->store->retrieve;
1818
foreach my $report ( reverse @$reports) {
1919
printf "%3s %20s %20s %15s\n", @$report{qw/ rid rcpt_domain from_domain begin /};
20-
foreach my $row ( @{ $report->{rows} } ) {
21-
printf "\t%15s %6s %6s \n", @$row{qw/ disposition dkim spf /};
22-
}
2320
}
2421
return $reports;
2522
}

lib/Mail/DMARC/Report/View/HTTP.pm

+7-1
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,15 @@ __END__
137137
138138
A HTTP interface for the local DMARC report store.
139139
140+
Start the HTTP server by running: dmarc_httpd
141+
142+
Connect with a web browser to L<http://localhost:8080|http://localhost:8080/>.
143+
140144
=head1 DESCRIPTION
141145
142-
This is implemented almost entirely in JavaScript, using jQuery, jQueryUI, and jgGrid.
146+
A L<Sample Report|http://search.cpan.org/dist/Mail-DMARC/example/report_cgi.png> is available which shows the web interface. It is implemented almost entirely in JavaScript, using jQuery, jQueryUI, and jgGrid.
147+
148+
Web server settings are in the [http] and [https] sections of mail-dmarc.ini.
143149
144150
=head1 THANKS
145151

share/html/index.html

+38-30
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,64 @@
22
<html>
33
<head>
44
<meta charset="utf-8" />
5-
<title>DMARC</title>
6-
<link rel="stylesheet" type="text/css" media="screen" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
5+
<title>Mail::DMARC::Report::View::HTTP</title>
6+
<link rel="stylesheet" type="text/css" media="screen" href="http://code.jquery.com/ui/1.10.3/themes/cupertino/jquery-ui.css" />
77
<link rel="stylesheet" type="text/css" media="screen" href="/dmarc/css/ui.jqgrid.css" />
88
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
99
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
1010
<script type="text/javascript" src="/dmarc/js/i18n/grid.locale-en.js"></script>
1111
<script type="text/javascript" src="/dmarc/js/jquery.jqGrid.min.js"></script>
1212

13+
<style type="text/css">
14+
html, body {
15+
margin: 0;
16+
padding: 0;
17+
font-size: 80%;
18+
}
19+
</style>
20+
1321
<script type="text/javascript">
14-
// Here we set the altRows option globally
15-
jQuery.extend(jQuery.jgrid.defaults, {
16-
altRows:true,
22+
// Set the options globally
23+
jQuery.extend(jQuery.jgrid.defaults, {
24+
altRows:true,
25+
datatype: "json",
1726
height:'500',
27+
jsonReader : {
28+
root: 'rows',
29+
page: 'cur_page',
30+
total: 'total_pages',
31+
records:'total_rows',
32+
repeatitems:false,
33+
subgrid: {
34+
root: 'rows',
35+
page: 'cur_page',
36+
total: 'total_pages',
37+
records:'total_rows',
38+
repeatitems:false,
39+
},
40+
},
41+
pager: '#gridpager',
1842
});
1943
</script>
2044

2145
<script type="text/javascript">
2246
jQuery(document).ready(function(){
2347
jQuery("#grid").jqGrid({
2448
url:'/dmarc/json/report',
25-
datatype: "json",
2649
mtype: 'POST',
27-
colNames:['Id','Begin','End','Recipient','From','Org Name','UUID'],
50+
colNames:['Id','Recipient','From','Org Name','Begin','End','UUID' ],
2851
colModel :[
2952
{name:'rid', index:'rid', width:30, align:'center', sortable: true },
30-
{name:'begin', index:'begin', width:90, sorttype:'date'},
31-
{name:'end', index:'end', width:90, sorttype:'date',},
3253
{name:'rcpt_domain', index:'rcpt_domain', width:135, align:'right', sortable: true},
3354
{name:'from_domain', index:'from_domain', width:135, align:'right', sortable: true},
3455
{name:'author', index:'author', width:170, align:'center' },
56+
{name:'begin', index:'begin', width:90, sorttype:'date'},
57+
{name:'end', index:'end', width:90, sorttype:'date',},
3558
{name:'uuid', index:'uuid', width:120, align:'left'},
3659
// {name:'type',index:'type', width:200,editable:true,edittype:'select',editoptions:{dataUrl: '/jqGridOptionData?entity=WineType'}},
3760
],
38-
jsonReader : {
39-
root: 'rows',
40-
page: 'cur_page',
41-
total: 'total_pages',
42-
records:'total_rows',
43-
repeatitems:false,
44-
subgrid: {
45-
root: 'rows',
46-
page: 'cur_page',
47-
total: 'total_pages',
48-
records:'total_rows',
49-
repeatitems:false,
50-
},
51-
},
5261
rowNum: 100,
5362
rowList: [50,100,500],
54-
pager: '#gridpager',
5563
sortname: 'rid',
5664
viewrecords: true,
5765
editurl:"/dmarc/json/record/edit",
@@ -60,12 +68,12 @@
6068
subGrid: true,
6169
subGridUrl:'/dmarc/json/row',
6270
subGridModel: [
63-
{
64-
name:['','IP','Count','Disposition','SPF','DKIM','Header From','Envelope To','Envelope From'],
65-
width:[50,100,10,30,30,40,100,100,100],
66-
align:[,'center','center','center','center','center','right','right','right'],
71+
{
72+
name:['','IP','Count','Disposition','SPF','DKIM','Envelope To','Envelope From'],
73+
width:[70,200,15,40,40,40,100,100,100],
74+
align:[,'center','center','center','center','center','right','right'],
6775
params: ['rid'],
68-
mapping: [,'source_ip','count','disposition','spf','dkim','header_from','envelope_to','envelope_from'],
76+
mapping: [,'source_ip','count','disposition','spf','dkim','envelope_to','envelope_from'],
6977
},
7078
],
7179
filterToolbar: {
@@ -84,7 +92,7 @@
8492
</head>
8593

8694
<body>
87-
<h2>DMARC Reports</h2>
95+
<p><a href="http://search.cpan.org/~msimerson/Mail-DMARC/">Mail::DMARC::Report::View::HTTP</a> - sponsored by <a href="http://www.colocateusa.net/">ColocateUSA</a>.</p>
8896

8997
<div id="mybutton"></div>
9098

t/15.Report.View.CLI.t

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ isa_ok( $cli, $mod );
1919

2020
$cli->store->backend->config('t/mail-dmarc.ini');
2121

22-
my $list = $cli->list();
23-
ok( $list, "list, ".scalar @$list );
24-
22+
# TODO: add a test report, so there's something to retrieve
23+
#my $list = $cli->list();
24+
#ok( ref $list, "list, ".ref $list );
2525
#warn Dumper($list);
2626

2727
done_testing();

0 commit comments

Comments
 (0)