diff --git a/common/lib/xmodule/xmodule/contentstore/content.py b/common/lib/xmodule/xmodule/contentstore/content.py index a7a76fa242..9badd4b892 100644 --- a/common/lib/xmodule/xmodule/contentstore/content.py +++ b/common/lib/xmodule/xmodule/contentstore/content.py @@ -46,6 +46,11 @@ class StaticContent(object): else: return None + @staticmethod + def get_base_url_path_for_course_assets(loc): + if loc is not None: + return "/c4x/{org}/{course}/asset".format(**loc.dict()) + @staticmethod def get_id_from_location(location): return { 'tag':location.tag, 'org' : location.org, 'course' : location.course, diff --git a/common/lib/xmodule/xmodule/js/src/video/display.coffee b/common/lib/xmodule/xmodule/js/src/video/display.coffee index d6c582d6fa..bb87679d37 100644 --- a/common/lib/xmodule/xmodule/js/src/video/display.coffee +++ b/common/lib/xmodule/xmodule/js/src/video/display.coffee @@ -3,6 +3,7 @@ class @Video @el = $(element).find('.video') @id = @el.attr('id').replace(/video_/, '') @caption_data_dir = @el.data('caption-data-dir') + @caption_asset_path = @el.data('caption-asset-path') @show_captions = @el.data('show-captions') == "true" window.player = null @el = $("#video_#{@id}") diff --git a/common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee b/common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee index cdd74c5d07..e840cd2a77 100644 --- a/common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee +++ b/common/lib/xmodule/xmodule/js/src/video/display/video_caption.coffee @@ -10,7 +10,7 @@ class @VideoCaption extends Subview .bind('DOMMouseScroll', @onMovement) captionURL: -> - "/static/#{@captionDataDir}/subs/#{@youtubeId}.srt.sjson" + "#{@captionAssetPath}#{@youtubeId}.srt.sjson" render: -> # TODO: make it so you can have a video with no captions. diff --git a/common/lib/xmodule/xmodule/js/src/video/display/video_player.coffee b/common/lib/xmodule/xmodule/js/src/video/display/video_player.coffee index 8829e25dac..b7c5bd8a89 100644 --- a/common/lib/xmodule/xmodule/js/src/video/display/video_player.coffee +++ b/common/lib/xmodule/xmodule/js/src/video/display/video_player.coffee @@ -31,7 +31,7 @@ class @VideoPlayer extends Subview el: @el youtubeId: @video.youtubeId('1.0') currentSpeed: @currentSpeed() - captionDataDir: @video.caption_data_dir + captionAssetPath: @video.caption_asset_path unless onTouchBasedDevice() @volumeControl = new VideoVolumeControl el: @$('.secondary-controls') @speedControl = new VideoSpeedControl el: @$('.secondary-controls'), speeds: @video.speeds, currentSpeed: @currentSpeed() diff --git a/common/lib/xmodule/xmodule/modulestore/xml_importer.py b/common/lib/xmodule/xmodule/modulestore/xml_importer.py index 12b495ab68..3f1229b004 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml_importer.py +++ b/common/lib/xmodule/xmodule/modulestore/xml_importer.py @@ -11,12 +11,12 @@ from xmodule.contentstore.content import StaticContent, XASSET_SRCREF_PREFIX log = logging.getLogger(__name__) -def import_static_content(modules, course_loc, course_data_path, static_content_store, target_location_namespace): +def import_static_content(modules, course_loc, course_data_path, static_content_store, target_location_namespace, subpath = 'static'): remap_dict = {} - + # now import all static assets - static_dir = course_data_path / 'static/' + static_dir = course_data_path / subpath for dirname, dirnames, filenames in os.walk(static_dir): for filename in filenames: @@ -24,6 +24,8 @@ def import_static_content(modules, course_loc, course_data_path, static_content_ try: content_path = os.path.join(dirname, filename) fullname_with_subpath = content_path.replace(static_dir, '') # strip away leading path from the name + if fullname_with_subpath.startswith('/'): + fullname_with_subpath = fullname_with_subpath[1:] content_loc = StaticContent.compute_location(target_location_namespace.org, target_location_namespace.course, fullname_with_subpath) mime_type = mimetypes.guess_type(filename)[0] @@ -125,8 +127,11 @@ def import_from_xml(store, data_dir, course_dirs=None, course_location = module.location if static_content_store is not None: + _namespace_rename = target_location_namespace if target_location_namespace is not None else module_store.modules[course_id].location + + # first pass to find everything in /static/ import_static_content(module_store.modules[course_id], course_location, course_data_path, static_content_store, - target_location_namespace if target_location_namespace is not None else course_location) + _namespace_rename, subpath='static') for module in module_store.modules[course_id].itervalues(): diff --git a/common/lib/xmodule/xmodule/video_module.py b/common/lib/xmodule/xmodule/video_module.py index 9a22950ca8..0593b7f00e 100644 --- a/common/lib/xmodule/xmodule/video_module.py +++ b/common/lib/xmodule/xmodule/video_module.py @@ -6,6 +6,9 @@ from pkg_resources import resource_string, resource_listdir from xmodule.x_module import XModule from xmodule.raw_module import RawDescriptor +from xmodule.modulestore.mongo import MongoModuleStore +from xmodule.modulestore.django import modulestore +from xmodule.contentstore.content import StaticContent log = logging.getLogger(__name__) @@ -93,6 +96,13 @@ class VideoModule(XModule): return self.youtube def get_html(self): + if isinstance(modulestore(), MongoModuleStore) : + caption_asset_path = StaticContent.get_base_url_path_for_course_assets(self.location) + '/subs_' + else: + # VS[compat] + # cdodge: filesystem static content support. + caption_asset_path = "/static/{0}/subs/".format(self.metadata['data_dir']) + return self.system.render_template('video.html', { 'streams': self.video_list(), 'id': self.location.html_id(), @@ -102,6 +112,7 @@ class VideoModule(XModule): 'display_name': self.display_name, # TODO (cpennington): This won't work when we move to data that isn't on the filesystem 'data_dir': self.metadata['data_dir'], + 'caption_asset_path': caption_asset_path, 'show_captions': self.show_captions }) diff --git a/lms/templates/video.html b/lms/templates/video.html index 5c041d5c70..18c1bcbced 100644 --- a/lms/templates/video.html +++ b/lms/templates/video.html @@ -2,7 +2,7 @@