Commit 214d03c1 by David Ormsbee

Merge pull request #177 from MITx/feature/lms-static-files

Allow module html to link to global static files as well as course static files
parents d1f8f4be fefda5db
...@@ -9,8 +9,11 @@ def replace(static_url, prefix=None): ...@@ -9,8 +9,11 @@ def replace(static_url, prefix=None):
prefix = prefix + '/' prefix = prefix + '/'
quote = static_url.group('quote') quote = static_url.group('quote')
url = staticfiles_storage.url(prefix + static_url.group('rest')) if staticfiles_storage.exists(static_url.group('rest')):
return "".join([quote, url, quote]) 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/'): def replace_urls(text, staticfiles_prefix=None, replace_prefix='/static/'):
...@@ -18,9 +21,9 @@ 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 replace(static_url, staticfiles_prefix)
return re.sub(r""" return re.sub(r"""
(?x) # flags=re.VERBOSE (?x) # flags=re.VERBOSE
(?P<quote>\\?['"]) # the opening quotes (?P<quote>\\?['"]) # the opening quotes
{prefix} # the prefix (?P<prefix>{prefix}) # the prefix
(?P<rest>.*?) # everything else in the url (?P<rest>.*?) # everything else in the url
(?P=quote) # the first matching closing quote (?P=quote) # the first matching closing quote
""".format(prefix=replace_prefix), replace_url, text) """.format(prefix=replace_prefix), replace_url, text)
...@@ -172,12 +172,8 @@ class XmlDescriptor(XModuleDescriptor): ...@@ -172,12 +172,8 @@ class XmlDescriptor(XModuleDescriptor):
log.debug('filepath=%s, resources_fs=%s' % (filepath, system.resources_fs)) log.debug('filepath=%s, resources_fs=%s' % (filepath, system.resources_fs))
try: try:
with system.resources_fs.open(filepath) as file: with system.resources_fs.open(filepath) as file:
try: definition_xml = cls.file_to_xml(file)
definition_xml = cls.file_to_xml(file) except (ResourceNotFoundError, etree.XMLSyntaxError):
except:
log.exception("Failed to parse xml in file %s" % filepath)
raise
except ResourceNotFoundError:
log.exception('Unable to load file contents at path %s' % filepath) log.exception('Unable to load file contents at path %s' % filepath)
return {'data': 'Error loading file contents at path %s' % filepath} return {'data': 'Error loading file contents at path %s' % filepath}
......
...@@ -184,7 +184,7 @@ if os.path.isdir(DATA_DIR): ...@@ -184,7 +184,7 @@ if os.path.isdir(DATA_DIR):
# should no longer be added to STATICFILES # should no longer be added to STATICFILES
(course_dir, DATA_DIR / course_dir) (course_dir, DATA_DIR / course_dir)
for course_dir in os.listdir(DATA_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 # Locale/Internationalization
......
...@@ -89,57 +89,57 @@ nav.sequence-nav { ...@@ -89,57 +89,57 @@ nav.sequence-nav {
//video //video
&.seq_video_inactive { &.seq_video_inactive {
@extend .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; background-position: center;
} }
&.seq_video_visited { &.seq_video_visited {
@extend .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; background-position: center;
} }
&.seq_video_active { &.seq_video_active {
@extend .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; background-position: center;
} }
//other //other
&.seq_other_inactive { &.seq_other_inactive {
@extend .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; background-position: center;
} }
&.seq_other_visited { &.seq_other_visited {
@extend .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; background-position: center;
} }
&.seq_other_active { &.seq_other_active {
@extend .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; background-position: center;
} }
//vertical & problems //vertical & problems
&.seq_vertical_inactive, &.seq_problem_inactive { &.seq_vertical_inactive, &.seq_problem_inactive {
@extend .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; background-position: center;
} }
&.seq_vertical_visited, &.seq_problem_visited { &.seq_vertical_visited, &.seq_problem_visited {
@extend .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; background-position: center;
} }
&.seq_vertical_active, &.seq_problem_active { &.seq_vertical_active, &.seq_problem_active {
@extend .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; background-position: center;
} }
...@@ -229,7 +229,7 @@ nav.sequence-nav { ...@@ -229,7 +229,7 @@ nav.sequence-nav {
&.prev { &.prev {
a { a {
background-image: url('../../images/sequence-nav/previous-icon.png'); background-image: url('../images/sequence-nav/previous-icon.png');
&:hover { &:hover {
background-color: $cream; background-color: $cream;
...@@ -239,7 +239,7 @@ nav.sequence-nav { ...@@ -239,7 +239,7 @@ nav.sequence-nav {
&.next { &.next {
a { a {
background-image: url('../../images/sequence-nav/next-icon.png'); background-image: url('../images/sequence-nav/next-icon.png');
&:hover { &:hover {
background-color: $cream; background-color: $cream;
...@@ -310,7 +310,7 @@ section.course-content { ...@@ -310,7 +310,7 @@ section.course-content {
&.prev { &.prev {
a { 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%); border-right: 1px solid darken(#f6efd4, 20%);
&:hover { &:hover {
...@@ -321,7 +321,7 @@ section.course-content { ...@@ -321,7 +321,7 @@ section.course-content {
&.next { &.next {
a { a {
background-image: url('../../images/sequence-nav/next-icon.png'); background-image: url('../images/sequence-nav/next-icon.png');
&:hover { &:hover {
background-color: none; background-color: none;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment