diff documentViewer.py @ 623:6012fe93f78c

better scheme-less URL code.
author casties
date Mon, 15 Dec 2014 16:10:05 +0100
parents bc68ca0d2c0a
children 80a0191ae51c
line wrap: on
line diff
--- a/documentViewer.py	Fri Dec 12 16:27:58 2014 +0100
+++ b/documentViewer.py	Mon Dec 15 16:10:05 2014 +0100
@@ -16,14 +16,11 @@
 
 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,8 +31,6 @@
                 return node.get('@text',None)
         return None
 
-
-
     return node
 
 def getParentPath(path, cnt=1):
@@ -173,15 +168,11 @@
             self.digilibScalerUrl = digilibBaseUrl + '/servlet/Scaler'
             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):
         """loads list of search results and stores XML in docinfo"""
@@ -233,7 +224,7 @@
             return "ERROR: template folder missing!"
                         
         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)
         #pageinfo = self.getPageinfo(start=start,current=pn,docinfo=docinfo)
@@ -267,8 +258,6 @@
             # this won't work
             logging.error("template folder missing!")
             return "ERROR: template folder missing!"
-        
-        
 
         if not getattr(self, 'digilibBaseUrl', None):
             self.digilibBaseUrl = self.findDigilibUrl() or "http://digilib.mpiwg-berlin.mpg.de/digitallibrary"
@@ -306,9 +295,6 @@
             # legacy fix
             viewMode = 'image'
             self.REQUEST['viewMode'] = 'image'
-            
-        
-            
 
         # safe viewLayer in userinfo
         userinfo['viewLayer'] = viewLayer
@@ -333,7 +319,7 @@
     def findDigilibUrl(self):
         """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):
         """returns URL to digilib Scaler with params"""
@@ -765,9 +751,6 @@
         # old style text URL
         textUrl = getMDText(texttool.get('text', None))
 
-        
-
-
         if textUrl and docPath:
             if urlparse.urlparse(textUrl)[0] == "": #keine url
                 textUrl = os.path.join(docPath, textUrl) 
@@ -1161,14 +1144,8 @@
     def getAnnotatorGroupsForUser(self, user, annotationServerUrl="http://tuxserve03.mpiwg-berlin.mpg.de/AnnotationManager"):
         """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)
         data = getHttpData(url=groupsUrl, noExceptions=True)
@@ -1205,6 +1182,7 @@
 
         if RESPONSE is not None:
             RESPONSE.redirect('manage_main')
+            
         
 def manage_AddDocumentViewerForm(self):
     """add the viewer form"""