Mercurial > hg > documentViewer
comparison documentViewer.py @ 608:0c6056271654
show is-part-of relation in header.
author | casties |
---|---|
date | Tue, 18 Dec 2012 19:26:22 +0100 |
parents | cb5a9c4f5e3a |
children | 7962e6891d99 |
comparison
equal
deleted
inserted
replaced
607:cb5a9c4f5e3a | 608:0c6056271654 |
---|---|
551 | 551 |
552 docinfo['documentUrl'] = docUrl | 552 docinfo['documentUrl'] = docUrl |
553 # process index.meta contents | 553 # process index.meta contents |
554 if metaDom is not None and metaDom.tag == 'resource': | 554 if metaDom is not None and metaDom.tag == 'resource': |
555 # document directory name and path | 555 # document directory name and path |
556 resource = self.metadataService.getResourceData(dom=metaDom) | 556 resource = self.metadataService.getResourceData(dom=metaDom, recursive=1) |
557 if resource: | 557 if resource: |
558 docinfo = self.getDocinfoFromResource(docinfo, resource) | 558 docinfo = self.getDocinfoFromResource(docinfo, resource) |
559 | 559 |
560 # texttool info | 560 # texttool info |
561 texttool = self.metadataService.getTexttoolData(dom=metaDom, recursive=1, all=True) | 561 texttool = self.metadataService.getTexttoolData(dom=metaDom, recursive=1, all=True) |
640 | 640 |
641 # min and max page no | 641 # min and max page no |
642 docinfo['minPageNo'] = docinfo.get('minPageNo', 1) | 642 docinfo['minPageNo'] = docinfo.get('minPageNo', 1) |
643 docinfo['maxPageNo'] = docinfo.get('maxPageNo', docinfo['numPages']) | 643 docinfo['maxPageNo'] = docinfo.get('maxPageNo', docinfo['numPages']) |
644 | 644 |
645 # part-of information | |
646 partOfPath = docinfo.get('partOfPath', None) | |
647 if partOfPath is not None: | |
648 partOfDom = self.metadataService.getDomFromPathOrUrl(partOfPath) | |
649 if partOfDom is not None: | |
650 docinfo['partOfLabel'] = self.metadataService.getBibFormattedLabel(dom=partOfDom) | |
651 docinfo['partOfUrl'] = "%s?url=%s"%(self.getDocumentViewerURL(), partOfPath) | |
652 logging.debug("partOfLabel=%s partOfUrl=%s"%(docinfo['partOfLabel'],docinfo['partOfUrl'])) | |
653 | |
645 # normalize path | 654 # normalize path |
646 if 'imagePath' in docinfo and not docinfo['imagePath'].startswith('/'): | 655 if 'imagePath' in docinfo and not docinfo['imagePath'].startswith('/'): |
647 docinfo['imagePath'] = '/' + docinfo['imagePath'] | 656 docinfo['imagePath'] = '/' + docinfo['imagePath'] |
648 | 657 |
649 logging.debug("documentViewer (getdocinfo) docinfo: keys=%s"%docinfo.keys()) | 658 logging.debug("documentViewer (getdocinfo) docinfo: keys=%s"%docinfo.keys()) |
652 return docinfo | 661 return docinfo |
653 | 662 |
654 | 663 |
655 def getDocinfoFromResource(self, docinfo, resource): | 664 def getDocinfoFromResource(self, docinfo, resource): |
656 """reads contents of resource element into docinfo""" | 665 """reads contents of resource element into docinfo""" |
657 docName = resource.get('name', None) | 666 logging.debug("getDocinfoFromResource: resource=%s"%(repr(resource))) |
667 docName = getMDText(resource.get('name', None)) | |
658 docinfo['documentName'] = docName | 668 docinfo['documentName'] = docName |
659 docPath = resource.get('archive-path', None) | 669 docPath = getMDText(resource.get('archive-path', None)) |
660 if docPath: | 670 if docPath: |
661 # clean up document path | 671 # clean up document path |
662 if docPath[0] != '/': | 672 if docPath[0] != '/': |
663 docPath = '/' + docPath | 673 docPath = '/' + docPath |
664 | 674 |
668 else: | 678 else: |
669 # use docUrl as docPath | 679 # use docUrl as docPath |
670 docUrl = docinfo['documentURL'] | 680 docUrl = docinfo['documentURL'] |
671 if not docUrl.startswith('http:'): | 681 if not docUrl.startswith('http:'): |
672 docPath = docUrl | 682 docPath = docUrl |
683 | |
673 if docPath: | 684 if docPath: |
674 # fix URLs starting with /mpiwg/online | 685 # fix URLs starting with /mpiwg/online |
675 docPath = docPath.replace('/mpiwg/online', '', 1) | 686 docPath = docPath.replace('/mpiwg/online', '', 1) |
676 | 687 |
677 docinfo['documentPath'] = docPath | 688 docinfo['documentPath'] = docPath |
689 | |
690 # is this part-of? | |
691 partOf = resource.get('is-part-of', None) | |
692 if partOf is not None: | |
693 partOf = getMDText(partOf.get('archive-path', None)) | |
694 if partOf is not None: | |
695 docinfo['partOfPath'] = partOf.strip() | |
696 | |
678 return docinfo | 697 return docinfo |
679 | 698 |
680 def getDocinfoFromTexttool(self, docinfo, texttool): | 699 def getDocinfoFromTexttool(self, docinfo, texttool): |
681 """reads contents of texttool element into docinfo""" | 700 """reads contents of texttool element into docinfo""" |
682 logging.debug("texttool=%s"%repr(texttool)) | 701 logging.debug("texttool=%s"%repr(texttool)) |