diff --git a/lms/djangoapps/staticbook/views.py b/lms/djangoapps/staticbook/views.py index 518fb58902..dd517687f8 100644 --- a/lms/djangoapps/staticbook/views.py +++ b/lms/djangoapps/staticbook/views.py @@ -7,6 +7,8 @@ from django.http import Http404 from edxmako.shortcuts import render_to_response from opaque_keys.edx.locations import SlashSeparatedCourseKey +from xmodule.annotator_token import retrieve_token + from courseware.access import has_access from courseware.courses import get_course_with_access from notes.utils import notes_enabled_for_course @@ -170,5 +172,7 @@ def html_index(request, course_id, book_index, chapter=None): 'student': student, 'staff_access': staff_access, 'notes_enabled': notes_enabled, + 'storage': course.annotation_storage_url, + 'token': retrieve_token(student.email, course.annotation_token_secret), }, ) diff --git a/lms/static/coffee/src/notes.coffee b/lms/static/coffee/src/notes.coffee index 956bdabf62..c8da11da60 100644 --- a/lms/static/coffee/src/notes.coffee +++ b/lms/static/coffee/src/notes.coffee @@ -13,10 +13,9 @@ class StudentNotes $(el).data('notes-instance', @) # Initializes annotations on a container element in response to an init event. - onInitNotes: (event, uri=null) => + onInitNotes: (event, uri=null, storage_url=null, token=null) => event.stopPropagation() - storeConfig = @getStoreConfig uri found = @targets.some (target) -> target is event.target # Get uri @@ -47,10 +46,10 @@ class StudentNotes return user.id if user and user.id user auth: - tokenUrl: location.protocol+'//'+location.host+"/token?course_id="+courseid + token: token store: - prefix: 'http://catch.aws.af.cm/annotator' + prefix: storage_url annotationData: uri:uri @@ -88,33 +87,6 @@ class StudentNotes else @targets.push(event.target) - # Returns a JSON config object that can be passed to the annotator Store plugin - getStoreConfig: (uri) -> - prefix = @getPrefix() - if uri is null - uri = @getURIPath() - - storeConfig = - prefix: prefix - loadFromSearch: - uri: uri - limit: 0 - annotationData: - uri: uri - storeConfig - - # Returns the API endpoint for the annotation store - getPrefix: () -> - re = /^(\/courses\/[^/]+\/[^/]+\/[^/]+)/ - match = re.exec(@getURIPath()) - prefix = (if match then match[1] else '') - return "#{prefix}/notes/api" - - # Returns the URI path of the current page for filtering annotations - getURIPath: () -> - window.location.href.toString().split(window.location.host)[1] - - # Enable notes by default on the document root. # To initialize annotations on a container element in the document: # diff --git a/lms/templates/static_htmlbook.html b/lms/templates/static_htmlbook.html index f93b67c83b..972074bed3 100644 --- a/lms/templates/static_htmlbook.html +++ b/lms/templates/static_htmlbook.html @@ -11,8 +11,9 @@ <%block name="js_extra"> + +