Changeset 607:cb5a9c4f5e3a in documentViewer for documentViewer.py
- Timestamp:
- Dec 14, 2012, 10:28:31 PM (11 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
documentViewer.py
r602 r607 161 161 #templateFolder._setObject('zogilib',zogilib) 162 162 except Exception, e: 163 logging.error("Unable to create zogiLib for zogilib: "+str(e))163 logging.error("Unable to create zogiLib for 'zogilib': "+str(e)) 164 164 165 165 try: … … 638 638 # replace with numTextPages (text-only?) 639 639 docinfo['numPages'] = docinfo['numTextPages'] 640 641 # min and max page no 642 docinfo['minPageNo'] = docinfo.get('minPageNo', 1) 643 docinfo['maxPageNo'] = docinfo.get('maxPageNo', docinfo['numPages']) 640 644 641 645 # normalize path … … 684 688 imageDir = getMDText(texttool.get('image', None)) 685 689 docPath = getMDText(docinfo.get('documentPath', None)) 686 if imageDir and docPath: 687 imageDir = os.path.join(docPath, imageDir) 688 imageDir = imageDir.replace('/mpiwg/online', '', 1) 689 docinfo['imagePath'] = imageDir 690 if imageDir: 691 if imageDir.startswith('/'): 692 # absolute path 693 imageDir = imageDir.replace('/mpiwg/online', '', 1) 694 docinfo['imagePath'] = imageDir 695 696 elif docPath: 697 # relative path 698 imageDir = os.path.join(docPath, imageDir) 699 imageDir = imageDir.replace('/mpiwg/online', '', 1) 700 docinfo['imagePath'] = imageDir 701 702 # start and end page (for subdocuments of other documents) 703 imgStartNo = getMDText(texttool.get('image-start-no', None)) 704 minPageNo = getInt(imgStartNo, 1) 705 docinfo['minPageNo'] = minPageNo 706 707 imgEndNo = getMDText(texttool.get('image-end-no', None)) 708 if imgEndNo: 709 docinfo['maxPageNo'] = getInt(imgEndNo) 690 710 691 711 # old style text URL … … 725 745 726 746 # number of title page (default 1) 727 docinfo['titlePage'] = getMDText(texttool.get('title-scan-no', 1))747 docinfo['titlePage'] = getMDText(texttool.get('title-scan-no', minPageNo)) 728 748 729 749 # old presentation stuff … … 865 885 pageinfo['tocMode'] = tocMode 866 886 887 minPageNo = docinfo.get('minPageNo', 1) 888 867 889 # pf takes precedence over pn 868 890 if pf: … … 873 895 self.REQUEST.form['pn'] = pn 874 896 else: 875 pn = getInt(pn, 1)897 pn = getInt(pn, minPageNo) 876 898 pf = getPfForPn(docinfo, pn) 877 899 pageinfo['pf'] = pf … … 884 906 grpsize = cols * rows 885 907 pageinfo['groupsize'] = grpsize 886 # is start is empty use one around pn 887 start = getInt(start, default=(math.ceil(float(pn)/float(grpsize))*grpsize-(grpsize-1))) 888 # int(current / grpsize) * grpsize +1)) 908 # if start is empty use one around pn 909 grouppn = math.ceil(float(pn)/float(grpsize))*grpsize-(grpsize-1) 910 # but not smaller than minPageNo 911 start = getInt(start, max(grouppn, minPageNo)) 889 912 pageinfo['start'] = start 890 913 # get number of pages 891 n p= int(docinfo.get('numPages', 0))892 if n p== 0:914 numPages = int(docinfo.get('numPages', 0)) 915 if numPages == 0: 893 916 # try numTextPages 894 np = docinfo.get('numTextPages', 0) 895 if np != 0: 896 docinfo['numPages'] = np 917 numPages = docinfo.get('numTextPages', 0) 918 if numPages != 0: 919 docinfo['numPages'] = numPages 920 921 maxPageNo = docinfo.get('maxPageNo', numPages) 922 logging.debug("minPageNo=%s maxPageNo=%s start=%s numPages=%s"%(minPageNo,maxPageNo,start,numPages)) 923 np = maxPageNo 897 924 898 925 # cache table of contents … … 907 934 pageZero = (cols == 2 and (pageFlowLtr != oddScanLeft)) 908 935 pageinfo['pageZero'] = pageZero 909 pageinfo['pageBatch'] = self.getPageBatch(start=start, rows=rows, cols=cols, pageFlowLtr=pageFlowLtr, pageZero=pageZero, minIdx= 1, maxIdx=np)936 pageinfo['pageBatch'] = self.getPageBatch(start=start, rows=rows, cols=cols, pageFlowLtr=pageFlowLtr, pageZero=pageZero, minIdx=minPageNo, maxIdx=np) 910 937 # more page parameters 911 938 pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization','reg') … … 939 966 def getPageBatch(self, start=1, rows=10, cols=2, pageFlowLtr=True, pageZero=False, minIdx=1, maxIdx=0): 940 967 """returns dict with array of page information for one screenfull of thumbnails""" 968 logging.debug("getPageBatch start=%s minIdx=%s maxIdx=%s"%(start,minIdx,maxIdx)) 941 969 batch = {} 942 970 grpsize = rows * cols … … 944 972 maxIdx = start + grpsize 945 973 946 nb = int(math.ceil(maxIdx / float(grpsize))) 974 np = maxIdx - minIdx + 1 975 nb = int(math.ceil(np / float(grpsize))) 947 976 # list of all batch start and end points 948 977 batches = [] 949 978 if pageZero: 950 ofs = 0951 else: 952 ofs = 1979 ofs = minIdx - 1 980 else: 981 ofs = minIdx 953 982 954 983 for i in range(nb): … … 960 989 961 990 pages = [] 962 if pageZero and start == 1:991 if pageZero and start == minIdx: 963 992 # correct beginning 964 idx = 0993 idx = minIdx - 1 965 994 else: 966 995 idx = start … … 982 1011 pages.append(row) 983 1012 984 if start > 1:985 batch['prevStart'] = max(start - grpsize, 1)1013 if start > minIdx: 1014 batch['prevStart'] = max(start - grpsize, minIdx) 986 1015 else: 987 1016 batch['prevStart'] = None
Note: See TracChangeset
for help on using the changeset viewer.