Changeset 478:cd37d6f8d5e8 in documentViewer for MpdlXmlTextServer.py
- Timestamp:
- Aug 12, 2011, 2:41:39 PM (13 years ago)
- Branch:
- elementtree
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
MpdlXmlTextServer.py
r477 r478 90 90 pagesize = pageinfo['queryPageSize'] 91 91 pn = pageinfo.get('searchPN',1) 92 sn = pageinfo ['sn']92 sn = pageinfo.get('sn',None) #TODO: is this s now? 93 93 highlightQuery = pageinfo['highlightQuery'] 94 94 query =pageinfo['query'] … … 270 270 """returns single page from fulltext""" 271 271 logging.debug("getTextPage mode=%s, pn=%s"%(mode,pn)) 272 # check for cached text -- but this shouldn't be called twice272 # check for cached text -- but ideally this shouldn't be called twice 273 273 if pageinfo.has_key('textPage'): 274 274 logging.debug("getTextPage: using cached text") … … 288 288 tocPN = pageinfo.get('tocPN',None) 289 289 characterNormalization = pageinfo.get('characterNormalization', None) 290 selfurl = docinfo['viewerUrl'] 290 291 selfurl = docinfo['viewerUrl'] 291 292 292 293 if mode == "dict" or mode == "text_dict": … … 323 324 # plain text mode 324 325 if mode == "text": 326 # get full url assuming documentViewer is parent 327 selfurl = self.getLink() 325 328 if pagediv is not None: 326 329 links = pagediv.findall(".//a") … … 328 331 href = l.get('href') 329 332 if href and href.startswith('#note-'): 330 href = href.replace('#note-'," ?mode=%s&url=%s&viewMode=text&tocMode=%s&tocPN=%s&pn=%s#note-"%(urlmode,url,tocMode,tocPN,pn))333 href = href.replace('#note-',"%s#note-"%selfurl) 331 334 l.set('href', href) 332 335 … … 336 339 elif mode == "dict": 337 340 if pagediv is not None: 341 viewerurl = docinfo['viewerUrl'] 342 selfurl = self.getLink() 338 343 # check all a-tags 339 344 links = pagediv.findall(".//a") … … 344 349 # is link with href 345 350 if href.startswith('http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/interface/lt/wordInfo.xql'): 346 # is pollux link 347 selfurl = self.absolute_url() 348 # change href 349 l.set('href', href.replace('http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/interface/lt/wordInfo.xql','%s/head_main_voc'%selfurl)) 350 # add target 351 # is dictionary link - change href (keeping parameters) 352 l.set('href', href.replace('http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/interface/lt/wordInfo.xql','%s/template/viewer_wordinfo'%viewerurl)) 353 # add target to open new page 351 354 l.set('target', '_blank') 352 355 353 if href.startswith('http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/lt/lemma.xql'): 356 # TODO: is this needed? 357 if href.startswith('http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/lt/lemma.xql'): 354 358 selfurl = self.absolute_url() 355 359 l.set('href', href.replace('http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/lt/lemma.xql','%s/head_main_lemma'%selfurl)) … … 359 363 360 364 if href.startswith('#note-'): 361 l.set('href', href.replace('#note-',"?mode=%s&url=%s&viewMode=text_dict&tocMode=%s&tocPN=%s&pn=%s#note-"%(urlmode,url,tocMode,tocPN,pn))) 365 # note link 366 l.set('href', href.replace('#note-',"%s#note-"%selfurl)) 362 367 363 368 return serialize(pagediv) … … 390 395 return "no text here" 391 396 392 # WTF: is this needed?393 def getOrigPages(self, docinfo=None, pageinfo=None):394 logging.debug("CALLED: getOrigPages!")395 if not pageinfo.has_key('pageNumberOrig'):396 logging.warning("getOrigPages: not in pageinfo!")397 return None398 399 return pageinfo['pageNumberOrig']400 401 # WTF: is this needed?402 def getOrigPagesNorm(self, docinfo=None, pageinfo=None):403 logging.debug("CALLED: getOrigPagesNorm!")404 if not pageinfo.has_key('pageNumberOrigNorm'):405 logging.warning("getOrigPagesNorm: not in pageinfo!")406 return None407 408 return pageinfo['pageNumberOrigNorm']409 410 397 # TODO: should be getWordInfo 411 def get Translate(self, word=None, language=None):412 """ translate into another languages"""413 data = self.getServerData("lt/wordInfo.xql","language= "+str(language)+"&word="+urllib.quote(word)+"&output=html")398 def getWordInfo(self, word='', language='', display=''): 399 """show information (like dictionaries) about word""" 400 data = self.getServerData("lt/wordInfo.xql","language=%s&word=%s&display=%s&output=html"%(language,urllib.quote(word),urllib.quote(display))) 414 401 return data 415 402
Note: See TracChangeset
for help on using the changeset viewer.