diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index aa6f6ce235..1445c47c23 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -98,7 +98,7 @@ def edit_item(request): item = modulestore().get_item(item_location) return render_to_response('unit.html', { 'contents': item.get_html(), - 'js_module': item.__class__.__name__, + 'js_module': item.js_module_name, 'category': item.category, 'name': item.name, 'previews': get_module_previews(item), diff --git a/cms/envs/common.py b/cms/envs/common.py index c11ca297b6..41b34bdaa1 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -26,6 +26,7 @@ import os import errno import glob2 import lms.envs.common +import hashlib from path import path ############################ FEATURE CONFIGURATION ############################# @@ -190,18 +191,27 @@ except OSError as exc: else: raise -module_js_sources = [] -for xmodule in XModuleDescriptor.load_classes() + [RawDescriptor]: - js = xmodule.get_javascript() +fragments = set() +for descriptor in XModuleDescriptor.load_classes() + [RawDescriptor]: + descriptor_js = descriptor.get_javascript() + module = getattr(descriptor, 'module_class', None) + if module is not None: + module_js = module.get_javascript() + else: + module_js = {} + for filetype in ('coffee', 'js'): - for idx, fragment in enumerate(js.get(filetype, [])): - path = os.path.join(js_file_dir, "{name}.{idx}.{type}".format( - name=xmodule.__name__, - idx=idx, - type=filetype)) - with open(path, 'w') as js_file: - js_file.write(fragment) - module_js_sources.append(path.replace(PROJECT_ROOT / "static/", "")) + for fragment in descriptor_js.get(filetype, []) + module_js.get(filetype, []): + fragments.add((filetype, fragment)) + +module_js_sources = [] +for filetype, fragment in fragments: + path = os.path.join(js_file_dir, "{hash}.{type}".format( + hash=hashlib.md5(fragment).hexdigest(), + type=filetype)) + with open(path, 'w') as js_file: + js_file.write(fragment) + module_js_sources.append(path.replace(PROJECT_ROOT / "static/", "")) PIPELINE_JS = { 'main': { diff --git a/cms/templates/widgets/navigation.html b/cms/templates/widgets/navigation.html index d01e8197b8..5c8b783716 100644 --- a/cms/templates/widgets/navigation.html +++ b/cms/templates/widgets/navigation.html @@ -55,7 +55,7 @@