changeset 562:60f5a636bc57

bugfixes for stability.
author casties
date Tue, 02 Oct 2012 15:22:11 +0200
parents 9255acc4518d
children 8f2dab2d2d2a
files documentViewer.py zpt/toc_thumbs.zpt zpt/viewer_index.zpt
diffstat 3 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/documentViewer.py	Mon Oct 01 18:09:01 2012 +0200
+++ b/documentViewer.py	Tue Oct 02 15:22:11 2012 +0200
@@ -558,10 +558,10 @@
             # asssume index.meta in parent dir
             docUrl = getParentPath(url)
             metaDom = self.metadataService.getDomFromPathOrUrl(docUrl)
+            docinfo['imagePath'] = url.replace('/mpiwg/online/', '', 1)
 
         elif mode=="filepath":
             # url points to image file, index.meta optional
-            docinfo['imagePath'] = url
             docinfo['imageURL'] = self.digilibBaseUrl + "/servlet/Scaler?fn=" + url
             docinfo['numPages'] = 1
             # asssume index.meta is two path segments up
@@ -635,8 +635,9 @@
         if docinfo.get('numPages', 0) == 0:
             # number of images from digilib
             if docinfo.get('imagePath', None):
-                docinfo['imageURL'] = self.digilibBaseUrl + "/servlet/Scaler?fn=" + docinfo['imagePath']
-                docinfo = self.getDocinfoFromDigilib(docinfo, docinfo['imagePath'])
+                imgpath = docinfo['imagePath'].replace('/mpiwg/online/', '', 1)
+                docinfo['imageURL'] = self.digilibBaseUrl + "/servlet/Scaler?fn=" + imgpath
+                docinfo = self.getDocinfoFromDigilib(docinfo, imgpath)
             else:
                 # imagePath still missing? try "./pageimg"
                 imgPath = os.path.join(docUrl, 'pageimg')
@@ -695,7 +696,6 @@
         imageDir = getMDText(texttool.get('image', None))
         docPath = getMDText(docinfo.get('documentPath', None))
         if imageDir and docPath:
-            #print "image: ", imageDir, " archivepath: ", archivePath
             imageDir = os.path.join(docPath, imageDir)
             imageDir = imageDir.replace('/mpiwg/online', '', 1)
             docinfo['imagePath'] = imageDir
--- a/zpt/toc_thumbs.zpt	Mon Oct 01 18:09:01 2012 +0200
+++ b/zpt/toc_thumbs.zpt	Tue Oct 02 15:22:11 2012 +0200
@@ -26,7 +26,7 @@
           <tr tal:repeat="row pageBatch/pages">
             <td tal:repeat="thumb row" tal:attributes="class python:here.getStyle(thumb['idx'],pn,'thumb')"><a
               tal:define="idx thumb/idx" tal:condition="idx" tal:attributes="href python:here.getLink('pn',idx)"> <img
-                tal:attributes="src python:test(docinfo['imageURL'],here.getScalerUrl(pn=idx,dw=100,dh=100,docinfo=docinfo),'images/pic');
+                tal:attributes="src python:test(docinfo.get('imageURL',None),here.getScalerUrl(pn=idx,dw=100,dh=100,docinfo=docinfo),'images/pic');
                                 alt idx" /><br />
                 <span tal:attributes="title string:Scan number $idx" tal:content="idx" /> <span
                 tal:condition="python:pageNumbers and pageNumbers.get(idx, False) and pageNumbers[idx]['no']"
--- a/zpt/viewer_index.zpt	Mon Oct 01 18:09:01 2012 +0200
+++ b/zpt/viewer_index.zpt	Tue Oct 02 15:22:11 2012 +0200
@@ -45,8 +45,8 @@
       <!-- image -->
       <a tal:define="tp docinfo/titlePage | string:1"
         tal:attributes="href python:context.getLink(params={'viewMode':'auto','pn':tp})"><img tal:condition="tp" border="0"
-        tal:attributes="src string:${docinfo/imageURL}&pn=$tp&dw=300&dh=500" /><img
-        tal:condition="python:not tp and exists('here/template/book.png')" border="0" src="template/book.png" /></a>
+        tal:attributes="src python:'%s&pn=%s&dw=300&dh=500'%(docinfo.get('imageURL',None),tp)" /><img
+        tal:condition="python:not docinfo.get('titlePage',None) and exists('here/template/book.png')" border="0" src="template/book.png" /></a>
     </div>
 
     <div class="col main">
@@ -118,11 +118,12 @@
               <td class="content"><a target="_blank" href="http://www.mpiwg-berlin.mpg.de">Max Planck Institute for the
                   History of Science</a> (unless stated otherwise)</td>
             </tr>
-            <tr>
+            <tr tal:define="accType python:docinfo.get('accessType', None)">
               <td class="type">License:</td>
-              <td tal:condition="python:docinfo.get('accessType', None) == 'free'" class="content"><a target="_blank" href="http://creativecommons.org/licenses/by-sa/3.0/de/">CC-BY-SA</a>
+              <td tal:condition="python:accType == 'free'" class="content"><a target="_blank" href="http://creativecommons.org/licenses/by-sa/3.0/de/">CC-BY-SA</a>
                 (unless stated otherwise)</td>
-              <td tal:condition="python:docinfo.get('accessType', None) != 'free'" class="content">Internal use only, please contact <a href="mailto:library@mpiwg-berlin.mpg.de">library@mpiwg-berlin.mpg.de</a>
+              <td tal:condition="python:accType != 'free'" class="content">Internal use only<span tal:condition="accType" tal:content="string: ($accType)"/>, 
+                please contact <a href="mailto:library@mpiwg-berlin.mpg.de">library@mpiwg-berlin.mpg.de</a>
                 (unless stated otherwise)</td>
             </tr>
           </table>