# HG changeset patch # User casties # Date 1355524111 18000 # Node ID cb5a9c4f5e3a21da04b087e9174bc8ccb411c68b # Parent 37ad612edf5a64f1d4ffde2a10de1f69eeb4698c CLOSED - # 268: display of subdocuments https://it-dev.mpiwg-berlin.mpg.de/tracs/mpdl-project-software/ticket/268 diff -r 37ad612edf5a -r cb5a9c4f5e3a css/docuviewer.css --- a/css/docuviewer.css Tue Dec 11 16:33:12 2012 -0500 +++ b/css/docuviewer.css Fri Dec 14 17:28:31 2012 -0500 @@ -172,6 +172,9 @@ div.tocbody table.thumbs .thumbcap { color: black; } +div.tocbody table.thumbs a.outside { + font-weight: normal; +} div.tocbody table.concordance { border-collapse: collapse; diff -r 37ad612edf5a -r cb5a9c4f5e3a documentViewer.py --- a/documentViewer.py Tue Dec 11 16:33:12 2012 -0500 +++ b/documentViewer.py Fri Dec 14 17:28:31 2012 -0500 @@ -160,7 +160,7 @@ templateFolder['zogilib'] = zogilib #templateFolder._setObject('zogilib',zogilib) except Exception, e: - logging.error("Unable to create zogiLib for zogilib: "+str(e)) + logging.error("Unable to create zogiLib for 'zogilib': "+str(e)) try: # assume MetaDataFolder instance is called metadata @@ -637,6 +637,10 @@ if docinfo.get('numTextPages', 0) > 0: # replace with numTextPages (text-only?) docinfo['numPages'] = docinfo['numTextPages'] + + # min and max page no + docinfo['minPageNo'] = docinfo.get('minPageNo', 1) + docinfo['maxPageNo'] = docinfo.get('maxPageNo', docinfo['numPages']) # normalize path if 'imagePath' in docinfo and not docinfo['imagePath'].startswith('/'): @@ -683,10 +687,26 @@ # image dir imageDir = getMDText(texttool.get('image', None)) docPath = getMDText(docinfo.get('documentPath', None)) - if imageDir and docPath: - imageDir = os.path.join(docPath, imageDir) - imageDir = imageDir.replace('/mpiwg/online', '', 1) - docinfo['imagePath'] = imageDir + if imageDir: + if imageDir.startswith('/'): + # absolute path + imageDir = imageDir.replace('/mpiwg/online', '', 1) + docinfo['imagePath'] = imageDir + + elif docPath: + # relative path + imageDir = os.path.join(docPath, imageDir) + imageDir = imageDir.replace('/mpiwg/online', '', 1) + docinfo['imagePath'] = imageDir + + # start and end page (for subdocuments of other documents) + imgStartNo = getMDText(texttool.get('image-start-no', None)) + minPageNo = getInt(imgStartNo, 1) + docinfo['minPageNo'] = minPageNo + + imgEndNo = getMDText(texttool.get('image-end-no', None)) + if imgEndNo: + docinfo['maxPageNo'] = getInt(imgEndNo) # old style text URL textUrl = getMDText(texttool.get('text', None)) @@ -724,7 +744,7 @@ docinfo['oddPage'] = getMDText(texttool.get('odd-scan-position', 'left')) # number of title page (default 1) - docinfo['titlePage'] = getMDText(texttool.get('title-scan-no', 1)) + docinfo['titlePage'] = getMDText(texttool.get('title-scan-no', minPageNo)) # old presentation stuff presentation = getMDText(texttool.get('presentation', None)) @@ -864,6 +884,8 @@ pageinfo['viewLayer'] = viewLayer pageinfo['tocMode'] = tocMode + minPageNo = docinfo.get('minPageNo', 1) + # pf takes precedence over pn if pf: pageinfo['pf'] = pf @@ -872,7 +894,7 @@ self.REQUEST.form.pop('pf', None) self.REQUEST.form['pn'] = pn else: - pn = getInt(pn, 1) + pn = getInt(pn, minPageNo) pf = getPfForPn(docinfo, pn) pageinfo['pf'] = pf @@ -883,17 +905,22 @@ pageinfo['cols'] = cols grpsize = cols * rows pageinfo['groupsize'] = grpsize - # is start is empty use one around pn - start = getInt(start, default=(math.ceil(float(pn)/float(grpsize))*grpsize-(grpsize-1))) - # int(current / grpsize) * grpsize +1)) + # if start is empty use one around pn + grouppn = math.ceil(float(pn)/float(grpsize))*grpsize-(grpsize-1) + # but not smaller than minPageNo + start = getInt(start, max(grouppn, minPageNo)) pageinfo['start'] = start # get number of pages - np = int(docinfo.get('numPages', 0)) - if np == 0: + numPages = int(docinfo.get('numPages', 0)) + if numPages == 0: # try numTextPages - np = docinfo.get('numTextPages', 0) - if np != 0: - docinfo['numPages'] = np + numPages = docinfo.get('numTextPages', 0) + if numPages != 0: + docinfo['numPages'] = numPages + + maxPageNo = docinfo.get('maxPageNo', numPages) + logging.debug("minPageNo=%s maxPageNo=%s start=%s numPages=%s"%(minPageNo,maxPageNo,start,numPages)) + np = maxPageNo # cache table of contents pageinfo['tocPageSize'] = getInt(self.REQUEST.get('tocPageSize', 30)) @@ -906,7 +933,7 @@ # add zeroth page for two columns pageZero = (cols == 2 and (pageFlowLtr != oddScanLeft)) pageinfo['pageZero'] = pageZero - pageinfo['pageBatch'] = self.getPageBatch(start=start, rows=rows, cols=cols, pageFlowLtr=pageFlowLtr, pageZero=pageZero, minIdx=1, maxIdx=np) + pageinfo['pageBatch'] = self.getPageBatch(start=start, rows=rows, cols=cols, pageFlowLtr=pageFlowLtr, pageZero=pageZero, minIdx=minPageNo, maxIdx=np) # more page parameters pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization','reg') if docinfo.get('pageNumbers'): @@ -938,18 +965,20 @@ def getPageBatch(self, start=1, rows=10, cols=2, pageFlowLtr=True, pageZero=False, minIdx=1, maxIdx=0): """returns dict with array of page information for one screenfull of thumbnails""" + logging.debug("getPageBatch start=%s minIdx=%s maxIdx=%s"%(start,minIdx,maxIdx)) batch = {} grpsize = rows * cols if maxIdx == 0: maxIdx = start + grpsize - nb = int(math.ceil(maxIdx / float(grpsize))) + np = maxIdx - minIdx + 1 + nb = int(math.ceil(np / float(grpsize))) # list of all batch start and end points batches = [] if pageZero: - ofs = 0 + ofs = minIdx - 1 else: - ofs = 1 + ofs = minIdx for i in range(nb): s = i * grpsize + ofs @@ -959,9 +988,9 @@ batch['batches'] = batches pages = [] - if pageZero and start == 1: + if pageZero and start == minIdx: # correct beginning - idx = 0 + idx = minIdx - 1 else: idx = start @@ -981,8 +1010,8 @@ pages.append(row) - if start > 1: - batch['prevStart'] = max(start - grpsize, 1) + if start > minIdx: + batch['prevStart'] = max(start - grpsize, minIdx) else: batch['prevStart'] = None diff -r 37ad612edf5a -r cb5a9c4f5e3a version.txt --- a/version.txt Tue Dec 11 16:33:12 2012 -0500 +++ b/version.txt Fri Dec 14 17:28:31 2012 -0500 @@ -1,1 +1,1 @@ -DocumentViewer 2.2.9 \ No newline at end of file +DocumentViewer 2.2.10 \ No newline at end of file diff -r 37ad612edf5a -r cb5a9c4f5e3a zpt/viewer/common_template.zpt --- a/zpt/viewer/common_template.zpt Tue Dec 11 16:33:12 2012 -0500 +++ b/zpt/viewer/common_template.zpt Fri Dec 14 17:28:31 2012 -0500 @@ -44,9 +44,9 @@ minPageNo,pn-1,None); next python:test(pnminPageNo,minPageNo,None); last python:test(pn
@@ -89,16 +89,16 @@ < < - > - > + > +
diff -r 37ad612edf5a -r cb5a9c4f5e3a zpt/viewer/toc_thumbs.zpt --- a/zpt/viewer/toc_thumbs.zpt Tue Dec 11 16:33:12 2012 -0500 +++ b/zpt/viewer/toc_thumbs.zpt Fri Dec 14 17:28:31 2012 -0500 @@ -10,6 +10,8 @@