Attachment 'HelpOn-1.6.0-8.py'
Download 1 # -*- coding: iso-8859-1 -*-
2 """
3 MoinMoin - HelpOn Action Macro
4
5 PURPOSE:
6 This action macro is used to get help on an other extensions
7
8 SYNTAX:
9 http://WikiServer/WikiName?action=HelpOn
10
11 PROCEDURE:
12 You get a pull down list of available extensions and after selection
13 the help from inside of the routine is shown
14
15 The extensions below the MoinMoin path are indicated by the prefix MM-
16 While the others are indicated by a W- in the list
17
18 Please remove the version number from the filename.
19
20 MODIFICATION HISTORY:
21 @copyright: 2005 by Reimar Bauer (R.Bauer@fz-juelich.de)
22 @license: GNU GPL, see COPYING for details.
23 Version: 1.3.5-1
24
25 1.3.5-2 bug fix if no routine desription is defined
26 minor change from table output to preformatted text
27
28 1.3.5-3 code refactored
29 1.3.5-4 PRE does not need an additional line break
30
31 1.5.1-5 removed request.cfg.excluded_actions
32 1.5.4-6 2006-07-04 RB: some PEP8 changes
33 1.6.0-7 RB code change for 1.6 release, string replaced
34 1.6.0-8 RB code changed to get multiple language support for plugins (local plugins not implemented now)
35 """
36 import codecs
37 from MoinMoin import wikiutil, macro, action, parser
38 from MoinMoin.Page import Page
39 from MoinMoin.formatter.text_html import Formatter
40
41 def HelpOn_Extract_Help(cfg, module):
42 if module.startswith('MoinMoin'):
43 return __import__(module).__doc__
44
45 def HelpOn(request,pagename,module):
46 request.formatter = Formatter(request)
47 info = HelpOn_Extract_Help(request.cfg,module)
48 html = "<PRE>%(txt)s</PRE>" % {
49 "txt" : ''.join(info)}
50
51 request.http_headers()
52 request.setContentLanguage(request.lang)
53 request.theme.send_title(pagename)
54 request.write(request.formatter.startContent("content"))
55 request.write(html)
56 request.write(request.formatter.endContent())
57 request.theme.send_footer(pagename)
58
59
60 def execute(pagename, request):
61 _ = request.getText
62 actname = __name__.split('.')[-1]
63 thispage = Page(request,pagename)
64
65 if request.form.has_key('button') and request.form.has_key('ticket'):
66 # check whether this is a valid ticket request (make outside
67 # attacks harder by requiring two full HTTP transactions)
68 if not wikiutil.checkTicket(request.form['ticket'][0]) :
69 return thispage.send_page(request, msg = _('Please use the interactive user interface for HelpOn extensions!'))
70 module = request.form.get('helpon', [u''])[0]
71
72 return (HelpOn(request, pagename, module))
73
74 html = []
75 for name in action.extension_actions :
76 html.append("<OPTION>MoinMoin.action.%(name)s</OPTION>" % { "name": name})
77 """
78 for name in wikiutil.wikiPlugins('macro', request.cfg): #request)[1]:
79 html.append("<OPTION>Wiki.action.%(name)s</OPTION>" % { "name": name})
80 """
81 for name in macro.extension_macros :
82 html.append("<OPTION>MoinMoin.macro.%(name)s</OPTION>" % { "name": name})
83 """
84 for name in wikiutil.wikiPlugins('macro', request.cfg):
85 html.append("<OPTION>Wiki.macro.%(name)s</OPTION>" % { "name": name})
86 """
87 for name in parser.modules :
88 html.append("<OPTION>MoinMoin.parser.%(name)s</OPTION>" % { "name": name})
89 """
90 for name in wikiutil.wikiPlugins('parser', request.cfg):
91 html.append("<OPTION>Wiki.parser.%(name)s</OPTION>" % { "name": name})
92 """
93 formhtml = '''
94 <form method="post" action="">
95 <select name="helpon" size="1">
96 %(option)s
97 </select>
98 <input type="hidden" name="action" value="%(actname)s">
99 <input type="submit" name="button" value="%(button)s">
100 <input type="hidden" name="ticket" value="%(ticket)s">
101 <p>
102 </form>''' % {
103 'actname': 'HelpOn',
104 'ticket' : wikiutil.createTicket(),
105 'option' : ''.join(html),
106 'button' : 'Help'}
107
108 return thispage.send_page(request, msg=formhtml)
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.