You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.4 KiB
51 lines
1.4 KiB
# -*- 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)
|
|
|