Attachment 'LastEdit-1.0.py'

Download

   1 """
   2     MoinMoin - LastEdit Macro Version 1.0, 18.05.2011
   3 
   4     A macro to insert the lastest edit date (and editor) for the page
   5 
   6     Usage: <<LastEdit>> date
   7            <<LastEdit(by)>> inserts: date 'by' editor
   8            <<LastEdit(...%s...)>> inserts: date '...'editor'...'
   9            <<LastEdit(...%(editor)s...)>> inserts: date '...'editor'...'
  10 
  11     @copyright: 2011 Ian Riley <ian.riley@adelaide.edu.au>
  12     @license: GNU GPL, see COPYING for details.
  13 
  14 """
  15 from MoinMoin import wikiutil
  16 from MoinMoin.parser.text_moin_wiki import Parser as wiki
  17 from MoinMoin.Page import Page
  18 
  19 Dependencies = ['pages']
  20 
  21 def execute(macro, args):
  22     request = macro.request
  23     page = macro.formatter.page
  24     _ = macro.request.getText
  25     EditedBy = args
  26     info = page.lastEditInfo()
  27     result = ''
  28     if info:
  29         result = ('%(time)s' % info)
  30         if info.get('editor') and EditedBy:
  31             EditedBy = wikiutil.renderText(macro.request, wiki, EditedBy)
  32             if '%s' in EditedBy:
  33                 result = ' '.join([result, (EditedBy % info.get('editor'))])
  34             elif '%(editor)s' in EditedBy:
  35                 result = ' '.join([result, (EditedBy % info)])
  36             else:
  37                 result = ' '.join([result, EditedBy, info.get('editor')])
  38     return result

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