[open-ils-commits] r11722 - in trunk/Open-ILS: examples src/perlmods/OpenILS/WWW

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Jan 2 12:38:00 EST 2009


Author: erickson
Date: 2009-01-02 12:37:57 -0500 (Fri, 02 Jan 2009)
New Revision: 11722

Modified:
   trunk/Open-ILS/examples/oils_web.xml.example
   trunk/Open-ILS/src/perlmods/OpenILS/WWW/EGWeb.pm
Log:
if the template path maps directly to a file, no need to require configuration it in the web config

Modified: trunk/Open-ILS/examples/oils_web.xml.example
===================================================================
--- trunk/Open-ILS/examples/oils_web.xml.example	2009-01-02 16:10:18 UTC (rev 11721)
+++ trunk/Open-ILS/examples/oils_web.xml.example	2009-01-02 17:37:57 UTC (rev 11722)
@@ -1,7 +1,12 @@
 <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/>
@@ -20,9 +25,8 @@
     </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'/>
@@ -31,17 +35,5 @@
         <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>

Modified: trunk/Open-ILS/src/perlmods/OpenILS/WWW/EGWeb.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/WWW/EGWeb.pm	2009-01-02 16:10:18 UTC (rev 11721)
+++ trunk/Open-ILS/src/perlmods/OpenILS/WWW/EGWeb.pm	2009-01-02 17:37:57 UTC (rev 11722)
@@ -30,7 +30,7 @@
     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";
@@ -86,6 +86,8 @@
 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);
@@ -105,9 +107,24 @@
         }
     }
 
-    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");
@@ -136,6 +153,7 @@
     $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;



More information about the open-ils-commits mailing list