2 # (c) Petr Baudis <pasky@suse.cz>
13 # Ultra-trivial templating engine;
16 # /^@header produces HTML header based on @section and @heading
17 # /@@gitweburl@@/ substitute for gitweburl configuration variable
18 # /@@ifmob@@...@@end@@/ remove unless mob defined
19 # /@@ifssh@@...@@end@@/ remove unless pushurl defined
20 # /@@ifhttps@@...@@end@@/ remove unless httpspushurl defined
22 my $pathinfo = $ENV{PATH_INFO
};
25 my $gcgi = Girocco
::CGI
->new('HTML Templater');
26 print "<p>Hi, this is your friendly HTML templater speaking. Pass me template name.</p>\n";
30 unless ($pathinfo !~ m
#\./# and open(TEMPLATE, "$Girocco::Config::basedir/html/$pathinfo")) {
31 my $gcgi = Girocco
::CGI
->new('HTML Templater');
32 print "<p>Invalid template name.</p>\n";
36 if ($pathinfo =~ /\.png$/) {
37 print "Content-type: image/png\n\n";
38 print while (<TEMPLATE
>);
42 my ($gcgi, $section, $heading);
44 my $template=join('', <TEMPLATE
>);
46 $template =~ s/@\@ifmob@\@(.*?)@\@end@\@/$Girocco::Config::mob?$1:''/ges;
47 $template =~ s/@\@ifssh@\@(.*?)@\@end@\@/$Girocco::Config::pushurl?$1:''/ges;
48 $template =~ s/@\@ifhttps@\@(.*?)@\@end@\@/$Girocco::Config::httpspushurl?$1:''/ges;
50 foreach (split(/\n/, $template)) {
52 if (s/^\@section=//) {
55 } elsif (s/^\@heading=//) {
58 } elsif (s/^\@header//) {
59 $gcgi = Girocco
::CGI
->new($heading, $section);
62 s/@@(\w+?)@@/${$Girocco::Config::{$1}}/ge;
67 $gcgi and $gcgi->srcname("html/$pathinfo");