Mercurial > hg > documentViewer
comparison documentViewer.py @ 508:d5a47f82e755 elementtree
more cleanup.
search works mostly now.
layers work better now.
author | casties |
---|---|
date | Mon, 27 Feb 2012 21:26:52 +0100 |
parents | 3c01e8f4e72b |
children | 9d05befdd462 |
comparison
equal
deleted
inserted
replaced
507:3c01e8f4e72b | 508:d5a47f82e755 |
---|---|
172 # proxy text server methods to fulltextclient | 172 # proxy text server methods to fulltextclient |
173 def getTextPage(self, **args): | 173 def getTextPage(self, **args): |
174 """returns full text content of page""" | 174 """returns full text content of page""" |
175 return self.template.fulltextclient.getTextPage(**args) | 175 return self.template.fulltextclient.getTextPage(**args) |
176 | 176 |
177 def getSearchResults(self, **args): | |
178 """loads list of search results and stores XML in docinfo""" | |
179 return self.template.fulltextclient.getSearchResults(**args) | |
180 | |
181 def getResultsPage(self, **args): | |
182 """returns one page of the search results""" | |
183 return self.template.fulltextclient.getResultsPage(**args) | |
184 | |
177 def getToc(self, **args): | 185 def getToc(self, **args): |
178 """returns the full table of contents (in internal format)""" | 186 """loads table of contents and stores XML in docinfo""" |
179 return self.template.fulltextclient.getToc(**args) | 187 return self.template.fulltextclient.getToc(**args) |
180 | 188 |
181 def getTocPage(self, **args): | 189 def getTocPage(self, **args): |
182 """returns one page of the table of contents""" | 190 """returns one page of the table of contents""" |
183 return self.template.fulltextclient.getTocPage(**args) | 191 return self.template.fulltextclient.getTocPage(**args) |
245 | 253 |
246 docinfo = self.getDocinfo(mode=mode,url=url) | 254 docinfo = self.getDocinfo(mode=mode,url=url) |
247 | 255 |
248 if tocMode != "thumbs": | 256 if tocMode != "thumbs": |
249 # get table of contents | 257 # get table of contents |
250 docinfo = self.getToc(mode=tocMode, docinfo=docinfo) | 258 self.getToc(mode=tocMode, docinfo=docinfo) |
251 | 259 |
252 # auto viewMode: text if there is a text else images | 260 # auto viewMode: text if there is a text else images |
253 if viewMode=="auto": | 261 if viewMode=="auto": |
254 if docinfo.get('textURL', None) or docinfo.get('textURLPath', None): | 262 if docinfo.get('textURL', None) or docinfo.get('textURLPath', None): |
255 viewMode = "text" | 263 viewMode = "text" |
256 viewLayer = "dict" | 264 if viewLayer is None: |
265 viewLayer = "dict" | |
257 else: | 266 else: |
258 viewMode = "images" | 267 viewMode = "images" |
259 | 268 |
260 elif viewMode == "text_dict": | 269 elif viewMode == "text_dict": |
261 # legacy fix | 270 # legacy fix |
262 viewMode = "text" | 271 viewMode = "text" |
263 viewLayer = "dict" | 272 viewLayer = "dict" |
264 | 273 |
265 # stringify viewLayer | |
266 if isinstance(viewLayer, list): | |
267 logging.debug("index_html: viewLayer is list:%s"%viewLayer) | |
268 viewLayer = ','.join([t for t in viewLayer if t]) | |
269 | |
270 pageinfo = self.getPageinfo(start=start, current=pn, docinfo=docinfo, viewMode=viewMode, viewLayer=viewLayer, tocMode=tocMode) | 274 pageinfo = self.getPageinfo(start=start, current=pn, docinfo=docinfo, viewMode=viewMode, viewLayer=viewLayer, tocMode=tocMode) |
271 | 275 |
272 # get template /template/viewer_$viewMode | 276 # get template /template/viewer_$viewMode |
273 pt = getattr(self.template, 'viewer_%s'%viewMode, None) | 277 pt = getattr(self.template, 'viewer_%s'%viewMode, None) |
274 if pt is None: | 278 if pt is None: |
672 def getPageinfo(self, current=None, start=None, rows=None, cols=None, docinfo=None, viewMode=None, viewLayer=None, tocMode=None): | 676 def getPageinfo(self, current=None, start=None, rows=None, cols=None, docinfo=None, viewMode=None, viewLayer=None, tocMode=None): |
673 """returns pageinfo with the given parameters""" | 677 """returns pageinfo with the given parameters""" |
674 logging.debug("getPageInfo(current=%s, start=%s, rows=%s, cols=%s, viewMode=%s, viewLayer=%s, tocMode=%s)"%(current,start,rows,cols,viewMode,viewLayer,tocMode)) | 678 logging.debug("getPageInfo(current=%s, start=%s, rows=%s, cols=%s, viewMode=%s, viewLayer=%s, tocMode=%s)"%(current,start,rows,cols,viewMode,viewLayer,tocMode)) |
675 pageinfo = {} | 679 pageinfo = {} |
676 pageinfo['viewMode'] = viewMode | 680 pageinfo['viewMode'] = viewMode |
681 # split viewLayer if necessary | |
682 if isinstance(viewLayer,basestring): | |
683 viewLayer = viewLayer.split(',') | |
684 | |
685 if isinstance(viewLayer, list): | |
686 logging.debug("getPageinfo: viewLayer is list:%s"%viewLayer) | |
687 # save (unique) list in viewLayers | |
688 seen = set() | |
689 viewLayers = [l for l in viewLayer if l and l not in seen and not seen.add(l)] | |
690 pageinfo['viewLayers'] = viewLayers | |
691 # stringify viewLayer | |
692 viewLayer = ','.join(viewLayers) | |
693 else: | |
694 #create list | |
695 pageinfo['viewLayers'] = [viewLayer] | |
696 | |
677 pageinfo['viewLayer'] = viewLayer | 697 pageinfo['viewLayer'] = viewLayer |
678 pageinfo['tocMode'] = tocMode | 698 pageinfo['tocMode'] = tocMode |
679 | 699 |
680 current = getInt(current) | 700 current = getInt(current) |
681 pageinfo['current'] = current | 701 pageinfo['current'] = current |