Changeset 623:6012fe93f78c in documentViewer
- Timestamp:
- Dec 15, 2014, 3:10:05 PM (10 years ago)
- Branch:
- default
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
SrvTxtUtils.py
r622 r623 8 8 import stat 9 9 import urllib 10 from urlparse import urlparse, urlunparse 10 11 import logging 11 12 import time … … 22 23 import xml.etree.ElementTree as ET 23 24 24 srvTxtUtilsVersion = "1.1 2.3"25 srvTxtUtilsVersion = "1.13" 25 26 26 27 map_months = {'en': [u"", … … 371 372 372 373 374 def sslifyUrl(url, app=None, force=False): 375 """returns URL with http or https scheme. 376 377 Looks at app.REQUEST.URL to find the scheme of the current page. 378 Changes only schemeless (starting with //) URLs unless force=True. 379 """ 380 thatUrl = urlparse(url) 381 if hasattr(app, 'REQUEST'): 382 # get current page URL 383 thisUrl = urlparse(app.REQUEST['URL']) 384 if thatUrl.scheme == '': 385 # schemeless URL -> use this scheme 386 return "%s:%s"%(thisUrl.scheme, url) 387 elif force: 388 # use this scheme 389 if thisUrl.scheme != thatUrl.scheme: 390 return urlunparse((thisUrl.scheme,)+thatUrl[1:]) 391 else: 392 # keep scheme 393 return url 394 395 else: 396 # keep scheme 397 return url 398 399 else: 400 # no current page URL 401 if force: 402 # use https for force 403 return urlunparse(('https',)+thatUrl[1:]) 404 405 return url -
documentViewer.py
r622 r623 17 17 from Products.MetaDataProvider import MetaDataFolder 18 18 19 from SrvTxtUtils import getInt, utf8ify, getText, getHttpData, refreshingImageFileIndexHtml 19 from SrvTxtUtils import getInt, utf8ify, getText, getHttpData, refreshingImageFileIndexHtml, sslifyUrl 20 20 21 21 22 22 def getMDText(node): 23 23 """returns the @text content from the MetaDataProvider metadata node""" 24 25 26 27 24 if isinstance(node, dict): 28 25 return node.get('@text', None) … … 34 31 return node.get('@text',None) 35 32 return None 36 37 38 33 39 34 return node … … 174 169 self.digilibViewerUrl = digilibBaseUrl + '/jquery/digilib.html' 175 170 176 171 177 172 # proxy text server methods to fulltextclient 178 173 def getTextPage(self, **args): 179 174 """returns full text content of page""" 180 181 175 return self.template.fulltextclient.getTextPage(**args) 182 183 184 185 176 186 177 def getSearchResults(self, **args): … … 234 225 235 226 if not self.digilibBaseUrl: 236 self.digilibBaseUrl = self.findDigilibUrl() or "http:// nausikaa.mpiwg-berlin.mpg.de/digitallibrary"227 self.digilibBaseUrl = self.findDigilibUrl() or "http://digilib.mpiwg-berlin.mpg.de/digitallibrary" 237 228 238 229 docinfo = self.getDocinfo(mode=mode,url=url) … … 268 259 logging.error("template folder missing!") 269 260 return "ERROR: template folder missing!" 270 271 272 261 273 262 if not getattr(self, 'digilibBaseUrl', None): … … 307 296 viewMode = 'image' 308 297 self.REQUEST['viewMode'] = 'image' 309 310 311 312 298 313 299 # safe viewLayer in userinfo … … 334 320 """try to get the digilib URL from zogilib""" 335 321 url = self.template.zogilib.getDLBaseUrl() 336 return url322 return sslifyUrl(url, self, force=True) 337 323 338 324 def getScalerUrl(self, fn=None, pn=None, dw=100, dh=100, docinfo=None): … … 765 751 # old style text URL 766 752 textUrl = getMDText(texttool.get('text', None)) 767 768 769 770 753 771 754 if textUrl and docPath: … … 1162 1145 """returns list of groups {name:*, id:*} on the annotation server for the user""" 1163 1146 groups = [] 1164 if annotationServerUrl.startswith('//'): 1165 # add matching http(s) from our URL 1166 myUrl = self.REQUEST['URL'] 1167 logging.debug("my URL: %s"%myUrl) 1168 if myUrl.startswith('https:'): 1169 annotationServerUrl = "https:%s"%annotationServerUrl 1170 else: 1171 annotationServerUrl = "http:%s"%annotationServerUrl 1147 # add matching http(s) from our URL 1148 annotationServerUrl = sslifyUrl(annotationServerUrl, self) 1172 1149 1173 1150 groupsUrl = "%s/annotator/groups?user=%s"%(annotationServerUrl,user) … … 1206 1183 if RESPONSE is not None: 1207 1184 RESPONSE.redirect('manage_main') 1185 1208 1186 1209 1187 def manage_AddDocumentViewerForm(self):
Note: See TracChangeset
for help on using the changeset viewer.