Commit d36e00d4 by Usman Khalid

Pass storage_url and token values as parameters to StudentNotes init.

LMS-2848
parent f253f9a7
...@@ -7,6 +7,8 @@ from django.http import Http404 ...@@ -7,6 +7,8 @@ from django.http import Http404
from edxmako.shortcuts import render_to_response from edxmako.shortcuts import render_to_response
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locations import SlashSeparatedCourseKey
from xmodule.annotator_token import retrieve_token
from courseware.access import has_access from courseware.access import has_access
from courseware.courses import get_course_with_access from courseware.courses import get_course_with_access
from notes.utils import notes_enabled_for_course from notes.utils import notes_enabled_for_course
...@@ -170,5 +172,7 @@ def html_index(request, course_id, book_index, chapter=None): ...@@ -170,5 +172,7 @@ def html_index(request, course_id, book_index, chapter=None):
'student': student, 'student': student,
'staff_access': staff_access, 'staff_access': staff_access,
'notes_enabled': notes_enabled, 'notes_enabled': notes_enabled,
'storage': course.annotation_storage_url,
'token': retrieve_token(student.email, course.annotation_token_secret),
}, },
) )
...@@ -13,10 +13,9 @@ class StudentNotes ...@@ -13,10 +13,9 @@ class StudentNotes
$(el).data('notes-instance', @) $(el).data('notes-instance', @)
# Initializes annotations on a container element in response to an init event. # 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() event.stopPropagation()
storeConfig = @getStoreConfig uri
found = @targets.some (target) -> target is event.target found = @targets.some (target) -> target is event.target
# Get uri # Get uri
...@@ -47,10 +46,10 @@ class StudentNotes ...@@ -47,10 +46,10 @@ class StudentNotes
return user.id if user and user.id return user.id if user and user.id
user user
auth: auth:
tokenUrl: location.protocol+'//'+location.host+"/token?course_id="+courseid token: token
store: store:
prefix: 'http://catch.aws.af.cm/annotator' prefix: storage_url
annotationData: uri:uri annotationData: uri:uri
...@@ -88,33 +87,6 @@ class StudentNotes ...@@ -88,33 +87,6 @@ class StudentNotes
else else
@targets.push(event.target) @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. # Enable notes by default on the document root.
# To initialize annotations on a container element in the document: # To initialize annotations on a container element in the document:
# #
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
<script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/tinymce.full.min.js')}"></script> <script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/tinymce.full.min.js')}"></script>
<script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/jquery.tinymce.min.js')}"></script> <script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/jquery.tinymce.min.js')}"></script>
<script type="text/javascript"> <script type="text/javascript">
tinyMCE.baseURL = "${static.url('js/vendor/tinymce/js/tinymce')}";
(function($) { (function($) {
$.fn.myHTMLViewer = function(options) { $.fn.myHTMLViewer = function(options) {
var urlToLoad = null; var urlToLoad = null;
...@@ -40,7 +39,7 @@ ...@@ -40,7 +39,7 @@
if(options.notesEnabled) { if(options.notesEnabled) {
onComplete = function(url) { onComplete = function(url) {
return function() { return function() {
$('#viewerContainer').trigger('notes:init', [url]); $('#viewerContainer').trigger('notes:init', [url, "${storage}", "${token}"]);
} }
}; };
} }
......
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