make better use of media_prefix; only apply ses cookie in secure context; updated...
authorBill Erickson <berick@esilibrary.com>
Tue, 18 Jan 2011 16:48:11 +0000 (11:48 -0500)
committerBill Erickson <berick@esilibrary.com>
Tue, 18 Jan 2011 16:48:11 +0000 (11:48 -0500)
Open-ILS/examples/oils_web.xml.example
Open-ILS/src/perlmods/OpenILS/WWW/EGCatLoader.pm
Open-ILS/src/perlmods/OpenILS/WWW/EGWeb.pm
Open-ILS/web/templates/default/opac/rdetail.tt2
Open-ILS/web/templates/default/opac/results.tt2

index c5d3622..e5f0efb 100644 (file)
@@ -9,8 +9,24 @@
         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.  Allows static files to be served from an alternate domain/server
+
+            Examples:
+
+                # local URL path
+                <media_prefix>/media</media_prefix> 
+
+                # server w/ path.  
+                <media_prefix>static.example.com/media</media_prefix> 
+
+                ===
+                In the first 2 examples, the request protocol (http vs https) will
+                match the protocol of the current page
+                ===
+
+                # full-qualified with static protocol
+                <media_prefix>http://static.example.com/media</media_prefix> 
+     -->
     <media_prefix/>
 
     <!-- If set to true, all output will be parsed as XML before delivery to the client.  
index 18afc95..634797d 100644 (file)
@@ -187,6 +187,7 @@ sub load_login {
             -cookie => $cgi->cookie(
                 -name => 'ses',
                 -path => '/',
+                -secure => 1,
                 -value => $response->{payload}->{authtoken},
                 -expires => CORE::time + $response->{payload}->{authtime}
             )
index 50de099..3929285 100644 (file)
@@ -120,6 +120,14 @@ sub load_context {
         parse_accept_lang($r->headers_in->get('Accept-Language')) || 'en-US';
     $r->log->debug('skin = ' . $ctx->{skin} . ' : theme = ' . 
         $ctx->{theme} . ' : locale = ' . $ctx->{locale});
+
+    my $mprefix = $ctx->{media_prefix};
+    if($mprefix !~ /^http/ and $mprefix !~ /^\//) {
+        # if a hostname is provided /w no protocol, match the protocol to the current page
+        $ctx->{media_prefix} = ($cgi->https) ? "https://$mprefix" : "http://$mprefix";
+    }
+
+
     return $ctx;
 }
 
index a4966fd..f32bd49 100644 (file)
@@ -22,7 +22,9 @@
     <table id='record_table' style='width:auto'>
         <tr>
             <td rowspan='10' style='width:55px; vertical-align:top; padding-right:4px;'>
-                <img width='50' height='70' src='/opac/extras/ac/jacket/small/[% attrs.isbn_clean || attrs.upc %]'/>
+                [% IF attrs.isbn_clean || attrs.upc %]
+                <img width='50' height='70' src='[% ctx.media_prefix %]/opac/extras/ac/jacket/small/[% attrs.isbn_clean || attrs.upc %]'/>
+                [% END %]
             </td>
         </tr>
         [% IF attrs.title %]<tr><td>Title</td><td>[% attrs.title %]</td></tr>[% END %]
index 8704eeb..f862973 100644 (file)
@@ -81,7 +81,7 @@
                 <tr>
                     <td style='width:52px;height:72px'>
                         [% IF attrs.isbn %]
-                        <img width='50' height='70' src='/opac/extras/ac/jacket/small/[% attrs.isbn_clean || attrs.upc %]'/>
+                        <img width='50' height='70' src='[% ctx.media_prefix %]/opac/extras/ac/jacket/small/[% attrs.isbn_clean || attrs.upc %]'/>
                         [% END %]
                     </td>
                     <td width='auto'>