X-Git-Url: http://git.rot13.org/?p=webpac2;a=blobdiff_plain;f=web%2Fbrowse.cgi;h=0ea35b981dce6afb3cb6f463399a52992fa4ecf6;hp=3981a869acbcc2d6d9dd26068d0b976a735a689d;hb=4727bc68c05d61385c0c5e34f32ace1361b48892;hpb=e2d6c68bb1438b387453a5157d6b88bcbdd0ceee diff --git a/web/browse.cgi b/web/browse.cgi index 3981a86..0ea35b9 100755 --- a/web/browse.cgi +++ b/web/browse.cgi @@ -18,7 +18,9 @@ my $abs_path = abs_path($0); $abs_path =~ s#/[^/]*$#/../#; my $db_path = $abs_path . '/db/'; -my $template_file = 'html_ffzg.tt'; +my $template_path = "$abs_path/conf/output/tt"; +opendir(my $dir, $template_path) || die "can't open template path $template_path: $!"; +my @templates = grep { /\.tt$/i } readdir($dir); my $css_file = 'user.css'; my $iconv_utf8 = new Text::Iconv('ISO-8859-2', 'UTF-8'); @@ -31,7 +33,7 @@ my $db = new WebPAC::DB( ); my $out = new WebPAC::Output::TT( - include_path => "$abs_path/conf/output/tt", + include_path => $template_path, filters => { foo => sub { shift } }, ); @@ -39,6 +41,7 @@ my $q = new CGI::Simple; my $self = $q->url( '-path_info'=>1, '-query'=>0, '-full'=>0 ); my $rec = $q->param('rec') || 1; +my $template_filename = $q->param('template') || $templates[0]; print $q->header( -charset => 'utf-8' ); @@ -82,7 +85,7 @@ if ($q->path_info =~ m#xml#) { print qq{ }, $iconv_utf8->convert( $out->apply( - template => $template_file, + template => $template_filename, data => $ds, ) ), qq{ @@ -117,7 +120,7 @@ if ($q->path_info =~ m#xml#) { } elsif ($q->path_info =~ m#template#) { - my $template_path = $out->{'include_path'} . '/' . $template_file; + my $template_path = $out->{'include_path'} . '/' . $template_filename; if ($q->param('save_template')) { @@ -125,7 +128,7 @@ if ($q->path_info =~ m#xml#) { print qq{ -$template_file saved +$template_filename saved