From 338ae34c0772184cadccb6e0f683c24533c0bc1d Mon Sep 17 00:00:00 2001 From: Morgan Aldridge Date: Thu, 10 Dec 2015 13:12:10 -0500 Subject: [PATCH] Applied mrtg-rrd.cgi-patch-addhead_pagetop_pagefoot_for_directories.diff from 2009-04-09 from http://www.makkintosshu.com/development/#mrtg-rrdcgi-patch-addhead-bodytag-pagefoot-support-in-directory-listings, which modifies parse_directories() & print_dir() so that AddHead[_], PageTop[_], and PageFoot[_] defaults work on directory listing pages. --- mrtg-rrd.cgi | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/mrtg-rrd.cgi b/mrtg-rrd.cgi index 7e0f615..69b1458 100755 --- a/mrtg-rrd.cgi +++ b/mrtg-rrd.cgi @@ -728,12 +728,12 @@ sub try_read_config($) read_mrtg_config($cfgfile, \%defaults, $cfgref, \$order); } + parse_directories(); + delete $targets{'^'}; delete $targets{_}; delete $targets{'$'}; - parse_directories(); - $config_time = time; } @@ -852,6 +852,8 @@ sub parse_directories { # FIXME: the sort is expensive for my $name (sort { $targets{$a}{order} <=> $targets{$b}{order} } keys %targets) { + next if $name =~ /^[\$\^_]$/; + my $dir = $targets{$name}{directory} if defined $targets{$name}{directory}; $dir = '' unless defined $dir; @@ -869,6 +871,9 @@ sub parse_directories { $targets{$name}{config}; $directories{$prefix}{bodytag} = $targets{$name}{bodytag}; + $directories{$prefix}{addhead} = $targets{_}{addhead}; + $directories{$prefix}{pagetop} = $targets{_}{pagetop}; + $directories{$prefix}{pagefoot} = $targets{_}{pagefoot}; } $prefix .= $component . '/'; } @@ -877,6 +882,9 @@ sub parse_directories { $targets{$name}{config}; $directories{$dir}{bodytag} = $targets{$name}{bodytag}; + $directories{$dir}{addhead} = $targets{_}{addhead}; + $directories{$dir}{pagetop} = $targets{_}{pagetop}; + $directories{$dir}{pagefoot} = $targets{_}{pagefoot}; } push (@{$directories{$dir}{target}}, $name); @@ -894,9 +902,12 @@ sub print_dir($) { MRTG: Directory $dir1 - EOF - print $directories{$dir}{bodytag}; + print $directories{$dir}{addhead} if defined $directories{$dir}{addhead}; + + print "\n", $directories{$dir}{bodytag}; + + print $directories{$dir}{pagetop} if defined $directories{$dir}{pagetop}; my $subdirs_printed; if (defined @{$directories{$dir}{subdir}}) { @@ -938,6 +949,9 @@ EOF } print_banner($directories{$dir}{config}); + + print $directories{$dir}{pagefoot} if defined $directories{$dir}{pagefoot}; + print "\n\n"; }