Mercurial > hg > documentViewer
comparison documentViewer.py @ 455:0a53fea83df7 elementtree
more work renovating
author | casties |
---|---|
date | Fri, 15 Jul 2011 21:34:41 +0200 |
parents | 73e3273c7624 |
children | 9fb231ad0bd2 |
comparison
equal
deleted
inserted
replaced
454:73e3273c7624 | 455:0a53fea83df7 |
---|---|
352 docinfo = self.getDocinfo(mode=mode,url=url) | 352 docinfo = self.getDocinfo(mode=mode,url=url) |
353 | 353 |
354 if tocMode != "thumbs": | 354 if tocMode != "thumbs": |
355 # get table of contents | 355 # get table of contents |
356 docinfo = self.getToc(mode=tocMode, docinfo=docinfo) | 356 docinfo = self.getToc(mode=tocMode, docinfo=docinfo) |
357 | 357 |
358 if viewMode=="auto": # automodus gewaehlt | 358 # auto viewMode: text_dict if text else images |
359 if docinfo.has_key('textURL') or docinfo.get('textURLPath',None): #texturl gesetzt und textViewer konfiguriert | 359 if viewMode=="auto": |
360 if docinfo.get('textURL', None) or docinfo.get('textURLPath', None): | |
361 #texturl gesetzt und textViewer konfiguriert | |
360 viewMode="text_dict" | 362 viewMode="text_dict" |
361 else: | 363 else: |
362 viewMode="images" | 364 viewMode="images" |
363 | 365 |
364 pageinfo = self.getPageinfo(start=start,current=pn, docinfo=docinfo,viewMode=viewMode,tocMode=tocMode) | 366 pageinfo = self.getPageinfo(start=start, current=pn, docinfo=docinfo, viewMode=viewMode, tocMode=tocMode) |
365 | 367 |
366 if (docinfo.get('textURLPath',None)): | 368 if viewMode != 'images' and docinfo.get('textURLPath', None): |
367 page = self.getTextPage(mode=viewMode, docinfo=docinfo, pageinfo=pageinfo) | 369 # get full text page |
370 page = self.getTextPage(mode=viewMode, pn=pn, docinfo=docinfo, pageinfo=pageinfo) | |
368 pageinfo['textPage'] = page | 371 pageinfo['textPage'] = page |
369 tt = getattr(self, 'template') | 372 |
370 pt = getattr(tt, 'viewer_main') | 373 # get template /template/viewer_main |
371 return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode,mk=self.generateMarks(mk)) | 374 pt = getattr(self.template, 'viewer_main') |
375 # and execute with parameters | |
376 return pt(docinfo=docinfo, pageinfo=pageinfo, viewMode=viewMode, mk=self.generateMarks(mk)) | |
372 | 377 |
373 def generateMarks(self,mk): | 378 def generateMarks(self,mk): |
374 ret="" | 379 ret="" |
375 if mk is None: | 380 if mk is None: |
376 return "" | 381 return "" |
864 # look for cached docinfo in session | 869 # look for cached docinfo in session |
865 if self.REQUEST.SESSION.has_key('docinfo'): | 870 if self.REQUEST.SESSION.has_key('docinfo'): |
866 docinfo = self.REQUEST.SESSION['docinfo'] | 871 docinfo = self.REQUEST.SESSION['docinfo'] |
867 # check if its still current | 872 # check if its still current |
868 if docinfo is not None and docinfo.get('mode') == mode and docinfo.get('url') == url: | 873 if docinfo is not None and docinfo.get('mode') == mode and docinfo.get('url') == url: |
869 logging.debug("documentViewer (getdocinfo) docinfo in session: %s"%docinfo) | 874 logging.debug("documentViewer (getdocinfo) docinfo in session. keys=%s"%docinfo.keys()) |
870 return docinfo | 875 return docinfo |
876 | |
871 # new docinfo | 877 # new docinfo |
872 docinfo = {'mode': mode, 'url': url} | 878 docinfo = {'mode': mode, 'url': url} |
873 if mode=="texttool": #index.meta with texttool information | 879 # add self url |
880 docinfo['viewerUrl'] = self.getDocumentViewerURL() | |
881 if mode=="texttool": | |
882 # index.meta with texttool information | |
874 docinfo = self.getDocinfoFromTextTool(url, docinfo=docinfo) | 883 docinfo = self.getDocinfoFromTextTool(url, docinfo=docinfo) |
875 elif mode=="imagepath": | 884 elif mode=="imagepath": |
885 # folder with images, index.meta optional | |
876 docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo) | 886 docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo) |
877 elif mode=="filepath": | 887 elif mode=="filepath": |
888 # filename | |
878 docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo,cut=1) | 889 docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo,cut=1) |
879 else: | 890 else: |
880 logging.error("documentViewer (getdocinfo) unknown mode: %s!"%mode) | 891 logging.error("documentViewer (getdocinfo) unknown mode: %s!"%mode) |
881 raise ValueError("Unknown mode %s! Has to be one of 'texttool','imagepath','filepath'."%(mode)) | 892 raise ValueError("Unknown mode %s! Has to be one of 'texttool','imagepath','filepath'."%(mode)) |
882 | 893 |