Index: documentViewer.py
===================================================================
--- documentViewer.py	(revision 459)
+++ documentViewer.py	(revision 460)
@@ -103,4 +103,9 @@
     return '/'.join(path.split('/')[0:-1])
         
+def normalizeBibtype(bt):
+    """returns normalised bib type for looking up mappings"""
+    bt = bt.strip().replace(' ', '-').lower()
+    return bt
+
 def getBibdataFromDom(dom):
     """returns dict with all elements from bib-tag"""
@@ -110,5 +115,5 @@
         # put type in @type
         type = bib.get('type')
-        bibinfo['@type'] = type
+        bibinfo['@type'] = normalizeBibtype(type)
         # put all subelements in dict
         for e in bib:
@@ -576,75 +581,17 @@
         bib = getBibdataFromDom(dom)
         docinfo['bib'] = bib
-        
-        # extract some fields (author, title, year) according to their mapping
-        metaData=self.metadata.main.meta.bib
-        bibtype=bib.get("@type")
-        #bibtype=dom.xpath("//bib/@type")
-        if not bibtype:
-            bibtype="generic"
-            
-        bibtype=bibtype.replace("-"," ") # wrong types in index meta "-" instead of " " (not wrong! ROC)
+        bibtype = bib.get('@type', None)
         docinfo['bib_type'] = bibtype
-        bibmap=metaData.generateMappingForType(bibtype)
-        logging.debug("documentViewer (getbibinfofromindexmeta) bibmap:"+repr(bibmap))
-        logging.debug("documentViewer (getbibinfofromindexmeta) bibtype:"+repr(bibtype))
-        # if there is no mapping bibmap is empty (mapping sometimes has empty fields)
-        if len(bibmap) > 0 and bibmap.get('author',None) or bibmap.get('title',None):
+        if bibtype:
+            # also store standard mapped metadata for convenience
             try:
-                docinfo['author']=bib.get(bibmap['author'][0])
-            except: pass
-            try:
-                docinfo['title']=bib.get(bibmap['title'][0])
-            except: pass
-            try:
-                docinfo['year']=bib.get(bibmap['year'][0])
-            except: pass
-            
-            # ROC: why is this here?
-            #            logging.debug("documentViewer (getbibinfofromindexmeta) using mapping for %s"%bibtype)
-            #            try:
-            #                docinfo['lang']=getTextFromNode(dom.find(".//bib/lang")[0])
-            #            except:
-            #                docinfo['lang']=''
-            #            try:
-            #                docinfo['city']=getTextFromNode(dom.find(".//bib/city")[0])
-            #            except:
-            #                docinfo['city']=''
-            #            try:
-            #                docinfo['number_of_pages']=getTextFromNode(dom.find(".//bib/number_of_pages")[0])
-            #            except:
-            #                docinfo['number_of_pages']=''
-            #            try:
-            #                docinfo['series_volume']=getTextFromNode(dom.find(".//bib/series_volume")[0])
-            #            except:
-            #                docinfo['series_volume']=''
-            #            try:
-            #                docinfo['number_of_volumes']=getTextFromNode(dom.find(".//bib/number_of_volumes")[0])
-            #            except:
-            #                docinfo['number_of_volumes']=''
-            #            try:
-            #                docinfo['translator']=getTextFromNode(dom.find(".//bib/translator")[0])
-            #            except:
-            #                docinfo['translator']=''
-            #            try:
-            #                docinfo['edition']=getTextFromNode(dom.find(".//bib/edition")[0])
-            #            except:
-            #                docinfo['edition']=''
-            #            try:
-            #                docinfo['series_author']=getTextFromNode(dom.find(".//bib/series_author")[0])
-            #            except:
-            #                docinfo['series_author']=''
-            #            try:
-            #                docinfo['publisher']=getTextFromNode(dom.find(".//bib/publisher")[0])
-            #            except:
-            #                docinfo['publisher']=''
-            #            try:
-            #                docinfo['series_title']=getTextFromNode(dom.find(".//bib/series_title")[0])
-            #            except:
-            #                docinfo['series_title']=''
-            #            try:
-            #                docinfo['isbn_issn']=getTextFromNode(dom.find(".//bib/isbn_issn")[0])
-            #            except:
-            #                docinfo['isbn_issn']=''           
+                stdbib = self.metadata.getStdMappedHash(bib)
+                docinfo['std_bib'] = stdbib
+                docinfo['author'] = stdbib['author']
+                docinfo['title'] = stdbib['title']
+                docinfo['year'] = stdbib['year']
+            except:
+                pass
+
         return docinfo
     
@@ -791,4 +738,5 @@
         docinfo['imageURL'] = imageUrl
         
+        #TODO: use getDocinfoFromIndexMeta
         #path ist the path to the images it assumes that the index.meta file is one level higher.
         docinfo = self.getBibinfoFromIndexMeta(pathorig,docinfo=docinfo,cut=cut+1)
@@ -825,10 +773,7 @@
             raise ValueError("Unknown mode %s! Has to be one of 'texttool','imagepath','filepath'."%(mode))
                 
-        # FIXME: fake texturlpath 
-        if not docinfo.has_key('textURLPath'):
-            docinfo['textURLPath'] = None
-        
         logging.debug("documentViewer (getdocinfo) docinfo: keys=%s"%docinfo.keys())
         #logging.debug("documentViewer (getdocinfo) docinfo: %s"%docinfo)
+        # store in session
         self.REQUEST.SESSION['docinfo'] = docinfo
         return docinfo
@@ -846,4 +791,5 @@
         grpsize = cols * rows
         pageinfo['groupsize'] = grpsize
+        # what does this do?
         start = getInt(start, default=(math.ceil(float(current)/float(grpsize))*grpsize-(grpsize-1)))
         # int(current / grpsize) * grpsize +1))
@@ -855,5 +801,6 @@
             pageinfo['numgroups'] = int(np / grpsize)
             if np % grpsize > 0:
-                pageinfo['numgroups'] += 1        
+                pageinfo['numgroups'] += 1
+                
         pageinfo['viewMode'] = viewMode
         pageinfo['tocMode'] = tocMode
@@ -867,8 +814,10 @@
         pageinfo['tocPageSize'] = self.REQUEST.get('tocPageSize', '30')
         pageinfo['queryPageSize'] =self.REQUEST.get('queryPageSize', '10')
-        pageinfo['tocPN'] = self.REQUEST.get('tocPN', '1')     
-        toc = int (pageinfo['tocPN'])
-        pageinfo['textPages'] =int (toc)
-        
+        pageinfo['tocPN'] = self.REQUEST.get('tocPN', '1')
+        # WTF?:
+        toc = int(pageinfo['tocPN'])
+        pageinfo['textPages'] =int(toc)
+        
+        # What does this do?
         if 'tocSize_%s'%tocMode in docinfo:
             tocSize = int(docinfo['tocSize_%s'%tocMode])
@@ -879,10 +828,13 @@
             else:
                 tocPages=tocSize/tocPageSize
-            pageinfo['tocPN'] = min (tocPages,toc)                    
+                
+            pageinfo['tocPN'] = min(tocPages,toc)
+            
         pageinfo['searchPN'] =self.REQUEST.get('searchPN','1')
         pageinfo['sn'] =self.REQUEST.get('sn','')
         return pageinfo
-    
-def changeDocumentViewer(self,title="",digilibBaseUrl=None,thumbrows=2,thumbcols=5,authgroups='mpiwg',RESPONSE=None):
+
+    
+    def changeDocumentViewer(self,title="",digilibBaseUrl=None,thumbrows=2,thumbcols=5,authgroups='mpiwg',RESPONSE=None):
         """init document viewer"""
         self.title=title
