1 package OpenILS::WWW::Web;
2 use strict; use warnings;
5 use Apache2::Const -compile => qw(OK REDIRECT :log);
6 use APR::Const -compile => qw(:error SUCCESS);
7 use Apache2::RequestRec ();
8 use Apache2::RequestIO ();
9 use Apache2::RequestUtil;
14 use OpenSRF::EX qw(:try);
17 my $main_ttk = "opac/logic/page_router.ttk";
18 my $error_ttk = "opac/pages/error.ttk";
19 my $init_ttk = "opac/logic/page_init.ttk";
20 my $bootstrap = "/openils/conf/opensrf_core.xml";
21 my $child_init_ttk = "opac/logic/child_init.ttk";
23 my $includes = []; # [ '/pines/cvs/ILS/Open-ILS/src/templates' ];
26 my( $self, $tdir ) = @_;
27 $includes = [ $tdir ];
32 my $plugin_base = 'OpenILS::Template::Plugin';
37 print "Content-type: text/html; charset=utf-8\n\n";
41 template => $main_ttk,
42 pre_process => $init_ttk );
44 return Apache2::Const::OK;
47 sub child_init_handler {
48 _process_template( template => $child_init_ttk );
51 sub _process_template {
54 my $ttk = $params{template} || return undef;
55 my $apache = $params{apache} || undef;
56 my $pre_process = $params{pre_process} || undef;
57 my $param_hash = $params{params} || {};
61 $template = Template->new( {
65 PLUGIN_BASE => $plugin_base,
66 PRE_PROCESS => $pre_process,
67 INCLUDE_PATH => $includes,
75 if( ! $template->process( $ttk, $param_hash ) ) {
76 warn "Error Occured: " . $template->error();
77 my $err = $template->error();
78 $err =~ s/\n/\<br\/\>/g;
79 warn "Error processing template $ttk\n";
80 my $string = "<br><b>Unable to process template:<br/><br/> " . $err . "!!!</b>";
81 $template->process( $error_ttk , { error => $string } );
86 warn "Error processing template $ttk: $e - $@ \n";
87 print "<center><br/><br/><b>Error<br/><br/> $e <br/><br/> $@ </b><br/></center>";