|
|
|
# -*- coding: iso-8859-1 -*-
|
|
|
|
u'''
|
|
|
|
MoinMoin - YouTubeVideo macro Version 0.1
|
|
|
|
Displays an embedded video
|
|
|
|
|
|
|
|
<<YouTube(video_id=None, width=None, height=None)>>
|
|
|
|
If an video_id is not given, no element will be shown
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
* <<YouTube(2SXKM-dLJV8)>>
|
|
|
|
* <<YouTube(2SXKM-dLJV8, width=560, height=315)>>
|
|
|
|
|
|
|
|
Repository for the macro:
|
|
|
|
https://git.cpi.imtek.uni-freiburg.de/holgi/YouTubeVideoMacro
|
|
|
|
|
|
|
|
@copyright: 2018 by Holger Frey
|
|
|
|
@license: Beerware license
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
from MoinMoin import wikiutil
|
|
|
|
|
|
|
|
|
|
|
|
def macro_YouTubeVideo(macro, video_id=None, width=None, height=None):
|
|
|
|
request = macro.request
|
|
|
|
_ = request.getText
|
|
|
|
|
|
|
|
if video_id is None:
|
|
|
|
# no video id given
|
|
|
|
return macro.formatter.rawHTML(u'')
|
|
|
|
|
|
|
|
video_id = wikiutil.escape(str(video_id))
|
|
|
|
|
|
|
|
if width is None:
|
|
|
|
width_attrib = ''
|
|
|
|
else:
|
|
|
|
escaped = wikiutil.escape(str(width))
|
|
|
|
width_attrib = 'width="%s"' % escaped
|
|
|
|
|
|
|
|
if height is None:
|
|
|
|
height_attrib = ''
|
|
|
|
else:
|
|
|
|
escaped = wikiutil.escape(str(height))
|
|
|
|
height_attrib = 'height="%s"' % escaped
|
|
|
|
|
|
|
|
tmp = (u'<iframe src="https://www.youtube-nocookie.com/embed/%s?rel=0" '
|
|
|
|
u'%s %s frameborder="0" allow="autoplay; encrypted-media" '
|
|
|
|
u'allowfullscreen></iframe>'
|
|
|
|
)
|
|
|
|
html = tmp % (video_id, width_attrib, height_attrib)
|
|
|
|
return macro.formatter.rawHTML(html)
|