diff 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
line wrap: on
line diff
--- a/documentViewer.py	Fri Dec 14 17:28:31 2012 -0500
+++ b/documentViewer.py	Tue Dec 18 19:26:22 2012 +0100
@@ -553,7 +553,7 @@
         # process index.meta contents
         if metaDom is not None and metaDom.tag == 'resource':
             # document directory name and path
-            resource = self.metadataService.getResourceData(dom=metaDom)
+            resource = self.metadataService.getResourceData(dom=metaDom, recursive=1)
             if resource:
                 docinfo = self.getDocinfoFromResource(docinfo, resource)
 
@@ -642,6 +642,15 @@
         docinfo['minPageNo'] = docinfo.get('minPageNo', 1)
         docinfo['maxPageNo'] = docinfo.get('maxPageNo', docinfo['numPages'])
 
+        # part-of information
+        partOfPath = docinfo.get('partOfPath', None)
+        if partOfPath is not None:
+            partOfDom = self.metadataService.getDomFromPathOrUrl(partOfPath)
+            if partOfDom is not None:
+                docinfo['partOfLabel'] = self.metadataService.getBibFormattedLabel(dom=partOfDom)
+                docinfo['partOfUrl'] = "%s?url=%s"%(self.getDocumentViewerURL(), partOfPath)
+                logging.debug("partOfLabel=%s partOfUrl=%s"%(docinfo['partOfLabel'],docinfo['partOfUrl']))
+
         # normalize path
         if 'imagePath' in docinfo and not docinfo['imagePath'].startswith('/'):
             docinfo['imagePath'] = '/' + docinfo['imagePath']
@@ -654,9 +663,10 @@
 
     def getDocinfoFromResource(self, docinfo, resource):
         """reads contents of resource element into docinfo"""
-        docName = resource.get('name', None)
+        logging.debug("getDocinfoFromResource: resource=%s"%(repr(resource)))
+        docName = getMDText(resource.get('name', None))
         docinfo['documentName'] = docName
-        docPath = resource.get('archive-path', None)
+        docPath = getMDText(resource.get('archive-path', None))
         if docPath:
             # clean up document path
             if docPath[0] != '/':
@@ -670,11 +680,20 @@
             docUrl = docinfo['documentURL']
             if not docUrl.startswith('http:'):
                 docPath = docUrl
+                
         if docPath:
             # fix URLs starting with /mpiwg/online
             docPath = docPath.replace('/mpiwg/online', '', 1)
 
         docinfo['documentPath'] = docPath
+        
+        # is this part-of?
+        partOf = resource.get('is-part-of', None)
+        if partOf is not None:
+            partOf = getMDText(partOf.get('archive-path', None))
+            if partOf is not None:
+                docinfo['partOfPath'] = partOf.strip()
+                
         return docinfo
 
     def getDocinfoFromTexttool(self, docinfo, texttool):