Mercurial > hg > documentViewer
comparison documentViewer.py @ 518:91051b36b9cc
uses xml info from doc-info.xql for table of contents now.
author | casties |
---|---|
date | Mon, 12 Mar 2012 19:01:14 +0100 |
parents | 7d7b639d7be7 |
children | 70c3ae5eac7c |
comparison
equal
deleted
inserted
replaced
517:aaacdf551f6f | 518:91051b36b9cc |
---|---|
254 return "ERROR: template folder missing!" | 254 return "ERROR: template folder missing!" |
255 | 255 |
256 if not getattr(self, 'digilibBaseUrl', None): | 256 if not getattr(self, 'digilibBaseUrl', None): |
257 self.digilibBaseUrl = self.findDigilibUrl() or "http://digilib.mpiwg-berlin.mpg.de/digitallibrary" | 257 self.digilibBaseUrl = self.findDigilibUrl() or "http://digilib.mpiwg-berlin.mpg.de/digitallibrary" |
258 | 258 |
259 docinfo = self.getDocinfo(mode=mode,url=url) | 259 docinfo = self.getDocinfo(mode=mode,url=url,tocMode=tocMode) |
260 | 260 |
261 if tocMode != "thumbs": | |
262 # get table of contents | |
263 self.getToc(mode=tocMode, docinfo=docinfo) | |
264 | |
265 # auto viewMode: text if there is a text else images | 261 # auto viewMode: text if there is a text else images |
266 if viewMode=="auto": | 262 if viewMode=="auto": |
267 if docinfo.get('textURL', None) or docinfo.get('textURLPath', None): | 263 if docinfo.get('textURL', None) or docinfo.get('textURLPath', None): |
268 viewMode = "text" | 264 viewMode = "text" |
269 if viewLayer is None: | 265 if viewLayer is None: |
427 logging.error("documentViewer (accessOK) unknown access type %s"%access) | 423 logging.error("documentViewer (accessOK) unknown access type %s"%access) |
428 return False | 424 return False |
429 | 425 |
430 | 426 |
431 | 427 |
432 def getDocinfo(self, mode, url): | 428 def getDocinfo(self, mode, url, tocMode=None): |
433 """returns docinfo depending on mode""" | 429 """returns docinfo depending on mode""" |
434 logging.debug("getDocinfo: mode=%s, url=%s"%(mode,url)) | 430 logging.debug("getDocinfo: mode=%s, url=%s"%(mode,url)) |
435 # look for cached docinfo in session | 431 # look for cached docinfo in session |
436 if self.REQUEST.SESSION.has_key('docinfo'): | 432 if self.REQUEST.SESSION.has_key('docinfo'): |
437 docinfo = self.REQUEST.SESSION['docinfo'] | 433 docinfo = self.REQUEST.SESSION['docinfo'] |
481 | 477 |
482 # texttool info | 478 # texttool info |
483 texttool = self.metadataService.getTexttoolData(dom=metaDom) | 479 texttool = self.metadataService.getTexttoolData(dom=metaDom) |
484 if texttool: | 480 if texttool: |
485 docinfo = self.getDocinfoFromTexttool(docinfo, texttool) | 481 docinfo = self.getDocinfoFromTexttool(docinfo, texttool) |
486 # document info from full text | 482 # document info (including toc) from full text |
487 if docinfo.get('textURLPath', None): | 483 if docinfo.get('textURLPath', None): |
488 docinfo = self.getTextInfo(docinfo=docinfo) | 484 docinfo = self.getTextInfo(mode=tocMode, docinfo=docinfo) |
489 | 485 |
490 # bib info | 486 # bib info |
491 bib = self.metadataService.getBibData(dom=metaDom) | 487 bib = self.metadataService.getBibData(dom=metaDom) |
492 if bib: | 488 if bib: |
493 docinfo = self.getDocinfoFromBib(docinfo, bib) | 489 docinfo = self.getDocinfoFromBib(docinfo, bib) |
727 # int(current / grpsize) * grpsize +1)) | 723 # int(current / grpsize) * grpsize +1)) |
728 pageinfo['start'] = start | 724 pageinfo['start'] = start |
729 # get number of pages | 725 # get number of pages |
730 np = int(docinfo.get('numPages', 0)) | 726 np = int(docinfo.get('numPages', 0)) |
731 if np == 0: | 727 if np == 0: |
732 # numPages unknown - maybe we can get it from text page | 728 # try numTextPages |
733 logging.warn("getPageInfo: numPages=0 trying getTextPage!") | 729 np = docinfo.get('numTextPages', 0) |
734 if docinfo.get('textURLPath', None): | 730 if np != 0: |
735 # cache text page as well | 731 docinfo['numPages'] = np |
736 pageinfo['textPage'] = self.getTextPage(mode=viewLayer, pn=current, docinfo=docinfo, pageinfo=pageinfo) | 732 |
737 np = int(docinfo.get('numPages', 0)) | |
738 | |
739 # cache table of contents | 733 # cache table of contents |
740 pageinfo['tocPageSize'] = getInt(self.REQUEST.get('tocPageSize', 30)) | 734 pageinfo['tocPageSize'] = getInt(self.REQUEST.get('tocPageSize', 30)) |
741 pageinfo['numgroups'] = int(np / grpsize) | 735 pageinfo['numgroups'] = int(np / grpsize) |
742 if np % grpsize > 0: | 736 if np % grpsize > 0: |
743 pageinfo['numgroups'] += 1 | 737 pageinfo['numgroups'] += 1 |