Commit 31216ccd by kimth

Do URL replacement in course info page

parent d095b777
...@@ -133,8 +133,13 @@ def get_course_info_section(course, section_key): ...@@ -133,8 +133,13 @@ def get_course_info_section(course, section_key):
if section_key in ['handouts', 'guest_handouts', 'updates', 'guest_updates']: if section_key in ['handouts', 'guest_handouts', 'updates', 'guest_updates']:
try: try:
with course.system.resources_fs.open(path("info") / section_key + ".html") as htmlFile: with course.system.resources_fs.open(path("info") / section_key + ".html") as htmlFile:
return replace_urls(htmlFile.read().decode('utf-8'), # Replace '/static/' urls
course.metadata['data_dir']) info_html = replace_urls(htmlFile.read().decode('utf-8'), course.metadata['data_dir'])
# Replace '/course/' urls
course_root = '/courses/' + course.location.course_id
info_html = replace_urls(info_html, course_root, '/course/')
return info_html
except ResourceNotFoundError: except ResourceNotFoundError:
log.exception("Missing info section {key} in course {url}".format( log.exception("Missing info section {key} in course {url}".format(
key=section_key, url=course.location.url())) key=section_key, url=course.location.url()))
......
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