Changeset 587:6000c7e24d8a in documentViewer
- Timestamp:
- Nov 15, 2012, 4:09:45 PM (12 years ago)
- Branch:
- default
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
MpiwgXmlTextServer.py
r583 r587 198 198 return None 199 199 200 # just checking201 if pageinfo['current'] != pn:202 logging.warning("getTextPage: current!=pn!")203 204 200 # stuff for constructing full urls 205 201 selfurl = docinfo['viewerUrl'] -
documentViewer.py
r585 r587 47 47 # split by /, shorten, and reassemble 48 48 return '/'.join(path.split('/')[0:-cnt]) 49 50 def getPnForPf(docinfo, pf): 51 """returns image number for image file name or 0""" 52 if 'imgFileNames' in docinfo: 53 pn = docinfo['imgFileNames'].get(pf, None) 54 if pn is None: 55 # try to cut extension 56 xi = pf.rfind('.') 57 if xi > 0: 58 pf = pf[:xi] 59 # try again, else return 0 60 pn = docinfo['imgFileNames'].get(pf, 0) 61 62 return pn 63 64 return 0 49 65 50 66 … … 205 221 docinfo = self.getDocinfo(mode=mode,url=url) 206 222 #pageinfo = self.getPageinfo(start=start,current=pn,docinfo=docinfo) 207 pageinfo = self.getPageinfo(start=start, current=pn, docinfo=docinfo)223 pageinfo = self.getPageinfo(start=start,pn=pn, docinfo=docinfo) 208 224 ''' ZDES ''' 209 225 pt = getattr(self.template, 'thumbs_main_rss') … … 219 235 220 236 security.declareProtected('View','index_html') 221 def index_html(self,url,mode="texttool",viewMode="auto",viewLayer=None,tocMode=None,start= 1,pn=1):237 def index_html(self,url,mode="texttool",viewMode="auto",viewLayer=None,tocMode=None,start=None,pn=None,pf=None): 222 238 """ 223 239 show page … … 229 245 """ 230 246 231 logging.debug("documentViewer(index_html) mode=%s url=%s viewMode=%s viewLayer=%s start=%s pn=%s "%(mode,url,viewMode,viewLayer,start,pn))247 logging.debug("documentViewer(index_html) mode=%s url=%s viewMode=%s viewLayer=%s start=%s pn=%s pf=%s"%(mode,url,viewMode,viewLayer,start,pn,pf)) 232 248 233 249 if not hasattr(self, 'template'): … … 272 288 273 289 # pageinfo: information about page (not cached) 274 pageinfo = self.getPageinfo(start=start, current=pn, docinfo=docinfo, userinfo=userinfo, viewMode=viewMode, viewLayer=viewLayer, tocMode=tocMode)290 pageinfo = self.getPageinfo(start=start, pn=pn, pf=pf, docinfo=docinfo, userinfo=userinfo, viewMode=viewMode, viewLayer=viewLayer, tocMode=tocMode) 275 291 276 292 # get template /template/viewer_$viewMode … … 452 468 return False 453 469 454 455 470 def getUserinfo(self): 456 471 """returns userinfo object""" … … 734 749 735 750 def getDocinfoFromDigilib(self, docinfo, path): 736 infoUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp? mo=dir&fn="+path751 infoUrl=self.digilibBaseUrl+"/dirInfo-xml.jsp?fn="+path 737 752 # fetch data 738 753 txt = getHttpData(infoUrl) … … 742 757 743 758 dom = ET.fromstring(txt) 744 size = getText(dom.find("size")) 759 dir = dom 760 # save size 761 size = dir.findtext('size') 745 762 logging.debug("getDocinfoFromDigilib: size=%s"%size) 746 763 if size: … … 748 765 else: 749 766 docinfo['numPages'] = 0 750 751 # TODO: produce and keep list of image names and numbers 767 return docinfo 768 769 # save list of image names and numbers 770 imgNames = {} 771 for f in dir: 772 fn = f.findtext('name') 773 pn = f.findtext('index') 774 imgNames[fn] = getInt(pn) 775 776 docinfo['imgFileNames'] = imgNames 752 777 return docinfo 753 778 … … 767 792 else: 768 793 # online path 769 770 794 server=self.digilibBaseUrl+"/servlet/Texter?fn=" 771 795 metaUrl=server+url … … 783 807 784 808 785 def getPageinfo(self, current=None, start=None, rows=None, cols=None, docinfo=None, userinfo=None, viewMode=None, viewLayer=None, tocMode=None):809 def getPageinfo(self, pn=None, pf=None, start=None, rows=None, cols=None, docinfo=None, userinfo=None, viewMode=None, viewLayer=None, tocMode=None): 786 810 """returns pageinfo with the given parameters""" 787 logging.debug("getPageInfo( current=%s, start=%s, rows=%s, cols=%s, viewMode=%s, viewLayer=%s, tocMode=%s)"%(current,start,rows,cols,viewMode,viewLayer,tocMode))811 logging.debug("getPageInfo(pn=%s, pf=%s, start=%s, rows=%s, cols=%s, viewMode=%s, viewLayer=%s, tocMode=%s)"%(pn,pf,start,rows,cols,viewMode,viewLayer,tocMode)) 788 812 pageinfo = {} 789 813 pageinfo['viewMode'] = viewMode … … 808 832 809 833 # TODO: unify current and pn! 810 current = getInt(current) 811 pageinfo['current'] = current 812 pageinfo['pn'] = current 834 #pageinfo['current'] = current 835 # pf takes precedence over pn 836 if pf: 837 pageinfo['pf'] = pf 838 pn = getPnForPf(docinfo, pf) 839 else: 840 pn = getInt(pn, 1) 841 842 pageinfo['pn'] = pn 813 843 rows = int(rows or self.thumbrows) 814 844 pageinfo['rows'] = rows … … 817 847 grpsize = cols * rows 818 848 pageinfo['groupsize'] = grpsize 819 # is start is empty use one around current820 start = getInt(start, default=(math.ceil(float( current)/float(grpsize))*grpsize-(grpsize-1)))849 # is start is empty use one around pn 850 start = getInt(start, default=(math.ceil(float(pn)/float(grpsize))*grpsize-(grpsize-1))) 821 851 # int(current / grpsize) * grpsize +1)) 822 852 pageinfo['start'] = start … … 845 875 if docinfo.get('pageNumbers'): 846 876 # get original page numbers 847 pageNumber = docinfo['pageNumbers'].get( current, None)877 pageNumber = docinfo['pageNumbers'].get(pn, None) 848 878 if pageNumber is not None: 849 879 pageinfo['pageNumberOrig'] = pageNumber['no'] -
version.txt
r580 r587 1 DocumentViewer 2.2. 71 DocumentViewer 2.2.8 -
zpt/layer_images_annotator.zpt
r586 r587 73 73 </form> 74 74 <p tal:define="std modules/Products.PythonScripts.standard"> 75 <a class="button" tal:attributes="href python:'%s/login/login?came_from=%s'%(viewerUrl,std.url_quote(here.getLink()))"> log in</a>75 <a class="button" tal:attributes="href python:'%s/login/login?came_from=%s'%(viewerUrl,std.url_quote(here.getLink()))">Log in</a> 76 76 </p> 77 77 </div> -
zpt/layer_text_annotator.zpt
r557 r587 126 126 </form> 127 127 <p tal:define="std modules/Products.PythonScripts.standard"> 128 <a class="button" tal:attributes="href python:'%s/login/login?came_from=%s'%(viewerUrl,std.url_quote(here.getLink()))">log in</a> 129 <!-- <a class="button" tal:attributes="href python:'%s/login/logout?came_from=%s'%(viewerUrl,std.url_quote(here.getLink()))">log out</a> --> 128 <a class="button" tal:attributes="href python:'%s/login/login?came_from=%s'%(viewerUrl,std.url_quote(here.getLink()))">Log in</a> 130 129 </p> 131 130 </div>
Note: See TracChangeset
for help on using the changeset viewer.