From 57835aa3ee50df2027b14ef0d46aa393687bc71c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Mon, 16 Dec 2013 23:58:24 +0100 Subject: [PATCH] Generating TOC. --- matrixgen.pl | 36 ++++++++++++++++++++++++++++++++++-- toc.pl | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 2 deletions(-) create mode 100755 toc.pl diff --git a/matrixgen.pl b/matrixgen.pl index 779e858..95845b1 100755 --- a/matrixgen.pl +++ b/matrixgen.pl @@ -198,10 +198,42 @@ foreach my $c (sort keys %components) { } } } + `cat /tmp/report-$c-install.part /tmp/report-$c-minor-upgrade.part /tmp/report-$c-major-upgrade.part /tmp/report-$c-double-upgrade.part /tmp/report-$c-update.part >> /tmp/report-body-$c.html 2>/dev/null`; + `rm -f /tmp/report-$c-*.part`; + + # TOC + # + # keep in sync with toc.pl + # + open TH, ">", "/tmp/toc-$c.html"; + open FH, "<", "/tmp/report-body-$c.html"; + if ($? == 0) { + my $i; + + printf TH "

Content

\n"; + while () { + chomp; + + if (/.*([^<]*)<\/H.*/) { + foreach $i (2..$2) { + printf TH "    "; + } + printf TH "$3
\n"; + } + } + printf TH "\n"; + close FH; + + printf TH "

Reports

\n"; + } + close TH; + `cat ../template.header.html | sed 's/\@TITLE\@/$c/' > /tmp/report-$c.html`; - `cat /tmp/report-$c-install.part /tmp/report-$c-minor-upgrade.part /tmp/report-$c-major-upgrade.part /tmp/report-$c-double-upgrade.part /tmp/report-$c-update.part >> /tmp/report-$c.html 2>/dev/null`; + `cat /tmp/toc-$c.html >> /tmp/report-$c.html`; + `cat /tmp/report-body-$c.html >> /tmp/report-$c.html`; `cat ../template.footer.html >> /tmp/report-$c.html`; - `rm -f /tmp/report-$c-*.part`; + + `rm -f /tmp/toc-$c.html /tmp/report-body-$c.html`; } diff --git a/toc.pl b/toc.pl new file mode 100755 index 0000000..bb0f590 --- /dev/null +++ b/toc.pl @@ -0,0 +1,45 @@ +#! /usr/bin/perl -w + +use strict; + +# +# keep in sync with gluer in matrixgen.pl +# + +# +# usage: +# cat report1.html report2.html... | ./toc.pl lb > reports.html +# + + # TOC + my $i; + my $c = 'Title'; + my $dir = `dirname $0`; + my $tmpbody = "/tmp/body.$$.html"; + chomp $dir; + + if ($#ARGV >= 0) { $c = $ARGV[0]; } + + system("cat $dir/template.header.html | sed 's/\@TITLE\@/$c/'"); + + open FH, ">", $tmpbody; + print "

Content

\n"; + while (<>) { + chomp; + printf FH "%s", "$_\n"; + + if (/.*([^<]*)<\/H.*/) { + foreach $i (2..$2) { + print "    "; + } + print "$3
\n"; + } + } + print "\n"; + close FH; + + print "

Reports

\n"; + + system("cat $tmpbody"); + system("cat $dir/template.footer.html"); + `rm -f $tmpbody`; -- 1.8.2.3