changeset 608:0c6056271654

show is-part-of relation in header.
author casties
date Tue, 18 Dec 2012 19:26:22 +0100
parents cb5a9c4f5e3a
children 7962e6891d99
files css/docuviewer.css documentViewer.py zpt/viewer/common_template.zpt
diffstat 3 files changed, 28 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/css/docuviewer.css	Fri Dec 14 17:28:31 2012 -0500
+++ b/css/docuviewer.css	Tue Dec 18 19:26:22 2012 +0100
@@ -41,6 +41,9 @@
 	border: 1px solid silver;
     padding: 0.5em;  
 }
+div.page-head div.title.part-of {
+    border-top: none;
+}
 
 ul.view-switcher {
     padding-left: 0;
--- 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):
--- a/zpt/viewer/common_template.zpt	Fri Dec 14 17:28:31 2012 -0500
+++ b/zpt/viewer/common_template.zpt	Tue Dec 18 19:26:22 2012 +0100
@@ -24,6 +24,9 @@
           tal:content="string:[no bibliographical information for this document (type ${bibType})]" />
       </div>
       <div class="title" tal:condition="formattedLabel" tal:content="structure formattedLabel" />
+      <div class="title part-of" tal:condition="exists:docinfo/partOfPath">
+        part of: <a tal:attributes="href docinfo/partOfUrl" target="_blank" tal:content="structure docinfo/partOfLabel"/>
+      </div>
       <ul class="view-switcher" metal:define-slot="view-switcher">
         <li tal:condition="docpath" tal:attributes="class python:here.getStyle(viewMode, 'text')"><a
           tal:omit-tag="python:viewMode=='text'" tal:attributes="href python:here.getLink('viewMode','text')">Text</a></li>