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 # /@@base(gitweburl)@@/ substitute for base portion of gitweburl variable
19 # /@@path(gitweburl)@@/ substitute for path portion of gitweburl variable
20 # /@@ifmob@@...@@end@@/ remove unless mob defined
21 # /@@ifssh@@...@@end@@/ remove unless pushurl defined
22 # /@@ifhttps@@...@@end@@/ remove unless httpspushurl defined
24 my $pathinfo = $ENV{PATH_INFO
} || '';
27 my $gcgi = Girocco
::CGI
->new('HTML Templater');
28 print "<p>Hi, this is your friendly HTML templater speaking. Pass me template name.</p>\n";
32 unless ($pathinfo !~ m
#\./# and open(TEMPLATE, "$Girocco::Config::basedir/html/$pathinfo")) {
33 my $gcgi = Girocco
::CGI
->new('HTML Templater');
34 print "<p>Invalid template name.</p>\n";
38 if ($pathinfo =~ /\.png$/) {
39 print "Content-type: image/png\n\n";
40 print while (<TEMPLATE
>);
44 my ($gcgi, $section, $heading);
46 my $template=join('', <TEMPLATE
>);
48 $template =~ s/@\@ifmob@\@(.*?)@\@end@\@/$Girocco::Config::mob?$1:''/ges;
49 $template =~ s/@\@ifssh@\@(.*?)@\@end@\@/$Girocco::Config::pushurl?$1:''/ges;
50 $template =~ s/@\@ifhttps@\@(.*?)@\@end@\@/$Girocco::Config::httpspushurl?$1:''/ges;
52 foreach (split(/\n/, $template)) {
54 if (s/^\@section=//) {
57 } elsif (s/^\@heading=//) {
60 } elsif (s/^\@header//) {
61 $gcgi = Girocco
::CGI
->new($heading, $section);
62 print "<div class=\"htmlcgi\">";
65 s/@\@base\((\w+?)\)@@/url_base(${$Girocco::Config::{$1}})/ge;
66 s/@\@path\((\w+?)\)@@/url_path(${$Girocco::Config::{$1}})/ge;
67 s/@@(\w+?)@@/${$Girocco::Config::{$1}}/ge;
72 $gcgi and $gcgi->srcname("html/$pathinfo");