Mercurial > hg > documentViewer
comparison MpdlXmlTextServer.py @ 443:ad5c3dedfc18
*** empty log message ***
author | abukhman |
---|---|
date | Tue, 10 May 2011 17:24:55 +0200 |
parents | 9148eac0cab3 |
children | f160791b0074 |
comparison
equal
deleted
inserted
replaced
442:9148eac0cab3 | 443:ad5c3dedfc18 |
---|---|
18 {'label':'Config','action':'manage_changeMpdlXmlTextServerForm'}, | 18 {'label':'Config','action':'manage_changeMpdlXmlTextServerForm'}, |
19 )+SimpleItem.manage_options | 19 )+SimpleItem.manage_options |
20 | 20 |
21 manage_changeMpdlXmlTextServerForm = PageTemplateFile("zpt/manage_changeMpdlXmlTextServer", globals()) | 21 manage_changeMpdlXmlTextServerForm = PageTemplateFile("zpt/manage_changeMpdlXmlTextServer", globals()) |
22 | 22 |
23 def __init__(self,id,title="",serverUrl="http://mpdl-text.mpiwg-berlin.mpg.de/mpdl/interface/", serverName=None, timeout=40): | 23 def __init__(self,id,title="",serverUrl="http://mpdl-system.mpiwg-berlin.mpg.de/mpdl/interface/", serverName=None, timeout=40): |
24 #def __init__(self,id,title="",serverUrl="http://mpdl-text.mpiwg-berlin.mpg.de:30030/mpdl/interface/", serverName=None, timeout=40): | 24 #def __init__(self,id,title="",serverUrl="http://mpdl-text.mpiwg-berlin.mpg.de:30030/mpdl/interface/", serverName=None, timeout=40): |
25 | 25 |
26 """constructor""" | 26 """constructor""" |
27 self.id=id | 27 self.id=id |
28 self.title=title | 28 self.title=title |
201 if highlightQuery is not None: | 201 if highlightQuery is not None: |
202 textParam +="&highlightQuery=%s&sn=%s"%(urllib.quote(highlightQuery),sn) | 202 textParam +="&highlightQuery=%s&sn=%s"%(urllib.quote(highlightQuery),sn) |
203 | 203 |
204 pagexml = self.getServerData("page-fragment.xql",textParam) | 204 pagexml = self.getServerData("page-fragment.xql",textParam) |
205 dom = Parse(pagexml) | 205 dom = Parse(pagexml) |
206 | |
207 | |
206 #original Pages | 208 #original Pages |
207 pagedivs = dom.xpath("//div[@class='pageNumberOrig']") | 209 pagedivs = dom.xpath("//div[@class='pageNumberOrig']") |
210 | |
208 """if pagedivs == dom.xpath("//div[@class='pageNumberOrig']"): | 211 """if pagedivs == dom.xpath("//div[@class='pageNumberOrig']"): |
209 if len(pagedivs)>0: | 212 if len(pagedivs)>0: |
210 docinfo['pageNumberOrig']= getTextFromNode(pagedivs[0]) | 213 docinfo['pageNumberOrig']= getTextFromNode(pagedivs[0]) |
211 logging.debug("ORIGINAL PAGE: %s"%(docinfo['pageNumberOrig'])) | 214 logging.debug("ORIGINAL PAGE: %s"%(docinfo['pageNumberOrig'])) |
212 | 215 |
341 pagedivs = dom.xpath("/div") | 344 pagedivs = dom.xpath("/div") |
342 if len(pagedivs) > 0: | 345 if len(pagedivs) > 0: |
343 pagenode = pagedivs[0] | 346 pagenode = pagedivs[0] |
344 # check all a-tags | 347 # check all a-tags |
345 links = pagenode.xpath("//a") | 348 links = pagenode.xpath("//a") |
349 | |
346 for l in links: | 350 for l in links: |
347 hrefNode = l.getAttributeNodeNS(None, u"href") | 351 hrefNode = l.getAttributeNodeNS(None, u"href") |
352 | |
348 if hrefNode: | 353 if hrefNode: |
349 # is link with href | 354 # is link with href |
350 href = hrefNode.nodeValue | 355 href = hrefNode.nodeValue |
351 if href.startswith('http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/interface/lt/wordInfo.xql'): | 356 if href.startswith('http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/interface/lt/wordInfo.xql'): |
352 # is pollux link | 357 # is pollux link |
353 selfurl = self.absolute_url() | 358 selfurl = self.absolute_url() |
354 # change href | 359 # change href |
355 hrefNode.nodeValue = href.replace('http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/interface/lt/wordInfo.xql','%s/head_main_voc'%selfurl) | 360 hrefNode.nodeValue = href.replace('http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/interface/lt/wordInfo.xql','%s/head_main_voc'%selfurl) |
356 # add target | 361 # add target |
357 l.setAttributeNS(None, 'target', '_blank') | 362 l.setAttributeNS(None, 'target', '_blank') |
358 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;") | 363 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;") |
359 l.setAttributeNS(None, "onDblclick", "popupWin.focus();") | 364 l.setAttributeNS(None, "ondblclick", "popupWin.focus();") |
360 #window.open("this.href, 'InfoWindow', 'menubar=no, location,width=500,height=600,top=180, left=700, toolbar=yes, scrollbars=1'"); return false;") | 365 #window.open("this.href, 'InfoWindow', 'menubar=no, location,width=500,height=600,top=180, left=700, toolbar=yes, scrollbars=1'"); return false;") |
361 | 366 |
362 if href.startswith('http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/lt/lemma.xql'): | 367 if href.startswith('http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/lt/lemma.xql'): |
363 selfurl = self.absolute_url() | 368 selfurl = self.absolute_url() |
364 hrefNode.nodeValue = href.replace('http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/lt/lemma.xql','%s/head_main_lemma'%selfurl) | 369 hrefNode.nodeValue = href.replace('http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/lt/lemma.xql','%s/head_main_lemma'%selfurl) |
365 l.setAttributeNS(None, 'target', '_blank') | 370 l.setAttributeNS(None, 'target', '_blank') |
366 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;") | 371 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;") |
367 l.setAttributeNS(None, 'onDblclick', 'popupWin.focus();') | 372 l.setAttributeNS(None, 'ondblclick', 'popupWin.focus();') |
368 | 373 |
369 if href.startswith('#note-'): | 374 if href.startswith('#note-'): |
370 hrefNode.nodeValue = href.replace('#note-',"?url=%s&viewMode=text_dict&tocMode=%s&tocPN=%s&pn=%s#note-"%(url,tocMode,tocPN,pn)) | 375 hrefNode.nodeValue = href.replace('#note-',"?url=%s&viewMode=text_dict&tocMode=%s&tocPN=%s&pn=%s#note-"%(url,tocMode,tocPN,pn)) |
376 | |
371 return serializeNode(pagenode) | 377 return serializeNode(pagenode) |
372 return "no text here" | 378 return "no text here" |
373 | 379 |
374 def getOrigPages(self, docinfo=None, pageinfo=None): | 380 def getOrigPages(self, docinfo=None, pageinfo=None): |
375 docpath = docinfo['textURLPath'] | 381 docpath = docinfo['textURLPath'] |