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 # /@@path(gitweburl)@@/ substitute for path portion of gitweburl variable
19 # /@@ifmob@@...@@end@@/ remove unless mob defined
20 # /@@ifssh@@...@@end@@/ remove unless pushurl defined
21 # /@@ifhttps@@...@@end@@/ remove unless httpspushurl defined
23 my $pathinfo = $ENV{PATH_INFO
} || '';
26 my $gcgi = Girocco
::CGI
->new('HTML Templater');
27 print "<p>Hi, this is your friendly HTML templater speaking. Pass me template name.</p>\n";
31 unless ($pathinfo !~ m
#\./# and open(TEMPLATE, "$Girocco::Config::basedir/html/$pathinfo")) {
32 my $gcgi = Girocco
::CGI
->new('HTML Templater');
33 print "<p>Invalid template name.</p>\n";
37 if ($pathinfo =~ /\.png$/) {
38 print "Content-type: image/png\n\n";
39 print while (<TEMPLATE
>);
43 my ($gcgi, $section, $heading);
45 my $template=join('', <TEMPLATE
>);
47 $template =~ s/@\@ifmob@\@(.*?)@\@end@\@/$Girocco::Config::mob?$1:''/ges;
48 $template =~ s/@\@ifssh@\@(.*?)@\@end@\@/$Girocco::Config::pushurl?$1:''/ges;
49 $template =~ s/@\@ifhttps@\@(.*?)@\@end@\@/$Girocco::Config::httpspushurl?$1:''/ges;
51 foreach (split(/\n/, $template)) {
53 if (s/^\@section=//) {
56 } elsif (s/^\@heading=//) {
59 } elsif (s/^\@header//) {
60 $gcgi = Girocco
::CGI
->new($heading, $section);
61 print "<div class=\"htmlcgi\">";
64 s/@\@path\((\w+?)\)@@/url_path(${$Girocco::Config::{$1}})/ge;
65 s/@@(\w+?)@@/${$Girocco::Config::{$1}}/ge;
70 $gcgi and $gcgi->srcname("html/$pathinfo");