# HG changeset patch # User casties # Date 1313435348 -7200 # Node ID 50a28442f21c17c952a391e65c8266819c8bf1ef # Parent fe5b0e4ac5f2c0d453a0c346c17889972a22e9b4 more new template stuff diff -r fe5b0e4ac5f2 -r 50a28442f21c css/docuviewer.css --- a/css/docuviewer.css Mon Aug 15 11:58:56 2011 +0200 +++ b/css/docuviewer.css Mon Aug 15 21:09:08 2011 +0200 @@ -1,3 +1,14 @@ + +div.page_body { + display: table-row; +} +div.toc { + display: table-cell; +} +div.text { + display: table-cell; +} + .thumb { padding: 3px; } diff -r fe5b0e4ac5f2 -r 50a28442f21c documentViewer.py --- a/documentViewer.py Mon Aug 15 11:58:56 2011 +0200 +++ b/documentViewer.py Mon Aug 15 21:09:08 2011 +0200 @@ -1,4 +1,5 @@ from OFS.Folder import Folder +from OFS.Image import File from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate from Products.PageTemplates.PageTemplateFile import PageTemplateFile from AccessControl import ClassSecurityInfo @@ -135,8 +136,9 @@ page_main_xml = PageTemplateFile('zpt/page_main_xml', globals()) page_main_pureXml = PageTemplateFile('zpt/page_main_pureXml', globals()) head_main = PageTemplateFile('zpt/head_main', globals()) - docuviewer_css = PageTemplateFile('css/docuviewer.css', globals()) info_xml = PageTemplateFile('zpt/info_xml', globals()) + # TODO: can this be nicer? + docuviewer_css = File('docuviewer_css','',open(os.path.join(package_home(globals()),'css/docuviewer.css')), content_type='text/css') thumbs_main_rss = PageTemplateFile('zpt/thumbs_main_rss', globals()) @@ -347,13 +349,32 @@ """try to get the digilib URL from zogilib""" url = self.template.zogilib.getDLBaseUrl() return url + + def getScalerUrl(self, fn=None, pn=None, dw=100, dh=100, docinfo=None): + """returns URL to digilib Scaler with params""" + url = None + if docinfo is not None: + url = docinfo.get('imageURL', None) + + if url is None: + url = "%s/servlet/Scaler?"%self.digilibBaseUrl + if fn is None and docinfo is not None: + fn = docinfo.get('imagePath','') + + url += "fn=%s"%fn + + if pn: + url += "&pn=%s"%pn + + url += "&dw=%s&dh=%s"%(dw,dh) + return url def getDocumentViewerURL(self): """returns the URL of this instance""" return self.absolute_url() def getStyle(self, idx, selected, style=""): - """returns a string with the given style and append 'sel' if path == selected.""" + """returns a string with the given style and append 'sel' if idx == selected.""" #logger("documentViewer (getstyle)", logging.INFO, "idx: %s selected: %s style: %s"%(idx,selected,style)) if idx == selected: return style + 'sel' @@ -708,6 +729,7 @@ current = getInt(current) pageinfo['current'] = current + pageinfo['pn'] = current rows = int(rows or self.thumbrows) pageinfo['rows'] = rows cols = int(cols or self.thumbcols) @@ -718,14 +740,13 @@ start = getInt(start, default=(math.ceil(float(current)/float(grpsize))*grpsize-(grpsize-1))) # int(current / grpsize) * grpsize +1)) pageinfo['start'] = start - pn = self.REQUEST.get('pn','1') - pageinfo['pn'] = pn + np = int(docinfo.get('numPages', 0)) if np == 0: # numPages unknown - maybe we can get it from text page if docinfo.get('textURLPath', None): # cache text page as well - pageinfo['textPage'] = self.getTextPage(mode=viewType, pn=pn, docinfo=docinfo, pageinfo=pageinfo) + pageinfo['textPage'] = self.getTextPage(mode=viewType, pn=current, docinfo=docinfo, pageinfo=pageinfo) np = int(docinfo.get('numPages', 0)) pageinfo['numgroups'] = int(np / grpsize) @@ -737,8 +758,9 @@ # add zeroth page for two columns pageZero = (cols == 2 and (pageFlowLtr != oddScanLeft)) pageinfo['pageZero'] = pageZero - pageinfo['pageList'] = self.getPageList(start=start, rows=rows, cols=cols, pageFlowLtr=pageFlowLtr, pageZero=pageZero, minIdx=1, maxIdx=np) + pageinfo['pageBatch'] = self.getPageBatch(start=start, rows=rows, cols=cols, pageFlowLtr=pageFlowLtr, pageZero=pageZero, minIdx=1, maxIdx=np) + # TODO: do we need this here? pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization','reg') pageinfo['query'] = self.REQUEST.get('query','') pageinfo['queryType'] = self.REQUEST.get('queryType','') @@ -764,10 +786,11 @@ return pageinfo - def getPageList(self, start=None, rows=None, cols=None, pageFlowLtr=True, pageZero=False, minIdx=1, maxIdx=0): - """returns array of page informations for one screenfull of thumbnails""" + def getPageBatch(self, start=None, rows=None, cols=None, pageFlowLtr=True, pageZero=False, minIdx=1, maxIdx=0): + """returns dict with array of page informations for one screenfull of thumbnails""" + grpsize = rows * cols if maxIdx == 0: - maxIdx = start + rows * cols + maxIdx = start + grpsize pages = [] if pageZero and start == 1: @@ -792,8 +815,20 @@ pages.append(row) - logging.debug("getPageList returns=%s"%(pages)) - return pages + batch = {} + if start > 1: + batch['prevStart'] = max(start - grpsize, 1) + else: + batch['prevStart'] = None + + if start + grpsize < maxIdx: + batch['nextStart'] = start + grpsize + else: + batch['nextStart'] = None + + batch['pages'] = pages + #logging.debug("getPageList returns=%s"%(batch)) + return batch security.declareProtected('View management screens','changeDocumentViewerForm') diff -r fe5b0e4ac5f2 -r 50a28442f21c zpt/head_main.zpt --- a/zpt/head_main.zpt Mon Aug 15 11:58:56 2011 +0200 +++ b/zpt/head_main.zpt Mon Aug 15 21:09:08 2011 +0200 @@ -1,4 +1,20 @@ - - - - + + + + + + + + + + + + + diff -r fe5b0e4ac5f2 -r 50a28442f21c zpt/toc_thumbs.zpt --- a/zpt/toc_thumbs.zpt Mon Aug 15 11:58:56 2011 +0200 +++ b/zpt/toc_thumbs.zpt Mon Aug 15 21:09:08 2011 +0200 @@ -1,31 +1,70 @@ -
+ + + + + + + +
+ -
- - < - - - - > - -
- - - - - - -
- - -
- -
-
+
+
+
+ + < + < + + + > + > +
+
+ + + + + +
+ +
+ +
+
+
+
+ + \ No newline at end of file diff -r fe5b0e4ac5f2 -r 50a28442f21c zpt/viewer_text.zpt --- a/zpt/viewer_text.zpt Mon Aug 15 11:58:56 2011 +0200 +++ b/zpt/viewer_text.zpt Mon Aug 15 21:09:08 2011 +0200 @@ -1,30 +1,64 @@ + tal:define="docinfo options/docinfo; pageinfo options/pageinfo; viewMode pageinfo/viewMode; + tocMode pageinfo/tocMode; viewType pageinfo/viewType; viewerUrl docinfo/viewerUrl; + numPages docinfo/numPages | nothing;"> - -
- - - - - - -
- - - -
-
- -
Sorry, access to this document is restricted.
-
+ + +
+
+ +
+ +
+
+
+ + page + |< + |< + < + < + + + ([]) + + + of + + > + > + >| + >| + +
+
+
+ +
+
+
+
+
Sorry, access to this document is restricted.
+
+ - -
Sorry, document doesn't exist.
+ +
Sorry, document doesn't exist.