Commit fefda5db by Calen Pennington

Only munge /static/ urls in module html to point to course static files if they…

Only munge /static/ urls in module html to point to course static files if they don't exist in the global static locations
parent c3ba8817
...@@ -9,6 +9,9 @@ def replace(static_url, prefix=None): ...@@ -9,6 +9,9 @@ def replace(static_url, prefix=None):
prefix = prefix + '/' prefix = prefix + '/'
quote = static_url.group('quote') quote = static_url.group('quote')
if staticfiles_storage.exists(static_url.group('rest')):
return static_url.group(0)
else:
url = staticfiles_storage.url(prefix + static_url.group('rest')) url = staticfiles_storage.url(prefix + static_url.group('rest'))
return "".join([quote, url, quote]) return "".join([quote, url, quote])
...@@ -20,7 +23,7 @@ def replace_urls(text, staticfiles_prefix=None, replace_prefix='/static/'): ...@@ -20,7 +23,7 @@ def replace_urls(text, staticfiles_prefix=None, replace_prefix='/static/'):
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)
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