# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - UstreamTvCaht Macro

    A macro to embed Chats from ustream.tv on wiki pages.
    
    Usage: [[UstreamTvChat(channel)]]
    
    Parameters:
    
    	channel: The name of the channel you want to embed. You find this this name in the string given under the chat-window marked as "Embed Chat:". The leading # must be removed. 
    	
    Example:
    
    	[[UstreamTvChat(WikiTreffen)]]
    	
    	The Code to embed given at ustream looks like this:
    	
    	<embed width="563" height="266" type="application/x-shockwave-flash" flashvars="channel=#WikiTreffen" pluginspage="http://www.adobe.com/go/getflashplayer" src="http://ustream.tv/IrcClient.swf"\>
    
    @copyright: 2007 by MoinMoin:RalfZosel 
    @license: GNU GPL, see COPYING for details.
"""

from MoinMoin import wikiutil

def execute(macro, args):
    channel = wikiutil.escape(args)
    result = '<embed width="563" height="266" type="application/x-shockwave-flash" flashvars="channel=#%s" pluginspage="http://www.adobe.com/go/getflashplayer" src="http://ustream.tv/IrcClient.swf"\>' % (channel)
    return macro.formatter.rawHTML(result)
