<oils_web>
+
<!-- This should match the Apache Directory/Location[Match] configuration path -->
<base_uri>/eg</base_uri>
+ <!-- when locating files that don't have explicit handlers defined, assume the
+ files have the following filename extension -->
+ <default_template_extension>tt2</default_template_extension>
+
<!-- media_prefix can be a remote server.
E.g. <media_prefix>http://static.example.com/media</media_prefix> -->
<media_prefix/>
</template_paths>
<handlers>
- <handler path='acq/picklist/list' template='acq/picklist/list.tt2'/>
- <handler path='acq/picklist/view' template='acq/picklist/view.tt2'/>
- <handler path='acq/picklist/bib_search' template='acq/picklist/bib_search.tt2'/>
+ <!-- add custom handlers here. These are for templates that live in non-obvious locations.
+ In other words, if the path + default extension does not map directly to a template file -->
<handler path='acq/fund/list' template='acq/financial/list_funds.tt2'/>
<handler path='acq/fund/view' template='acq/financial/view_fund.tt2'/>
<handler path='acq/funding_source/list' template='acq/financial/list_funding_sources.tt2'/>
<handler path='acq/currency_type/view' template='acq/financial/view_currency_type.tt2'/>
<handler path='acq/provider/list' template='acq/financial/list_providers.tt2'/>
<handler path='acq/provider/view' template='acq/financial/view_provider.tt2'/>
- <handler path='acq/po/view' template='acq/po/view.tt2'/>
- <handler path='acq/po/li_search' template='acq/po/li_search.tt2'/>
- <handler path='acq/po/search' template='acq/po/search.tt2'/>
- <handler path='acq/receiving/process' template='acq/receiving/process.tt2'/>
- <handler path='acq/settings/li_attr' template='acq/settings/li_attr.tt2'/>
-
- <handler path='conify/global/config/billing_type' template='conify/global/config/billing_type.tt2'/>
- <handler path='conify/global/config/standing_penalty' template='conify/global/config/standing_penalty.tt2'/>
- <handler path='conify/global/config/z3950_source' template='conify/global/config/z3950_source.tt2'/>
- <handler path='conify/global/config/circ_modifier' template='conify/global/config/circ_modifier.tt2'/>
- <handler path='conify/global/config/hold_matrix_matchpoint' template='conify/global/config/hold_matrix_matchpoint.tt2'/>
- <handler path='conify/global/permission/grp_penalty_threshold' template='conify/global/permission/grp_penalty_threshold.tt2'/>
</handlers>
</oils_web>
check_web_config($r); # option to disable this
my $ctx = load_context($r);
my $base = $ctx->{base_uri};
- my($template, $page_args) = find_template($r, $base);
+ my($template, $page_args) = find_template($r, $base, $ctx);
return Apache2::Const::DECLINED unless $template;
$template = $ctx->{skin} . "/$template";
sub find_template {
my $r = shift;
my $base = shift;
+ my $ctx = shift;
+ my $skin = $ctx->{skin};
my $path = $r->uri;
$path =~ s/$base//og;
my @parts = split('/', $path);
}
}
- unless($template) {
- $r->log->warn("No template configured for path $path");
- return ();
+ unless($template) { # no template configured
+
+ # see if we can magically find the template based on the path and default extension
+ my $ext = $ctx->{default_template_extension};
+ for my $tpath (@{$ctx->{template_paths}}) {
+ my $fpath = "$tpath/$skin/$path.$ext";
+ $r->log->debug("looking at possible template $fpath");
+ if(-r $fpath) {
+ $template = "$path.$ext";
+ last;
+ }
+ }
+
+ # no template configured or found
+ unless($template) {
+ $r->log->warn("No template configured for path $path");
+ return ();
+ }
}
$r->log->debug("template = $template : page args = @$page_args");
$ctx->{base_uri} = (ref $data->{base_uri}) ? '' : $data->{base_uri};
$ctx->{template_paths} = [];
$ctx->{force_valid_xml} = ($data->{force_valid_xml} =~ /true/io) ? 1 : 0;
+ $ctx->{default_template_extension} = $data->{default_template_extension} || 'tt2';
my $tpaths = $data->{template_paths}->{path};
$tpaths = [$tpaths] unless ref $tpaths;