changeset 559:eabfbad6aeb4

"extended" layer for index view and some bugfixes.
author casties
date Fri, 28 Sep 2012 18:50:59 +0200
parents 6ab436383fca
children 04c330b92cab
files MpdlXmlTextServer.py documentViewer.py zpt/layer_index_extended.zpt zpt/viewer_index.zpt zpt/viewer_text.zpt
diffstat 5 files changed, 92 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/MpdlXmlTextServer.py	Fri Sep 28 11:25:25 2012 +0200
+++ b/MpdlXmlTextServer.py	Fri Sep 28 18:50:59 2012 +0200
@@ -52,6 +52,17 @@
         return getHttpData(url,data,timeout=self.timeout)
 
 
+    def getTextDownloadUrl(self, type='xml', docinfo=None):
+        """returns a URL to download the current text"""
+        docpath = docinfo.get('textURLPath', None)
+        if not docpath:
+            return None
+
+        docpath = docpath.replace('.xml','.'+type)
+        url = '%sgetDoc?doc=%s'%(self.serverUrl.replace('interface/',''), docpath)
+        return url
+
+
     def getPlacesOnPage(self, docinfo=None, pn=None):
         """Returns list of GIS places of page pn"""
         docpath = docinfo.get('textURLPath',None)
--- a/documentViewer.py	Fri Sep 28 11:25:25 2012 +0200
+++ b/documentViewer.py	Fri Sep 28 18:50:59 2012 +0200
@@ -136,6 +136,7 @@
     layer_text_annotator = PageTemplateFile('zpt/layer_text_annotator', globals())
     layer_text_gis = PageTemplateFile('zpt/layer_text_gis', globals())
     layer_text_pundit = PageTemplateFile('zpt/layer_text_pundit', globals())
+    layer_index_extended = PageTemplateFile('zpt/layer_index_extended', globals())
     # toc templates
     toc_thumbs = PageTemplateFile('zpt/toc_thumbs', globals())
     toc_text = PageTemplateFile('zpt/toc_text', globals())
@@ -218,6 +219,10 @@
         """returns one page of the table of contents"""
         return self.template.fulltextclient.getTocPage(**args)
 
+    def getTextDownloadUrl(self, **args):
+        """get list of gis places on one page"""
+        return self.template.fulltextclient.getTextDownloadUrl(**args)
+ 
     def getPlacesOnPage(self, **args):
         """get list of gis places on one page"""
         return self.template.fulltextclient.getPlacesOnPage(**args)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zpt/layer_index_extended.zpt	Fri Sep 28 18:50:59 2012 +0200
@@ -0,0 +1,27 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<!-- redefine formatted data -->
+<metal:block metal:define-macro="html_head">
+  <tal:block tal:condition="python:'extended' in viewLayers">
+    <tal:block tal:define="global formattedData python:here.metadata.getBibFormattedMetaDataExtended(bibdata=docinfo.get('bib', None),bibxdata=docinfo.get('bibx', None));"/>
+  </tal:block>
+</metal:block>
+</head>
+<body>
+  <!-- right-side options -->
+  <div class="col buttons">
+    <!-- LAYER DISPLAY OPTION  -->
+    <ul>
+      <metal:block metal:define-macro="layer_select_li">
+        <li>
+          <input type="checkbox" class="autosubmit" name="viewLayer" value="extended"
+            tal:attributes="checked python:'extended' in viewLayers" /> All entries
+        </li>
+      </metal:block>
+    </ul>
+  </div>
+</body>
+
+</html>
--- a/zpt/viewer_index.zpt	Fri Sep 28 11:25:25 2012 +0200
+++ b/zpt/viewer_index.zpt	Fri Sep 28 18:50:59 2012 +0200
@@ -7,14 +7,27 @@
                   availableLayers python:here.getAvailableLayers().get('index', None);
                   docpath docinfo/textURLPath | nothing;
                   query nothing;
-                  numPages docinfo/numPages | nothing;">
+                  numPages docinfo/numPages | nothing;
+                  global formattedData python:here.metadata.getBibFormattedMetaData(bibdata=docinfo.get('bib', None));">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title tal:content="python:docinfo.get('creator',' ') + ' - ' + docinfo.get('title',' ')" />
-<link rel="stylesheet" href="template/docuviewer_css" type="text/css" />
-<!--  layer headers (rendered always) -->
+<link rel="stylesheet" tal:attributes="href string:$viewerUrl/template/docuviewer_css" type="text/css" />
+<script type="text/javascript" tal:attributes="src string:$viewerUrl/template/jquery_js"></script>
+<script type="text/javascript">
+// <!--
+  $(document).ready(function() {
+    // autosubmit forms
+    $('form.autosubmit').find('.autosubmit').change(function() {
+      this.form.submit();
+    });
+    $('form.autosubmit input[type="submit"]').hide();
+  });
+// -->
+</script>
+<!--  layer headers (all available) -->
 <tal:block tal:repeat="layer availableLayers">
-  <tal:block tal:define="mpath string:here/template/layer_text_${layer}/macros/html_head" tal:condition="python:exists(mpath)">
+  <tal:block tal:define="mpath string:here/template/layer_index_${layer}/macros/html_head" tal:condition="python:exists(mpath)">
     <metal:block metal:use-macro="python:path(mpath)" />
   </tal:block>
 </tal:block>
@@ -37,10 +50,10 @@
     </div>
 
     <div class="col main">
+     <!-- main content column --> 
       <div class="index-info">
         <h2>Bibliographic information</h2>
-        <table border="0"
-          tal:define="formattedData python:here.metadata.getBibFormattedMetaDataExtended(bibdata=docinfo.get('bib', None),bibxdata=docinfo.get('bibx', None))">
+        <table border="0">
           <tal:x condition="python:formattedData">
             <!-- wenn es bibinfo in docinfo gibt -->
             <tr tal:replace="structure python:formattedData" />
@@ -81,11 +94,11 @@
               <td class="type">Document ID:</td>
               <td class="content" tal:content="dri" />
             </tr>
-            <tr>
+            <!-- <tr>
               <td class="type">Permanent URL:</td>
               <td class="content"><a target="_blank" tal:attributes="href string:http://echo.mpiwg-berlin.mpg.de/$dri"
                 tal:content="string:http://echo.mpiwg-berlin.mpg.de/$dri" /></td>
-            </tr>
+            </tr> -->
           </table>
         </tal:block>
 
@@ -113,26 +126,10 @@
           </table>
         </tal:block>
       </div>
-    </div>
+    </div> <!-- /main content column --> 
+    
     <div class="col buttons">
-      <div class="options">
-        <h4>Metadata</h4>
-        <form tal:attributes="action viewerUrl" class="autosubmit">
-          <input type="hidden" tal:define="params python:here.getParams(params={'viewLayer':None,'viewMode':None})"
-            tal:repeat="param params" tal:attributes="name param; value python:params[param]" />
-          <ul>
-            <!-- text layer select buttons (rendered always) -->
-            <tal:block tal:repeat="layer availableLayers">
-              <tal:block tal:define="mpath string:here/template/layer_text_${layer}/macros/layer_select_li"
-                tal:condition="python:exists(mpath)">
-                <li metal:use-macro="python:path(mpath)" />
-              </tal:block>
-            </tal:block>
-          </ul>
-          <input type="submit" value="Go!" />
-        </form>
-      </div>
-
+      <!-- option block column --> 
       <div class="options">
         <h4>Browse</h4>
         <ul class="list">
@@ -144,11 +141,11 @@
         <h4>Download</h4>
         Download full document
         <ul class="list">
-          <li><a target="_blank"
-            tal:attributes="href python:'http://mpdl-system.mpiwg-berlin.mpg.de/mpdl/getDoc?doc=%s'%(docpath.replace('.xml','.html'))"
+          <li><a target="_blank" rel="nofollow" class="download"
+            tal:attributes="href python:here.getTextDownloadUrl(type='html',docinfo=docinfo)"
             target="_blank">as HTML</a></li>
-          <li><a target="_blank"
-            tal:attributes="href python:'http://mpdl-system.mpiwg-berlin.mpg.de/mpdl/getDoc?doc=%s'%(docpath)" target="_blank">as
+          <li><a target="_blank" rel="nofollow" class="download"
+            tal:attributes="href python:here.getTextDownloadUrl(type='xml',docinfo=docinfo)" target="_blank">as
               XML</a></li>
         </ul>
         (copyright and license see below)
@@ -175,8 +172,25 @@
           </ul>
         </form>
       </div>
-      <!-- end search options-->
-    </div>
+
+      <div class="options" tal:condition="availableLayers">
+        <h4>Metadata</h4>
+        <form tal:attributes="action viewerUrl" class="autosubmit">
+          <input type="hidden" tal:define="params python:here.getParams(params={'viewLayer':None})"
+            tal:repeat="param params" tal:attributes="name param; value python:params[param]" />
+          <ul>
+            <!-- text layer select buttons (rendered always) -->
+            <tal:block tal:repeat="layer availableLayers">
+              <tal:block tal:define="mpath string:here/template/layer_index_${layer}/macros/layer_select_li"
+                tal:condition="python:exists(mpath)">
+                <li metal:use-macro="python:path(mpath)" />
+              </tal:block>
+            </tal:block>
+          </ul>
+          <input type="submit" value="Go!" />
+        </form>
+      </div>
+    </div> <!-- /option block column -->     
   </div>
   <tal:block tal:condition="exists:here/template/site_template.pt/macros/footer">
     <!-- footer -->
--- a/zpt/viewer_text.zpt	Fri Sep 28 11:25:25 2012 +0200
+++ b/zpt/viewer_text.zpt	Fri Sep 28 18:50:59 2012 +0200
@@ -74,10 +74,10 @@
       <!-- right-side options -->
       <div class="col buttons">
         <!--"BEGIN TEXT DISPLAY"  -->
-        <div class="options">
+        <div class="options" tal:condition="availableLayers">
           <h4>Text layer</h4>
           <form tal:attributes="action viewerUrl" class="autosubmit">
-            <input type="hidden" tal:define="params python:here.getParams(params={'viewLayer':None,'viewMode':None})"
+            <input type="hidden" tal:define="params python:here.getParams(params={'viewLayer':None})"
               tal:repeat="param params" tal:attributes="name param; value python:params[param]" />
             <ul>
               <!-- text layer select buttons (rendered always) -->