changeset 571:f1906951be2a

nicer batching of tocs
author casties
date Fri, 12 Oct 2012 17:02:40 +0200
parents 61d53ccbdd70
children 51800c42bcda
files documentViewer.py zpt/common_template.zpt zpt/viewer_text.zpt
diffstat 3 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/documentViewer.py	Fri Oct 12 16:01:41 2012 +0200
+++ b/documentViewer.py	Fri Oct 12 17:02:40 2012 +0200
@@ -979,6 +979,8 @@
             batch['nextStart'] = None
 
         batch['pages'] = pages
+        batch['first'] = minIdx
+        batch['last'] = maxIdx
         return batch
         
     def getBatch(self, start=1, size=10, end=0, data=None, fullData=True):
@@ -1023,7 +1025,8 @@
         else:
             batch['nextStart'] = None
         
-        logging.debug("getBatch start=%s size=%s end=%s batch=%s"%(start,size,end,repr(batch)))
+        batch['first'] = start
+        batch['last'] = end
         return batch
         
 
--- a/zpt/common_template.zpt	Fri Oct 12 16:01:41 2012 +0200
+++ b/zpt/common_template.zpt	Fri Oct 12 17:02:40 2012 +0200
@@ -77,8 +77,9 @@
         tal:attributes="name param; value python:params[param]" /> <a tal:condition="batch/prevStart"
         tal:attributes="href python:here.getLink(startParam,batch['prevStart'])">&lt;</a> <span tal:condition="not:batch/prevStart">&lt;</span>
       <select class="autosubmit" tal:attributes="name startParam">
-        <option tal:repeat="grp batch/batches" tal:attributes="selected python:(start==grp['start']); value grp/start"
+        <option tal:repeat="grp batch/batches" tal:attributes="selected python:(start>=grp['start'] and start<=grp['end']); value grp/start"
           tal:content="string:${grp/start} - ${grp/end}" />
+        <option tal:condition="python:start>batch['last']" selected="selected" value="1">[out of range]</option>
       </select> <input type="submit" value="Go" /> <a tal:condition="batch/nextStart"
         tal:attributes="href python:here.getLink(startParam,batch['nextStart'])">&gt;</a> <span tal:condition="not:batch/nextStart">&gt;</span>
     </form>
@@ -92,8 +93,9 @@
         tal:attributes="href python:here.getLink('start',left)">&lt;</a> <span tal:condition="not:left">&lt;</span> <select
         class="autosubmit" name="start" tal:define="ofs python:test(pageinfo['pageZero'],0,1)">
           <tal:block>
-            <option tal:repeat="grp pageBatch/batches" tal:attributes="selected python:start==grp['start']; value grp/start;"
+            <option tal:repeat="grp pageBatch/batches" tal:attributes="selected python:(start>=grp['start'] and start<=grp['end']); value grp/start;"
               tal:content="string:${grp/start} - ${grp/end}" />
+            <option tal:condition="python:start>pageBatch['last']" selected="selected" value="1">[out of range]</option>
           </tal:block>
       </select> <input type="submit" value="Go" /> <a tal:condition="right" tal:attributes="href python:here.getLink('start',right)">&gt;</a>
         <span tal:condition="not:right">&gt;</span></span>
--- a/zpt/viewer_text.zpt	Fri Oct 12 16:01:41 2012 +0200
+++ b/zpt/viewer_text.zpt	Fri Oct 12 17:02:40 2012 +0200
@@ -58,7 +58,7 @@
           <div class="pageHeaderTitle" tal:condition="exists:pageinfo/pageHeaderTitle"
             tal:content="structure pageinfo/pageHeaderTitle" />
           <tal:block tal:condition="textPage" tal:replace="structure textPage"/>
-          <div class="emptyPage" tal:condition="not:textPage">[Error: no page]</div>
+          <div class="emptyPage" tal:condition="not:textPage">[Error: no text]</div>
         </div>
       </div>
       <!-- end of col-main -->