+ def handle_link(self, element):
+ if 'url' in element.attrib:
+ return tag('a', href=element.attrib['url'])(self, element)
+ elif 'material' in element.attrib:
+ material_err = u' [BRAKUJĄCY MATERIAŁ]'
+ slug = element.attrib['material']
+ make_url = lambda f: self.options['urlmapper'] \
+ .url_for_material(slug, f)
+
+ if 'format' in element.attrib:
+ formats = re.split(r"[, ]+",
+ element.attrib['format'])
+ else:
+ formats = [None]
+
+ formats = self.options['urlmapper'].materials(slug)
+
+ try:
+ def_href = make_url(formats[0][0])
+ def_err = u""
+ except (IndexError, self.options['urlmapper'].MaterialNotFound):
+ def_err = material_err
+ def_href = u""
+ fmt_links = []
+ for f in formats[1:]:
+ try:
+ fmt_links.append(u'<a href="%s">%s</a>' % (make_url(f[0]), f[0].upper()))
+ except self.options['urlmapper'].MaterialNotFound:
+ fmt_links.append(u'<a>%s%s</a>' % (f[0].upper(), material_err))
+ more_links = u' (%s)' % u', '.join(fmt_links) if fmt_links else u''
+
+ return u"<a href='%s'>" % def_href, u'%s</a>%s' % (def_err, more_links)
+
+ def handle_video(self, element):
+ url = element.attrib.get('url')
+ if not url:
+ print '!! <video> missing url'
+ return
+ m = re.match(r'https?://(?:www.)?youtube.com/watch\?(?:.*&)?v=([^&]+)(?:$|&)', url)
+ if not m:
+ print '!! unknown <video> url scheme:', url
+ return
+ return """<iframe width="630" height="384" src="http://www.youtube.com/embed/%s"
+ frameborder="0" allowfullscreen></iframe>""" % m.group(1), ""
+
+
+class Exercise(EduModule):
+ INSTRUCTION = ""