From 4c8c9f2adac46697d0b4edb36d5147dadb27c791 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 28 Jun 2010 02:42:36 +0100 Subject: [PATCH] use speedy_cgi --- cgi | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/cgi b/cgi index c348508..9fc7b5c 100755 --- a/cgi +++ b/cgi @@ -1,6 +1,7 @@ -#!/usr/bin/perl -w +#!/usr/bin/speedy -w -- -t100 -M1 use strict qw(vars); +use CGI::SpeedyCGI qw/:standard -no_xhtml/; use CGI qw/:standard -no_xhtml/; sub fail ($) { @@ -12,12 +13,14 @@ sub fail ($) { exit 0; } -our $R= '/var/lib/collectd/rrd/chiark.greenend.org.uk'; -our $SELF= '/home/ijackson/things/rrd-graphs'; +our (@sections, %section_groups, %group_elems, %graphs); -my $self= url(-relative=>1); +#---------- initialisation code, run once - graphs setup ---------- -our (@sections, %section_groups, %group_elems, %graphs); +BEGIN { + +our $R= '/var/lib/collectd/rrd/chiark.greenend.org.uk'; +our $SELF= '/home/ijackson/things/rrd-graphs'; our @timeranges= (3600, map { $_*86400 } qw(1 7 28), 13*7+1, 366); @@ -203,6 +206,12 @@ foreach my $src (sort { news_name_sortkey($a) cmp news_name_sortkey($b) } ]); } +} + +#---------- right, that was the initialisation ---------- + +our $self= url(-relative=>1); + if (param('debug')) { print "Content-Type: text/plain\n\n"; } @@ -240,9 +249,9 @@ sub num_param ($$$$) { return $v + 0; } -my $group= param('graph'); +our $group= param('graph'); -my $elem= param('elem'); +our $elem= param('elem'); if (defined $elem) { my $g= $graphs{$section,$group,$elem}; die unless $g; @@ -319,7 +328,7 @@ sub start_page ($) { print h1("$title"); } -my $detail= param('detail'); +our $detail= param('detail'); if ($detail) { my $elems= $group_elems{$section,$detail}; die unless $elems; -- 2.30.2