X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/3f24ff6b4246a5206555952f6e6c53f6ed5231d8..5135e076096ce04b1dbbb2f6210512d1a44fa237:/librarian/formats/html/__init__.py diff --git a/librarian/formats/html/__init__.py b/librarian/formats/html/__init__.py index ae6470a..01dcbde 100644 --- a/librarian/formats/html/__init__.py +++ b/librarian/formats/html/__init__.py @@ -187,6 +187,24 @@ class DivImage(NaturalText): HtmlFormat.renderers.register(core.Div, 'img', DivImage('img')) + +class DivVideo(NaturalText): + def render(self, element, ctx): + output = super(DivVideo, self).render(element, ctx) + video_id = element.attrib.get('videoid', '') + attribs = { + 'width': '854', + 'height': '480', + 'src': '//www.youtube.com/embed/%s?controls=2&rel=0&showinfo=0&theme=light' % video_id, + 'frameborder': '0', + 'allowfullscreen': '', + } + for attrib, value in attribs.iteritems(): + output[0].attrib[attrib] = value + return output + +HtmlFormat.renderers.register(core.Div, 'video', DivVideo('iframe')) + HtmlFormat.renderers.register(core.Div, 'item', NaturalText('li')) HtmlFormat.renderers.register(core.Div, 'list', NaturalText('ul')) HtmlFormat.renderers.register(core.Div, 'list.enum', NaturalText('ol'))