changeset 530:78ca2464edf9

macro.EmbedContent: embeds html content of an URL on a page (action=content)
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 25 May 2010 01:45:05 +0200
parents db71033db140
children bd8e88710547
files data/plugin/macro/EmbedContent.py
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/plugin/macro/EmbedContent.py	Tue May 25 01:45:05 2010 +0200
@@ -0,0 +1,19 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - macro to embed content of an other (wiki) page
+
+    <<EmbedContent(url="http://localhost:8080/Example?action=content")>>
+
+    @copyright: 2010 by MoinMoin:ReimarBauer
+    @license: GNU GPL, see COPYING for details.
+"""
+import urllib2
+
+def macro_EmbedContent(macro, url=u""):
+    fmt = macro.formatter
+    if url:
+        uo = urllib2.urlopen(url)
+        html = uo.read()
+        uo.close()
+        return fmt.rawHTML(html)
+