Patch from Jeff Godin (MLC/TADL) which:
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 2 Jun 2009 17:11:02 +0000 (17:11 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 2 Jun 2009 17:11:02 +0000 (17:11 +0000)
Fixes the mixed content warnings from IE7 and IE8 "out of the box" without
breaking sites that use static servers for CSS and Javascript.

This sets OILS_PROTOCOL based on the environment variable HTTPS (which
Apache sets to "on" for https:// requests).

Thus, a page loaded via https:// gets https:// urls, and a page loaded via
http:// gets http:// urls.

To accommodate sites with static servers that can not support https,
there's a new OILS_OPAC_STATIC_PROTOCOL variable in eg_vhost.conf
which can be set to "http" to force JS/CSS to be loaded over http://
(you'll get the same warnings that you got before).

git-svn-id: svn://svn.open-ils.org/ILS/trunk@13288 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/examples/apache/eg_vhost.conf
Open-ILS/web/opac/common/js/added_content.js
Open-ILS/web/opac/skin/default/xml/common/js_common.xml
Open-ILS/web/opac/skin/default/xml/setenv.xml

index 13eab05..3111fe0 100644 (file)
@@ -75,12 +75,26 @@ RewriteRule - - [E=locale:%1] [L]
     SetEnvIf Request_URI ".*" OILS_OPAC_BASE=/opac/
     
     # This gives you the option to configure a different host to serve OPAC images from
-    # Specify the hostname (withouth protocol) and path to the images.  Protocol will
+    # Specify the hostname (without protocol) and path to the images.  Protocol will
     # be determined at runtime
     #SetEnvIf Request_URI ".*" OILS_OPAC_IMAGES_HOST=static.example.org/opac/
+
+    # In addition to loading images from a static host, you can also load CSS and/or
+    # Javascript from a static host or hosts. Protocol will be determined at runtime
+    # and/or by configuration options immediately following.
     #SetEnvIf Request_URI ".*" OILS_OPAC_CSS_HOST=static.example.org/opac/
     #SetEnvIf Request_URI ".*" OILS_OPAC_JS_HOST=static.example.org/opac/
 
+    # If you are not able to serve static content via https and 
+    # wish to force http:// (and are comfortable with mixed-content
+    # warnings in client browsers), set this:
+    #SetEnvIf Request_URI ".*" OILS_OPAC_STATIC_PROTOCOL=http
+
+    # If you would prefer to fall back to your non-static servers for 
+    # https pages, avoiding mixed-content warnings in client browsers
+    # and are willing to accept some increased server load, set this:
+    #SetEnvIf Request_URI ".*" OILS_OPAC_BYPASS_STATIC_FOR_HTTPS=yes
+
 </LocationMatch>
 
 
index 850858d..4e2074c 100644 (file)
@@ -5,8 +5,9 @@
 
 function buildISBNSrc(isbn, size) {
        size = (size) ? size : 'small';
+       var protocol = (OILS_OPAC_STATIC_PROTOCOL) ? OILS_OPAC_STATIC_PROTOCOL + ':' : location.protocol;
     if(OILS_OPAC_IMAGES_HOST)
-        return location.protocol + '//' + OILS_OPAC_IMAGES_HOST + size + '/' + isbn;
+        return protocol + '//' + OILS_OPAC_IMAGES_HOST + size + '/' + isbn;
        return '../../../../extras/ac/jacket/'+size+'/'+isbn;
 }      
 
index 3bdcf30..a3de652 100644 (file)
                <!--#if expr="$OILS_OPAC_IMAGES_HOST"-->
                        OILS_OPAC_IMAGES_HOST = '<!--#echo var="OILS_OPAC_IMAGES_HOST"-->extras/ac/jacket/';
                <!--#endif -->
+               var OILS_OPAC_STATIC_PROTOCOL = null;
+               <!--#if expr="$OILS_OPAC_STATIC_PROTOCOL"-->
+                       OILS_OPAC_STATIC_PROTOCOL = '<!--#echo var="OILS_OPAC_STATIC_PROTOCOL"-->';
+               <!--#endif -->
 
                <!-- builds the "Now searching: <org_unit>" text on the home page -->
                function home_init() {
index d95a6ad..e64b270 100644 (file)
 
 <!--#endif-->
 
+<!--#if expr="$HTTPS"-->
+       <!--#set var="OILS_PROTOCOL" value="https"-->
+       <!--#if expr="$OILS_OPAC_BYPASS_STATIC_FOR_HTTPS=='yes'"-->
+               <!--#set var="OILS_OPAC_CSS_HOST" value=""-->
+               <!--#set var="OILS_OPAC_JS_HOST" value=""-->
+       <!--#endif-->
+<!--#else-->
+       <!--#set var="OILS_PROTOCOL" value="http"-->
+<!--#endif-->
+
+<!--#if expr="$OILS_OPAC_STATIC_PROTOCOL"-->
+
+<!--#else-->
+       <!--#set var="OILS_OPAC_STATIC_PROTOCOL" value="$OILS_PROTOCOL"-->
+<!--#endif-->
 
-<!--#set var="OILS_BASE" value="http://${SERVER_NAME}/${OILS_OPAC_BASE}"-->
+<!--#set var="OILS_BASE" value="${OILS_PROTOCOL}://${SERVER_NAME}/${OILS_OPAC_BASE}"-->
 <!--#set var="OILS_XML_BASE" value="${OILS_BASE}/common/xml"--> 
 
 
 <!-- Javascript host -->
 <!--#if expr="$OILS_OPAC_JS_HOST"-->
-    <!--#set var="OILS_OPAC_JS_HOST" value="http://${OILS_OPAC_JS_HOST}"-->
+    <!--#set var="OILS_OPAC_JS_HOST" value="${OILS_OPAC_STATIC_PROTOCOL}://${OILS_OPAC_JS_HOST}"-->
 <!--#else -->
     <!--#set var="OILS_OPAC_JS_HOST" value="$OILS_BASE"-->
 <!--#endif -->
@@ -45,7 +60,7 @@
 
 
 <!--#if expr="$OILS_OPAC_CSS_HOST"-->
-    <!--#set var="OILS_OPAC_CSS_HOST" value="http://${OILS_OPAC_CSS_HOST}"-->
+    <!--#set var="OILS_OPAC_CSS_HOST" value="${OILS_OPAC_STATIC_PROTOCOL}://${OILS_OPAC_CSS_HOST}"-->
 <!--#else -->
     <!--#set var="OILS_OPAC_CSS_HOST" value="$OILS_BASE"-->
 <!--#endif -->