changeset 615:d6eca930a534

hocr viewer eingebaut
author Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de>
date Mon, 21 Jul 2014 12:53:42 +0200
parents d16da6e739ef
children 54d3498a6e78
files __init__.py css/docuviewer.css documentViewer.py zpt/viewer/layer_text_annotator.zpt
diffstat 4 files changed, 61 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/__init__.py	Mon Oct 21 10:36:54 2013 +0200
+++ b/__init__.py	Mon Jul 21 12:53:42 2014 +0200
@@ -1,6 +1,7 @@
 import documentViewer
 import MpdlXmlTextServer
 import MpiwgXmlTextServer
+import HocrTextServer
 
 def initialize(context):
     """initialize ImageCollection"""
@@ -27,4 +28,14 @@
           MpiwgXmlTextServer.manage_addMpiwgXmlTextServer
           )
         )
+    
+    
+    context.registerClass(
+        HocrTextServer.HocrTextServer,
+        constructors = (
+          HocrTextServer.manage_addHocrTextServerForm,
+          HocrTextServer.manage_addHocrTextServer
+          )
+        )
+
     
\ No newline at end of file
--- a/css/docuviewer.css	Mon Oct 21 10:36:54 2013 +0200
+++ b/css/docuviewer.css	Mon Jul 21 12:53:42 2014 +0200
@@ -472,4 +472,8 @@
 div.footer div.content a:link,
 div.footer div.content a:visited {
 	color: gray;
+}
+
+span.ocr_line {
+display:block;
 }
\ No newline at end of file
--- a/documentViewer.py	Mon Oct 21 10:36:54 2013 +0200
+++ b/documentViewer.py	Mon Jul 21 12:53:42 2014 +0200
@@ -82,6 +82,7 @@
     #
     # viewMode templates
     viewer_text = PageTemplateFile('zpt/viewer/viewer_text', globals())
+    viewer_hocr = PageTemplateFile('zpt/viewer/viewer_hocr', globals())
     viewer_xml = PageTemplateFile('zpt/viewer/viewer_xml', globals())
     viewer_image = PageTemplateFile('zpt/viewer/viewer_image', globals())
     viewer_index = PageTemplateFile('zpt/viewer/viewer_index', globals())
@@ -164,7 +165,11 @@
     # proxy text server methods to fulltextclient
     def getTextPage(self, **args):
         """returns full text content of page"""
+       
         return self.template.fulltextclient.getTextPage(**args)
+    
+   
+   
 
     def getSearchResults(self, **args):
         """loads list of search results and stores XML in docinfo"""
@@ -239,7 +244,7 @@
         show page
         @param url: url which contains display information
         @param mode: defines how to access the document behind url 
-        @param viewMode: 'image': display images, 'text': display text, 'xml': display xml, default is 'auto'
+        @param viewMode: 'image': display images, 'text': display text, 'xml': display xml, default is 'auto', 'hocr' : hocr format
         @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)
         """
@@ -287,6 +292,9 @@
             # legacy fix
             viewMode = 'image'
             self.REQUEST['viewMode'] = 'image'
+            
+        
+            
 
         # safe viewLayer in userinfo
         userinfo['viewLayer'] = viewLayer
@@ -532,6 +540,23 @@
             docUrl = getParentPath(url)
             metaDom = self.metadataService.getDomFromPathOrUrl(docUrl)
             docinfo['imagePath'] = url.replace('/mpiwg/online', '', 1)
+            
+        elif mode=="hocr":
+            # url points to folder with images, index.meta optional
+            # asssume index.meta in parent dir
+            docUrl = getParentPath(url)
+            metaDom = self.metadataService.getDomFromPathOrUrl(docUrl)
+            docinfo['imagePath'] = url.replace('/mpiwg/online', '', 1)
+            docinfo['textURLPath'] = url.replace('/mpiwg/online', '', 1)
+            if docinfo.get("creator", None) is None:
+                docinfo['creator'] = "" 
+            
+            if docinfo.get("title", None) is None:
+                docinfo['title'] = "" 
+
+            if docinfo.get("documentPath", None) is None:
+                docinfo['documentPath'] = url.replace('/mpiwg/online', '', 1)
+                docinfo['documentPath'] = url.replace('/pages', '', 1)
 
         elif mode=="filepath":
             # url points to image file, index.meta optional
--- a/zpt/viewer/layer_text_annotator.zpt	Mon Oct 21 10:36:54 2013 +0200
+++ b/zpt/viewer/layer_text_annotator.zpt	Mon Jul 21 12:53:42 2014 +0200
@@ -4,9 +4,13 @@
 <head>
 <metal:block metal:define-macro="html_head" tal:condition="python:'annotator' in viewLayers">
   <!--  annotator -->
+ <link rel="stylesheet" type="text/css"
+    tal:attributes="href string:$rootUrl/template/annotator_files/css/style.css" />
+
   <link rel="stylesheet" type="text/css"
     tal:attributes="href string:$rootUrl/template/annotator_files/css/annotator.css" />
 
+
   <script type="text/javascript" tal:attributes="src string:$rootUrl/template/annotator_files/lib/vendor/json2.js"></script>
   <script type="text/javascript" tal:attributes="src string:$rootUrl/template/annotator_files/lib/vendor/showdown.js"></script>
   <script type="text/javascript" tal:attributes="src string:$rootUrl/template/annotator_files/lib/extensions.js"></script>
@@ -14,6 +18,9 @@
   <script type="text/javascript" tal:attributes="src string:$rootUrl/template/annotator_files/lib/class.js"></script>
   <script type="text/javascript" tal:attributes="src string:$rootUrl/template/annotator_files/lib/range.js"></script>
   <script type="text/javascript" tal:attributes="src string:$rootUrl/template/annotator_files/lib/annotator.js"></script>
+  <script type="text/javascript" tal:attributes="src string:$rootUrl/template/annotator_files/lib/locale/en/annotator.js"></script>
+  
+  
   <script type="text/javascript" tal:attributes="src string:$rootUrl/template/annotator_files/lib/widget.js"></script>
   <script type="text/javascript" tal:attributes="src string:$rootUrl/template/annotator_files/lib/editor.js"></script>
   <script type="text/javascript" tal:attributes="src string:$rootUrl/template/annotator_files/lib/viewer.js"></script>
@@ -24,6 +31,13 @@
   <script type="text/javascript" tal:attributes="src string:$rootUrl/template/annotator_files/lib/plugin/tags.js"></script>
   <script type="text/javascript" tal:attributes="src string:$rootUrl/template/annotator_files/lib/plugin/markdown.js"></script>
   <script type="text/javascript" tal:attributes="src string:$rootUrl/template/annotator_files/lib/plugin/unsupported.js"></script>
+  
+  <script type="text/javascript" tal:attributes="src string:$rootUrl/template/annotator_files/lib/jquery.dateFormat.js"></script>
+  <script type="text/javascript" tal:attributes="src string:$rootUrl/template/annotator_files/lib/jquery.slimscroll.js"></script>
+  <script type="text/javascript" tal:attributes="src string:$rootUrl/template/annotator_files/lib/jquery-i18n-master/jquery.i18n.min.js"></script>
+  <script type="text/javascript" tal:attributes="src string:$rootUrl/template/annotator_files/lib/plugin/view_annotator.js"></script>
+   
+  
   <!-- <script tal:attributes="src string:$rootUrl/template/annotator_files/lib/plugin/filter.js"></script> -->
 
   <script type="text/javascript" 
@@ -44,6 +58,9 @@
             // <!--
             $(document).ready(function() {
                 // annotator
+              
+
+                jQuery.i18n.load(i18n_dict);
                 var elem = $('div.pageContent').get(0);
                 var uri = annotatorPageUrl;
                 var devAnnotator = new Annotator(elem).addPlugin('Auth', {
@@ -78,7 +95,9 @@
                         'limit' : 20,
                         'uri' : uri
                     }
-                }).addPlugin('Tags').addPlugin('Markdown');
+                }).addPlugin('Tags').addPlugin('Markdown').addPlugin('AnnotatorViewer');
+                
+                $('#anotacions-uoc-panel').slimscroll({height: '100%'});
             });
         // -->
         </script>