Mercurial > hg > documentViewer
changeset 475:5a3ab27385ce elementtree
more new template stuff
author | casties |
---|---|
date | Fri, 05 Aug 2011 19:04:20 +0200 |
parents | 0bc4a153863a |
children | 1d93a8cb2d8f |
files | MpdlXmlTextServer.py documentViewer.py |
diffstat | 2 files changed, 19 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/MpdlXmlTextServer.py Fri Aug 05 15:31:27 2011 +0200 +++ b/MpdlXmlTextServer.py Fri Aug 05 19:04:20 2011 +0200 @@ -257,6 +257,10 @@ # WTF: s1 = int(s)/30+1 docinfo['numTocEntries'] = getInt(div.text) + # numPlaces + elif dc == 'countPlaces': + docinfo['numPlaces'] = getInt(div.text) + # numTextPages elif dc == 'countPages': np = getInt(div.text) @@ -302,6 +306,7 @@ textmode = "textPollux" elif not mode: # default is text + mode = "text" textmode = "text" else: textmode = mode @@ -340,7 +345,7 @@ return serialize(pagediv) # text-with-links mode - elif mode == "text_dict": + elif mode == "dict": if pagediv is not None: # check all a-tags links = pagediv.findall(".//a")
--- a/documentViewer.py Fri Aug 05 15:31:27 2011 +0200 +++ b/documentViewer.py Fri Aug 05 19:04:20 2011 +0200 @@ -276,7 +276,7 @@ @param tocMode: type of 'table of contents' for navigation (thumbs, text, figures, none) """ - logging.debug("documentViewer (index) mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn)) + logging.debug("documentViewer(index_html) mode=%s url=%s viewMode=%s viewType=%s start=%s pn=%s"%(mode,url,viewMode,viewType,start,pn)) if not hasattr(self, 'template'): # this won't work @@ -305,11 +305,19 @@ viewMode = "text" viewType = "dict" - + # stringify viewType + if isinstance(viewType, list): + viewType = ','.join([t for t in viewType if t]) + pageinfo = self.getPageinfo(start=start, current=pn, docinfo=docinfo, viewMode=viewMode, viewType=viewType, tocMode=tocMode) - # get template /template/viewer_main - pt = getattr(self.template, 'viewer_main') + # get template /template/viewer_$viewMode + pt = getattr(self.template, 'viewer_%s'%viewMode, None) + if pt is None: + logging.error("No template for viewMode=%s!"%viewMode) + # TODO: error page? + return "No template for viewMode=%s!"%viewMode + # and execute with parameters return pt(docinfo=docinfo, pageinfo=pageinfo) @@ -380,7 +388,7 @@ """returns URL to documentviewer with parameter param set to val or from dict params""" urlParams = self.getParams(param=param, val=val, params=params) # quote values and assemble into query string (not escaping '/') - ps = paramSep.join(["%s=%s"%(k,urllib.quote_plus(v,'/')) for (k, v) in urlParams.items()]) + ps = paramSep.join(["%s=%s"%(k,urllib.quote_plus(unicode(v),'/')) for (k, v) in urlParams.items()]) if baseUrl is None: baseUrl = self.getDocumentViewerURL()