Attachment 'ShortText-1.6.0-3.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 """
   3     MoinMoin - ShortText shows some text of a wiki page 
   4 
   5     PURPOSE:
   6         This macro is used to show the first 180 chars of a wikipage without processing instructions. 
   7 
   8     SYNTAX:
   9         <<ShortText(WikiName [,length=180])>>
  10 
  11     PROCEDURE:
  12        This routine needs the macro RecommendPage
  13 
  14        Please remove the version number from the filename.
  15 
  16     MODIFICATION HISTORY:
  17         @copyright: 2005 by MoinMoin:ReimarBauer
  18         @license: GNU GPL, see COPYING for details.
  19         Version: 1.3.4-1
  20         2005-09-09 : Version 1.3.5-2 : bug fixed if acl does not allow to read the routine has crashed before
  21         2007-01-10 : Version 1.6.0-3 : ported to 1.6 and added additional parameter for length, removed dependency to RecommendedPage
  22 
  23 
  24 """
  25 Dependencies = ["pages"]
  26 
  27 from MoinMoin.Page import Page
  28 from MoinMoin import wikiutil
  29 
  30 def macro_ShortText(macro, pagename=unicode, length=180):
  31     request = macro.request
  32     _ = request.getText
  33 
  34     if request.user.may.read(pagename):
  35         raw = Page(request, pagename).get_data()
  36         limit = min([len(raw), length])
  37         return request.formatter.text(raw[:length])
  38     else:
  39       return _("You are not allowed to view this page.")
  40 
  41 
  42 def execute(macro, args):
  43     try:
  44         return wikiutil.invoke_extension_function(
  45                    macro.request, macro_ShortText,
  46                    args, [macro])
  47     except ValueError, err:
  48         return macro.request.formatter.text(
  49                    "<<Example: %s>>" % err.args[0])

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] (2005-05-02 19:43:58, 1.1 KB) [[attachment:ShortText-1.3.4-1.py]]
  • [get | view] (2005-09-09 10:51:06, 1.1 KB) [[attachment:ShortText-1.3.5-2.py]]
  • [get | view] (2008-01-10 14:47:47, 1.5 KB) [[attachment:ShortText-1.6.0-3.py]]
 All files | Selected Files: delete move to page copy to page

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