Changeset 607:cb5a9c4f5e3a in documentViewer
- Timestamp:
- Dec 14, 2012, 10:28:31 PM (12 years ago)
- Branch:
- default
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
css/docuviewer.css
r597 r607 173 173 color: black; 174 174 } 175 div.tocbody table.thumbs a.outside { 176 font-weight: normal; 177 } 175 178 176 179 div.tocbody table.concordance { -
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 -
version.txt
r591 r607 1 DocumentViewer 2.2. 91 DocumentViewer 2.2.10 -
zpt/viewer/common_template.zpt
r594 r607 45 45 <!-- page ruler with previous/next page buttons --> 46 46 <metal:block metal:define-macro="page_ruler" 47 tal:define=" 48 prev python:test(pn> 1,pn-1,None); next python:test(pn<numPages,pn+1,None);49 first python:test(pn> 1,1,None); last python:test(pn<numPages,numPages,None);47 tal:define="minPageNo docinfo/minPageNo; maxPageNo docinfo/maxPageNo; 48 prev python:test(pn>minPageNo,pn-1,None); next python:test(pn<maxPageNo,pn+1,None); 49 first python:test(pn>minPageNo,minPageNo,None); last python:test(pn<maxPageNo,maxPageNo,None); 50 50 left python:test(flowLtr,prev,next); right python:test(flowLtr,next,prev); 51 51 leftest python:test(flowLtr,first,last); rightest python:test(flowLtr,last,first);"> … … 90 90 <form class="autosubmit" tal:attributes="action viewerUrl"> 91 91 <input type="hidden" tal:define="params python:here.getParams('start',None)" tal:repeat="param params" 92 tal:attributes="name param; value python:params[param]" /><span class="ruler-main"><a tal: condition="left"93 tal:attributes="href python:here.getLink('start',left)"><</a> <s pan tal:condition="not:left"><</span> <select92 tal:attributes="name param; value python:params[param]" /><span class="ruler-main"><a tal:omit-tag="not:left" 93 tal:attributes="href python:here.getLink('start',left)"><</a> <select 94 94 class="autosubmit" name="start" tal:define="ofs python:test(pageinfo['pageZero'],0,1)"> 95 95 <tal:block> … … 98 98 <option tal:condition="python:start>pageBatch['last']" selected="selected" value="1">[out of range]</option> 99 99 </tal:block> 100 </select> <input type="submit" value="Go" /> <a tal: condition="right" tal:attributes="href python:here.getLink('start',right)">></a>101 <span tal:condition="not:right">></span></span>100 </select> <input type="submit" value="Go" /> <a tal:omit-tag="not:right" tal:attributes="href python:here.getLink('start',right)">></a> 101 </span> 102 102 </form> 103 103 </metal:block> -
zpt/viewer/toc_thumbs.zpt
r594 r607 11 11 <div class="tocbody thumbs" 12 12 tal:define="start pageinfo/start; 13 minPageNo docinfo/minPageNo; 14 maxPageNo docinfo/maxPageNo; 13 15 grpsize pageinfo/groupsize; 14 16 numgroups pageinfo/numgroups; … … 26 28 <tr tal:repeat="row pageBatch/pages"> 27 29 <td tal:repeat="thumb row" tal:attributes="class python:here.getStyle(thumb['idx'],pn,'thumb')"><a 28 tal:define="idx thumb/idx" tal:condition="idx" tal:attributes="href python:here.getLink('pn',idx)"> <img 30 tal:define="idx thumb/idx" tal:condition="idx" 31 tal:attributes="href python:here.getLink('pn',idx); class python:test(idx<minPageNo or idx>maxPageNo, 'outside')"><img 32 tal:condition="python:docinfo.get('imageURL',None) or exists('template/text.png')" 29 33 tal:attributes="src python:test(docinfo.get('imageURL',None),here.getScalerUrl(pn=idx,dw=100,dh=100,docinfo=docinfo),'template/text.png'); 30 34 alt idx;" /><br /> -
zpt/viewer/viewer_thumbs.zpt
r594 r607 27 27 tal:define="pn pageinfo/pn; 28 28 start pageinfo/start; 29 minPageNo docinfo/minPageNo; 30 maxPageNo docinfo/maxPageNo; 29 31 thumbRows python:int(request.get('thumbRows', 10)); 30 32 thumbCols python:int(request.get('thumbCols', 12)); 31 33 thumbSize python:int(request.get('thumbSize', 100)); 32 34 flowLtr python:docinfo.get('pageFlow','ltr')!='rtl'; 33 pageBatch python:here.getPageBatch(start=start, rows=thumbRows, cols=thumbCols, pageFlowLtr=flowLtr, m axIdx=numPages);35 pageBatch python:here.getPageBatch(start=start, rows=thumbRows, cols=thumbCols, pageFlowLtr=flowLtr, minIdx=minPageNo, maxIdx=maxPageNo); 34 36 pageNumbers docinfo/pageNumbers | nothing; 35 37 left python:test(flowLtr,pageBatch['prevStart'],pageBatch['nextStart']);
Note: See TracChangeset
for help on using the changeset viewer.