Merge pull request #4190 from edx/usman/lms2848-htmlbooks-fix
Fix for htmlbooks
This commit is contained in:
@@ -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),
|
||||
},
|
||||
)
|
||||
|
||||
@@ -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:
|
||||
#
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
</%block>
|
||||
|
||||
<%block name="js_extra">
|
||||
<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">
|
||||
tinyMCE.baseURL = "${settings.STATIC_URL}" + "js/vendor/ova";
|
||||
(function($) {
|
||||
$.fn.myHTMLViewer = function(options) {
|
||||
var urlToLoad = null;
|
||||
@@ -38,7 +39,7 @@
|
||||
if(options.notesEnabled) {
|
||||
onComplete = function(url) {
|
||||
return function() {
|
||||
$('#viewerContainer').trigger('notes:init', [url]);
|
||||
$('#viewerContainer').trigger('notes:init', [url, "${storage}", "${token}"]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user