1 package OpenILS::WWW::Web;
2 use strict; use warnings;
6 use Apache::Const -compile => qw(OK REDIRECT :log);
7 use APR::Const -compile => qw(:error SUCCESS);
8 use Apache::RequestRec ();
9 use Apache::RequestIO ();
10 use Apache::RequestUtil;
13 use Template qw(:template);
15 use OpenSRF::EX qw(:try);
18 my $main_ttk = "opac/page_router.ttk";
19 my $error_ttk = "opac/error.ttk";
20 my $init_ttk = "opac/page_init.ttk";
21 my $bootstrap = "/pines/conf/bootstrap.conf";
22 my $child_init_ttk = "opac/child_init.ttk";
25 '/pines/cvs/ILS/Open-ILS/src/templates'
28 my $plugin_base = 'OpenILS::Template::Plugin';
33 print "Content-type: text/html; charset=utf-8\n\n";
37 template => $main_ttk,
38 pre_process => $init_ttk );
43 sub child_init_handler {
44 _process_template( template => $child_init_ttk );
47 sub _process_template {
50 my $ttk = $params{template} || return undef;
51 my $apache = $params{apache} || undef;
52 my $pre_process = $params{pre_process} || undef;
53 my $param_hash = $params{params} || {};
57 $template = Template->new( {
61 PLUGIN_BASE => $plugin_base,
62 PRE_PROCESS => $pre_process,
63 INCLUDE_PATH => $includes,
71 if( ! $template->process( $ttk, $param_hash ) ) {
72 warn "Error Occured: " . $template->error();
73 my $err = $template->error();
74 $err =~ s/\n/\<br\/\>/g;
75 warn "Error processing template $ttk\n";
76 my $string = "<br><b>Unable to process template:<br/><br/> " . $err . "!!!</b>";
77 $template->process( $error_ttk , { error => $string } );
82 warn "Error processing template $ttk: $e - $@ \n";
83 print "<center><br/><br/><b>Error<br/><br/> $e <br/><br/> $@ </b><br/></center>";