jobs/fixupcheck.sh: Move comment around
[girocco/test-forks.git] / cgi / html.cgi
blob98681bde45ac2d7f31292113a2f9e9d364907d68
1 #!/usr/bin/perl
2 # (c) Petr Baudis <pasky@suse.cz>
3 # GPLv2
5 use strict;
6 use warnings;
8 use lib ".";
9 use Girocco::CGI;
10 use Girocco::Config;
13 # Ultra-trivial templating engine
16 my $pathinfo = $ENV{PATH_INFO};
17 unless ($pathinfo) {
18 my $gcgi = Girocco::CGI->new('HTML Templater');
19 print "<p>Hi, this is your friendly HTML templater speaking. Pass me template name.</p>\n";
20 exit;
23 unless ($pathinfo !~ m#\./# and open(TEMPLATE, "$Girocco::Config::basedir/html/$pathinfo")) {
24 my $gcgi = Girocco::CGI->new('HTML Templater');
25 print "<p>Invalid template name.</p>\n";
26 exit;
29 my ($gcgi, $section, $heading);
31 while (<TEMPLATE>) {
32 chomp;
33 if (s/^\@section=//) {
34 $section = $_;
35 next;
36 } elsif (s/^\@heading=//) {
37 $heading = $_;
38 next;
39 } elsif (s/^\@header//) {
40 $gcgi = Girocco::CGI->new($heading, $section);
41 next;
42 } else {
43 print "$_\n";
47 close TEMPLATE;
49 $gcgi and $gcgi->srcname("html/$pathinfo");