1 package OpenILS::WWW::Web;
2 use strict; use warnings;
6 use Apache2::Const -compile => qw(OK REDIRECT :log);
7 use APR::Const -compile => qw(:error SUCCESS);
8 use Apache2::RequestRec ();
9 use Apache2::RequestIO ();
10 use Apache2::RequestUtil;
13 use Template qw(:template);
15 use OpenSRF::EX qw(:try);
18 my $main_ttk = "opac/logic/page_router.ttk";
19 my $error_ttk = "opac/pages/error.ttk";
20 my $init_ttk = "opac/logic/page_init.ttk";
21 my $bootstrap = "/pines/conf/bootstrap.conf";
22 my $child_init_ttk = "opac/logic/child_init.ttk";
24 my $includes = []; # [ '/pines/cvs/ILS/Open-ILS/src/templates' ];
27 my( $self, $tdir ) = @_;
28 $includes = [ $tdir ];
33 my $plugin_base = 'OpenILS::Template::Plugin';
38 print "Content-type: text/html; charset=utf-8\n\n";
42 template => $main_ttk,
43 pre_process => $init_ttk );
45 return Apache2::Const::OK;
48 sub child_init_handler {
49 _process_template( template => $child_init_ttk );
52 sub _process_template {
55 my $ttk = $params{template} || return undef;
56 my $apache = $params{apache} || undef;
57 my $pre_process = $params{pre_process} || undef;
58 my $param_hash = $params{params} || {};
62 $template = Template->new( {
66 PLUGIN_BASE => $plugin_base,
67 PRE_PROCESS => $pre_process,
68 INCLUDE_PATH => $includes,
76 if( ! $template->process( $ttk, $param_hash ) ) {
77 warn "Error Occured: " . $template->error();
78 my $err = $template->error();
79 $err =~ s/\n/\<br\/\>/g;
80 warn "Error processing template $ttk\n";
81 my $string = "<br><b>Unable to process template:<br/><br/> " . $err . "!!!</b>";
82 $template->process( $error_ttk , { error => $string } );
87 warn "Error processing template $ttk: $e - $@ \n";
88 print "<center><br/><br/><b>Error<br/><br/> $e <br/><br/> $@ </b><br/></center>";