changeset 548:7acc919f52ff

mode=filepath works again
author casties
date Fri, 31 Aug 2012 15:55:45 +0200
parents 7c6fdc31bd35
children 7bff5a6b0be5
files documentViewer.py
diffstat 1 files changed, 27 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/documentViewer.py	Wed Aug 29 17:52:37 2012 +0200
+++ b/documentViewer.py	Fri Aug 31 15:55:45 2012 +0200
@@ -221,7 +221,7 @@
         """get list of gis places on one page"""
         return self.template.fulltextclient.getPlacesOnPage(**args)
  
-    #WTF?
+    # Thumb list for CoolIris Plugin
     thumbs_main_rss = PageTemplateFile('zpt/thumbs_main_rss', globals())
     security.declareProtected('View','thumbs_rss')
     def thumbs_rss(self,mode,url,viewMode="auto",start=None,pn=1):
@@ -232,8 +232,6 @@
         @param viewMode: if images display images, if text display text, default is images (text,images or auto)
         
         '''
-        logging.debug("HHHHHHHHHHHHHH:load the rss")
-        logging.debug("documentViewer (index) mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn))
         
         if not hasattr(self, 'template'):
             # create template folder if it doesn't exist
@@ -258,7 +256,7 @@
 
   
     security.declareProtected('View','index_html')
-    def index_html(self,url,mode="texttool",viewMode="auto",viewLayer=None,tocMode="thumbs",start=1,pn=1):
+    def index_html(self,url,mode="texttool",viewMode="auto",viewLayer=None,tocMode=None,start=1,pn=1):
         """
         show page
         @param url: url which contains display information
@@ -278,6 +276,13 @@
         if not getattr(self, 'digilibBaseUrl', None):
             self.digilibBaseUrl = self.findDigilibUrl() or "http://digilib.mpiwg-berlin.mpg.de/digitallibrary"
             
+        # mode=filepath should not have toc-thumbs
+        if tocMode is None:
+            if mode == "filepath":
+                tocMode = "none"
+            else:
+                tocMode = "thumbs"
+            
         # docinfo: information about document (cached)
         docinfo = self.getDocinfo(mode=mode,url=url,tocMode=tocMode)
         
@@ -302,7 +307,7 @@
             
         # safe viewLayer in userinfo
         userinfo['viewLayer'] = viewLayer
-        
+                
         # pageinfo: information about page (not cached)
         pageinfo = self.getPageinfo(start=start, current=pn, docinfo=docinfo, userinfo=userinfo, viewMode=viewMode, viewLayer=viewLayer, tocMode=tocMode)
                     
@@ -539,6 +544,9 @@
 
         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
             docUrl = getParentPath(url, 2)
             metaDom = self.metadataService.getDomFromPathOrUrl(docUrl)
@@ -566,7 +574,7 @@
             # bib info
             bib = self.metadataService.getBibData(dom=metaDom)
             if bib:
-                # save extended version as 'bibx'
+                # save extended version as 'bibx' TODO: ugly
                 bibx = self.metadataService.getBibData(dom=metaDom, all=True, recursive=1)
                 if len(bibx) == 1:
                     # unwrap list if possible
@@ -606,18 +614,20 @@
             # override image path from texttool with url parameter TODO: how about mode=auto?
             docinfo['imagePath'] = url.replace('/mpiwg/online/', '', 1)
 
-        # 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'])
-        else:
-            # imagePath still missing? try "./pageimg"
-            imgPath = os.path.join(docUrl, 'pageimg')
-            docinfo = self.getDocinfoFromDigilib(docinfo, imgPath)
-            if docinfo.get('numPages', 0) > 0:
-                # there are pages
-                docinfo['imagePath'] = imgPath
+        # check numPages
+        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'])
+            else:
+                # imagePath still missing? try "./pageimg"
+                imgPath = os.path.join(docUrl, 'pageimg')
+                docinfo = self.getDocinfoFromDigilib(docinfo, imgPath)
+                if docinfo.get('numPages', 0) > 0:
+                    # there are pages
+                    docinfo['imagePath'] = imgPath
+                    docinfo['imageURL'] = self.digilibBaseUrl + "/servlet/Scaler?fn=" + docinfo['imagePath']
 
         # check numPages
         if docinfo.get('numPages', 0) == 0: