changeset 489:55e3398e395e elementtree

more new templates. monkey-patch for App.ImageFile.
author casties
date Thu, 25 Aug 2011 17:05:22 +0200
parents ec3d848fe9e8
children 6f116b86a226
files css/docuviewer.css documentViewer.py zpt/head_main.zpt zpt/toc_figures.zpt zpt/toc_text.zpt zpt/toc_thumbs.zpt zpt/viewer_images.zpt zpt/viewer_text.zpt
diffstat 8 files changed, 25 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/css/docuviewer.css	Wed Aug 24 10:58:20 2011 +0200
+++ b/css/docuviewer.css	Thu Aug 25 17:05:22 2011 +0200
@@ -15,7 +15,7 @@
     vertical-align: top;
 }
 
-div.col-left.text {
+div.toc-text, div.toc-figures {
     max-width: 20em;
 }
 
--- a/documentViewer.py	Wed Aug 24 10:58:20 2011 +0200
+++ b/documentViewer.py	Thu Aug 25 17:05:22 2011 +0200
@@ -2,6 +2,7 @@
 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 from App.ImageFile import ImageFile
+from App.Common import rfc1123_date
 #from Products.ZSimpleFile.ZSimpleFile import ZSimpleFile
 from AccessControl import ClassSecurityInfo
 from AccessControl import getSecurityManager
@@ -9,7 +10,8 @@
 
 import xml.etree.ElementTree as ET
 
-import os.path
+import os
+import stat
 import sys
 import urllib
 import logging
@@ -104,6 +106,14 @@
     # split by /, shorten, and reassemble
     return '/'.join(path.split('/')[0:-cnt])
 
+def devImageFileIndexHtml(self, REQUEST, RESPONSE):
+    """index_html method for App.ImageFile that updates the file info for each request."""
+    stat_info = os.stat(self.path)
+    self.size = stat_info[stat.ST_SIZE]
+    self.lmt = float(stat_info[stat.ST_MTIME]) or time.time()
+    self.lmh = rfc1123_date(self.lmt)
+    # call original method
+    return ImageFile.index_html(self, REQUEST, RESPONSE)
 
 ##
 ## documentViewer class
@@ -136,8 +146,9 @@
     page_main_pureXml = PageTemplateFile('zpt/page_main_pureXml', globals())
     head_main = PageTemplateFile('zpt/head_main', globals())
     info_xml = PageTemplateFile('zpt/info_xml', globals())
-    # TODO: can this be nicer?
     docuviewer_css = ImageFile('css/docuviewer.css',globals())
+    # make ImageFile better for development
+    docuviewer_css.index_html = devImageFileIndexHtml
     
     
     thumbs_main_rss = PageTemplateFile('zpt/thumbs_main_rss', globals())
--- a/zpt/head_main.zpt	Wed Aug 24 10:58:20 2011 +0200
+++ b/zpt/head_main.zpt	Thu Aug 25 17:05:22 2011 +0200
@@ -12,9 +12,9 @@
                queryType here/REQUEST/queryType | nothing;
                bib docinfo/bib | nothing; bibType docinfo/bibType | nothing;
                formattedLabel python:here.metadataService.getBibFormattedLabel(bibdata=bib);">
-    <span tal:condition="not:formattedLabel"
+    <div tal:condition="not:formattedLabel"
       tal:content="string:(no bibliographical information for ${bibType})" />
-    <span tal:condition="formattedLabel" tal:content="structure formattedLabel" />
+    <div tal:condition="formattedLabel" tal:content="structure formattedLabel" />
   </metal:block>
 </body>
 </html>
--- a/zpt/toc_figures.zpt	Wed Aug 24 10:58:20 2011 +0200
+++ b/zpt/toc_figures.zpt	Thu Aug 25 17:05:22 2011 +0200
@@ -6,7 +6,7 @@
 </head>
 <body>
   <!-- block used for main content area -->
-  <div class="col-left" metal:define-macro="main"
+  <div class="toc-figures" metal:define-macro="main"
     tal:define="start pageinfo/start; tocsize docinfo/tocSize_figures; grpsize pageinfo/tocPageSize;
                 batch python:here.getBatch(start=start,size=grpsize,end=tocsize);">
     <ul class="switcher">
--- a/zpt/toc_text.zpt	Wed Aug 24 10:58:20 2011 +0200
+++ b/zpt/toc_text.zpt	Thu Aug 25 17:05:22 2011 +0200
@@ -6,7 +6,7 @@
 </head>
 <body>
   <!-- block used for main content area -->
-  <div class="col-left" metal:define-macro="main"
+  <div class="toc-text" metal:define-macro="main"
     tal:define="start pageinfo/start; tocsize docinfo/tocSize_text; grpsize pageinfo/tocPageSize;
                 batch python:here.getBatch(start=start,size=grpsize,end=tocsize);">
     <ul class="switcher">
--- a/zpt/toc_thumbs.zpt	Wed Aug 24 10:58:20 2011 +0200
+++ b/zpt/toc_thumbs.zpt	Thu Aug 25 17:05:22 2011 +0200
@@ -6,7 +6,7 @@
 </head>
 <body>
   <!-- block used for main content area -->
-  <div class="col-left" metal:define-macro="main"
+  <div class="toc-thumbs" metal:define-macro="main"
     tal:define="start pageinfo/start;
                 grpsize pageinfo/groupsize;
                 numgroups pageinfo/numgroups;
--- a/zpt/viewer_images.zpt	Wed Aug 24 10:58:20 2011 +0200
+++ b/zpt/viewer_images.zpt	Thu Aug 25 17:05:22 2011 +0200
@@ -53,7 +53,9 @@
     <div class="page-head" metal:use-macro="here/template/head_main/macros/main" />
     <div class="page-body" tal:condition="python:here.isAccessible(docinfo)">
       <!--table of contents-->
-      <div class="col-left" metal:use-macro="python:path('here/template/toc_%s/macros/main'%tocMode)" />
+      <div class="col-left">
+        <metal:block metal:use-macro="python:path('here/template/toc_%s/macros/main'%tocMode)" />
+      </div>
       <!-- text page -->
       <div class="col-main">
         <div class="ruler">
--- a/zpt/viewer_text.zpt	Wed Aug 24 10:58:20 2011 +0200
+++ b/zpt/viewer_text.zpt	Thu Aug 25 17:05:22 2011 +0200
@@ -21,8 +21,9 @@
   <div class="page-head" metal:use-macro="here/template/head_main/macros/main" />
   <div class="page-body" tal:condition="python:here.isAccessible(docinfo)">
     <!--table of contents-->
-    <div class="col-left"
-      metal:use-macro="python:path('here/template/toc_%s/macros/main'%tocMode)" />
+    <div class="col-left">
+      <metal:block metal:use-macro="python:path('here/template/toc_%s/macros/main'%tocMode)" />
+    </div>
 
     <!-- text page -->
     <div class="col-main">