diff zpt/viewer_text.zpt @ 525:70c3ae5eac7c

layers can have their own templates. first version of annotations layer.
author casties
date Thu, 05 Apr 2012 19:29:50 +0200
parents c55e376be01b
children 3f375a048402
line wrap: on
line diff
--- a/zpt/viewer_text.zpt	Thu Apr 05 14:56:01 2012 +0200
+++ b/zpt/viewer_text.zpt	Thu Apr 05 19:29:50 2012 +0200
@@ -3,26 +3,34 @@
 <html xmlns="http://www.w3.org/1999/xhtml"
   tal:define="docinfo options/docinfo; pageinfo options/pageinfo; viewMode pageinfo/viewMode;
               tocMode pageinfo/tocMode; viewLayer pageinfo/viewLayer; viewLayers pageinfo/viewLayers;
+              availableLayers python:here.getAvailableLayers().get('text', None);
               viewerUrl docinfo/viewerUrl;
               rootUrl here/getDocumentViewerURL;
               numPages docinfo/numPages | nothing;">
 <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" />
-  <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() {
-                    this.form.submit();
-                });
-                $('form.autosubmit input[type="submit"]').hide();
-            });
-        // -->
-        </script>
+<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" />
+<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() {
+            this.form.submit();
+        });
+        $('form.autosubmit input[type="submit"]').hide();
+    });
+// -->
+</script>
+<!--  layer headers -->
+<tal:block tal:repeat="layer viewLayers">
+  <tal:block tal:define="mpath string:here/template/layer_text_${layer}/macros/html_head"
+    tal:condition="python:exists(mpath)">
+    <metal:block metal:use-macro="python:path(mpath)" />
+  </tal:block>
+</tal:block>
+
 </head>
 <body tal:condition="numPages">
   <tal:block
@@ -67,7 +75,7 @@
         <!--"BEGIN SEARCH RESULTS"  -->
         <div class="options">
           <h4>Search results</h4>
-          <div metal:use-macro="here/template/search_template/macros/results_div"/>
+          <div metal:use-macro="here/template/search_template/macros/results_div" />
         </div>
       </div>
 
@@ -86,6 +94,7 @@
                 <input class="autosubmit" type="radio" name="viewMode" value="text"
                   tal:attributes="checked python:viewMode=='text'" /> Text
                 <ul>
+                  <!-- text layers -->
                   <li>
                     <input type="checkbox" class="autosubmit" name="viewLayer"
                       value="dict" tal:attributes="checked python:'dict' in viewLayers" />
@@ -94,12 +103,17 @@
                   <li tal:condition="python:query">
                     <input type="checkbox" class="autosubmit" name="viewLayer"
                       value="search"
-                      tal:attributes="checked python:'search' in viewLayers" /> Search hits
+                      tal:attributes="checked python:'search' in viewLayers" /> Search
+                    hits
                   </li>
-                  <li tal:condition="python:docinfo.get('numPlaces',0)">
-                    <input type="checkbox" class="autosubmit" name="viewLayer" value="gis"
-                      tal:attributes="checked python:'gis' in viewLayers" /> Places<br />
-                  </li>
+                  <!-- auto-layer select buttons -->
+                  <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>
               </li>
               <li>
@@ -122,30 +136,32 @@
               tal:attributes="name param; value python:params[param]" />
             <!-- make sure we have one viewLayer=search -->
             <tal:block tal:repeat="vl viewLayers">
-                <input type="hidden" name="viewLayer" tal:attributes="value vl" tal:condition="python:vl != 'search'"/>
+              <input type="hidden" name="viewLayer" tal:attributes="value vl"
+                tal:condition="python:vl != 'search'" />
             </tal:block>
-            <input type="hidden" name="viewLayer" value="search"/>
+            <input type="hidden" name="viewLayer" value="search" />
             <!-- query text -->
-            <input type="text" name="query" tal:attributes="value query"/>
-            <input type="submit" value="Search"/>
-            <a tal:attributes="href python:here.getLink('query',None)">Clear</a>
+            <input type="text" name="query" tal:attributes="value query" /> <input
+              type="submit" value="Search" /> <a
+              tal:attributes="href python:here.getLink('query',None)">Clear</a>
             <ul>
-                <li>
-                  <input type="radio" name="queryType" value="fulltext" 
-                    tal:attributes="checked python:queryType=='fulltext'"/> Exact
-                </li>
-                <li>
-                  <input type="radio" name="queryType" value="fulltextMorph" 
-                    tal:attributes="checked python:queryType=='fulltextMorph'"/> All forms
-                </li>
-                <li>
-                  <input type="radio" name="queryType" value="ftIndex" 
-                    tal:attributes="checked python:queryType=='ftIndex'"/> Fulltext index
-                </li>
-                <li>
-                  <input type="radio" name="queryType" value="ftIndexMorph" 
-                    tal:attributes="checked python:queryType=='ftIndexMorph'"/> Morphological index
-                </li>
+              <li>
+                <input type="radio" name="queryType" value="fulltext"
+                  tal:attributes="checked python:queryType=='fulltext'" /> Exact
+              </li>
+              <li>
+                <input type="radio" name="queryType" value="fulltextMorph"
+                  tal:attributes="checked python:queryType=='fulltextMorph'" /> All forms
+              </li>
+              <li>
+                <input type="radio" name="queryType" value="ftIndex"
+                  tal:attributes="checked python:queryType=='ftIndex'" /> Fulltext index
+              </li>
+              <li>
+                <input type="radio" name="queryType" value="ftIndexMorph"
+                  tal:attributes="checked python:queryType=='ftIndexMorph'" />
+                Morphological index
+              </li>
             </ul>
           </form>
         </div>
@@ -213,27 +229,14 @@
         </div>
         <!--"END TEXT NORMALIZATION"-->
 
-        <!--"BEGIN PLACES"-->
-        <div class="options" tal:condition="python:'gis' in viewLayers">
-          <tal:block tal:define="
-            name docinfo/documentName;
-            places python:here.getPlacesOnPage(docinfo=docinfo, pn=pn);
-            pidlist python:','.join([p['id'] for p in places]);">
-            <h4>Places</h4>
-            <ul>
-            <li><a
-              tal:attributes="href python:'http://mappit.mpiwg-berlin.mpg.de/db/RESTdb/db/mpdl/%s?id=%s&format=gis'%(name,pidlist)"
-              target="_blank">on this page</a>
-            </li>
-            <li>
-              <a
-              tal:attributes="href python:'http://mappit.mpiwg-berlin.mpg.de/db/RESTdb/db/mpdl/%s?format=gis'%(name)"
-              target="_blank">in whole document</a>
-            </li>
-            </ul>
+        <!--  auto-layer option boxes -->
+        <tal:block tal:repeat="layer viewLayers">
+          <tal:block
+            tal:define="mpath string:here/template/layer_text_${layer}/macros/options_box"
+            tal:condition="python:exists(mpath)">
+            <metal:block metal:use-macro="python:path(mpath)" />
           </tal:block>
-        </div>
-        <!--"END PLACES"-->
+        </tal:block>
       </div>
       <!-- /col-right -->