Diff for /documentViewer/documentViewer.py between versions 1.175.2.1 and 1.175.2.3

version 1.175.2.1, 2011/07/14 17:43:56 version 1.175.2.3, 2011/07/15 19:34:41
Line 355  class documentViewer(Folder): Line 355  class documentViewer(Folder):
             # get table of contents              # get table of contents
             docinfo = self.getToc(mode=tocMode, docinfo=docinfo)              docinfo = self.getToc(mode=tocMode, docinfo=docinfo)
                           
         if viewMode=="auto": # automodus gewaehlt          # auto viewMode: text_dict if text else images
             if docinfo.has_key('textURL') or docinfo.get('textURLPath',None): #texturl gesetzt und textViewer konfiguriert          if viewMode=="auto": 
               if docinfo.get('textURL', None) or docinfo.get('textURLPath', None): 
                   #texturl gesetzt und textViewer konfiguriert
                 viewMode="text_dict"                  viewMode="text_dict"
             else:              else:
                 viewMode="images"                  viewMode="images"
                                   
         pageinfo = self.getPageinfo(start=start,current=pn, docinfo=docinfo,viewMode=viewMode,tocMode=tocMode)          pageinfo = self.getPageinfo(start=start,current=pn, docinfo=docinfo,viewMode=viewMode,tocMode=tocMode)
                   
         if (docinfo.get('textURLPath',None)):          if viewMode != 'images' and docinfo.get('textURLPath', None):
             page = self.getTextPage(mode=viewMode, docinfo=docinfo, pageinfo=pageinfo)              # get full text page
               page = self.getTextPage(mode=viewMode, pn=pn, docinfo=docinfo, pageinfo=pageinfo)
             pageinfo['textPage'] = page              pageinfo['textPage'] = page
         tt = getattr(self, 'template')                 
         pt = getattr(tt, 'viewer_main')                         # get template /template/viewer_main
           pt = getattr(self.template, 'viewer_main')
           # and execute with parameters
         return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode,mk=self.generateMarks(mk))          return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode,mk=self.generateMarks(mk))
       
     def generateMarks(self,mk):      def generateMarks(self,mk):
Line 499  class documentViewer(Folder): Line 504  class documentViewer(Folder):
             docinfo = {}              docinfo = {}
                   
         for x in range(cut):          for x in range(cut):
                  
                 path=getParentDir(path)                  path=getParentDir(path)
                 
         infoUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp?mo=dir&fn="+path          infoUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp?mo=dir&fn="+path
Line 630  class documentViewer(Folder): Line 634  class documentViewer(Folder):
                   
         logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path))          logging.debug("documentViewer (getbibinfofromindexmeta cutted) path: %s"%(path))
         # put in all raw bib fields as dict "bib"          # put in all raw bib fields as dict "bib"
         bib = dom.find(".//bib/*")          bib = dom.find(".//bib")
         #bib = dom.xpath("//bib/*")          #bib = dom.xpath("//bib/*")
         if bib and len(bib)>0:          if bib is not None:
             bibinfo = {}              bibinfo = {}
             for e in bib:              for e in bib:
                 bibinfo[e.localName] = getTextFromNode(e)                  bibinfo[e.tag] = getText(e)
                   
             docinfo['bib'] = bibinfo              docinfo['bib'] = bibinfo
                   
         # extract some fields (author, title, year) according to their mapping          # extract some fields (author, title, year) according to their mapping
         metaData=self.metadata.main.meta.bib          metaData=self.metadata.main.meta.bib
         bib = dom.find(".//bib")  
         bibtype=bib.get("type")          bibtype=bib.get("type")
         #bibtype=dom.xpath("//bib/@type")          #bibtype=dom.xpath("//bib/@type")
         if not bibtype:          if not bibtype:
Line 712  class documentViewer(Folder): Line 716  class documentViewer(Folder):
         return docinfo          return docinfo
           
             
       # TODO: is this needed?
     def getNameFromIndexMeta(self,path,docinfo=None,dom=None,cut=0):      def getNameFromIndexMeta(self,path,docinfo=None,dom=None,cut=0):
         """gets name info from the index.meta file at path or given by dom"""          """gets name info from the index.meta file at path or given by dom"""
         if docinfo is None:          if docinfo is None:
Line 739  class documentViewer(Folder): Line 744  class documentViewer(Folder):
         archivePath = None          archivePath = None
         archiveName = None          archiveName = None
           
         archiveName = getTextFromNode(dom.find("name"))          archiveName = getText(dom.find("name"))
         if not archiveName:          if not archiveName:
             logging.warning("documentViewer (getdocinfofromtexttool) resource/name missing in: %s" % (url))              logging.warning("documentViewer (getdocinfofromtexttool) resource/name missing in: %s" % (url))
                   
         archivePath = getTextFromNode(dom.find("archive-path"))          archivePath = getText(dom.find("archive-path"))
         if archivePath:          if archivePath:
             # clean up archive path              # clean up archive path
             if archivePath[0] != '/':              if archivePath[0] != '/':
Line 807  class documentViewer(Folder): Line 812  class documentViewer(Folder):
                     
         presentationUrl = getText(dom.find(".//texttool/presentation"))          presentationUrl = getText(dom.find(".//texttool/presentation"))
         docinfo = self.getBibinfoFromIndexMeta(url, docinfo=docinfo, dom=dom)   # get info von bib tag          docinfo = self.getBibinfoFromIndexMeta(url, docinfo=docinfo, dom=dom)   # get info von bib tag
           # TODO: is this needed here?
         docinfo = self.getNameFromIndexMeta(url, docinfo=docinfo, dom=dom)          docinfo = self.getNameFromIndexMeta(url, docinfo=docinfo, dom=dom)
                   
                   
Line 830  class documentViewer(Folder): Line 836  class documentViewer(Folder):
         """gets the bibliographical information from the preseantion entry in texttools          """gets the bibliographical information from the preseantion entry in texttools
         """          """
         dom=self.getPresentationInfoXML(url)          dom=self.getPresentationInfoXML(url)
         try:  
             docinfo['author']=getText(dom.find(".//author"))              docinfo['author']=getText(dom.find(".//author"))
         except:  
             pass  
         try:  
             docinfo['title']=getText(dom.find(".//title"))              docinfo['title']=getText(dom.find(".//title"))
         except:  
             pass  
         try:  
             docinfo['year']=getText(dom.find(".//date"))              docinfo['year']=getText(dom.find(".//date"))
         except:  
             pass  
         return docinfo          return docinfo
           
     def getDocinfoFromImagePath(self,path,docinfo=None,cut=0):      def getDocinfoFromImagePath(self,path,docinfo=None,cut=0):
Line 874  class documentViewer(Folder): Line 871  class documentViewer(Folder):
             docinfo = self.REQUEST.SESSION['docinfo']              docinfo = self.REQUEST.SESSION['docinfo']
             # check if its still current              # check if its still current
             if docinfo is not None and docinfo.get('mode') == mode and docinfo.get('url') == url:              if docinfo is not None and docinfo.get('mode') == mode and docinfo.get('url') == url:
                 logging.debug("documentViewer (getdocinfo) docinfo in session: %s"%docinfo)                  logging.debug("documentViewer (getdocinfo) docinfo in session. keys=%s"%docinfo.keys())
                 return docinfo                  return docinfo
               
         # new docinfo          # new docinfo
         docinfo = {'mode': mode, 'url': url}          docinfo = {'mode': mode, 'url': url}
         if mode=="texttool": #index.meta with texttool information          # add self url
           docinfo['viewerUrl'] = self.getDocumentViewerURL()
           if mode=="texttool": 
               # index.meta with texttool information
             docinfo = self.getDocinfoFromTextTool(url, docinfo=docinfo)              docinfo = self.getDocinfoFromTextTool(url, docinfo=docinfo)
         elif mode=="imagepath":          elif mode=="imagepath":
               # folder with images, index.meta optional
             docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo)              docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo)
         elif mode=="filepath":          elif mode=="filepath":
               # filename
             docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo,cut=1)              docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo,cut=1)
         else:          else:
             logging.error("documentViewer (getdocinfo) unknown mode: %s!"%mode)              logging.error("documentViewer (getdocinfo) unknown mode: %s!"%mode)

Removed from v.1.175.2.1  
changed lines
  Added in v.1.175.2.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>