changeset 448:35e7ea6f2368

*** empty log message ***
author abukhman
date Fri, 29 Jul 2011 12:33:17 +0200
parents 2169217252a0
children 6c11f3ec8698
files MpdlXmlTextServer.py documentViewer.py zpt/page_main_pureXml.zpt zpt/page_main_text.zpt zpt/page_main_xml.zpt
diffstat 5 files changed, 37 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/MpdlXmlTextServer.py	Mon Jul 18 16:02:37 2011 +0200
+++ b/MpdlXmlTextServer.py	Fri Jul 29 12:33:17 2011 +0200
@@ -21,7 +21,7 @@
     
     manage_changeMpdlXmlTextServerForm = PageTemplateFile("zpt/manage_changeMpdlXmlTextServer", globals())
         
-    def __init__(self,id,title="",serverUrl="http://mpdl-system.mpiwg-berlin.mpg.de/mpdl/interface/", serverName=None, timeout=40):
+    def __init__(self,id,title="",serverUrl="http://mpdl-test.mpiwg-berlin.mpg.de/mpdl/interface/", serverName=None, timeout=40):
     #def __init__(self,id,title="",serverUrl="http://mpdl-text.mpiwg-berlin.mpg.de:30030/mpdl/interface/", serverName=None, timeout=40):    
         
         """constructor"""
@@ -48,7 +48,11 @@
         url = docinfo['url']
         pagesize = pageinfo['queryPageSize']
         pn = pageinfo.get('searchPN',1)
-        sn = pageinfo['sn']
+        #sn = pageinfo['sn']
+        s = pageinfo['s']
+        highlightElementPos =pageinfo ['highlightElementPos']
+        highlightElement = pageinfo ['highlightElement']
+        
         highlightQuery = pageinfo['highlightQuery']
         query =pageinfo['query']
         queryType =pageinfo['queryType']
@@ -58,7 +62,8 @@
         #optionToggle = pageinfo['optionToggle']
         tocPN = pageinfo['tocPN']
         selfurl = self.absolute_url()
-        data = self.getServerData("doc-query.xql","document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&sn=%s&viewMode=%s&characterNormalization=%s&highlightQuery=%s"%(docpath, 'text', queryType, urllib.quote(query), pagesize, pn, sn, viewMode,characterNormalization, urllib.quote(highlightQuery)))
+        data = self.getServerData("doc-query.xql","document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&s=%s&viewMode=%s&characterNormalization=%s&highlightElementPos=%s&highlightElement=%s&highlightQuery=%s"%(docpath, 'text', queryType, urllib.quote(query), pagesize, pn, s, viewMode,characterNormalization, highlightElementPos, highlightElement, urllib.quote(highlightQuery)))
+        #data = self.getServerData("doc-query.xql","document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&sn=%s&viewMode=%s&characterNormalization=%s&highlightQuery=%s"%(docpath, 'text', queryType, urllib.quote(query), pagesize, pn, sn, viewMode,characterNormalization, urllib.quote(highlightQuery)))
         pagexml = data.replace('?document=%s'%str(docpath),'?url=%s'%url)
         pagedom = Parse(pagexml)
         
@@ -185,7 +190,10 @@
         url = docinfo.get('url',None)
         name = docinfo.get('name',None)
         pn =pageinfo['current']
-        sn = pageinfo['sn']
+        #sn = pageinfo['sn']
+        s = pageinfo['s']
+        highlightElementPos =pageinfo ['highlightElementPos']
+        highlightElement = pageinfo ['highlightElement']
         #optionToggle =pageinfo ['optionToggle']
         highlightQuery = pageinfo['highlightQuery']
         #mode = pageinfo ['viewMode']
@@ -200,7 +208,8 @@
         
         textParam = "document=%s&mode=%s&pn=%s&characterNormalization=%s"%(docpath,textmode,pn,characterNormalization)
         if highlightQuery is not None:
-            textParam +="&highlightQuery=%s&sn=%s"%(urllib.quote(highlightQuery),sn)           
+            #textParam +="&highlightQuery=%s&sn=%s"%(urllib.quote(highlightQuery),sn)
+            textParam +="&highlightQuery=%s&s=%s&highlightElement=%s&highlightElementPos=%s"%(urllib.quote(highlightQuery),s, highlightElement, highlightElementPos)           
         
         pagexml = self.getServerData("page-fragment.xql",textParam)
         dom = Parse(pagexml)
@@ -354,20 +363,20 @@
                     if hrefNode:
                         # is link with href
                         href = hrefNode.nodeValue
-                        if href.startswith('http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/interface/lt/wordInfo.xql'):
+                        if href.startswith('http://mpdl-text.mpiwg-berlin.mpg.de/mpdl/interface/lt/wordInfo.xql'):
                             # is pollux link
                             selfurl = self.absolute_url()
                             # change href
-                            hrefNode.nodeValue = href.replace('http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/interface/lt/wordInfo.xql','%s/head_main_voc'%selfurl)
+                            hrefNode.nodeValue = href.replace('http://mpdl-text.mpiwg-berlin.mpg.de/mpdl/interface/lt/wordInfo.xql','%s/head_main_voc'%selfurl)
                             # add target
                             l.setAttributeNS(None, 'target', '_blank')
                             #l.setAttributeNS(None, 'onclick',"popupWin = window.open(this.href, 'InfoWindow', 'menubar=no, location,width=500,height=600,top=180, left=700, toolbar=no, scrollbars=1'); return false;")
                             #l.setAttributeNS(None, "ondblclick", "popupWin.focus();")
                             #window.open("this.href, 'InfoWindow', 'menubar=no, location,width=500,height=600,top=180, left=700, toolbar=yes, scrollbars=1'"); return false;") 
                                                           
-                        if href.startswith('http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/lt/lemma.xql'):    
+                        if href.startswith('http://mpdl-text.mpiwg-berlin.mpg.de/mpdl/lt/lemma.xql'):    
                             selfurl = self.absolute_url()
-                            hrefNode.nodeValue = href.replace('http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/lt/lemma.xql','%s/head_main_lemma'%selfurl)
+                            hrefNode.nodeValue = href.replace('http://mpdl-text.mpiwg-berlin.mpg.de/mpdl/lt/lemma.xql','%s/head_main_lemma'%selfurl)
                             l.setAttributeNS(None, 'target', '_blank')
                             l.setAttributeNS(None, 'onclick',"popupWin = window.open(this.href, 'InfoWindow', 'menubar=no, location,width=300,height=400,top=180, left=700, toolbar=no, scrollbars=1'); return false;")
                             l.setAttributeNS(None, 'ondblclick', 'popupWin.focus();')   
--- a/documentViewer.py	Mon Jul 18 16:02:37 2011 +0200
+++ b/documentViewer.py	Fri Jul 29 12:33:17 2011 +0200
@@ -595,7 +595,7 @@
         
     def getBibinfoFromIndexMeta(self,path,docinfo=None,dom=None,cut=0):
         """gets bibliographical info from the index.meta file at path or given by dom"""
-        logging.debug("documentViewer (getbibinfofromindexmeta) path: %s"%(path))
+        #logging.debug("documentViewer (getbibinfofromindexmeta) path: %s"%(path))
         
         if docinfo is None:
             docinfo = {}
@@ -607,7 +607,7 @@
         
         docinfo['indexMetaPath']=self.getIndexMetaPath(path);
         
-        logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path))
+        #logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path))
         # put in all raw bib fields as dict "bib"
         bib = dom.xpath("//bib/*")
         if bib and len(bib)>0:
@@ -627,8 +627,8 @@
         bibtype=bibtype.replace("-"," ") # wrong typesiin index meta "-" instead of " " (not wrong! ROC)
         docinfo['bib_type'] = bibtype
         bibmap=metaData.generateMappingForType(bibtype)
-        logging.debug("documentViewer (getbibinfofromindexmeta) bibmap:"+repr(bibmap))
-        logging.debug("documentViewer (getbibinfofromindexmeta) bibtype:"+repr(bibtype))
+        #logging.debug("documentViewer (getbibinfofromindexmeta) bibmap:"+repr(bibmap))
+        #logging.debug("documentViewer (getbibinfofromindexmeta) bibtype:"+repr(bibtype))
         # if there is no mapping bibmap is empty (mapping sometimes has empty fields)
         if len(bibmap) > 0 and len(bibmap['author'][0]) > 0:
             try:
@@ -640,7 +640,7 @@
             try:
                 docinfo['year']=getTextFromNode(dom.xpath("//bib/%s"%bibmap['year'][0])[0])
             except: pass
-            logging.debug("documentViewer (getbibinfofromindexmeta) using mapping for %s"%bibtype)
+            #logging.debug("documentViewer (getbibinfofromindexmeta) using mapping for %s"%bibtype)
             try:
                 docinfo['lang']=getTextFromNode(dom.xpath("//bib/lang")[0])
             except:
@@ -685,9 +685,10 @@
                 docinfo['isbn_issn']=getTextFromNode(dom.xpath("//bib/isbn_issn")[0])
             except:
                 docinfo['isbn_issn']=''           
+        #logging.debug("I NEED BIBTEX %s"%docinfo)
         return docinfo
     
-     
+    
     def getNameFromIndexMeta(self,path,docinfo=None,dom=None,cut=0):
         """gets name info from the index.meta file at path or given by dom"""
         if docinfo is None:
@@ -791,6 +792,7 @@
          
         presentationUrls = dom.xpath("//texttool/presentation")
         docinfo = self.getBibinfoFromIndexMeta(url, docinfo=docinfo, dom=dom)   # get info von bib tag
+        #docinfo = self.getDownloadfromDocinfoToBibtex(url, docinfo=docinfo, dom=dom)
         docinfo = self.getNameFromIndexMeta(url, docinfo=docinfo, dom=dom)
         
         
@@ -846,6 +848,7 @@
         
         #path ist the path to the images it assumes that the index.meta file is one level higher.
         docinfo = self.getBibinfoFromIndexMeta(pathorig,docinfo=docinfo,cut=cut+1)
+        #docinfo = self.getDownloadfromDocinfoToBibtex(pathorig,docinfo=docinfo,cut=cut+1)
         docinfo = self.getAuthinfoFromIndexMeta(pathorig,docinfo=docinfo,cut=cut+1)
         return docinfo
     
@@ -912,6 +915,11 @@
         pageinfo['querySearch'] =self.REQUEST.get('querySearch', 'fulltext')
         pageinfo['textPN'] = self.REQUEST.get('textPN','1')
         pageinfo['highlightQuery'] = self.REQUEST.get('highlightQuery','')
+        
+        pageinfo ['highlightElementPos'] = self.REQUEST.get('highlightElementPos','')
+        pageinfo ['highlightElement'] = self.REQUEST.get('highlightElement','')
+        
+        
         pageinfo['tocPageSize'] = self.REQUEST.get('tocPageSize', '30')
         pageinfo['queryPageSize'] =self.REQUEST.get('queryPageSize', '10')
         pageinfo['tocPN'] = self.REQUEST.get('tocPN', '1')     
@@ -928,7 +936,8 @@
                 tocPages=tocSize/tocPageSize
             pageinfo['tocPN'] = min (tocPages,toc)                    
         pageinfo['searchPN'] =self.REQUEST.get('searchPN','1')
-        pageinfo['sn'] =self.REQUEST.get('sn','')
+        #pageinfo['sn'] =self.REQUEST.get('sn','')
+        pageinfo['s'] =self.REQUEST.get('s','')
         return pageinfo
     
 def changeDocumentViewer(self,title="",digilibBaseUrl=None,thumbrows=2,thumbcols=5,authgroups='mpiwg',RESPONSE=None):
--- a/zpt/page_main_pureXml.zpt	Mon Jul 18 16:02:37 2011 +0200
+++ b/zpt/page_main_pureXml.zpt	Fri Jul 29 12:33:17 2011 +0200
@@ -1,3 +1,3 @@
-<tal:block tal:define="pageinfo python:options.get('pageinfo',None); docinfo python:options.get('docinfo',None) ;highlightQuery python:pageinfo.get('highlightQuery','');sn python:pageinfo.get('sn','');optionToggle python:pageinfo.get('optionToggle','');  ">
+<tal:block tal:define="pageinfo python:options.get('pageinfo',None); docinfo python:options.get('docinfo',None) ;highlightQuery python:pageinfo.get('highlightQuery','');s python:pageinfo.get('s','');optionToggle python:pageinfo.get('optionToggle','');  ">
   <div tal:content="structure python:pageinfo['textPage']"></div>
 </tal:block>
\ No newline at end of file
--- a/zpt/page_main_text.zpt	Mon Jul 18 16:02:37 2011 +0200
+++ b/zpt/page_main_text.zpt	Fri Jul 29 12:33:17 2011 +0200
@@ -1,7 +1,7 @@
 <tal:block tal:define="pageinfo python:options.get('pageinfo',None); 
                        docinfo python:options.get('docinfo',None);
                        highlightQuery python:pageinfo.get('highlightQuery','');
-                       sn python:pageinfo.get('sn','');
+                       s python:pageinfo.get('s','');
                        pn python:pageinfo.get('pn',1);
                        characterNormalization python:pageinfo.get('characterNormalization','');
                        optionToggle python:pageinfo.get('optionToggle','');">
--- a/zpt/page_main_xml.zpt	Mon Jul 18 16:02:37 2011 +0200
+++ b/zpt/page_main_xml.zpt	Fri Jul 29 12:33:17 2011 +0200
@@ -1,3 +1,3 @@
-<tal:block tal:define="pageinfo python:options.get('pageinfo',None); docinfo python:options.get('docinfo',None) ;highlightQuery python:pageinfo.get('highlightQuery','');sn python:pageinfo.get('sn','');optionToggle python:pageinfo.get('optionToggle',''); mode python:pageinfo.get('mode', 'xml') ">
+<tal:block tal:define="pageinfo python:options.get('pageinfo',None); docinfo python:options.get('docinfo',None) ;highlightQuery python:pageinfo.get('highlightQuery','');s python:pageinfo.get('s','');optionToggle python:pageinfo.get('optionToggle',''); mode python:pageinfo.get('mode', 'xml') ">
   <div tal:content="structure python:pageinfo['textPage']"></div>
 </tal:block>
\ No newline at end of file