Index: SrvTxtUtils.py
===================================================================
--- SrvTxtUtils.py	(revision 622)
+++ SrvTxtUtils.py	(revision 623)
@@ -8,4 +8,5 @@
 import stat
 import urllib
+from urlparse import urlparse, urlunparse
 import logging
 import time
@@ -22,5 +23,5 @@
 import xml.etree.ElementTree as ET
 
-srvTxtUtilsVersion = "1.12.3"
+srvTxtUtilsVersion = "1.13"
 
 map_months = {'en': [u"",
@@ -371,2 +372,34 @@
 
 
+def sslifyUrl(url, app=None, force=False):
+    """returns URL with http or https scheme.
+    
+    Looks at app.REQUEST.URL to find the scheme of the current page.
+    Changes only schemeless (starting with //) URLs unless force=True.  
+    """
+    thatUrl = urlparse(url) 
+    if hasattr(app, 'REQUEST'):
+        # get current page URL
+        thisUrl = urlparse(app.REQUEST['URL'])
+        if thatUrl.scheme == '':
+            # schemeless URL -> use this scheme
+            return "%s:%s"%(thisUrl.scheme, url)
+        elif force:
+            # use this scheme
+            if thisUrl.scheme != thatUrl.scheme:
+                return urlunparse((thisUrl.scheme,)+thatUrl[1:])
+            else:
+                # keep scheme
+                return url
+            
+        else:
+            # keep scheme
+            return url
+        
+    else:
+        # no current page URL
+        if force:
+            # use https for force
+            return urlunparse(('https',)+thatUrl[1:])
+        
+    return url
Index: documentViewer.py
===================================================================
--- documentViewer.py	(revision 622)
+++ documentViewer.py	(revision 623)
@@ -17,12 +17,9 @@
 from Products.MetaDataProvider import MetaDataFolder
 
-from SrvTxtUtils import getInt, utf8ify, getText, getHttpData, refreshingImageFileIndexHtml
+from SrvTxtUtils import getInt, utf8ify, getText, getHttpData, refreshingImageFileIndexHtml, sslifyUrl
     
 
 def getMDText(node):
     """returns the @text content from the MetaDataProvider metadata node"""
-
-    
-
     if isinstance(node, dict):
         return node.get('@text', None)
@@ -34,6 +31,4 @@
                 return node.get('@text',None)
         return None
-
-
 
     return node
@@ -174,13 +169,9 @@
             self.digilibViewerUrl = digilibBaseUrl + '/jquery/digilib.html'
             
-        
+
     # proxy text server methods to fulltextclient
     def getTextPage(self, **args):
         """returns full text content of page"""
-       
         return self.template.fulltextclient.getTextPage(**args)
-    
-   
-   
 
     def getSearchResults(self, **args):
@@ -234,5 +225,5 @@
                         
         if not self.digilibBaseUrl:
-            self.digilibBaseUrl = self.findDigilibUrl() or "http://nausikaa.mpiwg-berlin.mpg.de/digitallibrary"
+            self.digilibBaseUrl = self.findDigilibUrl() or "http://digilib.mpiwg-berlin.mpg.de/digitallibrary"
             
         docinfo = self.getDocinfo(mode=mode,url=url)
@@ -268,6 +259,4 @@
             logging.error("template folder missing!")
             return "ERROR: template folder missing!"
-        
-        
 
         if not getattr(self, 'digilibBaseUrl', None):
@@ -307,7 +296,4 @@
             viewMode = 'image'
             self.REQUEST['viewMode'] = 'image'
-            
-        
-            
 
         # safe viewLayer in userinfo
@@ -334,5 +320,5 @@
         """try to get the digilib URL from zogilib"""
         url = self.template.zogilib.getDLBaseUrl()
-        return url
+        return sslifyUrl(url, self, force=True)
     
     def getScalerUrl(self, fn=None, pn=None, dw=100, dh=100, docinfo=None):
@@ -765,7 +751,4 @@
         # old style text URL
         textUrl = getMDText(texttool.get('text', None))
-
-        
-
 
         if textUrl and docPath:
@@ -1162,12 +1145,6 @@
         """returns list of groups {name:*, id:*} on the annotation server for the user"""
         groups = []
-        if annotationServerUrl.startswith('//'):
-            # add matching http(s) from our URL
-            myUrl = self.REQUEST['URL']
-            logging.debug("my URL: %s"%myUrl)
-            if myUrl.startswith('https:'):
-                annotationServerUrl = "https:%s"%annotationServerUrl
-            else:
-                annotationServerUrl = "http:%s"%annotationServerUrl
+        # add matching http(s) from our URL
+        annotationServerUrl = sslifyUrl(annotationServerUrl, self)
             
         groupsUrl = "%s/annotator/groups?user=%s"%(annotationServerUrl,user)
@@ -1206,4 +1183,5 @@
         if RESPONSE is not None:
             RESPONSE.redirect('manage_main')
+            
         
 def manage_AddDocumentViewerForm(self):
