[collectd] Bug#575029: collectd2html.pl should produce XHTML

Max Henkel henkel at gmx.at
Thu Apr 8 12:06:29 CEST 2010


Hello Sebastian and list!

On Wed, Mar 24, 2010 at 05:52:47PM +0100, Sebastian Harl wrote:
[...]
> (This is a follow-up to Debian bug #575029 -- see
> <http://bugs.debian.org/575029> for details.)
> 
> On Wed, Mar 24, 2010 at 10:07:27PM +0600, Ivan Shmakov wrote:
> > >>>>> Sebastian Harl <tokkee at debian.org> writes:
> > >>>>> Ivan Shmakov wrote:
> > 
> >  >> As the support for XHTML becomes increasingly common, it may make
> >  >> sense to implement XHTML output in collectd2html.pl.
> > 
> > [...]
> > 
> >  > To cut a long story short: would you be willing to provide a patch
> >  > for that?
> > 
> > 	I'd be willing, but most likely unable to.  Not during the next
> > 	three weeks or so, at least.
> 
> Okay. With this E-mail, I'm forwarding the issue upstream. Let's see who
> manages to provide a patch first ;-)

Probably the attached one is suitable.

> >  > If not, I'd be forwarding the issue upstream, but I would not expect
> >  > much feedback. Patches are always very welcome (upstream), though.
> > 
> > 	ACK.
> > 
> > 	FWIW, the whole issue is, as it seems to me, mostly about
> > 	lowercasing the tags and checking the output with W3C Validator
> > 	(and fixing the issues reported.)
> 
> Yes -- I did not expect that to be hard, but it's rather boring work on
> something that seems to be used rarely.
[...]

Full ACK. Nonetheless there might be useful applications for it or
it can be used as a starting point for own developments.

Best regards,

Max
-- 
< henkel at gmx dot at >

---
 contrib/collectd2html.pl |   31 +++++++++++++++++--------------
 1 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/contrib/collectd2html.pl b/contrib/collectd2html.pl
index 7953d67..209e48c 100644
--- a/contrib/collectd2html.pl
+++ b/contrib/collectd2html.pl
@@ -118,14 +118,18 @@ open(OUT, ">$HTML");
 my $title="Rrd plot for $HOST";
 
 print OUT <<END;
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
-   "http://www.w3.org/TR/html4/loose.dtd">
-<html>
+<!DOCTYPE html PUBLIC
+  "-//W3C//DTD XHTML 1.1//EN"
+  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
+<style type="text/css" media="screen">
+body { text-align: center; }
+</style>
 <title>$title</title>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
 </head>
 <body>
-<center>
 END
 
 # list interesting rrd
@@ -147,20 +151,20 @@ foreach my $rrd (sort @list){
 
 # table of contents
 print OUT <<END;
-<A name="top"></A><H1>$title</H1>
-<P>
+<h1><a id="top">$title</a></h1>
+<p>
 END
 
 foreach my $bn (@rrds){
 	my $cleaned_bn = $bn;
 	$cleaned_bn =~ tr/%\//__/;
 	print OUT <<END;
-<A href="#$cleaned_bn">$bn</A>
+<a href="#$cleaned_bn">$bn</a>
 END
 }
 
 print OUT <<END;
-</P>
+</p>
 END
 
 # graph interesting rrd
@@ -205,7 +209,7 @@ for (my $i = 0; $i < scalar(@rrds); ++$i) {
 	my $cleaned_bn = $bn;
 	$cleaned_bn =~ tr/%\//__/;
 	print OUT <<END;
-<A name="$cleaned_bn"></A><H1>$bn</H1>
+<h1><a id="$cleaned_bn">$bn</a></h1>
 END
 
 	# graph various ranges
@@ -222,24 +226,23 @@ END
 		my $cleaned_img = $img; $cleaned_img =~ s/%/%25/g;
 		if (! $svg_p) {
 			print OUT <<END;
-<P><IMG src="$cleaned_img" alt="${bn} $span"></P>
+<p><img src="$cleaned_img" alt="${bn} $span" /></p>
 END
 		} else {
 			print OUT <<END;
-<P><object data="$cleaned_img" type="image/svg+xml"
+<p><object data="$cleaned_img" type="image/svg+xml"
            width="670" height="179">
-  ${bn} $span</object></P>
+  ${bn} $span</object></p>
 END
 		}
 	}
 
 	print OUT <<END;
-<A href="#top">[top]</A>
+<p><a href="#top">[top]</a></p>
 END
 }
 
 print OUT <<END;
-</center>
 </body>
 </html>
 END
-- 
1.7.0




More information about the collectd mailing list