From 48a063c16bcaffdd19628133496f281db18b5f54 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 4 Aug 2014 13:24:37 -0400 Subject: [PATCH] LP#1350042 browser client apache config additions * Location configuratoin for /eg/staff templates * Support for "stop-at-index" in EGWeb, so that navigating to "/eg/foo" can result in /eg/index.tt2 getting served. * Cache and compress additions for /js files. Signed-off-by: Bill Erickson Signed-off-by: Ben Shum --- Open-ILS/examples/apache/eg_vhost.conf.in | 27 ++++++++++++++++++ Open-ILS/examples/apache_24/eg_vhost.conf.in | 28 +++++++++++++++++++ .../src/perlmods/lib/OpenILS/WWW/EGWeb.pm | 25 ++++++++++++++++- 3 files changed, 79 insertions(+), 1 deletion(-) diff --git a/Open-ILS/examples/apache/eg_vhost.conf.in b/Open-ILS/examples/apache/eg_vhost.conf.in index d1b48f0b90..2f077ea0b2 100644 --- a/Open-ILS/examples/apache/eg_vhost.conf.in +++ b/Open-ILS/examples/apache/eg_vhost.conf.in @@ -794,6 +794,33 @@ RewriteRule ^/openurl$ ${openurl:%1} [NE,PT] + + Options -MultiViews + PerlSetVar OILSWebStopAtIndex "true" + + # sample staff-specific translation files + #PerlAddVar OILSWebLocale "en_ca" + #PerlAddVar OILSWebLocale "/openils/var/data/locale/staff/en-CA.po" + #PerlAddVar OILSWebLocale "fr_ca" + #PerlAddVar OILSWebLocale "/openils/var/data/locale/staff/fr-CA.po" + + + + + Header append Cache-Control "public" + + + SetOutputFilter DEFLATE + BrowserMatch ^Mozilla/4 gzip-only-text/html + BrowserMatch ^Mozilla/4\.0[678] no-gzip + BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html + SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary + + Header append Vary User-Agent env=!dont-vary + + + + # Uncomment the following to force SSL for everything. Note that this defeats caching # and you will suffer a performance hit. #RewriteCond %{HTTPS} off diff --git a/Open-ILS/examples/apache_24/eg_vhost.conf.in b/Open-ILS/examples/apache_24/eg_vhost.conf.in index f6e65e7abe..a44b9ada09 100644 --- a/Open-ILS/examples/apache_24/eg_vhost.conf.in +++ b/Open-ILS/examples/apache_24/eg_vhost.conf.in @@ -806,6 +806,34 @@ RewriteRule ^/openurl$ ${openurl:%1} [NE,PT] + + Options -MultiViews + PerlSetVar OILSWebStopAtIndex "true" + + # sample staff-specific translation files + #PerlAddVar OILSWebLocale "en_ca" + #PerlAddVar OILSWebLocale "/openils/var/data/locale/staff/en-CA.po" + #PerlAddVar OILSWebLocale "fr_ca" + #PerlAddVar OILSWebLocale "/openils/var/data/locale/staff/fr-CA.po" + + + + + Header append Cache-Control "public" + + + SetOutputFilter DEFLATE + BrowserMatch ^Mozilla/4 gzip-only-text/html + BrowserMatch ^Mozilla/4\.0[678] no-gzip + BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html + SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary + + Header append Vary User-Agent env=!dont-vary + + + + + # Uncomment the following to force SSL for everything. Note that this defeats caching # and you will suffer a performance hit. #RewriteCond %{HTTPS} off diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm index 0f9e93e859..d111cd2ac9 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm @@ -239,11 +239,12 @@ sub find_template { my $page_args = []; my $as_xml = $r->dir_config('OILSWebForceValidXML'); my $ext = $r->dir_config('OILSWebDefaultTemplateExtension'); + my $at_index = $r->dir_config('OILSWebStopAtIndex'); my @parts = split('/', $path); my $localpath = $path; - if ($localpath =~ m|opac/css|) { + if ($localpath =~ m|/css/|) { $r->content_type('text/css; encoding=utf8'); } else { $r->content_type('text/html; encoding=utf8'); @@ -257,9 +258,31 @@ sub find_template { if(-r $fpath) { $template = "$localpath.$ext"; last; + } + } + last if $template; + + if ($at_index) { + # no matching template was found in the current directory. + # stop-at-index requested; see if there is an index.ext + # file in the same directory instead. + for my $tpath (@{$ctx->{template_paths}}) { + # replace the final path component with 'index' + if ($localpath =~ m|/$|) { + $localpath .= 'index'; + } else { + $localpath =~ s|/[^/]+$|/index|; + } + my $fpath = "$tpath/$localpath.$ext"; + $r->log->debug("egweb: looking at possible template $fpath"); + if (-r $fpath) { + $template = "$localpath.$ext"; + last; + } } } last if $template; + push(@args, pop @parts); $localpath = join('/', @parts); } -- 2.43.2