changeset 514:dda4017bc8a4

macro.ShortText: It shows the beginning of a wiki page without any processing instructions and only if the user is allowed to read that page.
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 06 Apr 2010 17:03:43 +0200
parents 438f1d16e63f
children 236d21d4b0b7
files data/plugin/macro/ShortText.py
diffstat 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/plugin/macro/ShortText.py	Tue Apr 06 17:03:43 2010 +0200
@@ -0,0 +1,26 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - ShortText macro
+
+    It shows the first 180 chars of a wiki page without any processing instructions
+    and only if the user is allowed to read that page.
+
+    @copyright: 2005-2010 by MoinMoin:ReimarBauer
+    @license: GNU GPL, see COPYING for details.
+"""
+Dependencies = ["pages"]
+
+from MoinMoin.Page import Page
+from MoinMoin import wikiutil
+
+def macro_ShortText(macro, pagename=unicode, length=180):
+    request = macro.request
+    _ = request.getText
+    if request.user.may.read(pagename):
+        raw = Page(request, pagename).get_data()
+        return request.formatter.text(raw[:length])
+    else:
+        return _("You are not allowed to view this page.")
+
+
+