diff --git a/cms/djangoapps/contentstore/views/component.py b/cms/djangoapps/contentstore/views/component.py index a2acd86d4f..dd7c7c3815 100644 --- a/cms/djangoapps/contentstore/views/component.py +++ b/cms/djangoapps/contentstore/views/component.py @@ -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', diff --git a/common/lib/xmodule/xmodule/annotator_mixin.py b/common/lib/xmodule/xmodule/annotator_mixin.py index 8b12263580..9c4875e462 100644 --- a/common/lib/xmodule/xmodule/annotator_mixin.py +++ b/common/lib/xmodule/xmodule/annotator_mixin.py @@ -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 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() diff --git a/common/lib/xmodule/xmodule/annotator_token.py b/common/lib/xmodule/xmodule/annotator_token.py index 129315739c..501917cc3d 100644 --- a/common/lib/xmodule/xmodule/annotator_token.py +++ b/common/lib/xmodule/xmodule/annotator_token.py @@ -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) diff --git a/common/lib/xmodule/xmodule/imageannotation_module.py b/common/lib/xmodule/xmodule/imageannotation_module.py index 1875b3d668..31f86a0f82 100644 --- a/common/lib/xmodule/xmodule/imageannotation_module.py +++ b/common/lib/xmodule/xmodule/imageannotation_module.py @@ -1,3 +1,4 @@ +# 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"}], """)) @@ -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 diff --git a/common/lib/xmodule/xmodule/tests/test_annotator_mixin.py b/common/lib/xmodule/xmodule/tests/test_annotator_mixin.py index 09d216b709..a33c05c32d 100644 --- a/common/lib/xmodule/xmodule/tests/test_annotator_mixin.py +++ b/common/lib/xmodule/xmodule/tests/test_annotator_mixin.py @@ -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) diff --git a/common/lib/xmodule/xmodule/tests/test_imageannotation.py b/common/lib/xmodule/xmodule/tests/test_imageannotation.py index 5a6710b7a0..c3cb9aaef5 100644 --- a/common/lib/xmodule/xmodule/tests/test_imageannotation.py +++ b/common/lib/xmodule/xmodule/tests/test_imageannotation.py @@ -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): ''' - + 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) diff --git a/common/static/js/vendor/ova/OpenSeaDragonAnnotation.js b/common/static/js/vendor/ova/OpenSeaDragonAnnotation.js index 8a1b939340..0fdd10b70a 100644 --- a/common/static/js/vendor/ova/OpenSeaDragonAnnotation.js +++ b/common/static/js/vendor/ova/OpenSeaDragonAnnotation.js @@ -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; diff --git a/common/static/js/vendor/ova/images/fullpage_grouphover.png b/common/static/js/vendor/ova/images/fullpage_grouphover.png old mode 100755 new mode 100644 index 3ca4e1e3c3..2cf72a3d73 Binary files a/common/static/js/vendor/ova/images/fullpage_grouphover.png and b/common/static/js/vendor/ova/images/fullpage_grouphover.png differ diff --git a/common/static/js/vendor/ova/images/fullpage_hover.png b/common/static/js/vendor/ova/images/fullpage_hover.png old mode 100755 new mode 100644 index d08eb2d0b0..d8cbd6630b Binary files a/common/static/js/vendor/ova/images/fullpage_hover.png and b/common/static/js/vendor/ova/images/fullpage_hover.png differ diff --git a/common/static/js/vendor/ova/images/fullpage_pressed.png b/common/static/js/vendor/ova/images/fullpage_pressed.png old mode 100755 new mode 100644 index 0ee45b5fc6..f5bb48376d Binary files a/common/static/js/vendor/ova/images/fullpage_pressed.png and b/common/static/js/vendor/ova/images/fullpage_pressed.png differ diff --git a/common/static/js/vendor/ova/images/fullpage_rest.png b/common/static/js/vendor/ova/images/fullpage_rest.png old mode 100755 new mode 100644 index 3172005c6e..2cf72a3d73 Binary files a/common/static/js/vendor/ova/images/fullpage_rest.png and b/common/static/js/vendor/ova/images/fullpage_rest.png differ diff --git a/common/static/js/vendor/ova/images/home_grouphover.png b/common/static/js/vendor/ova/images/home_grouphover.png old mode 100755 new mode 100644 index 204e1cc94b..bba978a57a Binary files a/common/static/js/vendor/ova/images/home_grouphover.png and b/common/static/js/vendor/ova/images/home_grouphover.png differ diff --git a/common/static/js/vendor/ova/images/home_hover.png b/common/static/js/vendor/ova/images/home_hover.png old mode 100755 new mode 100644 index ec218a00a0..1828267cf6 Binary files a/common/static/js/vendor/ova/images/home_hover.png and b/common/static/js/vendor/ova/images/home_hover.png differ diff --git a/common/static/js/vendor/ova/images/home_pressed.png b/common/static/js/vendor/ova/images/home_pressed.png old mode 100755 new mode 100644 index 4439508bc6..655d665286 Binary files a/common/static/js/vendor/ova/images/home_pressed.png and b/common/static/js/vendor/ova/images/home_pressed.png differ diff --git a/common/static/js/vendor/ova/images/home_rest.png b/common/static/js/vendor/ova/images/home_rest.png old mode 100755 new mode 100644 index 009d1bbf4c..bba978a57a Binary files a/common/static/js/vendor/ova/images/home_rest.png and b/common/static/js/vendor/ova/images/home_rest.png differ diff --git a/common/static/js/vendor/ova/images/newan_grouphover.png b/common/static/js/vendor/ova/images/newan_grouphover.png old mode 100755 new mode 100644 index ab0cb6ece1..7b5284a9fe Binary files a/common/static/js/vendor/ova/images/newan_grouphover.png and b/common/static/js/vendor/ova/images/newan_grouphover.png differ diff --git a/common/static/js/vendor/ova/images/newan_hover.png b/common/static/js/vendor/ova/images/newan_hover.png old mode 100755 new mode 100644 index d34f9f5d55..997c848dd7 Binary files a/common/static/js/vendor/ova/images/newan_hover.png and b/common/static/js/vendor/ova/images/newan_hover.png differ diff --git a/common/static/js/vendor/ova/images/newan_pressed.png b/common/static/js/vendor/ova/images/newan_pressed.png old mode 100755 new mode 100644 index d0ad47d963..9f4a4eb830 Binary files a/common/static/js/vendor/ova/images/newan_pressed.png and b/common/static/js/vendor/ova/images/newan_pressed.png differ diff --git a/common/static/js/vendor/ova/images/newan_rest.png b/common/static/js/vendor/ova/images/newan_rest.png old mode 100755 new mode 100644 index 00e07e1aa6..7b5284a9fe Binary files a/common/static/js/vendor/ova/images/newan_rest.png and b/common/static/js/vendor/ova/images/newan_rest.png differ diff --git a/common/static/js/vendor/ova/images/next_grouphover.png b/common/static/js/vendor/ova/images/next_grouphover.png old mode 100755 new mode 100644 index 8d83d8a142..de92d99d13 Binary files a/common/static/js/vendor/ova/images/next_grouphover.png and b/common/static/js/vendor/ova/images/next_grouphover.png differ diff --git a/common/static/js/vendor/ova/images/next_hover.png b/common/static/js/vendor/ova/images/next_hover.png old mode 100755 new mode 100644 index ba24ca988f..4beeb4a937 Binary files a/common/static/js/vendor/ova/images/next_hover.png and b/common/static/js/vendor/ova/images/next_hover.png differ diff --git a/common/static/js/vendor/ova/images/next_pressed.png b/common/static/js/vendor/ova/images/next_pressed.png old mode 100755 new mode 100644 index 95f169d651..173734c777 Binary files a/common/static/js/vendor/ova/images/next_pressed.png and b/common/static/js/vendor/ova/images/next_pressed.png differ diff --git a/common/static/js/vendor/ova/images/next_rest.png b/common/static/js/vendor/ova/images/next_rest.png old mode 100755 new mode 100644 index 5ead544b5d..de92d99d13 Binary files a/common/static/js/vendor/ova/images/next_rest.png and b/common/static/js/vendor/ova/images/next_rest.png differ diff --git a/common/static/js/vendor/ova/images/previous_grouphover.png b/common/static/js/vendor/ova/images/previous_grouphover.png old mode 100755 new mode 100644 index 016e63957a..7b7f6db7f6 Binary files a/common/static/js/vendor/ova/images/previous_grouphover.png and b/common/static/js/vendor/ova/images/previous_grouphover.png differ diff --git a/common/static/js/vendor/ova/images/previous_hover.png b/common/static/js/vendor/ova/images/previous_hover.png old mode 100755 new mode 100644 index d4a5c1552c..9547e65b79 Binary files a/common/static/js/vendor/ova/images/previous_hover.png and b/common/static/js/vendor/ova/images/previous_hover.png differ diff --git a/common/static/js/vendor/ova/images/previous_pressed.png b/common/static/js/vendor/ova/images/previous_pressed.png old mode 100755 new mode 100644 index f999fe4985..0c7a1bf5ec Binary files a/common/static/js/vendor/ova/images/previous_pressed.png and b/common/static/js/vendor/ova/images/previous_pressed.png differ diff --git a/common/static/js/vendor/ova/images/previous_rest.png b/common/static/js/vendor/ova/images/previous_rest.png old mode 100755 new mode 100644 index 9716dac67b..7b7f6db7f6 Binary files a/common/static/js/vendor/ova/images/previous_rest.png and b/common/static/js/vendor/ova/images/previous_rest.png differ diff --git a/common/static/js/vendor/ova/images/zoomin_grouphover.png b/common/static/js/vendor/ova/images/zoomin_grouphover.png old mode 100755 new mode 100644 index c985d0f958..df0c524675 Binary files a/common/static/js/vendor/ova/images/zoomin_grouphover.png and b/common/static/js/vendor/ova/images/zoomin_grouphover.png differ diff --git a/common/static/js/vendor/ova/images/zoomin_hover.png b/common/static/js/vendor/ova/images/zoomin_hover.png old mode 100755 new mode 100644 index 3cab721f1b..206d205540 Binary files a/common/static/js/vendor/ova/images/zoomin_hover.png and b/common/static/js/vendor/ova/images/zoomin_hover.png differ diff --git a/common/static/js/vendor/ova/images/zoomin_pressed.png b/common/static/js/vendor/ova/images/zoomin_pressed.png old mode 100755 new mode 100644 index 9c3a75169c..ebe3df83ef Binary files a/common/static/js/vendor/ova/images/zoomin_pressed.png and b/common/static/js/vendor/ova/images/zoomin_pressed.png differ diff --git a/common/static/js/vendor/ova/images/zoomin_rest.png b/common/static/js/vendor/ova/images/zoomin_rest.png old mode 100755 new mode 100644 index f4219a50ae..df0c524675 Binary files a/common/static/js/vendor/ova/images/zoomin_rest.png and b/common/static/js/vendor/ova/images/zoomin_rest.png differ diff --git a/common/static/js/vendor/ova/images/zoomout_grouphover.png b/common/static/js/vendor/ova/images/zoomout_grouphover.png old mode 100755 new mode 100644 index 46d21b3e50..f9661201df Binary files a/common/static/js/vendor/ova/images/zoomout_grouphover.png and b/common/static/js/vendor/ova/images/zoomout_grouphover.png differ diff --git a/common/static/js/vendor/ova/images/zoomout_hover.png b/common/static/js/vendor/ova/images/zoomout_hover.png old mode 100755 new mode 100644 index 7b924c26d8..e3b0fcd794 Binary files a/common/static/js/vendor/ova/images/zoomout_hover.png and b/common/static/js/vendor/ova/images/zoomout_hover.png differ diff --git a/common/static/js/vendor/ova/images/zoomout_pressed.png b/common/static/js/vendor/ova/images/zoomout_pressed.png old mode 100755 new mode 100644 index c028db7240..6b4d8199c3 Binary files a/common/static/js/vendor/ova/images/zoomout_pressed.png and b/common/static/js/vendor/ova/images/zoomout_pressed.png differ diff --git a/common/static/js/vendor/ova/images/zoomout_rest.png b/common/static/js/vendor/ova/images/zoomout_rest.png old mode 100755 new mode 100644 index a13e07de79..f9661201df Binary files a/common/static/js/vendor/ova/images/zoomout_rest.png and b/common/static/js/vendor/ova/images/zoomout_rest.png differ diff --git a/common/static/js/vendor/ova/richText-annotator.js b/common/static/js/vendor/ova/richText-annotator.js index af3410faab..b5add53706 100644 --- a/common/static/js/vendor/ova/richText-annotator.js +++ b/common/static/js/vendor/ova/richText-annotator.js @@ -38,7 +38,7 @@ Annotator.Plugin.RichText = (function(_super) { } }, codemirror: { - path: "static/js/vendor" + path: "/static/js/vendor" }, plugins: "image link codemirror", menubar: false, diff --git a/lms/templates/imageannotation.html b/lms/templates/imageannotation.html index a4c121cac8..72b73e7188 100644 --- a/lms/templates/imageannotation.html +++ b/lms/templates/imageannotation.html @@ -1,9 +1,4 @@ <%! 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)} -