Mercurial > hg > documentViewer
comparison documentViewer.py @ 615:d6eca930a534
hocr viewer eingebaut
author | Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 21 Jul 2014 12:53:42 +0200 |
parents | c57d80a649ea |
children | 54d3498a6e78 |
comparison
equal
deleted
inserted
replaced
614:d16da6e739ef | 615:d6eca930a534 |
---|---|
80 # | 80 # |
81 # templates and forms | 81 # templates and forms |
82 # | 82 # |
83 # viewMode templates | 83 # viewMode templates |
84 viewer_text = PageTemplateFile('zpt/viewer/viewer_text', globals()) | 84 viewer_text = PageTemplateFile('zpt/viewer/viewer_text', globals()) |
85 viewer_hocr = PageTemplateFile('zpt/viewer/viewer_hocr', globals()) | |
85 viewer_xml = PageTemplateFile('zpt/viewer/viewer_xml', globals()) | 86 viewer_xml = PageTemplateFile('zpt/viewer/viewer_xml', globals()) |
86 viewer_image = PageTemplateFile('zpt/viewer/viewer_image', globals()) | 87 viewer_image = PageTemplateFile('zpt/viewer/viewer_image', globals()) |
87 viewer_index = PageTemplateFile('zpt/viewer/viewer_index', globals()) | 88 viewer_index = PageTemplateFile('zpt/viewer/viewer_index', globals()) |
88 viewer_thumbs = PageTemplateFile('zpt/viewer/viewer_thumbs', globals()) | 89 viewer_thumbs = PageTemplateFile('zpt/viewer/viewer_thumbs', globals()) |
89 viewer_indexonly = PageTemplateFile('zpt/viewer/viewer_indexonly', globals()) | 90 viewer_indexonly = PageTemplateFile('zpt/viewer/viewer_indexonly', globals()) |
162 | 163 |
163 | 164 |
164 # proxy text server methods to fulltextclient | 165 # proxy text server methods to fulltextclient |
165 def getTextPage(self, **args): | 166 def getTextPage(self, **args): |
166 """returns full text content of page""" | 167 """returns full text content of page""" |
168 | |
167 return self.template.fulltextclient.getTextPage(**args) | 169 return self.template.fulltextclient.getTextPage(**args) |
170 | |
171 | |
172 | |
168 | 173 |
169 def getSearchResults(self, **args): | 174 def getSearchResults(self, **args): |
170 """loads list of search results and stores XML in docinfo""" | 175 """loads list of search results and stores XML in docinfo""" |
171 return self.template.fulltextclient.getSearchResults(**args) | 176 return self.template.fulltextclient.getSearchResults(**args) |
172 | 177 |
237 def index_html(self, url, mode="texttool", viewMode="auto", viewLayer=None, tocMode=None, start=None, pn=None, pf=None): | 242 def index_html(self, url, mode="texttool", viewMode="auto", viewLayer=None, tocMode=None, start=None, pn=None, pf=None): |
238 """ | 243 """ |
239 show page | 244 show page |
240 @param url: url which contains display information | 245 @param url: url which contains display information |
241 @param mode: defines how to access the document behind url | 246 @param mode: defines how to access the document behind url |
242 @param viewMode: 'image': display images, 'text': display text, 'xml': display xml, default is 'auto' | 247 @param viewMode: 'image': display images, 'text': display text, 'xml': display xml, default is 'auto', 'hocr' : hocr format |
243 @param viewLayer: sub-type of viewMode, e.g. layer 'dict' for viewMode='text' | 248 @param viewLayer: sub-type of viewMode, e.g. layer 'dict' for viewMode='text' |
244 @param tocMode: type of 'table of contents' for navigation (thumbs, text, figures, none) | 249 @param tocMode: type of 'table of contents' for navigation (thumbs, text, figures, none) |
245 """ | 250 """ |
246 | 251 |
247 logging.debug("documentViewer(index_html) mode=%s url=%s viewMode=%s viewLayer=%s start=%s pn=%s pf=%s"%(mode,url,viewMode,viewLayer,start,pn,pf)) | 252 logging.debug("documentViewer(index_html) mode=%s url=%s viewMode=%s viewLayer=%s start=%s pn=%s pf=%s"%(mode,url,viewMode,viewLayer,start,pn,pf)) |
285 | 290 |
286 elif viewMode == 'images': | 291 elif viewMode == 'images': |
287 # legacy fix | 292 # legacy fix |
288 viewMode = 'image' | 293 viewMode = 'image' |
289 self.REQUEST['viewMode'] = 'image' | 294 self.REQUEST['viewMode'] = 'image' |
295 | |
296 | |
297 | |
290 | 298 |
291 # safe viewLayer in userinfo | 299 # safe viewLayer in userinfo |
292 userinfo['viewLayer'] = viewLayer | 300 userinfo['viewLayer'] = viewLayer |
293 | 301 |
294 # pageinfo: information about page (not cached) | 302 # pageinfo: information about page (not cached) |
530 # url points to folder with images, index.meta optional | 538 # url points to folder with images, index.meta optional |
531 # asssume index.meta in parent dir | 539 # asssume index.meta in parent dir |
532 docUrl = getParentPath(url) | 540 docUrl = getParentPath(url) |
533 metaDom = self.metadataService.getDomFromPathOrUrl(docUrl) | 541 metaDom = self.metadataService.getDomFromPathOrUrl(docUrl) |
534 docinfo['imagePath'] = url.replace('/mpiwg/online', '', 1) | 542 docinfo['imagePath'] = url.replace('/mpiwg/online', '', 1) |
543 | |
544 elif mode=="hocr": | |
545 # url points to folder with images, index.meta optional | |
546 # asssume index.meta in parent dir | |
547 docUrl = getParentPath(url) | |
548 metaDom = self.metadataService.getDomFromPathOrUrl(docUrl) | |
549 docinfo['imagePath'] = url.replace('/mpiwg/online', '', 1) | |
550 docinfo['textURLPath'] = url.replace('/mpiwg/online', '', 1) | |
551 if docinfo.get("creator", None) is None: | |
552 docinfo['creator'] = "" | |
553 | |
554 if docinfo.get("title", None) is None: | |
555 docinfo['title'] = "" | |
556 | |
557 if docinfo.get("documentPath", None) is None: | |
558 docinfo['documentPath'] = url.replace('/mpiwg/online', '', 1) | |
559 docinfo['documentPath'] = url.replace('/pages', '', 1) | |
535 | 560 |
536 elif mode=="filepath": | 561 elif mode=="filepath": |
537 # url points to image file, index.meta optional | 562 # url points to image file, index.meta optional |
538 docinfo['imageURL'] = "%s?fn=%s"%(self.digilibScalerUrl, url) | 563 docinfo['imageURL'] = "%s?fn=%s"%(self.digilibScalerUrl, url) |
539 docinfo['numPages'] = 1 | 564 docinfo['numPages'] = 1 |