Attachment 'YouTube-0.4.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 u"""
   3     MoinMoin - YouTube macro Version 0.4
   4                Displays an emended object with the wanted video or
   5                displays a list of videos (videobar)
   6 
   7     <<YouTube(id="YouTubeID", keyword="keyword")>>
   8     Default is to using the current pagename as keyword
   9 
  10     Exampels: 
  11      * <<YouTube>>
  12      * <<YouTube(2SXKM-dLJV8)>>
  13      * <<YouTube(keyword="iron maiden")>>
  14 
  15     @copyright: 2008 by MarcelHäfner (http://moinmo.in/MarcelHäfner)
  16     @license: GNU GPL, see COPYING for details.
  17 
  18     Attention! The "keyword" part is created with the "Google AJAX Search API Tools". 
  19     Licence Information can be viewed under: http://code.google.com/intl/de-DE/apis/ajaxsearch/terms.html
  20 
  21     @TODO:
  22      * Change the hardcoded https string into http/https depending on the requested url
  23      * Don't use the google ajax stuff
  24      * check if youtube videos are disabled (mimetypes_xss)
  25 
  26 """
  27 
  28 from MoinMoin import wikiutil
  29 
  30 def macro_YouTube(macro, id, keyword):
  31     
  32     request = macro.request
  33     _ = request.getText
  34     html = u""
  35 
  36     if id is None and keyword is None:
  37         # default: keyword will be uses
  38         keyword = macro.formatter.page.page_name
  39 
  40     if keyword is not None:
  41         # for the videobar to display the flash videos (keyword)
  42         parameters = {
  43             "keyword":  wikiutil.escape(keyword), 
  44             "msg_youtubelink": _("View the related videos on YouTube."),
  45             }
  46         html = u""" <div class="youtube youtube_keyword">
  47         <!-- ++Begin Video Bar Wizard Generated Code++ -->
  48           <!--
  49           // Created with a Google AJAX Search Wizard
  50           // http://code.google.com/apis/ajaxsearch/wizards.html
  51           -->
  52 
  53           <!--
  54           // The Following div element will end up holding the actual videobar.
  55           // You can place this anywhere on your page.
  56           -->
  57           <div id="videoBar-bar">
  58             <span style="color:#676767;font-size:11px;margin:10px;padding:4px;">Loading...</span>
  59           </div>
  60 
  61           <!-- Ajax Search Api and Stylesheet
  62           // Note: If you are already using the AJAX Search API, then do not include it
  63           //       or its stylesheet again
  64           -->
  65           <script src="https://www.google.com/uds/api?file=uds.js&v=1.0&source=uds-vbw"
  66             type="text/javascript"></script>
  67           <style type="text/css">
  68             @import url("https://www.google.com/uds/css/gsearch.css");
  69           </style>
  70 
  71           <!-- Video Bar Code and Stylesheet -->
  72           <script type="text/javascript">
  73             window._uds_vbw_donotrepair = true;
  74           </script>
  75           <script src="https://www.google.com/uds/solutions/videobar/gsvideobar.js?mode=new"
  76             type="text/javascript"></script>
  77           <style type="text/css">
  78             @import url("https://www.google.com/uds/solutions/videobar/gsvideobar.css");
  79           </style>
  80 
  81           <style type="text/css">
  82             .playerInnerBox_gsvb .player_gsvb {
  83               width : 320px;
  84               height : 260px;
  85             }
  86           </style>
  87           <script type="text/javascript">
  88             function LoadVideoBar() {
  89 
  90             var videoBar;
  91             var options = {
  92                 largeResultSet : !true,
  93                 horizontal : true,
  94                 autoExecuteList : {
  95                   cycleTime : GSvideoBar.CYCLE_TIME_MEDIUM,
  96                   cycleMode : GSvideoBar.CYCLE_MODE_LINEAR,
  97                   executeList : ["%(keyword)s"]
  98                 }
  99               }
 100             
 101             videoBar = new GSvideoBar(document.getElementById("videoBar-bar"),
 102                                       GSvideoBar.PLAYER_ROOT_FLOATING,
 103                                       options);
 104             }
 105             // arrange for this function to be called during body.onload
 106             // event processing
 107             GSearch.setOnLoadCallback(LoadVideoBar);
 108           </script>
 109         <!-- ++End Video Bar Wizard Generated Code++ -->
 110             <p class="youtube_link" style="display:none;">
 111                 <a href="http://http://www.youtube.com/results?search_query=%(keyword)s">%(msg_youtubelink)s</a>
 112             </p>
 113         </div>
 114         """ % parameters
 115 
 116     if id is not None:
 117         # for the embedded flashplayer to play a single video (id)
 118         parameters = {
 119             "id":  wikiutil.escape(id), 
 120             "msg_youtubelink": _("View the video on YouTube."),
 121             }
 122         html = u""" 
 123         <div class="youtube youtube_id">
 124 
 125             <object width="425" height="344">
 126                 <param name="movie" value="http://www.youtube.com/v/%(id)s&rel=0&fs=1"></param>
 127                 <param name="rel" value="0"></param>
 128                 <param name="allowFullScreen" value="true"></param>
 129                 <embed src="http://www.youtube.com/v/%(id)s&fs=1&rel=0"
 130                     type="application/x-shockwave-flash"
 131                     allowfullscreen="true"
 132                     rel="false"
 133                     width="425" height="344">
 134                 </embed>
 135             </object>
 136 
 137             <p class="youtube_link" style="display:none;">
 138                 <a href="http://www.youtube.com/v/%(id)s&fs=1&rel=0">%(msg_youtubelink)s</a>
 139             </p>
 140 
 141         </div>
 142         """ % parameters
 143 
 144     return macro.formatter.rawHTML(html)

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2006-11-30 17:28:46, 0.8 KB) [[attachment:YouTube-0.0.2.py]]
  • [get | view] (2009-10-18 15:05:59, 5.2 KB) [[attachment:YouTube-0.4.py]]
  • [get | view] (2010-05-19 21:23:36, 5.5 KB) [[attachment:YouTube-0.5.py]]
  • [get | view] (2011-01-29 10:49:40, 5.6 KB) [[attachment:YouTube-0.6.py]]
  • [get | view] (2009-10-18 15:06:13, 175.1 KB) [[attachment:youtube_singlevideo.png]]
  • [get | view] (2009-10-18 15:18:09, 299.2 KB) [[attachment:youtube_videobar.png]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.