changeset 112:d48c1d507556

*** empty log message ***
author abukhman
date Fri, 21 May 2010 16:20:38 +0200
parents 3345a4545d74
children 8cd56b99972c
files documentViewer.py
diffstat 1 files changed, 29 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/documentViewer.py	Fri May 21 16:20:21 2010 +0200
+++ b/documentViewer.py	Fri May 21 16:20:38 2010 +0200
@@ -659,13 +659,12 @@
             if np % grpsize > 0:
                 pageinfo['numgroups'] += 1
         
-        #pageinfo['viewMode'] = viewMode   
+          
         pageinfo['viewMode'] = viewMode
         pageinfo['tocMode'] = tocMode
         pageinfo['query'] = self.REQUEST.get('query',' ')
         pageinfo['queryType'] = self.REQUEST.get('queryType',' ')
         pageinfo['querySearch'] =self.REQUEST.get('querySearch', 'fulltext')
-        pageinfo['sn'] = self.REQUEST.get('sn','')
         pageinfo['textPN'] = self.REQUEST.get('textPN','1')
         pageinfo['highlightQuery'] = self.REQUEST.get('highlightQuery','')
         pageinfo['tocPageSize'] = self.REQUEST.get('tocPageSize', '30')
@@ -686,7 +685,7 @@
             pageinfo['tocPN'] = min (tocPages,toc)
                      
         pageinfo['searchPN'] =self.REQUEST.get('searchPN','1')
-        pageinfo['sn'] =self.REQUEST.get('sn','1')
+        pageinfo['sn'] =self.REQUEST.get('sn','')
 
         return pageinfo
                 
@@ -706,7 +705,6 @@
         tocMode = pageinfo['tocMode']
         tocPN = pageinfo['tocPN']
         selfurl = self.absolute_url()
-       # logging.debug("documentViewer (gettoc) /mpdl/interface/doc-query.xql?document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&sn=%s&viewMode=%s"%(docpath, 'text', queryType, query, pagesize, pn, sn, viewMode))
         page=self.template.fulltextclient.eval("/mpdl/interface/doc-query.xql","document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&sn=%s&viewMode=%s&highlightQuery=%s"%(docpath, 'text', queryType, query, pagesize, pn, sn, viewMode,highlightQuery) ,outputUnicode=False)                
         pagexml = page.replace('?document=%s'%str(docpath),'?url=%s'%url)
         pagedom = Parse(pagexml)
@@ -720,13 +718,9 @@
                     if hrefNode:
                         href = hrefNode.nodeValue
                         if href.startswith('page-fragment.xql'):
-                            selfurl = self.absolute_url()
-                            #l.setAttributeNS(None, "span class = 'hit highlight'", "background-color: #77DD77;")            
+                            selfurl = self.absolute_url()            
                             pagexml=href.replace('mode=text','mode=texttool&viewMode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&tocMode=%s&searchPN=%s&tocPN=%s'%(viewMode,queryType,query,pagesize,pn,tocMode,pn,tocPN))
-                            hrefNode.nodeValue = pagexml.replace('page-fragment.xql','%s'%selfurl)                                          
-                            l.setAttributeNS(None, "onClick", "id='highlighting'") 
-                            logging.debug("documentViewer (gettoc) highlightQuery: %s"%(highlightQuery))
-                            l.setAttributeNS(None, highlightQuery, "id='highlighting'") 
+                            hrefNode.nodeValue = pagexml.replace('page-fragment.xql','%s'%selfurl)                                           
                 return serializeNode(pagenode)
         
         if (queryType=="fulltextMorph"):
@@ -763,13 +757,11 @@
                         hrefNode.nodeValue=href.replace('mode=text','mode=texttool&viewMode=%s&tocMode=%s&tocPN=%s&pn=%s'%(viewMode,tocMode,tocPN,pn))
                        
                         if href.startswith('../lt/lex.xql'):
-                           # selfurl = self.absolute_url()
                             hrefNode.nodeValue = href.replace('../lt/lex.xql','%s/template/head_main_voc'%selfurl)         
                             l.setAttributeNS(None, 'target', '_blank')
                             l.setAttributeNS(None, 'onClick',"popupWin = window.open(this.href, 'contacts', 'location,width=500,height=600,top=180, left=400, scrollbars=1'); return false;")
                             l.setAttributeNS(None, 'onDblclick', 'popupWin.focus();')
                         if href.startswith('../lt/lemma.xql'):
-                            #selfurl = self.absolute_url()
                             hrefNode.nodeValue = href.replace('../lt/lemma.xql','%s/template/head_main_lemma'%selfurl)        
                             l.setAttributeNS(None, 'target', '_blank')
                             l.setAttributeNS(None, 'onClick',"popupWin = window.open(this.href, 'contacts', 'location,width=500,height=600,top=180, left=400, scrollbars=1'); return false;")
@@ -785,40 +777,45 @@
         docinfo['numPages'] = text.count("<pb ")
         return docinfo
        
-    def getTextPage(self, mode="text", pn=1, docinfo=None, pageinfo=None, highlightQuery=None,sn=None):
+    def getTextPage(self, mode="text", pn=1, docinfo=None, pageinfo=None, highlightQuery=None,sn=None, viewMode=None):
         """returns single page from fulltext"""
         docpath = docinfo['textURLPath']
-        #pageinfo = pageinfo['highlightQuery']
+        path = docinfo['textURLPath']
+        url = docinfo['url']
+        viewMode= pageinfo['viewMode']
+        tocMode = pageinfo['tocMode']
+        tocPN = pageinfo['tocPN']
+        selfurl = self.absolute_url()   
+       
+        #pn = pageinfo['searchPN']
+     
         if mode == "text_dict":
             textmode = "textPollux"
         else:
             textmode = mode
+        
+        textParam = "document=%s&mode=%s&pn=%s"%(docpath,textmode,pn)
+        if highlightQuery is not None:
+            textParam +="&highlightQuery=%s&sn=%s"%(highlightQuery,sn)
             
-        #selfurl = self.absolute_url()  
-        #viewMode=  pageinfo['viewMode']
-        #tocMode = pageinfo['tocMode']
-        #tocPN = pageinfo['tocPN']
-  
-        pagexml=self.template.fulltextclient.eval("/mpdl/interface/page-fragment.xql", "document=%s&mode=%s&pn=%s&highlightQuery=%s&sn=%s"%(docpath,textmode,pn,highlightQuery,sn), outputUnicode=False)
-        logging.debug("documentViewer (gettoc) document=%s&mode=%s&pn=%s&highlightQuery=%s"%(docpath,textmode,pn,highlightQuery))
-        # post-processing downloaded xml
+        pagexml=self.template.fulltextclient.eval("/mpdl/interface/page-fragment.xql", textParam, outputUnicode=False)
         pagedom = Parse(pagexml)
         # plain text mode
         if mode == "text":
             # first div contains text
             pagedivs = pagedom.xpath("/div")
             #queryResultPage
-            if len(pagedivs) > 0:
-               
+            if len(pagedivs) > 0:      
                 pagenode = pagedivs[0]
                 links = pagenode.xpath("//a")
                 for l in links:
                     hrefNode = l.getAttributeNodeNS(None, u"href")
+
                     if hrefNode:
                         href= hrefNode.nodeValue
-                        if href.startswith('#note-0006-01'):
-                            selfurl = self.absolute_url()
-                            hrefNode.nodeValue = href.replace("href='#note-'",'xaxa/%s/'%selfurl)
+                        if href.startswith('#note-'):
+                            hrefNode.nodeValue = href.replace('#note-',"?url=%s&viewMode=%s&tocMode=%s&tocPN=%s&pn=%s#note-"%(url,viewMode,tocMode,tocPN,pn))
+                
                 return serializeNode(pagenode)
         if mode == "xml":
               # first div contains text
@@ -855,6 +852,11 @@
                             l.setAttributeNS(None, 'target', '_blank')
                             l.setAttributeNS(None, 'onClick',"popupWin = window.open(this.href, 'contacts', 'location,width=500,height=600,top=180, left=700, scrollbars=1'); return false;")
                             l.setAttributeNS(None, 'onDblclick', 'popupWin.focus();')
+                        
+                        if href.startswith('#note-'):
+                            hrefNode.nodeValue = href.replace('#note-',"?url=%s&viewMode=%s&tocMode=%s&tocPN=%s&pn=%s#note-"%(url,viewMode,tocMode,tocPN,pn))    
+                            
+                            
                 return serializeNode(pagenode)
         
         return "no text here"