A collection of macros for the MoinMoin wiki software.
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.

41 lines
1.2 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'')
width = '' if width is None else 'width="%s"' % str(width)
height = '' if height is None else 'height="%s"' % str(height)
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, height)
return macro.formatter.rawHTML(html)