Changeset 480:50a28442f21c in documentViewer
- Timestamp:
- Aug 15, 2011, 7:09:08 PM (13 years ago)
- Branch:
- elementtree
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
css/docuviewer.css
r21 r480 1 2 div.page_body { 3 display: table-row; 4 } 5 div.toc { 6 display: table-cell; 7 } 8 div.text { 9 display: table-cell; 10 } 11 1 12 .thumb { 2 13 padding: 3px; -
documentViewer.py
r479 r480 1 1 from OFS.Folder import Folder 2 from OFS.Image import File 2 3 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate 3 4 from Products.PageTemplates.PageTemplateFile import PageTemplateFile … … 136 137 page_main_pureXml = PageTemplateFile('zpt/page_main_pureXml', globals()) 137 138 head_main = PageTemplateFile('zpt/head_main', globals()) 138 docuviewer_css = PageTemplateFile('css/docuviewer.css', globals())139 139 info_xml = PageTemplateFile('zpt/info_xml', globals()) 140 # TODO: can this be nicer? 141 docuviewer_css = File('docuviewer_css','',open(os.path.join(package_home(globals()),'css/docuviewer.css')), content_type='text/css') 140 142 141 143 … … 348 350 url = self.template.zogilib.getDLBaseUrl() 349 351 return url 352 353 def getScalerUrl(self, fn=None, pn=None, dw=100, dh=100, docinfo=None): 354 """returns URL to digilib Scaler with params""" 355 url = None 356 if docinfo is not None: 357 url = docinfo.get('imageURL', None) 358 359 if url is None: 360 url = "%s/servlet/Scaler?"%self.digilibBaseUrl 361 if fn is None and docinfo is not None: 362 fn = docinfo.get('imagePath','') 363 364 url += "fn=%s"%fn 365 366 if pn: 367 url += "&pn=%s"%pn 368 369 url += "&dw=%s&dh=%s"%(dw,dh) 370 return url 350 371 351 372 def getDocumentViewerURL(self): … … 354 375 355 376 def getStyle(self, idx, selected, style=""): 356 """returns a string with the given style and append 'sel' if path== selected."""377 """returns a string with the given style and append 'sel' if idx == selected.""" 357 378 #logger("documentViewer (getstyle)", logging.INFO, "idx: %s selected: %s style: %s"%(idx,selected,style)) 358 379 if idx == selected: … … 709 730 current = getInt(current) 710 731 pageinfo['current'] = current 732 pageinfo['pn'] = current 711 733 rows = int(rows or self.thumbrows) 712 734 pageinfo['rows'] = rows … … 719 741 # int(current / grpsize) * grpsize +1)) 720 742 pageinfo['start'] = start 721 pn = self.REQUEST.get('pn','1') 722 pageinfo['pn'] = pn 743 723 744 np = int(docinfo.get('numPages', 0)) 724 745 if np == 0: … … 726 747 if docinfo.get('textURLPath', None): 727 748 # cache text page as well 728 pageinfo['textPage'] = self.getTextPage(mode=viewType, pn= pn, docinfo=docinfo, pageinfo=pageinfo)749 pageinfo['textPage'] = self.getTextPage(mode=viewType, pn=current, docinfo=docinfo, pageinfo=pageinfo) 729 750 np = int(docinfo.get('numPages', 0)) 730 751 … … 738 759 pageZero = (cols == 2 and (pageFlowLtr != oddScanLeft)) 739 760 pageinfo['pageZero'] = pageZero 740 pageinfo['page List'] = self.getPageList(start=start, rows=rows, cols=cols, pageFlowLtr=pageFlowLtr, pageZero=pageZero, minIdx=1, maxIdx=np)761 pageinfo['pageBatch'] = self.getPageBatch(start=start, rows=rows, cols=cols, pageFlowLtr=pageFlowLtr, pageZero=pageZero, minIdx=1, maxIdx=np) 741 762 763 # TODO: do we need this here? 742 764 pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization','reg') 743 765 pageinfo['query'] = self.REQUEST.get('query','') … … 765 787 766 788 767 def getPageList(self, start=None, rows=None, cols=None, pageFlowLtr=True, pageZero=False, minIdx=1, maxIdx=0): 768 """returns array of page informations for one screenfull of thumbnails""" 789 def getPageBatch(self, start=None, rows=None, cols=None, pageFlowLtr=True, pageZero=False, minIdx=1, maxIdx=0): 790 """returns dict with array of page informations for one screenfull of thumbnails""" 791 grpsize = rows * cols 769 792 if maxIdx == 0: 770 maxIdx = start + rows * cols793 maxIdx = start + grpsize 771 794 772 795 pages = [] … … 793 816 pages.append(row) 794 817 795 logging.debug("getPageList returns=%s"%(pages)) 796 return pages 818 batch = {} 819 if start > 1: 820 batch['prevStart'] = max(start - grpsize, 1) 821 else: 822 batch['prevStart'] = None 823 824 if start + grpsize < maxIdx: 825 batch['nextStart'] = start + grpsize 826 else: 827 batch['nextStart'] = None 828 829 batch['pages'] = pages 830 #logging.debug("getPageList returns=%s"%(batch)) 831 return batch 797 832 798 833 -
zpt/head_main.zpt
r460 r480 1 <tal:block tal:define="docinfo options/docinfo; pageinfo options/pageinfo; formattedLabel python:here.metadata.getFormattedLabel(bibdata=docinfo.get('bib',None))"> 2 <span tal:condition="not:formattedLabel" tal:content="string:(no bibliographical information for ${docinfo/bib_type})"/> 3 <span tal:condition="formattedLabel" tal:content="structure formattedLabel"/> 4 </tal:block> 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3 <html xmlns="http://www.w3.org/1999/xhtml"> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 6 </head> 7 <body> 8 <!-- block used for page header content area --> 9 <metal:block metal:define-macro="main" 10 tal:define="docpath docinfo/textURLPath | nothing; 11 query here/REQUEST/query | nothing; 12 queryType here/REQUEST/queryType | nothing; 13 bib docinfo/bib | nothing; bibType docinfo/bibType | nothing; 14 formattedLabel python:here.metadataService.getBibFormattedLabel(bibdata=bib);"> 15 <span tal:condition="not:formattedLabel" 16 tal:content="string:(no bibliographical information for ${bibType})" /> 17 <span tal:condition="formattedLabel" tal:content="structure formattedLabel" /> 18 </metal:block> 19 </body> 20 </html> -
zpt/toc_thumbs.zpt
r122 r480 1 <div tal:define="docinfo options/docinfo; pageinfo options/pageinfo; 2 start pageinfo/start; end pageinfo/end; rows pageinfo/rows; cols pageinfo/cols; 3 current pageinfo/current; grpsize pageinfo/groupsize"> 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3 <html xmlns="http://www.w3.org/1999/xhtml"> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 6 </head> 7 <body> 8 <!-- block used for main content area --> 9 <div class="toc" metal:define-macro="main" 10 tal:define="start pageinfo/start; 11 grpsize pageinfo/groupsize; 12 numgroups pageinfo/numgroups; 13 pageBatch pageinfo/pageBatch; pageZero pageinfo/pageZero; 14 left python:test(flowLtr,pageBatch['prevStart'],pageBatch['nextStart']); 15 right python:test(flowLtr,pageBatch['nextStart'],pageBatch['prevStart']);"> 16 <ul class="toctype"> 17 <li class="sel"> 18 <a tal:attributes="href python:here.getLink('tocMode','thumbs')">Thumbnails</a> 19 </li> 20 <li tal:condition="python:docinfo.get('numTocEntries', None)"> 21 <a tal:attributes="href python:here.getLink('tocMode','text')">Content</a> 22 </li> 23 <li tal:condition="python:docinfo.get('numFigureEntries', None)"> 24 <a tal:attributes="href python:here.getLink('tocMode','figures')">Figures</a> 25 </li> 26 <li> 27 <a tal:attributes="href python:here.getLink('tocMode','none')">None</a> 28 </li> 29 </ul> 4 30 5 <div class="thumbruler"> 6 <span tal:condition="python:(start>1)"> 7 <a tal:attributes="href python:here.getLink(param='start',val=max(start-grpsize,1))"><</a> 8 </span> 9 <select tal:attributes="onChange python:'location.href=\''+here.getLink(param='start',val=None)+'&start=\'+this.options[this.selectedIndex].value'"> 10 <option tal:repeat="grp python:range(pageinfo['numgroups'])" 11 tal:attributes="selected python:(start==grp*grpsize+1); value python:(grp*grpsize+1)" 12 tal:content="python:(grp*grpsize+1)"/> 13 </select> 14 <span tal:condition="python:(start+grpsize<int(docinfo['numPages']))"> 15 <a tal:attributes="href python:here.getLink(param='start',val=start+grpsize)">></a> 16 </span> 17 </div> 18 <table> 19 <tr tal:repeat="row python:range(rows)"> 20 <tal:block tal:repeat="idx python:range(start+row*cols,start+(row+1)*cols)"> 21 <td align="center" tal:condition="python:(idx<=end)" 22 tal:attributes="class python:here.getStyle(idx,current,'thumb')"> 23 <a tal:attributes="href python:here.getLink(param='pn',val=idx)"> 24 <img class="thumbimg" border="0" tal:attributes="src string:${docinfo/imageURL}&pn=$idx&dw=100&dh=100"/> 25 <div class="thumbcap" tal:content="idx"/> 26 </a> 27 </td> 28 </tal:block> 29 </tr> 30 </table> 31 </div> 31 <div class="content"> 32 <div class="ruler"> 33 <form class="autosubmit" tal:attributes="action viewerUrl"> 34 <input type="hidden" tal:define="params python:here.getParams('start',None)" 35 tal:repeat="param params" 36 tal:attributes="name param; value python:params[param]" /> 37 <a tal:condition="left" tal:attributes="href python:here.getLink('start',left)"><</a> 38 <span tal:condition="not:left"><</span> 39 <select class="autosubmit" name="start" 40 tal:define="ofs python:test(pageinfo['pageZero'],0,1)"> 41 <tal:block tal:repeat="grp python:range(numgroups)"> 42 <option tal:define="idx python:max(grp*grpsize+ofs,1)" 43 tal:attributes="selected python:start==idx; value idx;" 44 tal:content="python:'%s - %s'%(idx,min((grp+1)*grpsize+ofs-1,numPages))" /> 45 </tal:block> 46 </select> 47 <input type="submit" value="Go" /> 48 <a tal:condition="right" tal:attributes="href python:here.getLink('start',right)">></a> 49 <span tal:condition="not:right">></span> 50 </form> 51 </div> 52 53 <table class="thumbs"> 54 <tr tal:repeat="row pageBatch/pages"> 55 <td tal:repeat="thumb row" 56 tal:attributes="class python:here.getStyle(thumb['idx'],pn,'thumb')"> 57 <a tal:define="idx thumb/idx" tal:condition="idx" 58 tal:attributes="href python:here.getLink('pn',idx)"> 59 <img 60 tal:attributes="src python:test(docinfo['imageURL'],here.getScalerUrl(pn=idx,dw=100,dh=100,docinfo=docinfo),'images/pic'); 61 alt idx" /><br/> 62 <span tal:content="idx" /> 63 </a> 64 </td> 65 </tr> 66 </table> 67 </div> <!-- content --> 68 </div> <!-- toc --> 69 </body> 70 </html> -
zpt/viewer_text.zpt
r479 r480 2 2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3 3 <html xmlns="http://www.w3.org/1999/xhtml" 4 tal:define="docinfo options/docinfo; pageinfo options/pageinfo; viewMode pageinfo/viewMode; tocMode pageinfo/tocMode"> 4 tal:define="docinfo options/docinfo; pageinfo options/pageinfo; viewMode pageinfo/viewMode; 5 tocMode pageinfo/tocMode; viewType pageinfo/viewType; viewerUrl docinfo/viewerUrl; 6 numPages docinfo/numPages | nothing;"> 5 7 <head> 6 8 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 7 9 <link rel="stylesheet" href="template/docuviewer_css" type="text/css"> 8 10 </head> 9 <body tal:condition="docinfo/numPages"> 10 <div tal:replace="structure python:here.template.head_main(docinfo=docinfo,viewMode=viewMode,pageinfo=pageinfo)"/> 11 <tal:block tal:condition="python:here.isAccessible(docinfo)"> 12 <table border="0" width="100%" height="100%"> 13 <tr> 14 <td width="300px" valign="top"> 15 <tal:block tal:replace="structure python:getattr(here.template, 'toc_%s'%tocMode)(docinfo=docinfo,pageinfo=pageinfo)"/> 16 </td> 17 <td width="100%" valign="top"> 18 <tal:block tal:content="structure python:getattr(here.template, 'page_main_%s'%viewMode)(docinfo=docinfo,pageinfo=pageinfo,mk=options['mk'])"/> 19 </td> 20 </tr> 21 </table> 22 </tal:block> 23 <tal:block tal:condition="not:python:here.isAccessible(docinfo)"> 24 <div class="errortext">Sorry, access to this document is restricted.</div> 25 </tal:block> 11 <body tal:condition="numPages"> 12 <tal:block tal:define="docpath docinfo/textURLPath; 13 pn pageinfo/pn; 14 flowLtr python:pageinfo.get('pageFlow','ltr')!='rtl'; 15 prev python:test(pn>1,pn-1,None); next python:test(pn<numPages,pn+1,None); 16 first python:test(pn>1,1,None); last python:test(pn<numPages,numPages,None); 17 left python:test(flowLtr,prev,next); right python:test(flowLtr,next,prev); 18 leftest python:test(flowLtr,first,last); rightest python:test(flowLtr,last,first); 19 textPage python:here.getTextPage(mode=viewType, pn=pn, docinfo=docinfo, pageinfo=pageinfo);"> 20 <div class="page_head" metal:use-macro="here/template/head_main/macros/main" /> 21 <div class="page_body" tal:condition="python:here.isAccessible(docinfo)"> 22 <!--table of contents--> 23 <div class="toc" 24 metal:use-macro="python:path('here/template/toc_%s/macros/main'%tocMode)" /> 25 <!-- text page --> 26 <div class="text"> 27 <div class="ruler"> 28 <form class="autosubmit pageruler" tal:attributes="action viewerUrl"> 29 <input type="hidden" tal:define="params python:here.getParams('pn', None)" 30 tal:repeat="param params" tal:attributes="name param; value python:params[param]" /> 31 page 32 <a tal:condition="leftest" tal:attributes="href python:here.getLink('pn',leftest)">|<</a> 33 <span tal:condition="not:leftest">|<</span> 34 <a tal:condition="left" tal:attributes="href python:here.getLink('pn',left)"><</a> 35 <span tal:condition="not:left"><</span> 36 <input class="autosubmit" size="3" type="text" name="pn" tal:attributes="value pn" /> 37 <tal:block tal:define="originalPage pageinfo/pageNumberOrig | nothing" 38 tal:condition="python:originalPage!=None"> 39 (<span tal:replace="originalPage"/><span tal:define="originalPageNorm pageinfo/pageNumberOrigNorm | nothing" tal:condition="python:originalPageNorm!=None">[<span tal:replace="originalPageNorm"/>]</span>) 40 </tal:block> 41 <input type="submit" value="Go" /> 42 of 43 <span tal:replace="numPages"/> 44 <a tal:condition="right" tal:attributes="href python:here.getLink('pn',right)">></a> 45 <span tal:condition="not:right">></span> 46 <a tal:condition="rightest" tal:attributes="href python:here.getLink('pn',rightest)">>|</a> 47 <span tal:condition="not:rightest">>|</span> 48 </form> 49 </div> 50 <div class="page"> 51 <div class="pageHeaderTitle" tal:condition="exists:pageinfo/pageHeaderTitle" tal:content="structure pageinfo/pageHeaderTitle"/> 52 <tal:block tal:replace="structure textPage"/> 53 </div> 54 </div> 55 </div> 56 <div class="page_body" tal:condition="python:not here.isAccessible(docinfo)"> 57 <div class="errortext">Sorry, access to this document is restricted.</div> 58 </div> 59 </tal:block> 26 60 </body> 27 <body tal:condition="not: docinfo/numPages">28 <div class="errortext">Sorry, document doesn't exist.</div>61 <body tal:condition="not:numPages"> 62 <div class="errortext">Sorry, document doesn't exist.</div> 29 63 </body> 30 64 </html>
Note: See TracChangeset
for help on using the changeset viewer.