Commit def9b5ef by Calen Pennington

Use html safe IDs for sequences and videos

parent 34d68348
......@@ -113,6 +113,12 @@ class Location(object):
url += "/" + self.revision
return url
def html_id(self):
"""
Return a string with a version of the location that is safe for use in html id attributes
"""
return "-".join(str(v) for v in self.list() if v is not None)
def list(self):
"""
Return a list representing this location
......
......@@ -67,7 +67,7 @@ class SequenceModule(XModule):
# of script, even if it occurs mid-string. Do this after json.dumps()ing
# so that we can be sure of the quotations being used
params = {'items': json.dumps(contents).replace('</script>', '<"+"/script>'),
'element_id': "-".join(str(v) for v in self.location.list()),
'element_id': self.location.html_id(),
'item_id': self.id,
'position': self.position,
'tag': self.location.category}
......
......@@ -46,7 +46,7 @@ class VideoModule(XModule):
def get_html(self):
return self.system.render_template('video.html', {
'streams': self.video_list(),
'id': self.id,
'id': self.location.html_id(),
'position': self.position,
'name': self.name,
'annotations': self.annotations,
......
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