Changeset 516:7d7b639d7be7 in documentViewer for documentViewer.py


Ignore:
Timestamp:
Mar 5, 2012, 5:04:49 PM (12 years ago)
Author:
casties
Branch:
default
Message:

add methods to use doc-info.xql.
read list of page numbers from doc-info.xql.
add original page numbers to thumbs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • documentViewer.py

    r514 r516  
    184184        return self.template.fulltextclient.getResultsPage(**args)
    185185
     186    def getTextInfo(self, **args):
     187        """returns document info from the text server"""
     188        return self.template.fulltextclient.getTextInfo(**args)
     189
    186190    def getToc(self, **args):
    187191        """loads table of contents and stores XML in docinfo"""
     
    480484            if texttool:
    481485                docinfo = self.getDocinfoFromTexttool(docinfo, texttool)
     486                # document info from full text
     487                if docinfo.get('textURLPath', None):
     488                    docinfo = self.getTextInfo(docinfo=docinfo)
    482489           
    483490            # bib info
     
    510517        # image path
    511518        if mode != 'texttool':
    512             # override image path from texttool with url
     519            # override image path from texttool with url TODO: how about mode=auto?
    513520            docinfo['imagePath'] = url.replace('/mpiwg/online/', '', 1)
    514521
     
    517524            docinfo['imageURL'] = self.digilibBaseUrl + "/servlet/Scaler?fn=" + docinfo['imagePath']
    518525            docinfo = self.getDocinfoFromDigilib(docinfo, docinfo['imagePath'])
     526
     527        # check numPages
     528        if docinfo.get('numPages', 0) == 0:
     529            if docinfo.get('numTextPages', 0) > 0:
     530                # replace with numTextPages (text-only?)
     531                docinfo['numPages'] = docinfo['numTextPages']
    519532
    520533        logging.debug("documentViewer (getdocinfo) docinfo: keys=%s"%docinfo.keys())
     
    523536        self.REQUEST.SESSION['docinfo'] = docinfo
    524537        return docinfo
     538
    525539
    526540    def getDocinfoFromResource(self, docinfo, resource):
     
    699713        pageinfo['tocMode'] = tocMode
    700714
     715        # TODO: unify current and pn!
    701716        current = getInt(current)
    702717        pageinfo['current'] = current
     
    716731        if np == 0:
    717732            # numPages unknown - maybe we can get it from text page
     733            logging.warn("getPageInfo: numPages=0 trying getTextPage!")
    718734            if docinfo.get('textURLPath', None):
    719735                # cache text page as well
     
    733749        pageinfo['pageZero'] = pageZero
    734750        pageinfo['pageBatch'] = self.getPageBatch(start=start, rows=rows, cols=cols, pageFlowLtr=pageFlowLtr, pageZero=pageZero, minIdx=1, maxIdx=np)
    735                
     751        # more page parameters
    736752        pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization','reg')
     753        if docinfo.get('pageNumbers'):
     754            # get original page numbers
     755            pageNumber = docinfo['pageNumbers'].get(current, None)
     756            if pageNumber is not None:
     757                pageinfo['pageNumberOrig'] = pageNumber['no']
     758                pageinfo['pageNumberOrigNorm'] = pageNumber['non']
    737759       
    738760        # cache search results
Note: See TracChangeset for help on using the changeset viewer.