Changeset 476:1d93a8cb2d8f in documentViewer


Ignore:
Timestamp:
Aug 9, 2011, 6:27:41 PM (13 years ago)
Author:
casties
Branch:
elementtree
Message:

more new template stuff

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • MpdlXmlTextServer.py

    r475 r476  
    3030    if node is None:
    3131        return ""
    32     # ET:
    33 #    text = node.text or ""
    34 #    for e in node:
    35 #        text += gettext(e)
    36 #        if e.tail:
    37 #            text += e.tail
    3832
    3933    # 4Suite:
     
    188182            return None
    189183
    190         url = docinfo['url']
    191         selfurl = self.absolute_url()
    192184        pn = pageinfo['current']
    193185        hrefList=[]
     
    207199        """Show all Gis Places of whole Book """
    208200        xpath ='//echo:place'
    209         docpath =docinfo['textURLPath']
    210         url = docinfo['url']
    211         selfurl =self.absolute_url()
    212         pn =pageinfo['current']
    213201        hrefList=[]
    214202        myList=""
     
    505493        return docinfo
    506494   
    507     def getTocPage(self, mode="text", pn=1, pageinfo=None, docinfo=None):
     495    def getTocPage(self, mode="text", pn=0, pageinfo=None, docinfo=None):
    508496        """returns single page from the table of contents"""
    509497        logging.debug("getTocPage mode=%s, pn=%s"%(mode,pn))
     
    522510            return "No ToC"
    523511       
    524         pagesize = int(pageinfo['tocPageSize'])
    525         url = docinfo['url']
    526         urlmode = docinfo['mode']
    527         selfurl = docinfo['viewerUrl']
    528         viewMode=  pageinfo['viewMode']
    529         tocMode = pageinfo['tocMode']
    530         tocPN = int(pageinfo['tocPN'])
    531         pn = tocPN
     512        pagesize = pageinfo['tocPageSize']
     513        tocPN = pageinfo['tocPN']
     514        if not pn:
     515            pn = tocPN
    532516
    533517        fulltoc = ET.fromstring(tocxml)
     
    549533                    m = re.match(r'page-fragment\.xql.*pn=(\d+)', href)
    550534                    if m is not None:
    551                         # and create new url
    552                         l.set('href', '%s?mode=%s&url=%s&viewMode=%s&pn=%s&tocMode=%s&tocPN=%s'%(selfurl, urlmode, url, viewMode, m.group(1), tocMode, tocPN))
     535                        # and create new url (assuming parent is documentViewer)
     536                        url = self.getLink('pn', m.group(1))
     537                        l.set('href', url)
    553538                    else:
    554539                        logging.warning("getTocPage: Problem with link=%s"%href)
  • documentViewer.py

    r475 r476  
    583583           
    584584        # odd pages are left
    585         docinfo['oddPage'] = texttool.get('odd-scan-orientation', 'left')
     585        docinfo['oddPage'] = texttool.get('odd-scan-position', 'left')
    586586           
    587587        # number of title page (0: not defined)
     
    696696        grpsize = cols * rows
    697697        pageinfo['groupsize'] = grpsize
    698         # what does this do?
     698        # is start is empty use one around current
    699699        start = getInt(start, default=(math.ceil(float(current)/float(grpsize))*grpsize-(grpsize-1)))
    700700        # int(current / grpsize) * grpsize +1))
    701701        pageinfo['start'] = start
    702         pageinfo['end'] = start + grpsize
    703702        pn = self.REQUEST.get('pn','1')
    704703        pageinfo['pn'] = pn
     
    711710                np = int(docinfo.get('numPages', 0))
    712711               
    713         pageinfo['end'] = min(pageinfo['end'], np)
    714712        pageinfo['numgroups'] = int(np / grpsize)
    715713        if np % grpsize > 0:
    716714            pageinfo['numgroups'] += 1
     715
     716        pageFlowLtr = docinfo.get('pageFlow', 'ltr') != 'rtl'
     717        oddScanLeft = docinfo.get('oddPage', 'left') != 'right'
     718        # add zeroth page for two columns
     719        pageZero = (cols == 2 and (pageFlowLtr != oddScanLeft))
     720        pageinfo['pageZero'] = pageZero
     721        pageinfo['pageList'] = self.getPageList(start=start, rows=rows, cols=cols, pageFlowLtr=pageFlowLtr, pageZero=pageZero, minIdx=1, maxIdx=np)
    717722               
    718723        pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization','reg')
     
    721726        pageinfo['querySearch'] =self.REQUEST.get('querySearch', 'fulltext')
    722727        pageinfo['highlightQuery'] = self.REQUEST.get('highlightQuery','')
    723         pageinfo['tocPageSize'] = self.REQUEST.get('tocPageSize', '30')
    724         pageinfo['queryPageSize'] =self.REQUEST.get('queryPageSize', '10')
    725         pageinfo['tocPN'] = self.REQUEST.get('tocPN', '1')
    726         # WTF?:
    727         toc = int(pageinfo['tocPN'])
    728         pageinfo['textPages'] = int(toc)
    729        
    730         # What does this do?
     728        pageinfo['tocPageSize'] = getInt(self.REQUEST.get('tocPageSize', 30))
     729        pageinfo['queryPageSize'] = getInt(self.REQUEST.get('queryPageSize', 10))
     730        pageinfo['tocPN'] = getInt(self.REQUEST.get('tocPN', '1'))
     731        pageinfo['searchPN'] = getInt(self.REQUEST.get('searchPN','1'))
     732       
     733        # limit tocPN
    731734        if 'tocSize_%s'%tocMode in docinfo:
    732             tocSize = int(docinfo['tocSize_%s'%tocMode])
    733             tocPageSize = int(pageinfo['tocPageSize'])
     735            tocSize = docinfo['tocSize_%s'%tocMode]
     736            tocPageSize = pageinfo['tocPageSize']
    734737            # cached toc           
    735738            if tocSize%tocPageSize>0:
     
    738741                tocPages=tocSize/tocPageSize
    739742               
    740             pageinfo['tocPN'] = min(tocPages,toc)
    741            
    742         pageinfo['searchPN'] =self.REQUEST.get('searchPN','1')
     743            pageinfo['tocPN'] = min(tocPages,pageinfo['tocPN'])
     744           
    743745        return pageinfo
    744746
     747
     748    def getPageList(self, start=None, rows=None, cols=None, pageFlowLtr=True, pageZero=False, minIdx=1, maxIdx=0):
     749        """returns array of page informations for one screenfull of thumbnails"""
     750        if maxIdx == 0:
     751            maxIdx = start + rows * cols
     752
     753        pages = []
     754        if pageZero and start == 1:
     755            # correct beginning
     756            idx = 0
     757        else:
     758            idx = start
     759           
     760        for r in range(rows):
     761            row = []
     762            for c in range(cols):
     763                if idx < minIdx or idx > maxIdx:
     764                    page = {'idx':None}
     765                else:
     766                    page = {'idx':idx}
     767                   
     768                idx += 1
     769                if pageFlowLtr:
     770                    row.append(page)
     771                else:
     772                    row.insert(0, page)
     773               
     774            pages.append(row)
     775           
     776        logging.debug("getPageList returns=%s"%(pages))
     777        return pages
     778       
    745779
    746780    security.declareProtected('View management screens','changeDocumentViewerForm')   
Note: See TracChangeset for help on using the changeset viewer.