changeset 543:6cdc31e9ed8e

fixed problem with dict-mode in default view. added configurable footer and logo in site_template.pt
author casties
date Wed, 22 Aug 2012 16:25:38 +0200
parents dbaa7dce60a5
children 6c529ec1b295
files css/docuviewer.css documentViewer.py version.txt zpt/common_template.zpt zpt/layer_text_gis.zpt zpt/viewer_images.zpt zpt/viewer_index.zpt zpt/viewer_text.zpt zpt/viewer_thumbs.zpt zpt/viewer_xml.zpt
diffstat 10 files changed, 108 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/css/docuviewer.css	Tue Aug 21 13:28:35 2012 +0200
+++ b/css/docuviewer.css	Wed Aug 22 16:25:38 2012 +0200
@@ -252,7 +252,10 @@
     font-size: 14px;
 	line-height: 1.3;
 }
-
+div.col.main div.content.text div.emptyPage {
+    font-family: Verdana,Arial,sans-serif;
+    font-size: 12px;
+}
 /*
  * search results
  */
@@ -325,8 +328,6 @@
 	display: none;
 }
 
-
-
 /*
  * thumbnail overview
  */
@@ -337,3 +338,23 @@
 div.col.main table.thumbs td {
 	text-align: center;
 }
+
+/*
+ * footer
+ */
+div.footer {
+    max-width: 68em;
+	margin-top: 1em;
+	border-top: 1px solid silver;
+	margin-left: 28px;
+	margin-right: 28px;
+	text-align: center;
+}
+div.footer div.content {
+	font-size: 10px;
+	color: grey;	
+}
+div.footer div.content a:link,
+div.footer div.content a:visited {
+	color: grey;
+}
\ No newline at end of file
--- a/documentViewer.py	Tue Aug 21 13:28:35 2012 +0200
+++ b/documentViewer.py	Wed Aug 22 16:25:38 2012 +0200
@@ -260,11 +260,11 @@
     security.declareProtected('View','index_html')
     def index_html(self,url,mode="texttool",viewMode="auto",viewLayer=None,tocMode="thumbs",start=1,pn=1):
         """
-        view page
+        show page
         @param url: url which contains display information
         @param mode: defines how to access the document behind url 
         @param viewMode: 'images': display images, 'text': display text, 'xml': display xml, default is 'auto'
-        @param viewLayer: sub-type of viewMode, e.g. 'dict' for viewMode='text'
+        @param viewLayer: sub-type of viewMode, e.g. layer 'dict' for viewMode='text'
         @param tocMode: type of 'table of contents' for navigation (thumbs, text, figures, none)
         """
         
@@ -278,14 +278,19 @@
         if not getattr(self, 'digilibBaseUrl', None):
             self.digilibBaseUrl = self.findDigilibUrl() or "http://digilib.mpiwg-berlin.mpg.de/digitallibrary"
             
+        # docinfo: information about document (cached)
         docinfo = self.getDocinfo(mode=mode,url=url,tocMode=tocMode)
         
+        # userinfo: user settings (cached)
+        userinfo = self.getUserinfo()
+        
         # auto viewMode: text if there is a text else images
         if viewMode=="auto": 
             if docinfo.get('textURLPath', None):
                 # docinfo.get('textURL', None) not implemented yet
                 viewMode = "text"
-                if viewLayer is None:
+                if viewLayer is None and 'viewLayer' not in userinfo:
+                    # use layer dict as default 
                     viewLayer = "dict"
             else:
                 viewMode = "images"
@@ -295,7 +300,11 @@
             viewMode = "text"
             viewLayer = "dict"
             
-        pageinfo = self.getPageinfo(start=start, current=pn, docinfo=docinfo, viewMode=viewMode, viewLayer=viewLayer, tocMode=tocMode)
+        # safe viewLayer in userinfo
+        userinfo['viewLayer'] = viewLayer
+        
+        # pageinfo: information about page (not cached)
+        pageinfo = self.getPageinfo(start=start, current=pn, docinfo=docinfo, userinfo=userinfo, viewMode=viewMode, viewLayer=viewLayer, tocMode=tocMode)
                     
         # get template /template/viewer_$viewMode
         pt = getattr(self.template, 'viewer_%s'%viewMode, None)
@@ -494,6 +503,20 @@
         return False
 
 
+    def getUserinfo(self):
+        """returns userinfo object"""
+        logging.debug("getUserinfo")
+        userinfo = {}
+        # look for cached userinfo in session
+        if self.REQUEST.SESSION.has_key('userinfo'):
+            userinfo = self.REQUEST.SESSION['userinfo']
+            # check if its still current?
+        else:
+            # store in session
+            self.REQUEST.SESSION['userinfo'] = userinfo
+            
+        return userinfo
+
     def getDocinfo(self, mode, url, tocMode=None):
         """returns docinfo depending on mode"""
         logging.debug("getDocinfo: mode=%s, url=%s"%(mode,url))
@@ -771,7 +794,7 @@
         return docinfo
     
 
-    def getPageinfo(self, current=None, start=None, rows=None, cols=None, docinfo=None, viewMode=None, viewLayer=None, tocMode=None):
+    def getPageinfo(self, current=None, start=None, rows=None, cols=None, docinfo=None, userinfo=None, viewMode=None, viewLayer=None, tocMode=None):
         """returns pageinfo with the given parameters"""
         logging.debug("getPageInfo(current=%s, start=%s, rows=%s, cols=%s, viewMode=%s, viewLayer=%s, tocMode=%s)"%(current,start,rows,cols,viewMode,viewLayer,tocMode))
         pageinfo = {}
--- a/version.txt	Tue Aug 21 13:28:35 2012 +0200
+++ b/version.txt	Wed Aug 22 16:25:38 2012 +0200
@@ -1,1 +1,1 @@
-DocumentViewer 2.2.0
\ No newline at end of file
+DocumentViewer 2.2.2
\ No newline at end of file
--- a/zpt/common_template.zpt	Tue Aug 21 13:28:35 2012 +0200
+++ b/zpt/common_template.zpt	Wed Aug 22 16:25:38 2012 +0200
@@ -11,8 +11,8 @@
                 docpath docinfo/textURLPath | nothing;
                 bib docinfo/bib | nothing; bibType docinfo/bibType | nothing;
                 formattedLabel python:here.metadataService.getBibFormattedLabel(bibdata=bib);">
-    <div class="logo" tal:condition="exists:here/template/logo.png">
-      <img tal:attributes="src here/template/logo.png/absolute_url" />
+    <div class="logo" tal:condition="exists:here/template/site_template.pt/macros/logo">
+      <metal:block metal:use-macro="here/template/site_template.pt/macros/logo"/>
     </div>
     <div class="title-block">
       <div class="title" tal:condition="not:formattedLabel">
--- a/zpt/layer_text_gis.zpt	Tue Aug 21 13:28:35 2012 +0200
+++ b/zpt/layer_text_gis.zpt	Wed Aug 22 16:25:38 2012 +0200
@@ -30,7 +30,8 @@
             places python:here.getPlacesOnPage(docinfo=docinfo, pn=pn);
             pidlist python:','.join([p['id'] for p in places]);">
         <h4>Places</h4>
-        <ul>
+        Show all places
+        <ul class="list">
           <li>
             <a
               tal:attributes="href python:'http://mappit.mpiwg-berlin.mpg.de/db/RESTdb/db/mpdl/%s?id=%s&format=gis'%(name,pidlist)"
--- a/zpt/viewer_images.zpt	Tue Aug 21 13:28:35 2012 +0200
+++ b/zpt/viewer_images.zpt	Wed Aug 22 16:25:38 2012 +0200
@@ -110,9 +110,18 @@
     <div class="page-body" tal:condition="python:not here.isAccessible(docinfo)">
       <div class="errortext">Sorry, access to this document is restricted.</div>
     </div>
+    <tal:block tal:condition="exists:here/template/site_template.pt/macros/footer">
+      <!-- footer -->
+      <metal:block metal:use-macro="here/template/site_template.pt/macros/footer"/>
+    </tal:block>
+    
   </tal:block>
 </body>
 <body tal:condition="not:numPages">
   <div class="errortext">Sorry, document doesn't exist.</div>
+  <tal:block tal:condition="exists:here/template/site_template.pt/macros/footer">
+    <!-- footer -->
+    <metal:block metal:use-macro="here/template/site_template.pt/macros/footer"/>
+  </tal:block>
 </body>
 </html>
--- a/zpt/viewer_index.zpt	Tue Aug 21 13:28:35 2012 +0200
+++ b/zpt/viewer_index.zpt	Wed Aug 22 16:25:38 2012 +0200
@@ -127,12 +127,11 @@
         (copyright and license see below)
       </div>
 
-      <div class="options">
+      <div class="options" tal:condition="docpath">
         <h4>Search</h4>
         <form tal:define="queryType string:fulltextMorph" tal:condition="docpath" tal:attributes="action viewerUrl">
-          <input type="hidden" tal:define="params python:here.getParams(params={'query':None,'queryType':None,'viewMode':None,'viewLayer':None})"
-            tal:repeat="param params" tal:attributes="name param; value python:params[param]" /> <input type="hidden"
-            name="viewLayer" value="search" />
+          <input type="hidden" tal:define="params python:here.getParams(params={'query':None,'queryType':None,'viewMode':None,'viewLayer':'search'})"
+            tal:repeat="param params" tal:attributes="name param; value python:params[param]" />
           <!-- query text -->
           <input type="text" name="query" tal:attributes="value query" /> <br /> <input type="submit" value="Search" /> <a
             tal:condition="query" tal:attributes="href python:here.getLink('query',None)">Clear</a>
@@ -149,23 +148,19 @@
         </form>
       </div>
       <!-- end search options-->
-      <!--BEGIN search
-          <form tal:define="queryType string:fulltextMorph" tal:condition="docpath" tal:attributes="action python:here.getLink()">
-            <input type="hidden" tal:define="params python:here.getParams('viewMode', None)" tal:repeat="param params"
-              tal:attributes="name param; value python:params[param]" /> <input type="hidden" name="viewLayer" value="search" />
-            <input type="text" name="query" tal:attributes="value query" /> <input type="submit" value="Search full document" /> <a
-              tal:condition="query" tal:attributes="href python:here.getLink('query',None)">Clear</a><br /> <input type="radio"
-              name="queryType" value="fulltext" tal:attributes="checked python:queryType=='fulltext'" /> Exact <input type="radio"
-              name="queryType" value="fulltextMorph" tal:attributes="checked python:queryType=='fulltextMorph'" /> All forms <input
-              type="radio" name="queryType" value="ftIndex" tal:attributes="checked python:queryType=='ftIndex'" /> Fulltext index
-            <input type="radio" name="queryType" value="ftIndexMorph" tal:attributes="checked python:queryType=='ftIndexMorph'" />
-            Morphological index
-          </form>
-          END search-->
     </div>
   </div>
+  <tal:block tal:condition="exists:here/template/site_template.pt/macros/footer">
+    <!-- footer -->
+    <metal:block metal:use-macro="here/template/site_template.pt/macros/footer"/>
+  </tal:block>
+  
 </body>
 <body tal:condition="not:numPages">
   <div class="errortext">Sorry, document doesn't exist.</div>
+  <tal:block tal:condition="exists:here/template/site_template.pt/macros/footer">
+    <!-- footer -->
+    <metal:block metal:use-macro="here/template/site_template.pt/macros/footer"/>
+  </tal:block>
 </body>
 </html>
\ No newline at end of file
--- a/zpt/viewer_text.zpt	Tue Aug 21 13:28:35 2012 +0200
+++ b/zpt/viewer_text.zpt	Wed Aug 22 16:25:38 2012 +0200
@@ -14,7 +14,7 @@
 <!--[if IE]><link rel="stylesheet" href="template/docuviewer_ie_css" type="text/css" /><![endif]-->
 <script type="text/javascript" tal:attributes="src string:$rootUrl/template/jquery_js"></script>
 <script type="text/javascript">
-	// <!--
+// <!--
 	$(document).ready(function() {
 		// autosubmit forms
 		$('form.autosubmit').find('.autosubmit').change(function() {
@@ -37,7 +37,7 @@
     tal:define="docpath docinfo/textURLPath | nothing;
                 pn pageinfo/pn; 
                 flowLtr python:docinfo.get('pageFlow','ltr')!='rtl';
-                textPage python:here.getTextPage(mode=viewLayer, pn=pn, docinfo=docinfo, pageinfo=pageinfo) or '[no text here]';">
+                textPage python:here.getTextPage(mode=viewLayer, pn=pn, docinfo=docinfo, pageinfo=pageinfo);">
     <!-- header -->
     <div class="page-head">
       <metal:block metal:use-macro="here/template/common_template/macros/head" />
@@ -54,10 +54,11 @@
         <div class="ruler top">
           <metal:block metal:use-macro="here/template/common_template/macros/page_ruler" />
         </div>
-        <div class="content text">
+        <div class="content text" tal:condition="textPage">
           <div class="pageHeaderTitle" tal:condition="exists:pageinfo/pageHeaderTitle"
             tal:content="structure pageinfo/pageHeaderTitle" />
-          <tal:block tal:replace="structure textPage" />
+          <tal:block tal:condition="textPage" tal:replace="structure textPage"/>
+          <div class="emptyPage" tal:condition="not:textPage">[Empty page]</div>
         </div>
       </div>
       <!-- end of col-main -->
@@ -139,10 +140,18 @@
     <div class="page-body" tal:condition="python:not here.isAccessible(docinfo)">
       <div class="errortext">Sorry, access to this document is restricted.</div>
     </div>
-
+    
+    <tal:block tal:condition="exists:here/template/site_template.pt/macros/footer">
+      <!-- footer -->
+      <metal:block metal:use-macro="here/template/site_template.pt/macros/footer"/>
+    </tal:block>
   </tal:block>
 </body>
 <body tal:condition="not:numPages">
   <div class="errortext">Sorry, document doesn't exist.</div>
+    <tal:block tal:condition="exists:here/template/site_template.pt/macros/footer">
+      <!-- footer -->
+      <metal:block metal:use-macro="here/template/site_template.pt/macros/footer"/>
+    </tal:block>
 </body>
 </html>
--- a/zpt/viewer_thumbs.zpt	Tue Aug 21 13:28:35 2012 +0200
+++ b/zpt/viewer_thumbs.zpt	Wed Aug 22 16:25:38 2012 +0200
@@ -95,9 +95,17 @@
     <div class="page-body" tal:condition="python:not here.isAccessible(docinfo)">
       <div class="errortext">Sorry, access to this document is restricted.</div>
     </div>
+    <tal:block tal:condition="exists:here/template/site_template.pt/macros/footer">
+      <!-- footer -->
+      <metal:block metal:use-macro="here/template/site_template.pt/macros/footer"/>
+    </tal:block>
   </tal:block>
 </body>
 <body tal:condition="not:numPages">
   <div class="errortext">Sorry, document doesn't exist.</div>
+  <tal:block tal:condition="exists:here/template/site_template.pt/macros/footer">
+    <!-- footer -->
+    <metal:block metal:use-macro="here/template/site_template.pt/macros/footer"/>
+  </tal:block>
 </body>
 </html>
\ No newline at end of file
--- a/zpt/viewer_xml.zpt	Tue Aug 21 13:28:35 2012 +0200
+++ b/zpt/viewer_xml.zpt	Wed Aug 22 16:25:38 2012 +0200
@@ -82,9 +82,17 @@
       <div class="errortext">Sorry, access to this document is restricted.</div>
     </div>
 
+    <tal:block tal:condition="exists:here/template/site_template.pt/macros/footer">
+      <!-- footer -->
+      <metal:block metal:use-macro="here/template/site_template.pt/macros/footer"/>
+    </tal:block>
   </tal:block>
 </body>
 <body tal:condition="not:numPages">
   <div class="errortext">Sorry, document doesn't exist.</div>
+  <tal:block tal:condition="exists:here/template/site_template.pt/macros/footer">
+    <!-- footer -->
+    <metal:block metal:use-macro="here/template/site_template.pt/macros/footer"/>
+  </tal:block>
 </body>
 </html>