From 7fad6570d3d4a35910d8e70cb2cace2a255a9d6f Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Mon, 7 May 2018 11:43:44 +0200 Subject: [PATCH] new working YouTubeVideo macro --- YouTubeVideo.py | 154 +++++++----------------------------------------- 1 file changed, 21 insertions(+), 133 deletions(-) diff --git a/YouTubeVideo.py b/YouTubeVideo.py index 5c59abd..5ad5477 100644 --- a/YouTubeVideo.py +++ b/YouTubeVideo.py @@ -1,149 +1,37 @@ # -*- coding: iso-8859-1 -*- -u""" - MoinMoin - YouTube macro Version 0.6 - Displays an embedded object with the wanted video or - displays a list of videos (videobar). +u''' + MoinMoin - YouTubeVideo macro Version 0.1 + Displays an embedded video - <> - Default is to use the current pagename as keyword. + <> + If an video_id is not given, no element will be shown Examples: - * <> - * <> - * <> + * <> + * <> - @copyright: 2008 by MarcelHäfner (http://moinmo.in/MarcelHäfner), - 2010 by ThomasWaldmann (http://moinmo.in/ThomasWaldmann) - @license: GNU GPL, see COPYING for details. + @copyright: 2018 by Holger Frey + @license: Beerware license - Attention! The "keyword" part is created with the "Google AJAX Search API Tools". - Licence Information can be viewed under: http://code.google.com/intl/de-DE/apis/ajaxsearch/terms.html - - @TODO: - * Change the hardcoded https string into http/https depending on the requested url. - * Don't use the google ajax stuff. - * Check if youtube videos are disabled (mimetypes_xss). - -""" +''' from MoinMoin import wikiutil -def macro_YouTube(macro, id, keyword): +def macro_YouTubeVideo(macro, video_id=None, width=None, height=None): request = macro.request _ = request.getText - html = u"" - - if id is None and keyword is None: - # default: keyword will be used and default to current page name - keyword = macro.formatter.page.page_name - - if keyword is not None: - # for the videobar to display the flash videos (keyword) - parameters = { - "keyword": wikiutil.escape(keyword), - "msg_youtubelink": _("View the related videos on YouTube."), - } - html = u""" -
- - - - -
- Loading... -
- - - - - - - - - - - - - -
- """ % parameters - - if id is not None: - # for the embedded flashplayer to play a single video (id) - parameters = { - "id": wikiutil.escape(id), - "msg_youtubelink": _("View the video on YouTube."), - } - html = u""" -
- - - - - - - - - - - - -
- """ % parameters + width = '' if width is None else 'width="%s"' % str(width) + height = '' if height is None else 'height="%s"' % str(height) + tmp = (u'' + ) + html = tmp % (video_id, width, height) return macro.formatter.rawHTML(html) -