changeset 1142:e05b101f7790

uri of annotated page configurable.
author robcast
date Mon, 19 Nov 2012 16:37:29 +0100
parents bbb09797d7fc
children c2b8f777979f
files webapp/src/main/webapp/jquery/digilib-mpiwg.html webapp/src/main/webapp/jquery/jquery.digilib.annotator.js
diffstat 2 files changed, 94 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webapp/src/main/webapp/jquery/digilib-mpiwg.html	Mon Nov 19 16:37:29 2012 +0100
@@ -0,0 +1,69 @@
+<!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>
+        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+        <meta name="viewport" content="initial-scale=1.0"/>
+        <title>Digilib jQuery: fullscreen+mpiwg+annotations</title>
+
+        <style type="text/css">
+            body {
+                 background: silver;
+            }
+        </style>
+
+        <script type="text/javascript" src="json2.js"></script>
+        <script type="text/javascript" src="jquery.js"></script>
+        <script type="text/javascript" src="jquery.cookie.js"></script>
+        <script type="text/javascript" src="jquery.digilib.js"></script>
+        <link rel="stylesheet" type="text/css" href="jquery.digilib.css" />
+        <script type="text/javascript" src="jquery.digilib.geometry.js"></script>
+        <script type="text/javascript" src="jquery.digilib.arrows.js"></script>
+        <script type="text/javascript" src="jquery.range.js"></script>
+        <link rel="stylesheet" type="text/css" href="jquery.range.css" />
+        <script type="text/javascript" src="jquery.digilib.buttons.js"></script>
+        <script type="text/javascript" src="jquery.digilib.dialogs.js"></script>
+        <script type="text/javascript" src="jquery.digilib.sliders.js"></script>
+        <script type="text/javascript" src="jquery.digilib.birdseye.js"></script>
+        <script type="text/javascript" src="jquery.digilib.marks.js"></script>
+        <script type="text/javascript" src="jquery.digilib.regions.js"></script>
+        <script type="text/javascript" src="showdown.js"></script>
+        <script type="text/javascript" src="annotator-dl.js"></script>
+        <link rel="stylesheet" type="text/css" href="annotator.min.css" />
+        <script type="text/javascript" src="jquery.digilib.annotator.js"></script>
+
+        <script type="text/javascript">
+            $(document).ready(function(){
+                var opts = {
+                    interactionMode : 'fullscreen',
+                    showRegionNumbers : true,
+                    // URL of annotation server
+                    'annotationServerUrl' : 'http://tuxserve03.mpiwg-berlin.mpg.de/AnnotationManager/annotator',
+                    // are annotations read-only?
+                    'annotationsReadOnly' : false,
+                    // URL of authentication token server
+                    'annotationTokenUrl' : 'http://libcoll.mpiwg-berlin.mpg.de/libviewa/template/token/getLoginToken',
+                    // URL of safe authentication token server
+                    'annotationSafeTokenUrl' : 'https://libcoll.mpiwg-berlin.mpg.de/libviewa/template/token/getLoginToken',
+                    // function that returns a normalized URI for the annotated image
+                    'annotationPageUri' : function (data) {
+                    	var fn = data.settings.fn;
+                    	return 'http://echo.mpiwg-berlin.mpg.de/documents'+(fn.charAt(0)==='/'?'':'/')+fn+'?pn='+data.settings.pn;
+                    },
+                    // list of Annotator plugins
+                    'annotatorPlugins' : ['Auth', 'Permissions', 'Store', 'Markdown', 'DigilibIntegrator']
+                };
+                var $div = $('div#digilib');
+                $div.digilib(opts);
+            });
+
+        </script>
+    </head>
+
+    <body>
+        <div id="digilib">
+            <p>digilib doesn't work! Please switch on Javascript or notify the server administrator!</p>
+            <img src="http://digilib.berlios.de/images/digilib-logo-big.png" />
+        </div>
+    </body>
+</html>
+
--- a/webapp/src/main/webapp/jquery/jquery.digilib.annotator.js	Sat Nov 17 01:20:55 2012 +0100
+++ b/webapp/src/main/webapp/jquery/jquery.digilib.annotator.js	Mon Nov 19 16:37:29 2012 +0100
@@ -1,9 +1,10 @@
 /**
  digilib plugin for annotations.
 
- currently only point-like annotations (like marks).
+ Currently supported are point annotations (like marks) and region annotations.
  
- Annotations are stored on a Annotator http://annotateit.org compatible server.
+ Annotations are displayed using code from the Annotator (http://annotateit.org) project
+and stored on a Annotator-API compatible server.
 
  */
 
@@ -113,12 +114,20 @@
     };
 
     /**
-     * returns an annotatable url to this digilib image
+     * returns an annotatable uri to this digilib image
      */
-    var getAnnotationPageUrl = function(data) {
-        var url = data.settings.digilibBaseUrl + '/jquery/digilib.html?';
-        url += digilib.fn.getParamString(data.settings, ['fn', 'pn'], digilib.defaults);
-        return url;
+    var getAnnotationPageUri = function(data) {
+        var settings = data.settings;
+        var uri = settings.annotationPageUri; 
+        if (uri == null) {
+            // default uri with digilibBaseUrl
+            uri = settings.digilibBaseUrl + settings.digilibFrontendPath;
+            uri += '?' + digilib.fn.getParamString(data.settings, ['fn', 'pn'], digilib.defaults);
+        } else if (typeof uri === 'function') {
+            // call function
+            uri = uri(data);
+        }
+        return uri;
     };
     
     /**
@@ -246,7 +255,6 @@
             screenRect = data.imgTrafo.transform(clippedArea);
             // console.debug("renderRegion: pos=",geom.position(screenRect));
 	        $annotation = $('<div class="'+cssPrefix+'annotationregion '+cssPrefix+'overlay annotator-hl">'+idx+'</div>');
-        	//addRegionAttributes(data, $regionDiv, attr);
         } else {
 	        var pos = area.getPosition();
 	        if (!data.zoomArea.containsPosition(pos)) return;
@@ -257,6 +265,10 @@
 	    }
         // save annotation in data for Annotator
         $annotation.data('annotation', annotation);
+        // add css class from annotation
+        if (annotation.cssclass != null) {
+            $annotation.addClass(annotation.cssclass);
+        }
         // save reference to div
         annot.$div = $annotation;
         $elem.append($annotation);
@@ -376,6 +388,8 @@
         'annotationSafeTokenUrl' : null,
         // annotation user name
         'annotationUser' : 'anonymous',
+        // string or function that returns the uri of the page being annotated
+        'annotationPageUri' : null,
         // list of Annotator plugins
         'annotatorPlugins' : ['Auth', 'Permissions', 'Store', 'DigilibIntegrator'],
         // Annotator plugin settings (values that are functions are replaced by fn(data))
@@ -413,10 +427,10 @@
             'Store' : { 
                 'prefix' : getAnnotationServerUrl,
                 'annotationData': {
-                    'uri': getAnnotationPageUrl
+                    'uri': getAnnotationPageUri
                 }, 
                 'loadFromSearch': {
-                    'uri': getAnnotationPageUrl
+                    'uri': getAnnotationPageUri
                 }
             },
             'DigilibIntegrator' : {
@@ -475,7 +489,7 @@
         var data = this;
         var settings = data.settings;
         // set up annotator (after html has been set up)
-        var uri = getAnnotationPageUrl(data);
+        var uri = getAnnotationPageUri(data);
         var elem = data.$elem.get(0);
         var opts = {'readOnly' : data.settings.annotationsReadOnly};
         var annotator = new Annotator(elem, opts);