Attachment 'IrcChat.py'
Download 1 """
2 MoinMoin - action for interfacing with cgi:irc
3
4 Copyright (c) 2002 by Thomas Waldmann
5 All rights reserved, see COPYING for details.
6
7 This action allows you to have an easy way to login into an irc channel.
8 You need to have cgi:irc installed (get it from http://www.cgiirc.visionhost.net/).
9 Then change the irc_url setting in the execute function (see a few lines below).
10 This should be all needed to make it work.
11 """
12
13 # Imports
14 from MoinMoin import config, user, webapi, wikiutil
15 from MoinMoin.i18n import _
16
17
18 def execute(pagename, request):
19 # change here:
20 # irc_url = config.irc_url
21 irc_url = "chat/irc.cgi"
22
23 # javascript code needed for cgi:irc
24 js = """
25 <script language="JavaScript"><!--
26 function setjs() {
27 if(navigator.product == 'Gecko') {
28 document.loginform["interface"].value = 'mozilla';
29 }else if(navigator.appName == 'Microsoft Internet Explorer' &&
30 window["ietest"] && window["ietest"].innerHTML) {
31 document.loginform["interface"].value = 'ie';
32 }else if(window.opera) {
33 document.loginform["interface"].value = 'opera';
34 }
35 }
36 //-->
37 </script>
38 """
39 # automatically submit form
40 bodyopts='onload="setjs();document.loginform.submit()"'
41
42 # use wiki user name as nick name for IRC
43 nick = wikiutil.quoteWikiname(('',user.current.name)[user.current.valid])
44 button = _(' Chat ')
45
46
47 formhtml = """
48 <form method="POST" action="%(irc_url)s" name="loginform" onsubmit="setjs();return true;" id="ietest">
49 <input type="hidden" name="interface" value="nonjs">
50 <input type="hidden" name="Nickname" value="%(nick)s">
51 <input type="submit" name="button" value="%(button)s">
52 </form>""" % locals()
53
54
55 # send header
56 webapi.http_headers(request)
57
58 # send head and body
59 print """
60 <html>
61 <head>
62 %(js)s
63 </head>
64 <body %(bodyopts)s>
65 %(formhtml)s
66 """ % locals()
67
68 # end tags are sent automagically
69
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.You are not allowed to attach a file to this page.