view zpt/layer_text_annotator.zpt @ 562:60f5a636bc57

bugfixes for stability.
author casties
date Tue, 02 Oct 2012 15:22:11 +0200
parents abcb67f5cab4
children 6000c7e24d8a
line wrap: on
line source

<!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>
<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/annotator.css" />

  <script
    tal:attributes="src string:$rootUrl/template/annotator_files/lib/vendor/json2.js"></script>
  <script tal:attributes="src string:$rootUrl/template/annotator_files/lib/extensions.js"></script>
  <script tal:attributes="src string:$rootUrl/template/annotator_files/lib/console.js"></script>
  <script tal:attributes="src string:$rootUrl/template/annotator_files/lib/class.js"></script>
  <script tal:attributes="src string:$rootUrl/template/annotator_files/lib/range.js"></script>
  <script tal:attributes="src string:$rootUrl/template/annotator_files/lib/annotator.js"></script>
  <script tal:attributes="src string:$rootUrl/template/annotator_files/lib/widget.js"></script>
  <script tal:attributes="src string:$rootUrl/template/annotator_files/lib/editor.js"></script>
  <script tal:attributes="src string:$rootUrl/template/annotator_files/lib/viewer.js"></script>
  <script
    tal:attributes="src string:$rootUrl/template/annotator_files/lib/notification.js"></script>
  <script
    tal:attributes="src string:$rootUrl/template/annotator_files/lib/plugin/store.js"></script>
  <script
    tal:attributes="src string:$rootUrl/template/annotator_files/lib/plugin/permissions.js"></script>
  <!-- <script tal:attributes="src string:$rootUrl/template/annotator_files/lib/plugin/annotateitpermissions.js"></script> -->
  <script tal:attributes="src string:$rootUrl/template/annotator_files/lib/plugin/auth.js"></script>
  <script tal:attributes="src string:$rootUrl/template/annotator_files/lib/plugin/tags.js"></script>
  <script
    tal:attributes="src string:$rootUrl/template/annotator_files/lib/plugin/unsupported.js"></script>
  <!-- <script tal:attributes="src string:$rootUrl/template/annotator_files/lib/plugin/filter.js"></script> -->

  <script type="text/javascript" 
    tal:define="global annServerUrl string:http://tuxserve03.mpiwg-berlin.mpg.de/AnnotationManager;
    annUrl python:'http://echo.mpiwg-berlin.mpg.de/documents%s?pn=%s'%(docinfo['documentPath'],pageinfo['pn']);
    resUrl python:'http://echo.mpiwg-berlin.mpg.de/documents%s'%(docinfo['documentPath']);
    global annUser python:here.getAuthenticatedUser(anon='anonymous');
    global annGroup python:request.get('annotator_group', None);
    permUser python:test(annGroup, 'group:%s'%annGroup, annUser);"
    tal:content="structure string:
    var annotatorServerUrl='$annServerUrl';
    var annotatorPageUrl='$annUrl'; 
    var annotatorResourceUrl='$resUrl'; 
    var annotatorUser='$annUser'; 
    var permissionUser='$permUser';"></script>

  <script type="text/javascript">
            // <!--
            $(document).ready(function() {
                // annotator
                var elem = $('div.pageContent').get(0);
                var uri = annotatorPageUrl;
                var devAnnotator = new Annotator(elem).addPlugin('Auth', {
                    tokenUrl : 'template/token?user='+annotatorUser
                }).addPlugin('Permissions', {
                    permissions: {
                        'read':   [],
                        'update': [permissionUser],
                        'delete': [permissionUser],
                        'admin':  [permissionUser]
                    },
                    user : permissionUser,
                    userString : function(user) {
                        if (user && user.name) {
                            return user.name;
                        }
                        return user;
                    },
                    userId : function(user) {
                        if (user && user.id) {
                            return user.id;
                        }
                        return user;
                    }
                }).addPlugin('Store', {
                    prefix: annotatorServerUrl+'/annotator',
                    annotationData : {
                        'uri' : uri,
                        'resource' : annotatorResourceUrl
                    },
                    loadFromSearch : {
                        'limit' : 20,
                        'uri' : uri
                    }
                }).addPlugin('Tags'
                );
            });
        // -->
        </script>

</metal:block>
</head>
<body>
  <!-- right-side options -->
  <div class="col buttons">
    <!-- LAYER DISPLAY OPTION  -->
    <ul>
      <li metal:define-macro="layer_select_li">
        <input type="checkbox" class="autosubmit" name="viewLayer" value="annotator"
          tal:attributes="checked python:'annotator' in viewLayers" /> Annotator
      </li>
    </ul>
  </div>

  <metal:block metal:define-macro="options_box" tal:condition="python:'annotator' in viewLayers">
    <!-- BEGIN ANNOTATIONS -->
    <div class="options">
      <h4>Annotator</h4>
      <p>
        User "<span tal:replace="annUser" />"<span tal:condition="annGroup" tal:content="string: ($annGroup)"/>.
      </p>
      <!-- TODO: login button -->
      <form class="autosubmit" tal:attributes="action viewerUrl">
        <input type="hidden" tal:define="params python:here.getParams(params={'annotator_group':None});" tal:repeat="param params"
          tal:attributes="name param; value python:params[param]" />
        <p>
          In group
          <select class="autosubmit" name="annotator_group">
            <option value="" tal:attributes="selected not:annGroup;"> </option>
            <option
              tal:repeat="group python:here.getAnnotatorGroupsForUser(user=annUser,annotationServerUrl=annServerUrl)"
              tal:attributes="value group/id; selected python:group['id']==annGroup;" tal:content="group/name" />
          </select> <br /> 
          <input type="submit" value="Go!" />
        </p>
      </form>
      <p tal:define="std modules/Products.PythonScripts.standard">
        <a class="button" tal:attributes="href python:'%s/login/login?came_from=%s'%(viewerUrl,std.url_quote(here.getLink()))">log in</a>
        <!--  <a class="button" tal:attributes="href python:'%s/login/logout?came_from=%s'%(viewerUrl,std.url_quote(here.getLink()))">log out</a> -->
      </p>
    </div>
    <!-- END ANNOTATIONS -->
  </metal:block>

</body>

</html>