Diff for /documentViewer/documentViewer.py between versions 1.53 and 1.61

version 1.53, 2010/05/19 16:24:16 version 1.61, 2010/05/21 14:36:17
Line 665  class documentViewer(Folder): Line 665  class documentViewer(Folder):
         pageinfo['query'] = self.REQUEST.get('query',' ')          pageinfo['query'] = self.REQUEST.get('query',' ')
         pageinfo['queryType'] = self.REQUEST.get('queryType',' ')          pageinfo['queryType'] = self.REQUEST.get('queryType',' ')
         pageinfo['querySearch'] =self.REQUEST.get('querySearch', 'fulltext')          pageinfo['querySearch'] =self.REQUEST.get('querySearch', 'fulltext')
           
         pageinfo['textPN'] = self.REQUEST.get('textPN','1')          pageinfo['textPN'] = self.REQUEST.get('textPN','1')
                   pageinfo['highlightQuery'] = self.REQUEST.get('highlightQuery','')
         pageinfo['tocPageSize'] = self.REQUEST.get('tocPageSize', '30')          pageinfo['tocPageSize'] = self.REQUEST.get('tocPageSize', '30')
         pageinfo['queryPageSize'] =self.REQUEST.get('queryPageSize', '20')          pageinfo['queryPageSize'] =self.REQUEST.get('queryPageSize', '10')
         pageinfo['tocPN'] = self.REQUEST.get('tocPN', '1')          pageinfo['tocPN'] = self.REQUEST.get('tocPN', '1')
         toc = int (pageinfo['tocPN'])          toc = int (pageinfo['tocPN'])
         pageinfo['textPages'] =int (toc)          pageinfo['textPages'] =int (toc)
Line 686  class documentViewer(Folder): Line 685  class documentViewer(Folder):
             pageinfo['tocPN'] = min (tocPages,toc)              pageinfo['tocPN'] = min (tocPages,toc)
                                             
         pageinfo['searchPN'] =self.REQUEST.get('searchPN','1')          pageinfo['searchPN'] =self.REQUEST.get('searchPN','1')
         pageinfo['sn'] =self.REQUEST.get('sn','1')          pageinfo['sn'] =self.REQUEST.get('sn','')
   
         return pageinfo          return pageinfo
                                   
Line 699  class documentViewer(Folder): Line 698  class documentViewer(Folder):
         pagesize = pageinfo['queryPageSize']          pagesize = pageinfo['queryPageSize']
         pn = pageinfo['searchPN']          pn = pageinfo['searchPN']
         sn = pageinfo['sn']          sn = pageinfo['sn']
           highlightQuery = pageinfo['highlightQuery']
         query =pageinfo['query']          query =pageinfo['query']
         queryType =pageinfo['queryType']          queryType =pageinfo['queryType']
         viewMode=  pageinfo['viewMode']          viewMode=  pageinfo['viewMode']
         tocMode = pageinfo['tocMode']          tocMode = pageinfo['tocMode']
         tocPN = pageinfo['tocPN']          tocPN = pageinfo['tocPN']
         selfurl = self.absolute_url()          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)                
         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"%(docpath, 'text', queryType, query, pagesize, pn, sn, viewMode) ,outputUnicode=False)                  
         pagexml = page.replace('?document=%s'%str(docpath),'?url=%s'%url)          pagexml = page.replace('?document=%s'%str(docpath),'?url=%s'%url)
         pagedom = Parse(pagexml)          pagedom = Parse(pagexml)
         if (queryType=="fulltext")or(queryType=="xpath")or(queryType=="xquery")or(queryType=="fulltextMorphLemma"):             if (queryType=="fulltext")or(queryType=="xpath")or(queryType=="xquery")or(queryType=="fulltextMorphLemma"):   
Line 720  class documentViewer(Folder): Line 719  class documentViewer(Folder):
                         href = hrefNode.nodeValue                          href = hrefNode.nodeValue
                         if href.startswith('page-fragment.xql'):                          if href.startswith('page-fragment.xql'):
                             selfurl = self.absolute_url()                              selfurl = self.absolute_url()
                             #l.setAttributeNS(None, "span class = 'hit highlight'", "background-color: #77DD77;")              
                             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))                              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)                                                                        hrefNode.nodeValue = pagexml.replace('page-fragment.xql','%s'%selfurl)                                          
                             l.setAttributeNS(None, "onClick", "id='highlighting'")                
                 return serializeNode(pagenode)                  return serializeNode(pagenode)
                   
         if (queryType=="fulltextMorph"):          if (queryType=="fulltextMorph"):
             pagedivs = pagedom.xpath("//div[@class='queryResult']")              pagedivs = pagedom.xpath("//div[@class='queryResult']")
               
             if len(pagedivs)>0:              if len(pagedivs)>0:
                 pagenode=pagedivs[0]                  pagenode=pagedivs[0]
                 links=pagenode.xpath("//a")                  links=pagenode.xpath("//a")
Line 742  class documentViewer(Folder): Line 738  class documentViewer(Folder):
                             hrefNode.nodeValue = pagexml.replace('page-fragment.xql','%s'%selfurl)                                hrefNode.nodeValue = pagexml.replace('page-fragment.xql','%s'%selfurl)  
                         if href.startswith('../lt/lemma.xql'):                          if href.startswith('../lt/lemma.xql'):
                             selfurl = self.absolute_url()                              selfurl = self.absolute_url()
                             hrefNode.nodeValue = href.replace('lt/lemma.xql','%s/template/head_main_lemma'%selfurl)                                      hrefNode.nodeValue = href.replace('..lt/lemma.xql','%s/template/head_main_lemma'%selfurl)        
                             l.setAttributeNS(None, 'target', '_blank')                              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, '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();')                                                l.setAttributeNS(None, 'onDblclick', 'popupWin.focus();')                  
Line 760  class documentViewer(Folder): Line 756  class documentViewer(Folder):
                         hrefNode.nodeValue=href.replace('mode=text','mode=texttool&viewMode=%s&tocMode=%s&tocPN=%s&pn=%s'%(viewMode,tocMode,tocPN,pn))                          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'):                          if href.startswith('../lt/lex.xql'):
                            # selfurl = self.absolute_url()                              hrefNode.nodeValue = href.replace('../lt/lex.xql','%s/template/head_main_voc'%selfurl)         
                             hrefNode.nodeValue = href.replace('../lt/lex.xql','%s../template/head_main_voc'%selfurl)           
                             l.setAttributeNS(None, 'target', '_blank')                              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, '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();')                              l.setAttributeNS(None, 'onDblclick', 'popupWin.focus();')
                         if href.startswith('../lt/lemma.xql'):                          if href.startswith('../lt/lemma.xql'):
                             #selfurl = self.absolute_url()                              hrefNode.nodeValue = href.replace('../lt/lemma.xql','%s/template/head_main_lemma'%selfurl)        
                             hrefNode.nodeValue = href.replace('../lt/lemma.xql','%s../template/head_main_lemma'%selfurl)          
                             l.setAttributeNS(None, 'target', '_blank')                              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, '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();')                              l.setAttributeNS(None, 'onDblclick', 'popupWin.focus();')
Line 782  class documentViewer(Folder): Line 776  class documentViewer(Folder):
         docinfo['numPages'] = text.count("<pb ")          docinfo['numPages'] = text.count("<pb ")
         return docinfo          return docinfo
                 
     def getTextPage(self, mode="text", pn=1, docinfo=None, pageinfo=None,):      def getTextPage(self, mode="text", pn=1, docinfo=None, pageinfo=None, highlightQuery=None,sn=None, viewMode=None):
         """returns single page from fulltext"""          """returns single page from fulltext"""
         docpath = docinfo['textURLPath']          docpath = docinfo['textURLPath']
           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":          if mode == "text_dict":
             textmode = "textPollux"              textmode = "textPollux"
         else:          else:
             textmode = mode              textmode = mode
                           
         #selfurl = self.absolute_url()            textParam = "document=%s&mode=%s&pn=%s"%(docpath,textmode,pn)
         #viewMode=  pageinfo['viewMode']          if highlightQuery is not None:
         #tocMode = pageinfo['tocMode']              textParam +="&highlightQuery=%s&sn=%s"%(highlightQuery,sn)
         #tocPN = pageinfo['tocPN']  
       
         pagexml=self.template.fulltextclient.eval("/mpdl/interface/page-fragment.xql", "document=%s&mode=%s&pn=%s"%(docpath,textmode,pn), outputUnicode=False)          pagexml=self.template.fulltextclient.eval("/mpdl/interface/page-fragment.xql", textParam, outputUnicode=False)
         # post-processing downloaded xml  
         pagedom = Parse(pagexml)          pagedom = Parse(pagexml)
         # plain text mode          # plain text mode
         if mode == "text":          if mode == "text":
Line 804  class documentViewer(Folder): Line 805  class documentViewer(Folder):
             pagedivs = pagedom.xpath("/div")              pagedivs = pagedom.xpath("/div")
             #queryResultPage              #queryResultPage
             if len(pagedivs) > 0:              if len(pagedivs) > 0:
                  
                 pagenode = pagedivs[0]                  pagenode = pagedivs[0]
                 links = pagenode.xpath("//a")                  links = pagenode.xpath("//a")
                 for l in links:                  for l in links:
                     hrefNode = l.getAttributeNodeNS(None, u"href")                      hrefNode = l.getAttributeNodeNS(None, u"href")
   
                     if hrefNode:                      if hrefNode:
                         href= hrefNode.nodeValue                          href= hrefNode.nodeValue
                         if href.startswith('#note-0006-01'):                          if href.startswith('#note-'):
                             selfurl = self.absolute_url()                              hrefNode.nodeValue = href.replace('#note-',"?url=%s&viewMode=%s&tocMode=%s&tocPN=%s&pn=%s#note-"%(url,viewMode,tocMode,tocPN,pn))
                             hrefNode.nodeValue = href.replace("href='#note-'",'xaxa/%s/'%selfurl)                  
                 return serializeNode(pagenode)                  return serializeNode(pagenode)
         if mode == "xml":          if mode == "xml":
               # first div contains text                # first div contains text
Line 850  class documentViewer(Folder): Line 851  class documentViewer(Folder):
                             l.setAttributeNS(None, 'target', '_blank')                              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, '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();')                              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 serializeNode(pagenode)
                   
         return "no text here"          return "no text here"
Line 880  class documentViewer(Folder): Line 886  class documentViewer(Folder):
          pagedom = Parse(pagexml)           pagedom = Parse(pagexml)
          numdivs = pagedom.xpath("//div[@class='queryResultHits']")           numdivs = pagedom.xpath("//div[@class='queryResultHits']")
          tocSearch = int(getTextFromNode(numdivs[0]))           tocSearch = int(getTextFromNode(numdivs[0]))
          tc=int((tocSearch/20)+1)           tc=int((tocSearch/10)+1)
          logging.debug("documentViewer (gettoc) tc: %s"%(tc))           logging.debug("documentViewer (gettoc) tc: %s"%(tc))
          return tc           return tc
   

Removed from v.1.53  
changed lines
  Added in v.1.61


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>