changeset 74:ad51b86d7bc1

introduce macro arnica which calls the arnica parser
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Fri, 06 Jun 2008 23:30:54 +0200
parents c827091b3427
children b88e1e1ded14
files data/plugin/macro/arnica.py data/plugin/parser/text_x_arnica.py
diffstat 2 files changed, 43 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/plugin/macro/arnica.py	Fri Jun 06 23:30:54 2008 +0200
@@ -0,0 +1,31 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - arnica
+
+    This macro is used to call the prser arnica,
+    it is just a thin wrapper around it.
+
+    based on Gallery2/gallery2image by ReimarBauer 2005-2008
+
+    @copyright: 2008 by MoinMoin:ReimarBauer
+    @license: GNU GPL, see COPYING for details.
+"""
+from MoinMoin import wikiutil
+
+class arnica:
+    def __init__(self, macro, args):
+        self.macro = macro
+        self.formatter = macro.formatter
+        self.args = args
+
+    def renderInPage(self):
+        arnica_parser = wikiutil.importPlugin(self.macro.cfg, 'parser', 'text_x_arnica', 'Parser')
+        if arnica_parser is None:
+            return self.formatter.text("Please install the arnica parser!")
+
+        ap = arnica_parser("", self.macro.request, format_args=self.args)
+        if ap.init_settings:
+            return ap.render(self.formatter)
+
+def execute(macro, args):
+    return arnica(macro, args).renderInPage()
--- a/data/plugin/parser/text_x_arnica.py	Fri Jun 06 21:33:10 2008 +0200
+++ b/data/plugin/parser/text_x_arnica.py	Fri Jun 06 23:30:54 2008 +0200
@@ -529,12 +529,12 @@
                 im_obj.thumbnail((self.thumbnail_width, self.thumbnail_width), Image.ANTIALIAS)
                 im_obj.save(thumbf, image_type)
 
-    def format(self, formatter):
-        """ does the format """
+    def render(self, formatter):
+        """ renders thumbnails """
 
         _ = self._
 
-        # checks if nitializing of all attributes in __init__ was done
+        # checks if initializing of all attributes in __init__ was done
         if not self.init_settings:
             return
 
@@ -616,4 +616,12 @@
 
         browser = DataBrowserWidget(self.request, show_header=False)
         browser.setData(data)
-        self.request.write(browser.format())
+        return browser.format()
+
+    def format(self, formatter):
+        """ parser output """
+        # checks if initializing of all attributes in __init__ was done
+        if not self.init_settings:
+            return
+
+        self.request.write(self.render(formatter))