changeset 599:3b79ae4a23ca

normalize uri of annotated image.
author casties
date Mon, 19 Nov 2012 17:15:13 +0100
parents 4fe11d2bd4ae
children 87f3a0e63b13
files documentViewer.py zpt/viewer/layer_image_annotator.zpt
diffstat 2 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/documentViewer.py	Mon Nov 19 16:35:56 2012 +0100
+++ b/documentViewer.py	Mon Nov 19 17:15:13 2012 +0100
@@ -535,7 +535,7 @@
             # asssume index.meta in parent dir
             docUrl = getParentPath(url)
             metaDom = self.metadataService.getDomFromPathOrUrl(docUrl)
-            docinfo['imagePath'] = url.replace('/mpiwg/online/', '', 1)
+            docinfo['imagePath'] = url.replace('/mpiwg/online', '', 1)
 
         elif mode=="filepath":
             # url points to image file, index.meta optional
@@ -613,13 +613,13 @@
         # image path
         if mode != 'texttool':
             # override image path from texttool with url parameter TODO: how about mode=auto?
-            docinfo['imagePath'] = url.replace('/mpiwg/online/', '', 1)
+            docinfo['imagePath'] = url.replace('/mpiwg/online', '', 1)
 
         # check numPages
         if docinfo.get('numPages', 0) == 0:
             # number of images from digilib
             if docinfo.get('imagePath', None):
-                imgpath = docinfo['imagePath'].replace('/mpiwg/online/', '', 1)
+                imgpath = docinfo['imagePath'].replace('/mpiwg/online', '', 1)
                 logging.debug("imgpath=%s"%imgpath)
                 docinfo['imageURL'] = "%s?fn=%s"%(self.digilibScalerUrl, imgpath)
                 docinfo = self.getDocinfoFromDigilib(docinfo, imgpath)
@@ -638,8 +638,11 @@
                 # replace with numTextPages (text-only?)
                 docinfo['numPages'] = docinfo['numTextPages']
 
+        # normalize path
+        if 'imagePath' in docinfo and not docinfo['imagePath'].startswith('/'):
+            docinfo['imagePath'] = '/' + docinfo['imagePath']
+
         logging.debug("documentViewer (getdocinfo) docinfo: keys=%s"%docinfo.keys())
-        #logging.debug("documentViewer (getdocinfo) docinfo: %s"%docinfo)
         # store in session
         self.REQUEST.SESSION['docinfo'] = docinfo
         return docinfo
--- a/zpt/viewer/layer_image_annotator.zpt	Mon Nov 19 16:35:56 2012 +0100
+++ b/zpt/viewer/layer_image_annotator.zpt	Mon Nov 19 17:15:13 2012 +0100
@@ -12,7 +12,7 @@
   <script type="text/javascript" 
     tal:define="global annServerUrl string:http://tuxserve03.mpiwg-berlin.mpg.de/AnnotationManager;
     global annTokenUrl string:$viewerUrl/template/token/getLoginToken;
-    annUrl python:'http://echo.mpiwg-berlin.mpg.de/documents%s?pn=%s'%(docinfo['documentPath'],pageinfo['pn']);
+    annUrl python:'http://echo.mpiwg-berlin.mpg.de/documents%s?pn=%s'%(docinfo['imagePath'],pageinfo['pn']);
     resUrl python:'http://echo.mpiwg-berlin.mpg.de/documents%s'%(docinfo['documentPath']);
     global annUser python:here.getAuthenticatedUser(anon='anonymous');
     global annGroup python:request.get('annotator_group', None);