Attachment 'HelpOn-1.7.1-10.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 MoinMoin:ReimarBauer 
  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-9 2008-01-10 refactored for 1.6 getting the header is not quite optimal currently
  34 """
  35 
  36 import codecs, os
  37 from MoinMoin import config, wikiutil, user, macro, action, parser
  38 from MoinMoin.Page import Page
  39 from MoinMoin.formatter.text_html import Formatter
  40 
  41 def HelpOn_Extract_Help(module_path_name, module_name):
  42     # if the module is not a file it is defined in __init__
  43     if not os.path.exists(module_path_name):
  44         module_path_name = module_path_name.replace(module_name.split(':')[1], '__init__')
  45 
  46     file = codecs.open(module_path_name, 'r')
  47     lines = file.readlines()
  48     file.close()
  49 
  50     index = []
  51     i = 0
  52     for line in lines:
  53         if line.strip() == '"""':
  54             index.append(i)
  55         i += 1
  56 
  57     if len(index) >= 2:
  58         txt = lines[(index[0])+1: index[1]]
  59     else:
  60         txt = ["no help available for %(name)s" % {"name": module_name}]
  61 
  62     return txt
  63 
  64 def HelpOn(request, pagename, module):
  65     request.formatter = Formatter(request)
  66     mod = module.split(':')
  67     module_type = mod[0]
  68     this_type = module_type.split('-')
  69     module_type = this_type[1]
  70     module_name = mod[1]
  71 
  72     if this_type[0] == 'MM':
  73         module_path_name = "%(path)s/%(module_type)s/%(name)s.py" % {
  74              "module_type": module_type,
  75              "path": request.cfg.moinmoin_dir,
  76              "name": module_name }
  77 
  78     if this_type[0] == 'W':
  79         module_path_name = "%(path)s/plugin/%(module_type)s/%(name)s.py" % {
  80              "module_type": module_type,
  81              "path": request.cfg.data_dir,
  82              "name": module_name}
  83 
  84     info = HelpOn_Extract_Help(module_path_name, module)
  85     html = "<PRE>%(txt)s</PRE>" % {
  86                "txt": '\n'.join(info)}
  87 
  88     request.emit_http_headers()
  89     request.setContentLanguage(request.lang)
  90     request.theme.send_title('Helpon %s' % module_name, pagename=pagename)
  91     request.write(request.formatter.startContent("content"))
  92     request.write(html)
  93     request.write(request.formatter.endContent())
  94     request.theme.send_footer(pagename)
  95     return
  96 
  97 
  98 def execute(pagename, request):
  99     thispage = Page(request, pagename)
 100     if not request.user.valid:
 101         msg="Please log in"
 102         request.theme.add_msg(msg)
 103         thispage.send_page()
 104         return
 105 
 106     _ = request.getText
 107     actname = __name__.split('.')[-1]
 108 
 109     if request.form.has_key('button') and request.form.has_key('ticket'):
 110         if not wikiutil.checkTicket(request, request.form['ticket'][0]):
 111             msg = _('Please use the interactive user interface for HelpOn extensions!')
 112             request.theme.add_msg(msg)
 113             thispage.send_page()
 114             return
 115         module = request.form.get('helpon', [u''])[0]
 116         return (HelpOn(request, pagename, module))
 117 
 118     html = []
 119 
 120     for name in action.getNames(request.cfg):
 121         html.append("<OPTION>MM-action:%(name)s</OPTION>" % {"name": name})
 122 
 123     for name in wikiutil.wikiPlugins('action', request.cfg):
 124         html.append("<OPTION>W-action:%(name)s</OPTION>" % {"name": name})
 125 
 126     for name in macro.getNames(request.cfg):
 127         html.append("<OPTION>MM-macro:%(name)s</OPTION>" % {"name": name})
 128 
 129     for name in wikiutil.wikiPlugins('macro', request.cfg):
 130         html.append("<OPTION>W-macro:%(name)s</OPTION>" % {"name": name})
 131 
 132     for name in  parser.modules:
 133         html.append("<OPTION>MM-parser:%(name)s</OPTION>" % {"name": name})
 134 
 135     for name in wikiutil.wikiPlugins('parser', request.cfg):
 136         html.append("<OPTION>W-parser:%(name)s</OPTION>" % {"name": name})
 137 
 138     formhtml = '''
 139 <form method="post" action="">
 140 <select name="helpon" size="1">
 141 %(option)s
 142 </select>
 143 <input type="hidden" name="action" value="%(actname)s">
 144 <input type="submit" name="button" value="%(button)s">
 145 <input type="hidden" name="ticket" value="%(ticket)s">
 146 <p>
 147 </form>''' % {
 148     'actname': 'HelpOn',
 149     'ticket': wikiutil.createTicket(request),
 150     'option': '\n'.join(html),
 151     'button': 'Help'}
 152 
 153     request.theme.add_msg(formhtml)
 154     thispage.send_page()
 155     return

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] (2011-04-14 07:28:03, 4.7 KB) [[attachment:CreateNewPage.py]]
  • [get | view] (2011-04-14 07:26:24, 4.2 KB) [[attachment:CreateNewPage1.6.py]]
  • [get | view] (2006-09-10 21:29:29, 40.4 KB) [[attachment:CreatePdfDocument2_0_3.py]]
  • [get | view] (2006-09-12 06:05:06, 40.5 KB) [[attachment:CreatePdfDocument2_0_4.py]]
  • [get | view] (2006-09-12 12:00:09, 40.6 KB) [[attachment:CreatePdfDocument2_0_5.py]]
  • [get | view] (2006-11-14 21:56:11, 43.5 KB) [[attachment:CreatePdfDocument2_0_6.py]]
  • [get | view] (2006-11-15 17:00:47, 43.8 KB) [[attachment:CreatePdfDocument2_0_7.py]]
  • [get | view] (2006-11-16 22:06:18, 43.8 KB) [[attachment:CreatePdfDocument2_0_8.py]]
  • [get | view] (2006-12-17 15:54:21, 43.6 KB) [[attachment:CreatePdfDocument2_0_9.py]]
  • [get | view] (2007-08-20 09:10:23, 67.2 KB) [[attachment:CreatePdfDocument2_1_0.py]]
  • [get | view] (2007-08-21 07:39:49, 67.1 KB) [[attachment:CreatePdfDocument2_1_1.py]]
  • [get | view] (2007-09-11 19:16:37, 67.3 KB) [[attachment:CreatePdfDocument2_1_2.py]]
  • [get | view] (2007-09-18 20:17:58, 68.1 KB) [[attachment:CreatePdfDocument2_1_3.py]]
  • [get | view] (2007-09-21 13:32:54, 71.1 KB) [[attachment:CreatePdfDocument2_1_4.py]]
  • [get | view] (2007-09-23 20:56:30, 73.4 KB) [[attachment:CreatePdfDocument2_1_5.py]]
  • [get | view] (2007-09-25 20:54:48, 74.5 KB) [[attachment:CreatePdfDocument2_2_0.py]]
  • [get | view] (2008-06-23 21:08:49, 77.0 KB) [[attachment:CreatePdfDocument2_3_0.py]]
  • [get | view] (2008-06-26 19:25:07, 81.0 KB) [[attachment:CreatePdfDocument2_3_1.py]]
  • [get | view] (2008-07-06 05:50:38, 83.1 KB) [[attachment:CreatePdfDocument2_3_2.py]]
  • [get | view] (2008-07-09 17:42:02, 83.3 KB) [[attachment:CreatePdfDocument2_3_3.py]]
  • [get | view] (2008-09-07 11:11:01, 83.5 KB) [[attachment:CreatePdfDocument2_3_4.py]]
  • [get | view] (2009-01-11 15:53:09, 84.3 KB) [[attachment:CreatePdfDocument2_3_5.py]]
  • [get | view] (2009-02-16 06:52:06, 84.2 KB) [[attachment:CreatePdfDocument2_3_6.py]]
  • [get | view] (2010-01-29 11:53:21, 82.8 KB) [[attachment:CreatePdfDocument2_4_0.py]]
  • [get | view] (2010-01-31 14:10:03, 84.6 KB) [[attachment:CreatePdfDocument2_4_1.py]]
  • [get | view] (2010-09-18 16:23:23, 85.6 KB) [[attachment:CreatePdfDocument2_4_2.py]]
  • [get | view] (2006-06-16 20:56:53, 4.9 KB) [[attachment:FlashManager.py-1.5.3-1]]
  • [get | view] (2003-12-07 18:15:53, 3.9 KB) [[attachment:HTML2MoinMoin.py]]
  • [get | view] (2005-10-16 08:24:35, 4.9 KB) [[attachment:HelpOn-1.3.5-4.py]]
  • [get | view] (2006-02-03 19:21:04, 4.9 KB) [[attachment:HelpOn-1.5.1-5.py]]
  • [get | view] (2006-07-04 10:45:22, 4.8 KB) [[attachment:HelpOn-1.5.4-6.py]]
  • [get | view] (2006-07-04 22:39:14, 4.8 KB) [[attachment:HelpOn-1.6.0-7.py]]
  • [get | view] (2006-07-06 13:50:17, 4.0 KB) [[attachment:HelpOn-1.6.0-8.py]]
  • [get | view] (2008-01-10 17:43:24, 4.8 KB) [[attachment:HelpOn-1.6.0-9.py]]
  • [get | view] (2008-08-19 14:44:54, 5.0 KB) [[attachment:HelpOn-1.7.1-10.py]]
  • [get | view] (2005-02-20 18:28:34, 10.8 KB) [[attachment:IRSS.py]]
  • [get | view] (2005-03-09 22:46:23, 2.9 KB) [[attachment:ImportHtml-1.2.py]]
  • [get | view] (2003-12-07 18:15:53, 2.8 KB) [[attachment:ImportHtml.py]]
  • [get | view] (2003-12-07 18:15:53, 1.8 KB) [[attachment:IrcChat.py]]
  • [get | view] (2008-06-09 11:27:20, 4.4 KB) [[attachment:MoinCrypt.py]]
  • [get | view] (2010-11-29 12:08:27, 7.5 KB) [[attachment:PageActions.py]]
  • [get | view] (2006-08-07 15:12:19, 0.5 KB) [[attachment:PermanentLink.py]]
  • [get | view] (2003-12-07 18:15:53, 6.3 KB) [[attachment:PhoneDial.py]]
  • [get | view] (2005-04-17 14:21:47, 3.6 KB) [[attachment:RecommendPage-1.3.4-1.py]]
  • [get | view] (2005-04-19 18:21:52, 5.5 KB) [[attachment:RecommendPage-1.3.4-2.py]]
  • [get | view] (2005-05-02 19:53:09, 5.6 KB) [[attachment:RecommendPage-1.3.4-3.py]]
  • [get | view] (2005-09-03 07:33:35, 6.3 KB) [[attachment:RecommendPage-1.3.4-4.py]]
  • [get | view] (2005-09-05 17:44:03, 6.9 KB) [[attachment:RecommendPage-1.3.5-5.py]]
  • [get | view] (2005-09-07 16:42:26, 7.5 KB) [[attachment:RecommendPage-1.3.5-6.py]]
  • [get | view] (2005-09-08 16:06:28, 7.7 KB) [[attachment:RecommendPage-1.3.5-7.py]]
  • [get | view] (2005-11-01 11:31:51, 9.0 KB) [[attachment:RecommendPage-1.3.5-8.py]]
  • [get | view] (2006-02-03 19:40:51, 8.3 KB) [[attachment:RecommendPage-1.5.1-9.py]]
  • [get | view] (2008-01-11 09:14:35, 6.8 KB) [[attachment:RecommendPage-1.6.0-10.py]]
  • [get | view] (2008-08-19 14:44:59, 6.9 KB) [[attachment:RecommendPage-1.7.1-11.py]]
  • [get | view] (2008-06-09 11:27:40, 1.7 KB) [[attachment:ShowActions.py]]
  • [get | view] (2008-06-09 10:34:02, 5.3 KB) [[attachment:ShowDecrypted.py]]
  • [get | view] (2005-03-30 21:17:28, 7.7 KB) [[attachment:Slideshow.py]]
  • [get | view] (2004-02-02 20:48:31, 2.0 KB) [[attachment:SubscribeUser.py]]
  • [get | view] (2007-01-26 17:08:30, 2.2 KB) [[attachment:Subscribers-1.6.0.py]]
  • [get | view] (2003-12-07 18:15:53, 1.8 KB) [[attachment:Subscribers.py]]
  • [get | view] (2006-03-18 23:16:51, 0.8 KB) [[attachment:UserPreferences.py]]
  • [get | view] (2004-01-05 09:56:25, 8.1 KB) [[attachment:VisualSiteMap.py]]
  • [get | view] (2015-08-30 21:04:23, 11.1 KB) [[attachment:VisualSiteMap_1.10.py]]
  • [get | view] (2004-10-08 10:59:16, 9.3 KB) [[attachment:VisualSiteMap_1.2.py]]
  • [get | view] (2005-03-16 01:30:09, 9.8 KB) [[attachment:VisualSiteMap_1.3.py]]
  • [get | view] (2014-08-19 01:34:10, 10.8 KB) [[attachment:VisualSiteMap_1.9.py]]
  • [get | view] (2007-08-18 18:52:55, 1.0 KB) [[attachment:backlink.py]]
  • [get | view] (2007-03-15 05:53:49, 23.5 KB) [[attachment:findandreplace0.1Beta.py]]
  • [get | view] (2005-03-27 20:32:10, 3.6 KB) [[attachment:gallery2image-1.3.3-1.py]]
  • [get | view] (2005-08-03 20:14:56, 4.0 KB) [[attachment:gallery2image-1.3.3-2.py]]
  • [get | view] (2005-11-13 18:10:26, 20.7 KB) [[attachment:gallery2image-1.3.5-10.py]]
  • [get | view] (2005-11-25 22:03:50, 20.8 KB) [[attachment:gallery2image-1.3.5-11.py]]
  • [get | view] (2005-08-08 17:23:43, 8.4 KB) [[attachment:gallery2image-1.3.5-4.py]]
  • [get | view] (2005-08-13 15:15:45, 13.7 KB) [[attachment:gallery2image-1.3.5-5.py]]
  • [get | view] (2005-08-31 22:05:22, 15.5 KB) [[attachment:gallery2image-1.3.5-6.py]]
  • [get | view] (2005-10-29 20:23:50, 15.9 KB) [[attachment:gallery2image-1.3.5-8.py]]
  • [get | view] (2005-11-01 11:31:24, 17.6 KB) [[attachment:gallery2image-1.3.5-9.py]]
  • [get | view] (2006-01-27 20:52:32, 20.9 KB) [[attachment:gallery2image-1.5.1-12.py]]
  • [get | view] (2006-08-06 09:01:01, 22.1 KB) [[attachment:gallery2image-1.5.4-13.py]]
  • [get | view] (2006-08-11 18:21:40, 22.2 KB) [[attachment:gallery2image-1.5.4-14.py]]
  • [get | view] (2006-11-16 20:23:27, 22.6 KB) [[attachment:gallery2image-1.5.6-16.py]]
  • [get | view] (2006-08-11 18:30:22, 22.2 KB) [[attachment:gallery2image-1.6.0-15.py]]
  • [get | view] (2008-02-06 10:13:45, 22.3 KB) [[attachment:gallery2image-1.6.0-16.py]]
  • [get | view] (2008-05-20 15:51:09, 22.4 KB) [[attachment:gallery2image-1.6.3-17.py]]
  • [get | view] (2006-09-06 06:19:48, 1.3 KB) [[attachment:getmmap.py]]
  • [get | view] (2004-07-18 09:48:00, 1.5 KB) [[attachment:localnames.py]]
  • [get | view] (2005-03-25 15:02:31, 2.6 KB) [[attachment:newpageonly.py]]
  • [get | view] (2005-03-30 09:02:00, 3.5 KB) [[attachment:newpageonly_20050330.py]]
  • [get | view] (2006-06-06 19:12:27, 9.7 KB) [[attachment:pdf.py]]
  • [get | view] (2006-08-30 10:51:51, 36.0 KB) [[attachment:pdf2_0_0.py]]
  • [get | view] (2006-08-30 13:57:36, 36.5 KB) [[attachment:pdf2_0_1.py]]
  • [get | view] (2006-02-04 04:25:29, 1.0 KB) [[attachment:sisterindex.py]]
  • [get | view] (2004-10-28 07:33:10, 0.7 KB) [[attachment:xml.py]]
 All files | Selected Files: delete move to page copy to page

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