Commit 0318c955 by lduarte1991

Image Annotation Tool Fixes

- Added component to view

- Added correct images for OSD

- Fixed path to codemirror

- Tinymce fullscreen works now

- Pep8/Pylint Fixes

- Default image changed and added call to super
parent 008bbc22
......@@ -54,6 +54,7 @@ else:
'annotatable',
'textannotation', # module for annotating text (with annotation table)
'videoannotation', # module for annotating video (with annotation table)
'imageannotation', # module for annotating image (with annotation table)
'word_cloud',
'graphical_slider_tool',
'lti',
......
......@@ -2,12 +2,12 @@
Annotations Tool Mixin
This file contains global variables and functions used in the various Annotation Tools.
"""
from pkg_resources import resource_string
from lxml import etree
from urlparse import urlparse
from os.path import splitext, basename
from HTMLParser import HTMLParser
def get_instructions(xmltree):
""" Removes <instructions> from the xmltree and returns them as a string, otherwise None. """
instructions = xmltree.find('instructions')
......@@ -17,8 +17,9 @@ def get_instructions(xmltree):
return etree.tostring(instructions, encoding='unicode')
return None
def get_extension(srcurl):
''' get the extension of a given url '''
"""get the extension of a given url """
if 'youtu' in srcurl:
return 'video/youtube'
else:
......@@ -26,20 +27,29 @@ def get_extension(srcurl):
file_ext = splitext(basename(disassembled.path))[1]
return 'video/' + file_ext.replace('.', '')
class MLStripper(HTMLParser):
"helper function for html_to_text below"
def __init__(self):
HTMLParser.__init__(self)
self.reset()
self.fed = []
def handle_data(self, d):
self.fed.append(d)
def handle_data(self, data):
"""takes the data in separate chunks"""
self.fed.append(data)
def handle_entityref(self, name):
"""appends the reference to the body"""
self.fed.append('&%s;' % name)
def get_data(self):
"""joins together the seperate chunks into one cohesive string"""
return ''.join(self.fed)
def html_to_text(html):
"strips the html tags off of the text to return plaintext"
s = MLStripper()
s.feed(html)
return s.get_data()
\ No newline at end of file
htmlStripper = MLStripper()
htmlStripper.feed(html)
return htmlStripper.get_data()
......@@ -25,7 +25,7 @@ def retrieve_token(userid, secret):
delta = dtnow - dtutcnow
newhour, newmin = divmod((delta.days * 24 * 60 * 60 + delta.seconds + 30) // 60, 60) # pylint: disable=E1103
newtime = "%s%+02d:%02d" % (dtnow.isoformat(), newhour, newmin) # pylint: disable=E1103
# uses the issued time (UTC plus timezone), the consumer key and the user's email to maintain a
# uses the issued time (UTC plus timezone), the consumer key and the user's email to maintain a
# federated system in the annotation backend server
custom_data = {"issuedAt": newtime, "consumerKey": secret, "userId": userid, "ttl": 86400}
newtoken = create_token(secret, custom_data)
......
# pylint: disable=W0223
"""
Module for Image annotations using annotator.
"""
......@@ -31,20 +32,7 @@ class AnnotatableFields(object):
showNavigator: true,
navigatorPosition: "BOTTOM_LEFT",
showNavigationControl: true,
tileSources: [{
Image: {
xmlns: "http://schemas.microsoft.com/deepzoom/2009",
Url: "http://static.seadragon.com/content/misc/milwaukee_files/",
TileSize: "254",
Overlap: "1",
Format: "jpg",
ServerFormat: "Default",
Size: {
Width: "15497",
Height: "5378"
}
}
},],
tileSources: [{"profile": "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2", "scale_factors": [1, 2, 4, 8, 16, 32, 64], "tile_height": 1024, "height": 3466, "width": 113793, "tile_width": 1024, "qualities": ["native", "bitonal", "grey", "color"], "formats": ["jpg", "png", "gif"], "@context": "http://library.stanford.edu/iiif/image-api/1.1/context.json", "@id": "http://54.187.32.48/loris/suzhou_orig.jp2"}],
</json>
</annotatable>
"""))
......@@ -100,7 +88,7 @@ class ImageAnnotationModule(AnnotatableFields, XModule):
'display_name': self.display_name_with_default,
'instructions_html': self.instructions,
'annotation_storage': self.annotation_storage_url,
'token':retrieve_token(self.user, self.annotation_token_secret),
'token': retrieve_token(self.user, self.annotation_token_secret),
'tag': self.instructor_tags,
'openseadragonjson': self.openseadragonjson,
}
......@@ -120,4 +108,4 @@ class ImageAnnotationDescriptor(AnnotatableFields, RawDescriptor):
ImageAnnotationDescriptor.annotation_storage_url,
ImageAnnotationDescriptor.annotation_token_secret,
])
return non_editable_fields
\ No newline at end of file
return non_editable_fields
......@@ -7,6 +7,7 @@ from lxml import etree
from xmodule.annotator_mixin import get_instructions, get_extension, html_to_text
class HelperFunctionTest(unittest.TestCase):
"""
Tests to ensure that the following helper functions work for the annotation tool
......@@ -47,6 +48,6 @@ class HelperFunctionTest(unittest.TestCase):
self.assertEqual(expectednotyoutube, result1)
def test_html_to_text(self):
expectedText = "Testing here and not bolded here"
expectedtext = "Testing here and not bolded here"
result = html_to_text(self.sample_html)
self.assertEqual(expectedText, result)
\ No newline at end of file
self.assertEqual(expectedtext, result)
......@@ -28,11 +28,11 @@ class ImageAnnotationModuleTestCase(unittest.TestCase):
Image: {
xmlns: "http://schemas.microsoft.com/deepzoom/2009",
Url: "http://static.seadragon.com/content/misc/milwaukee_files/",
TileSize: "254",
Overlap: "1",
Format: "jpg",
TileSize: "254",
Overlap: "1",
Format: "jpg",
ServerFormat: "Default",
Size: {
Size: {
Width: "15497",
Height: "5378"
}
......@@ -41,7 +41,7 @@ class ImageAnnotationModuleTestCase(unittest.TestCase):
</json>
</annotatable>
'''
def setUp(self):
"""
Makes sure that the Module is declared and mocked with the sample xml above.
......@@ -75,4 +75,4 @@ class ImageAnnotationModuleTestCase(unittest.TestCase):
"""
context = self.mod.get_html()
for key in ['display_name', 'instructions_html', 'annotation_storage', 'token', 'tag', 'openseadragonjson']:
self.assertIn(key, context)
\ No newline at end of file
self.assertIn(key, context)
......@@ -782,6 +782,28 @@ OpenSeadragonAnnotation = function (element, options) {
//Set annotator.editor.OpenSeaDragon by default
this.annotator.editor.OpenSeaDragon=-1;
function reloadEditor(){
tinymce.EditorManager.execCommand('mceRemoveEditor',true, "annotator-field-0");
tinymce.EditorManager.execCommand('mceAddEditor',true, "annotator-field-0");
}
var self = this;
document.addEventListener("fullscreenchange", function () {
reloadEditor();
}, false);
document.addEventListener("mozfullscreenchange", function () {
reloadEditor();
}, false);
document.addEventListener("webkitfullscreenchange", function () {
reloadEditor();
}, false);
document.addEventListener("msfullscreenchange", function () {
reloadEditor();
}, false);
this.options = options;
......
common/static/js/vendor/ova/images/fullpage_grouphover.png

4.79 KB | W: | H:

common/static/js/vendor/ova/images/fullpage_grouphover.png

698 Bytes | W: | H:

common/static/js/vendor/ova/images/fullpage_grouphover.png
common/static/js/vendor/ova/images/fullpage_grouphover.png
common/static/js/vendor/ova/images/fullpage_grouphover.png
common/static/js/vendor/ova/images/fullpage_grouphover.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/fullpage_hover.png

5.09 KB | W: | H:

common/static/js/vendor/ova/images/fullpage_hover.png

831 Bytes | W: | H:

common/static/js/vendor/ova/images/fullpage_hover.png
common/static/js/vendor/ova/images/fullpage_hover.png
common/static/js/vendor/ova/images/fullpage_hover.png
common/static/js/vendor/ova/images/fullpage_hover.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/fullpage_pressed.png

5.09 KB | W: | H:

common/static/js/vendor/ova/images/fullpage_pressed.png

817 Bytes | W: | H:

common/static/js/vendor/ova/images/fullpage_pressed.png
common/static/js/vendor/ova/images/fullpage_pressed.png
common/static/js/vendor/ova/images/fullpage_pressed.png
common/static/js/vendor/ova/images/fullpage_pressed.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/fullpage_rest.png

5.03 KB | W: | H:

common/static/js/vendor/ova/images/fullpage_rest.png

698 Bytes | W: | H:

common/static/js/vendor/ova/images/fullpage_rest.png
common/static/js/vendor/ova/images/fullpage_rest.png
common/static/js/vendor/ova/images/fullpage_rest.png
common/static/js/vendor/ova/images/fullpage_rest.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/home_grouphover.png

4.7 KB | W: | H:

common/static/js/vendor/ova/images/home_grouphover.png

672 Bytes | W: | H:

common/static/js/vendor/ova/images/home_grouphover.png
common/static/js/vendor/ova/images/home_grouphover.png
common/static/js/vendor/ova/images/home_grouphover.png
common/static/js/vendor/ova/images/home_grouphover.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/home_hover.png

4.99 KB | W: | H:

common/static/js/vendor/ova/images/home_hover.png

737 Bytes | W: | H:

common/static/js/vendor/ova/images/home_hover.png
common/static/js/vendor/ova/images/home_hover.png
common/static/js/vendor/ova/images/home_hover.png
common/static/js/vendor/ova/images/home_hover.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/home_pressed.png

5.02 KB | W: | H:

common/static/js/vendor/ova/images/home_pressed.png

741 Bytes | W: | H:

common/static/js/vendor/ova/images/home_pressed.png
common/static/js/vendor/ova/images/home_pressed.png
common/static/js/vendor/ova/images/home_pressed.png
common/static/js/vendor/ova/images/home_pressed.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/home_rest.png

4.94 KB | W: | H:

common/static/js/vendor/ova/images/home_rest.png

672 Bytes | W: | H:

common/static/js/vendor/ova/images/home_rest.png
common/static/js/vendor/ova/images/home_rest.png
common/static/js/vendor/ova/images/home_rest.png
common/static/js/vendor/ova/images/home_rest.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/newan_grouphover.png

4.75 KB | W: | H:

common/static/js/vendor/ova/images/newan_grouphover.png

746 Bytes | W: | H:

common/static/js/vendor/ova/images/newan_grouphover.png
common/static/js/vendor/ova/images/newan_grouphover.png
common/static/js/vendor/ova/images/newan_grouphover.png
common/static/js/vendor/ova/images/newan_grouphover.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/newan_hover.png

4.91 KB | W: | H:

common/static/js/vendor/ova/images/newan_hover.png

815 Bytes | W: | H:

common/static/js/vendor/ova/images/newan_hover.png
common/static/js/vendor/ova/images/newan_hover.png
common/static/js/vendor/ova/images/newan_hover.png
common/static/js/vendor/ova/images/newan_hover.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/newan_pressed.png

4.78 KB | W: | H:

common/static/js/vendor/ova/images/newan_pressed.png

828 Bytes | W: | H:

common/static/js/vendor/ova/images/newan_pressed.png
common/static/js/vendor/ova/images/newan_pressed.png
common/static/js/vendor/ova/images/newan_pressed.png
common/static/js/vendor/ova/images/newan_pressed.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/newan_rest.png

4.66 KB | W: | H:

common/static/js/vendor/ova/images/newan_rest.png

746 Bytes | W: | H:

common/static/js/vendor/ova/images/newan_rest.png
common/static/js/vendor/ova/images/newan_rest.png
common/static/js/vendor/ova/images/newan_rest.png
common/static/js/vendor/ova/images/newan_rest.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/next_grouphover.png

2.93 KB | W: | H:

common/static/js/vendor/ova/images/next_grouphover.png

656 Bytes | W: | H:

common/static/js/vendor/ova/images/next_grouphover.png
common/static/js/vendor/ova/images/next_grouphover.png
common/static/js/vendor/ova/images/next_grouphover.png
common/static/js/vendor/ova/images/next_grouphover.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/next_hover.png

3.35 KB | W: | H:

common/static/js/vendor/ova/images/next_hover.png

753 Bytes | W: | H:

common/static/js/vendor/ova/images/next_hover.png
common/static/js/vendor/ova/images/next_hover.png
common/static/js/vendor/ova/images/next_hover.png
common/static/js/vendor/ova/images/next_hover.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/next_pressed.png

3.42 KB | W: | H:

common/static/js/vendor/ova/images/next_pressed.png

752 Bytes | W: | H:

common/static/js/vendor/ova/images/next_pressed.png
common/static/js/vendor/ova/images/next_pressed.png
common/static/js/vendor/ova/images/next_pressed.png
common/static/js/vendor/ova/images/next_pressed.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/next_rest.png

2.99 KB | W: | H:

common/static/js/vendor/ova/images/next_rest.png

656 Bytes | W: | H:

common/static/js/vendor/ova/images/next_rest.png
common/static/js/vendor/ova/images/next_rest.png
common/static/js/vendor/ova/images/next_rest.png
common/static/js/vendor/ova/images/next_rest.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/previous_grouphover.png

2.92 KB | W: | H:

common/static/js/vendor/ova/images/previous_grouphover.png

661 Bytes | W: | H:

common/static/js/vendor/ova/images/previous_grouphover.png
common/static/js/vendor/ova/images/previous_grouphover.png
common/static/js/vendor/ova/images/previous_grouphover.png
common/static/js/vendor/ova/images/previous_grouphover.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/previous_hover.png

3.38 KB | W: | H:

common/static/js/vendor/ova/images/previous_hover.png

755 Bytes | W: | H:

common/static/js/vendor/ova/images/previous_hover.png
common/static/js/vendor/ova/images/previous_hover.png
common/static/js/vendor/ova/images/previous_hover.png
common/static/js/vendor/ova/images/previous_hover.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/previous_pressed.png

3.42 KB | W: | H:

common/static/js/vendor/ova/images/previous_pressed.png

755 Bytes | W: | H:

common/static/js/vendor/ova/images/previous_pressed.png
common/static/js/vendor/ova/images/previous_pressed.png
common/static/js/vendor/ova/images/previous_pressed.png
common/static/js/vendor/ova/images/previous_pressed.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/previous_rest.png

2.99 KB | W: | H:

common/static/js/vendor/ova/images/previous_rest.png

661 Bytes | W: | H:

common/static/js/vendor/ova/images/previous_rest.png
common/static/js/vendor/ova/images/previous_rest.png
common/static/js/vendor/ova/images/previous_rest.png
common/static/js/vendor/ova/images/previous_rest.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/zoomin_grouphover.png

4.68 KB | W: | H:

common/static/js/vendor/ova/images/zoomin_grouphover.png

612 Bytes | W: | H:

common/static/js/vendor/ova/images/zoomin_grouphover.png
common/static/js/vendor/ova/images/zoomin_grouphover.png
common/static/js/vendor/ova/images/zoomin_grouphover.png
common/static/js/vendor/ova/images/zoomin_grouphover.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/zoomin_hover.png

5.01 KB | W: | H:

common/static/js/vendor/ova/images/zoomin_hover.png

608 Bytes | W: | H:

common/static/js/vendor/ova/images/zoomin_hover.png
common/static/js/vendor/ova/images/zoomin_hover.png
common/static/js/vendor/ova/images/zoomin_hover.png
common/static/js/vendor/ova/images/zoomin_hover.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/zoomin_pressed.png

5.05 KB | W: | H:

common/static/js/vendor/ova/images/zoomin_pressed.png

615 Bytes | W: | H:

common/static/js/vendor/ova/images/zoomin_pressed.png
common/static/js/vendor/ova/images/zoomin_pressed.png
common/static/js/vendor/ova/images/zoomin_pressed.png
common/static/js/vendor/ova/images/zoomin_pressed.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/zoomin_rest.png

4.92 KB | W: | H:

common/static/js/vendor/ova/images/zoomin_rest.png

612 Bytes | W: | H:

common/static/js/vendor/ova/images/zoomin_rest.png
common/static/js/vendor/ova/images/zoomin_rest.png
common/static/js/vendor/ova/images/zoomin_rest.png
common/static/js/vendor/ova/images/zoomin_rest.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/zoomout_grouphover.png

4.49 KB | W: | H:

common/static/js/vendor/ova/images/zoomout_grouphover.png

504 Bytes | W: | H:

common/static/js/vendor/ova/images/zoomout_grouphover.png
common/static/js/vendor/ova/images/zoomout_grouphover.png
common/static/js/vendor/ova/images/zoomout_grouphover.png
common/static/js/vendor/ova/images/zoomout_grouphover.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/zoomout_hover.png

4.82 KB | W: | H:

common/static/js/vendor/ova/images/zoomout_hover.png

559 Bytes | W: | H:

common/static/js/vendor/ova/images/zoomout_hover.png
common/static/js/vendor/ova/images/zoomout_hover.png
common/static/js/vendor/ova/images/zoomout_hover.png
common/static/js/vendor/ova/images/zoomout_hover.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/zoomout_pressed.png

4.89 KB | W: | H:

common/static/js/vendor/ova/images/zoomout_pressed.png

561 Bytes | W: | H:

common/static/js/vendor/ova/images/zoomout_pressed.png
common/static/js/vendor/ova/images/zoomout_pressed.png
common/static/js/vendor/ova/images/zoomout_pressed.png
common/static/js/vendor/ova/images/zoomout_pressed.png
  • 2-up
  • Swipe
  • Onion skin
common/static/js/vendor/ova/images/zoomout_rest.png

4.7 KB | W: | H:

common/static/js/vendor/ova/images/zoomout_rest.png

504 Bytes | W: | H:

common/static/js/vendor/ova/images/zoomout_rest.png
common/static/js/vendor/ova/images/zoomout_rest.png
common/static/js/vendor/ova/images/zoomout_rest.png
common/static/js/vendor/ova/images/zoomout_rest.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -38,7 +38,7 @@ Annotator.Plugin.RichText = (function(_super) {
}
},
codemirror: {
path: "static/js/vendor"
path: "/static/js/vendor"
},
plugins: "image link codemirror",
menubar: false,
......
<%! from django.utils.translation import ugettext as _ %>
<%namespace name='static' file='/static_content.html'/>
${static.css(group='style-vendor-tinymce-content', raw=True)}
${static.css(group='style-vendor-tinymce-skin', raw=True)}
<script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/tinymce.full.min.js', raw=True)}" />
<script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/jquery.tinymce.min.js', raw=True)}" />
<style type="text/css">
.openseadragon1{
......@@ -33,6 +28,11 @@ ${static.css(group='style-vendor-tinymce-skin', raw=True)}
<div class="annotatable-section">
<div class="annotatable-content">
<div id="imageHolder" class="openseadragon1">
<%namespace name='static' file='/static_content.html'/>
${static.css(group='style-vendor-tinymce-content', raw=True)}
${static.css(group='style-vendor-tinymce-skin', raw=True)}
<script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/tinymce.full.min.js', raw=True)}" />
<script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/jquery.tinymce.min.js', raw=True)}" />
</div>
<div id="catchDIV">
<div class="annotationListContainer">${_('You do not have any notes.')}</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment