1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## bts575029-collectd2html-xhtml.dpatch by Max Henkel <henkel@gmx.at> and
3 ## Timur Kirilichev <dontstay@pochta.ru>
4 ##
5 ## DP: collectd2html.pl: Added support for XHTML.
7 @DPATCH@
9 diff a/contrib/collectd2html.pl b/contrib/collectd2html.pl
10 --- a/contrib/collectd2html.pl
11 +++ b/contrib/collectd2html.pl
12 @@ -68,7 +68,7 @@ $HOST = $tmp[0] if (! defined $HOST);
13 my $svg_p = ($IMG_FMT eq "SVG");
14 my $IMG_SFX = $svg_p ? ".svg" : ".png";
15 my $IMG_DIR = "${HOST}.dir";
16 -my $HTML = "${HOST}.html";
17 +my $HTML = "${HOST}.xhtml";
19 ################################################################################
20 #
21 @@ -118,14 +118,20 @@ open(OUT, ">$HTML");
22 my $title="Rrd plot for $HOST";
24 print OUT <<END;
25 -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
26 - "http://www.w3.org/TR/html4/loose.dtd">
27 -<html>
28 +<!DOCTYPE html PUBLIC
29 + "-//W3C//DTD XHTML 1.1//EN"
30 + "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
31 +<html xmlns="http://www.w3.org/1999/xhtml">
32 <head>
33 +<style type="text/css" media="screen">
34 +.graph { text-align: center; }
35 +object.graph { width: 670; height: 179; }
36 +</style>
37 <title>$title</title>
38 +<meta http-equiv="Content-Type"
39 + content="application/xhtml+xml; charset=us-ascii" />
40 </head>
41 <body>
42 -<center>
43 END
45 # list interesting rrd
46 @@ -148,20 +154,20 @@ foreach my $rrd (@list){
48 # table of contents
49 print OUT <<END;
50 -<A name="top"></A><H1>$title</H1>
51 -<P>
52 +<h1><a id="top">$title</a></h1>
53 +<p>
54 END
56 foreach my $bn (@rrds){
57 my $cleaned_bn = $bn;
58 $cleaned_bn =~ tr/%\//__/;
59 print OUT <<END;
60 -<A href="#$cleaned_bn">$bn</A>
61 +<a href="#$cleaned_bn">$bn</a>
62 END
63 }
65 print OUT <<END;
66 -</P>
67 +</p>
68 END
70 # graph interesting rrd
71 @@ -206,7 +212,7 @@ for (my $i = 0; $i < scalar(@rrds); ++$i) {
72 my $cleaned_bn = $bn;
73 $cleaned_bn =~ tr/%\//__/;
74 print OUT <<END;
75 -<A name="$cleaned_bn"></A><H1>$bn</H1>
76 +<h2><a id="$cleaned_bn">$bn</a></h2>
77 END
79 # graph various ranges
80 @@ -223,24 +229,28 @@ END
81 my $cleaned_img = $img; $cleaned_img =~ s/%/%25/g;
82 if (! $svg_p) {
83 print OUT <<END;
84 -<P><IMG src="$cleaned_img" alt="${bn} $span"></P>
85 +<p class="graph"><img src="$cleaned_img" alt="${bn} $span" /></p>
86 END
87 } else {
88 print OUT <<END;
89 -<P><object data="$cleaned_img" type="image/svg+xml"
90 - width="670" height="179">
91 - ${bn} $span</object></P>
92 +<p class="graph"><object data="$cleaned_img" type="image/svg+xml">
93 + ${bn} $span</object></p>
94 END
95 }
96 }
98 print OUT <<END;
99 -<A href="#top">[top]</A>
100 +<p><a href="#top">[top]</a></p>
101 END
102 }
104 print OUT <<END;
105 -</center>
106 +<hr />
107 +<p>
108 + <a href="http://validator.w3.org/check?uri=referer"><img
109 + src="http://www.w3.org/Icons/valid-xhtml10"
110 + alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
111 +</p>
112 </body>
113 </html>
114 END