Mercurial > hg > documentViewer
comparison MpiwgXmlTextServer.py @ 577:9251719154a3
toc with list of handwritten notes.
| author | casties |
|---|---|
| date | Thu, 18 Oct 2012 17:53:09 +0200 |
| parents | b2c7e272e075 |
| children | fc861a6cef17 |
comparison
equal
deleted
inserted
replaced
| 576:b2c7e272e075 | 577:9251719154a3 |
|---|---|
| 157 | 157 |
| 158 if pn > 0: | 158 if pn > 0: |
| 159 pages[pn] = page | 159 pages[pn] = page |
| 160 | 160 |
| 161 docinfo['pageNumbers'] = pages | 161 docinfo['pageNumbers'] = pages |
| 162 logging.debug("got pageNumbers=%s"%repr(pages)) | |
| 163 | 162 |
| 164 # toc | 163 # toc |
| 165 elif lt == 'toc' or lt == 'figures' or lt == 'handwritten': | 164 elif lt == 'toc' or lt == 'figures' or lt == 'handwritten': |
| 166 # contains tags with table of contents/figures | 165 # contains tags with table of contents/figures |
| 167 # <item n="2.1." lv="2">CAP.I. <ref o="119">132</ref></item> | 166 # <item n="2.1." lv="2">CAP.I. <ref o="119">132</ref></item> |
| 293 # add target to open new page | 292 # add target to open new page |
| 294 l.set('target', '_blank') | 293 l.set('target', '_blank') |
| 295 | 294 |
| 296 if punditMode: | 295 if punditMode: |
| 297 self._addPunditAttributes(pagediv, pageinfo, docinfo) | 296 self._addPunditAttributes(pagediv, pageinfo, docinfo) |
| 297 | |
| 298 # TODO: move empty page text | |
| 299 ep = dom.find(".//div[@class='emptyPage']") | |
| 300 if ep is not None: | |
| 301 pagediv.append(ep) | |
| 298 | 302 |
| 299 s = serialize(pagediv) | 303 s = serialize(pagediv) |
| 300 logging.debug("getTextPage done in %s"%(datetime.now()-startTime)) | 304 logging.debug("getTextPage done in %s"%(datetime.now()-startTime)) |
| 301 return s | 305 return s |
| 302 | 306 |
| 542 size = pageinfo.get('resultPageSize', 10) | 546 size = pageinfo.get('resultPageSize', 10) |
| 543 | 547 |
| 544 if start is None: | 548 if start is None: |
| 545 start = (pn - 1) * size | 549 start = (pn - 1) * size |
| 546 | 550 |
| 547 #fullresult = ET.fromstring(resultxml) | |
| 548 #fullresult = resultxml | |
| 549 #logging.debug("resultxml=%s"%repr(resultxml)) | |
| 550 | |
| 551 if resultxml is not None: | 551 if resultxml is not None: |
| 552 # paginate | 552 # paginate |
| 553 first = start-1 | 553 first = start-1 |
| 554 last = first+size | 554 last = first+size |
| 555 tocdivs = resultxml[first:last] | 555 tocdivs = resultxml[first:last] |
| 556 #del fullresult[:first] | |
| 557 #del fullresult[len:] | |
| 558 #tocdivs = fullresult | |
| 559 | 556 |
| 560 toc = ET.Element('div', attrib={'class':'queryResultPage'}) | 557 toc = ET.Element('div', attrib={'class':'queryResultPage'}) |
| 561 for div in tocdivs: | 558 for div in tocdivs: |
| 562 # check all a-tags | 559 # check all a-tags |
| 563 links = div.findall(".//a") | 560 links = div.findall(".//a") |
| 618 # paginate | 615 # paginate |
| 619 first = (start - 1) | 616 first = (start - 1) |
| 620 last = first + size | 617 last = first + size |
| 621 tocs = fulltoc[first:last] | 618 tocs = fulltoc[first:last] |
| 622 tp = '<div>' | 619 tp = '<div>' |
| 620 label = {'figures': 'Figure', 'handwritten': 'Handwritten note'}.get(mode, 'Item') | |
| 623 for toc in tocs: | 621 for toc in tocs: |
| 624 pageurl = self.getLink('pn', toc['pn']) | 622 pageurl = self.getLink('pn', toc['pn']) |
| 625 tp += '<div class="tocline">' | 623 tp += '<div class="tocline">' |
| 626 content = toc['content'] | 624 content = toc['content'] |
| 627 if content: | 625 if content: |
| 628 tp += '<div class="toc name">[%s] %s</div>'%(toc['level-string'], toc['content']) | 626 tp += '<div class="toc name">[%s] %s</div>'%(toc['level-string'], toc['content']) |
| 629 else: | 627 else: |
| 630 tp += '<div class="toc name">[Figure %s]</div>'%(toc['level-string']) | 628 tp += '<div class="toc name">[%s %s]</div>'%(label, toc['level-string']) |
| 631 | 629 |
| 632 if toc.get('no', None): | 630 if toc.get('no', None): |
| 633 tp += '<div class="toc page"><a href="%s">Page: %s (%s)</a></div>'%(pageurl, toc['pn'], toc['no']) | 631 tp += '<div class="toc page"><a href="%s">Page: %s (%s)</a></div>'%(pageurl, toc['pn'], toc['no']) |
| 634 else: | 632 else: |
| 635 tp += '<div class="toc page"><a href="%s">Page: %s</a></div>'%(pageurl, toc['pn']) | 633 tp += '<div class="toc page"><a href="%s">Page: %s</a></div>'%(pageurl, toc['pn']) |
| 656 """Form for adding""" | 654 """Form for adding""" |
| 657 pt = PageTemplateFile("zpt/manage_addMpiwgXmlTextServer", globals()).__of__(self) | 655 pt = PageTemplateFile("zpt/manage_addMpiwgXmlTextServer", globals()).__of__(self) |
| 658 return pt() | 656 return pt() |
| 659 | 657 |
| 660 def manage_addMpiwgXmlTextServer(self,id,title="",serverUrl="http://mpdl-text.mpiwg-berlin.mpg.de/mpdl/interface/",timeout=40,RESPONSE=None): | 658 def manage_addMpiwgXmlTextServer(self,id,title="",serverUrl="http://mpdl-text.mpiwg-berlin.mpg.de/mpdl/interface/",timeout=40,RESPONSE=None): |
| 661 #def manage_addMpiwgXmlTextServer(self,id,title="",serverUrl="http://mpdl-text.mpiwg-berlin.mpg.de:30030/mpdl/interface/",timeout=40,RESPONSE=None): | 659 """add MpiwgXmlTextServer""" |
| 662 """add zogiimage""" | |
| 663 newObj = MpiwgXmlTextServer(id=id,title=title,serverUrl=serverUrl,timeout=timeout) | 660 newObj = MpiwgXmlTextServer(id=id,title=title,serverUrl=serverUrl,timeout=timeout) |
| 664 self.Destination()._setObject(id, newObj) | 661 self.Destination()._setObject(id, newObj) |
| 665 if RESPONSE is not None: | 662 if RESPONSE is not None: |
| 666 RESPONSE.redirect('manage_main') | 663 RESPONSE.redirect('manage_main') |
| 667 | 664 |
