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 @@
% for module in week.get_children():
- -
+
-
${module.name}
handle
diff --git a/cms/templates/widgets/sequence-edit.html b/cms/templates/widgets/sequence-edit.html
index 017057c45d..5da8d8dfb2 100644
--- a/cms/templates/widgets/sequence-edit.html
+++ b/cms/templates/widgets/sequence-edit.html
@@ -36,7 +36,7 @@
% for child in module.get_children():
-
- ${child.name}
+ ${child.name}
handle
%endfor
diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py
index 12872f64f1..1dc92c915b 100644
--- a/common/lib/xmodule/xmodule/x_module.py
+++ b/common/lib/xmodule/xmodule/x_module.py
@@ -196,6 +196,11 @@ class XModule(object):
return ""
# ================================== HTML INTERFACE DEFINITIONS ======================
+
+ @property
+ def js_module_name(self):
+ return self.__class__.__name__
+
@classmethod
def get_javascript(cls):
"""
@@ -401,6 +406,10 @@ class XModuleDescriptor(Plugin):
raise NotImplementedError('Modules must implement export_to_xml to enable xml export')
# ================================== HTML INTERFACE DEFINITIONS ======================
+ @property
+ def js_module_name(self):
+ return self.__class__.__name__
+
@classmethod
def get_javascript(cls):
"""
diff --git a/lms/envs/common.py b/lms/envs/common.py
index 37ec0de15b..8b179e90d4 100644
--- a/lms/envs/common.py
+++ b/lms/envs/common.py
@@ -23,6 +23,7 @@ import os
import tempfile
import glob2
import errno
+import hashlib
import djcelery
from path import path
@@ -341,7 +342,7 @@ except OSError as exc:
else:
raise
-module_js_sources = []
+fragments = set()
for descriptor in XModuleDescriptor.load_classes() + [HiddenDescriptor]:
module = getattr(descriptor, 'module_class', None)
if module is None:
@@ -349,14 +350,17 @@ for descriptor in XModuleDescriptor.load_classes() + [HiddenDescriptor]:
js = module.get_javascript()
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=module.__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 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 = {