diff documentViewer.py @ 508:d5a47f82e755 elementtree

more cleanup. search works mostly now. layers work better now.
author casties
date Mon, 27 Feb 2012 21:26:52 +0100
parents 3c01e8f4e72b
children 9d05befdd462
line wrap: on
line diff
--- a/documentViewer.py	Tue Feb 21 19:23:52 2012 +0100
+++ b/documentViewer.py	Mon Feb 27 21:26:52 2012 +0100
@@ -174,8 +174,16 @@
         """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"""
+        return self.template.fulltextclient.getSearchResults(**args)
+
+    def getResultsPage(self, **args):
+        """returns one page of the search results"""
+        return self.template.fulltextclient.getResultsPage(**args)
+
     def getToc(self, **args):
-        """returns the full table of contents (in internal format)"""
+        """loads table of contents and stores XML in docinfo"""
         return self.template.fulltextclient.getToc(**args)
 
     def getTocPage(self, **args):
@@ -247,13 +255,14 @@
         
         if tocMode != "thumbs":
             # get table of contents
-            docinfo = self.getToc(mode=tocMode, docinfo=docinfo)
+            self.getToc(mode=tocMode, docinfo=docinfo)
 
         # auto viewMode: text if there is a text else images
         if viewMode=="auto": 
             if docinfo.get('textURL', None) or docinfo.get('textURLPath', None): 
                 viewMode = "text"
-                viewLayer = "dict"
+                if viewLayer is None:
+                    viewLayer = "dict"
             else:
                 viewMode = "images"
                 
@@ -262,11 +271,6 @@
             viewMode = "text"
             viewLayer = "dict"
             
-        # stringify viewLayer
-        if isinstance(viewLayer, list):
-            logging.debug("index_html: viewLayer is list:%s"%viewLayer)
-            viewLayer = ','.join([t for t in viewLayer if t])
-                        
         pageinfo = self.getPageinfo(start=start, current=pn, docinfo=docinfo, viewMode=viewMode, viewLayer=viewLayer, tocMode=tocMode)
                     
         # get template /template/viewer_$viewMode
@@ -674,6 +678,22 @@
         logging.debug("getPageInfo(current=%s, start=%s, rows=%s, cols=%s, viewMode=%s, viewLayer=%s, tocMode=%s)"%(current,start,rows,cols,viewMode,viewLayer,tocMode))
         pageinfo = {}
         pageinfo['viewMode'] = viewMode
+        # split viewLayer if necessary
+        if isinstance(viewLayer,basestring):
+            viewLayer = viewLayer.split(',')
+            
+        if isinstance(viewLayer, list):
+            logging.debug("getPageinfo: viewLayer is list:%s"%viewLayer)
+            # save (unique) list in viewLayers
+            seen = set()
+            viewLayers = [l for l in viewLayer if l and l not in seen and not seen.add(l)]
+            pageinfo['viewLayers'] = viewLayers
+            # stringify viewLayer
+            viewLayer = ','.join(viewLayers)
+        else:
+            #create list
+            pageinfo['viewLayers'] = [viewLayer]
+                        
         pageinfo['viewLayer'] = viewLayer
         pageinfo['tocMode'] = tocMode