Mercurial > hg > documentViewer
comparison documentViewer.py @ 589:d8d6975cebcb
more fixes for pf-parameter
| author | casties |
|---|---|
| date | Thu, 15 Nov 2012 17:58:14 +0100 |
| parents | 6000c7e24d8a |
| children | ed4485d2748e |
comparison
equal
deleted
inserted
replaced
| 588:e1034c2ca255 | 589:d8d6975cebcb |
|---|---|
| 45 # make sure path doesn't end with / | 45 # make sure path doesn't end with / |
| 46 path = path.rstrip('/') | 46 path = path.rstrip('/') |
| 47 # split by /, shorten, and reassemble | 47 # split by /, shorten, and reassemble |
| 48 return '/'.join(path.split('/')[0:-cnt]) | 48 return '/'.join(path.split('/')[0:-cnt]) |
| 49 | 49 |
| 50 def getPnForPf(docinfo, pf): | 50 def getPnForPf(docinfo, pf, default=0): |
| 51 """returns image number for image file name or 0""" | 51 """returns image number for image file name or default""" |
| 52 if 'imgFileNames' in docinfo: | 52 if 'imgFileNames' in docinfo: |
| 53 pn = docinfo['imgFileNames'].get(pf, None) | 53 pn = docinfo['imgFileNames'].get(pf, None) |
| 54 if pn is None: | 54 if pn is None: |
| 55 # try to cut extension | 55 # try to cut extension |
| 56 xi = pf.rfind('.') | 56 xi = pf.rfind('.') |
| 57 if xi > 0: | 57 if xi > 0: |
| 58 pf = pf[:xi] | 58 pf = pf[:xi] |
| 59 # try again, else return 0 | 59 # try again, else return 0 |
| 60 pn = docinfo['imgFileNames'].get(pf, 0) | 60 pn = docinfo['imgFileNames'].get(pf, default) |
| 61 else: | |
| 62 # no extension | |
| 63 pn = default | |
| 61 | 64 |
| 62 return pn | 65 return pn |
| 63 | 66 |
| 64 return 0 | 67 return default |
| 65 | 68 |
| 66 | 69 |
| 67 ## | 70 ## |
| 68 ## documentViewer class | 71 ## documentViewer class |
| 69 ## | 72 ## |
| 232 | 235 |
| 233 return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode) | 236 return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode) |
| 234 | 237 |
| 235 | 238 |
| 236 security.declareProtected('View','index_html') | 239 security.declareProtected('View','index_html') |
| 237 def index_html(self,url,mode="texttool",viewMode="auto",viewLayer=None,tocMode=None,start=None,pn=None,pf=None): | 240 def index_html(self, url, mode="texttool", viewMode="auto", viewLayer=None, tocMode=None, start=None, pn=None, pf=None): |
| 238 """ | 241 """ |
| 239 show page | 242 show page |
| 240 @param url: url which contains display information | 243 @param url: url which contains display information |
| 241 @param mode: defines how to access the document behind url | 244 @param mode: defines how to access the document behind url |
| 242 @param viewMode: 'images': display images, 'text': display text, 'xml': display xml, default is 'auto' | 245 @param viewMode: 'images': display images, 'text': display text, 'xml': display xml, default is 'auto' |
| 828 pageinfo['viewLayers'] = [viewLayer] | 831 pageinfo['viewLayers'] = [viewLayer] |
| 829 | 832 |
| 830 pageinfo['viewLayer'] = viewLayer | 833 pageinfo['viewLayer'] = viewLayer |
| 831 pageinfo['tocMode'] = tocMode | 834 pageinfo['tocMode'] = tocMode |
| 832 | 835 |
| 833 # TODO: unify current and pn! | |
| 834 #pageinfo['current'] = current | |
| 835 # pf takes precedence over pn | 836 # pf takes precedence over pn |
| 836 if pf: | 837 if pf: |
| 837 pageinfo['pf'] = pf | 838 pageinfo['pf'] = pf |
| 838 pn = getPnForPf(docinfo, pf) | 839 pn = getPnForPf(docinfo, pf) |
| 840 # replace pf in request params (used for creating new URLs) | |
| 841 self.REQUEST.form.pop('pf', None) | |
| 842 self.REQUEST.form['pn'] = pn | |
| 839 else: | 843 else: |
| 840 pn = getInt(pn, 1) | 844 pn = getInt(pn, 1) |
| 841 | 845 |
| 842 pageinfo['pn'] = pn | 846 pageinfo['pn'] = pn |
| 843 rows = int(rows or self.thumbrows) | 847 rows = int(rows or self.thumbrows) |
