comparison documentViewer.py @ 599:3b79ae4a23ca

normalize uri of annotated image.
author casties
date Mon, 19 Nov 2012 17:15:13 +0100
parents da7daa783df4
children ef1d0a1fc9fa
comparison
equal deleted inserted replaced
598:4fe11d2bd4ae 599:3b79ae4a23ca
533 elif mode=="imagepath": 533 elif mode=="imagepath":
534 # url points to folder with images, index.meta optional 534 # url points to folder with images, index.meta optional
535 # asssume index.meta in parent dir 535 # asssume index.meta in parent dir
536 docUrl = getParentPath(url) 536 docUrl = getParentPath(url)
537 metaDom = self.metadataService.getDomFromPathOrUrl(docUrl) 537 metaDom = self.metadataService.getDomFromPathOrUrl(docUrl)
538 docinfo['imagePath'] = url.replace('/mpiwg/online/', '', 1) 538 docinfo['imagePath'] = url.replace('/mpiwg/online', '', 1)
539 539
540 elif mode=="filepath": 540 elif mode=="filepath":
541 # url points to image file, index.meta optional 541 # url points to image file, index.meta optional
542 docinfo['imageURL'] = "%s?fn=%s"%(self.digilibScalerUrl, url) 542 docinfo['imageURL'] = "%s?fn=%s"%(self.digilibScalerUrl, url)
543 docinfo['numPages'] = 1 543 docinfo['numPages'] = 1
611 docinfo['presentationContext'] = ctx 611 docinfo['presentationContext'] = ctx
612 612
613 # image path 613 # image path
614 if mode != 'texttool': 614 if mode != 'texttool':
615 # override image path from texttool with url parameter TODO: how about mode=auto? 615 # override image path from texttool with url parameter TODO: how about mode=auto?
616 docinfo['imagePath'] = url.replace('/mpiwg/online/', '', 1) 616 docinfo['imagePath'] = url.replace('/mpiwg/online', '', 1)
617 617
618 # check numPages 618 # check numPages
619 if docinfo.get('numPages', 0) == 0: 619 if docinfo.get('numPages', 0) == 0:
620 # number of images from digilib 620 # number of images from digilib
621 if docinfo.get('imagePath', None): 621 if docinfo.get('imagePath', None):
622 imgpath = docinfo['imagePath'].replace('/mpiwg/online/', '', 1) 622 imgpath = docinfo['imagePath'].replace('/mpiwg/online', '', 1)
623 logging.debug("imgpath=%s"%imgpath) 623 logging.debug("imgpath=%s"%imgpath)
624 docinfo['imageURL'] = "%s?fn=%s"%(self.digilibScalerUrl, imgpath) 624 docinfo['imageURL'] = "%s?fn=%s"%(self.digilibScalerUrl, imgpath)
625 docinfo = self.getDocinfoFromDigilib(docinfo, imgpath) 625 docinfo = self.getDocinfoFromDigilib(docinfo, imgpath)
626 else: 626 else:
627 # imagePath still missing? try "./pageimg" 627 # imagePath still missing? try "./pageimg"
636 if docinfo.get('numPages', 0) == 0: 636 if docinfo.get('numPages', 0) == 0:
637 if docinfo.get('numTextPages', 0) > 0: 637 if docinfo.get('numTextPages', 0) > 0:
638 # replace with numTextPages (text-only?) 638 # replace with numTextPages (text-only?)
639 docinfo['numPages'] = docinfo['numTextPages'] 639 docinfo['numPages'] = docinfo['numTextPages']
640 640
641 # normalize path
642 if 'imagePath' in docinfo and not docinfo['imagePath'].startswith('/'):
643 docinfo['imagePath'] = '/' + docinfo['imagePath']
644
641 logging.debug("documentViewer (getdocinfo) docinfo: keys=%s"%docinfo.keys()) 645 logging.debug("documentViewer (getdocinfo) docinfo: keys=%s"%docinfo.keys())
642 #logging.debug("documentViewer (getdocinfo) docinfo: %s"%docinfo)
643 # store in session 646 # store in session
644 self.REQUEST.SESSION['docinfo'] = docinfo 647 self.REQUEST.SESSION['docinfo'] = docinfo
645 return docinfo 648 return docinfo
646 649
647 650