From d1d57e81cffb9151cd7b8ce7712b141ed7f3ab97 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Thu, 12 Jul 2012 14:04:09 -0400 Subject: [PATCH 1/4] Don't crash the system if you can't parse an xml file while loading a definition for a module descriptor --- common/lib/xmodule/xmodule/xml_module.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/common/lib/xmodule/xmodule/xml_module.py b/common/lib/xmodule/xmodule/xml_module.py index b0bfaebab5..ce41ff68bc 100644 --- a/common/lib/xmodule/xmodule/xml_module.py +++ b/common/lib/xmodule/xmodule/xml_module.py @@ -172,12 +172,8 @@ class XmlDescriptor(XModuleDescriptor): log.debug('filepath=%s, resources_fs=%s' % (filepath, system.resources_fs)) try: with system.resources_fs.open(filepath) as file: - try: - definition_xml = cls.file_to_xml(file) - except: - log.exception("Failed to parse xml in file %s" % filepath) - raise - except ResourceNotFoundError: + definition_xml = cls.file_to_xml(file) + except (ResourceNotFoundError, etree.XMLSyntaxError): log.exception('Unable to load file contents at path %s' % filepath) return {'data': 'Error loading file contents at path %s' % filepath} From 305cd30da9744e522c1eb32898e8d39823b95136 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Thu, 12 Jul 2012 16:03:12 -0400 Subject: [PATCH 2/4] The path user by url is based on the output css file, which ends up in static/sass, so only use ../, rather than ../../, to reference images --- .../sass_old/courseware/_sequence-nav.scss | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lms/static/sass/sass_old/courseware/_sequence-nav.scss b/lms/static/sass/sass_old/courseware/_sequence-nav.scss index 564cbaae9d..4472724e6d 100644 --- a/lms/static/sass/sass_old/courseware/_sequence-nav.scss +++ b/lms/static/sass/sass_old/courseware/_sequence-nav.scss @@ -89,57 +89,57 @@ nav.sequence-nav { //video &.seq_video_inactive { @extend .inactive; - background-image: url('../../images/sequence-nav/video-icon-normal.png'); + background-image: url('../images/sequence-nav/video-icon-normal.png'); background-position: center; } &.seq_video_visited { @extend .visited; - background-image: url('../../images/sequence-nav/video-icon-visited.png'); + background-image: url('../images/sequence-nav/video-icon-visited.png'); background-position: center; } &.seq_video_active { @extend .active; - background-image: url('../../images/sequence-nav/video-icon-current.png'); + background-image: url('../images/sequence-nav/video-icon-current.png'); background-position: center; } //other &.seq_other_inactive { @extend .inactive; - background-image: url('../../images/sequence-nav/document-icon-normal.png'); + background-image: url('../images/sequence-nav/document-icon-normal.png'); background-position: center; } &.seq_other_visited { @extend .visited; - background-image: url('../../images/sequence-nav/document-icon-visited.png'); + background-image: url('../images/sequence-nav/document-icon-visited.png'); background-position: center; } &.seq_other_active { @extend .active; - background-image: url('../../images/sequence-nav/document-icon-current.png'); + background-image: url('../images/sequence-nav/document-icon-current.png'); background-position: center; } //vertical & problems &.seq_vertical_inactive, &.seq_problem_inactive { @extend .inactive; - background-image: url('../../images/sequence-nav/list-icon-normal.png'); + background-image: url('../images/sequence-nav/list-icon-normal.png'); background-position: center; } &.seq_vertical_visited, &.seq_problem_visited { @extend .visited; - background-image: url('../../images/sequence-nav/list-icon-visited.png'); + background-image: url('../images/sequence-nav/list-icon-visited.png'); background-position: center; } &.seq_vertical_active, &.seq_problem_active { @extend .active; - background-image: url('../../images/sequence-nav/list-icon-current.png'); + background-image: url('../images/sequence-nav/list-icon-current.png'); background-position: center; } @@ -229,7 +229,7 @@ nav.sequence-nav { &.prev { a { - background-image: url('../../images/sequence-nav/previous-icon.png'); + background-image: url('../images/sequence-nav/previous-icon.png'); &:hover { background-color: $cream; @@ -239,7 +239,7 @@ nav.sequence-nav { &.next { a { - background-image: url('../../images/sequence-nav/next-icon.png'); + background-image: url('../images/sequence-nav/next-icon.png'); &:hover { background-color: $cream; @@ -310,7 +310,7 @@ section.course-content { &.prev { a { - background-image: url('../../images/sequence-nav/previous-icon.png'); + background-image: url('../images/sequence-nav/previous-icon.png'); border-right: 1px solid darken(#f6efd4, 20%); &:hover { @@ -321,7 +321,7 @@ section.course-content { &.next { a { - background-image: url('../../images/sequence-nav/next-icon.png'); + background-image: url('../images/sequence-nav/next-icon.png'); &:hover { background-color: none; From c3ba8817e94e280c7fa0740f6c1d197bba62310d Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Thu, 12 Jul 2012 16:06:05 -0400 Subject: [PATCH 3/4] Correctly add course_dirs to static files --- lms/envs/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/envs/common.py b/lms/envs/common.py index dc748f8482..4e81afe870 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -184,7 +184,7 @@ if os.path.isdir(DATA_DIR): # should no longer be added to STATICFILES (course_dir, DATA_DIR / course_dir) for course_dir in os.listdir(DATA_DIR) - if os.path.isdir(course_dir) + if os.path.isdir(DATA_DIR / course_dir) ] # Locale/Internationalization From fefda5db62acbfb47cbdf6f50a14bd2ad4f6253a Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Thu, 12 Jul 2012 16:09:34 -0400 Subject: [PATCH 4/4] Only munge /static/ urls in module html to point to course static files if they don't exist in the global static locations --- common/djangoapps/static_replace.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/common/djangoapps/static_replace.py b/common/djangoapps/static_replace.py index 70031cc754..f9660e7f5e 100644 --- a/common/djangoapps/static_replace.py +++ b/common/djangoapps/static_replace.py @@ -9,8 +9,11 @@ def replace(static_url, prefix=None): prefix = prefix + '/' quote = static_url.group('quote') - url = staticfiles_storage.url(prefix + static_url.group('rest')) - return "".join([quote, url, quote]) + if staticfiles_storage.exists(static_url.group('rest')): + return static_url.group(0) + else: + url = staticfiles_storage.url(prefix + static_url.group('rest')) + return "".join([quote, url, quote]) def replace_urls(text, staticfiles_prefix=None, replace_prefix='/static/'): @@ -18,9 +21,9 @@ def replace_urls(text, staticfiles_prefix=None, replace_prefix='/static/'): return replace(static_url, staticfiles_prefix) return re.sub(r""" - (?x) # flags=re.VERBOSE - (?P\\?['"]) # the opening quotes - {prefix} # the prefix - (?P.*?) # everything else in the url - (?P=quote) # the first matching closing quote + (?x) # flags=re.VERBOSE + (?P\\?['"]) # the opening quotes + (?P{prefix}) # the prefix + (?P.*?) # everything else in the url + (?P=quote) # the first matching closing quote """.format(prefix=replace_prefix), replace_url, text)