changeset 567:854b5b2a059c

parser.interwiki: renders interwikimap page as link list
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Thu, 12 Jan 2012 13:46:41 +0100
parents ca006bf7dae8
children ee926de5e6e1
files data/plugin/parser/interwiki.py
diffstat 1 files changed, 42 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/plugin/parser/interwiki.py	Thu Jan 12 13:46:41 2012 +0100
@@ -0,0 +1,42 @@
+ # -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - interwiki parser 
+    renders urls from the definition of the InterWikiMap page
+    
+    @copyright: 2008-2011 by MoinMoin:ReimarBauer
+    
+    @license: GNU GPL, see COPYING for details.
+    
+"""
+
+Dependencies = []
+
+from MoinMoin.formatter.text_html import Formatter
+
+class Parser:
+
+    extensions = '*'
+    Dependencies = []
+
+    def __init__(self, raw, request, **kw):
+        self.raw = raw
+        self.request = request
+        self.form = request.form
+        self._ = request.getText
+
+    def format(self, formatter):
+        html_formatter = Formatter(self.request)
+        lines = self.raw.split('\n')
+        result = []
+        result.append(formatter.number_list(1))
+        for line in sorted(lines):
+            if line:
+                wiki, url = line.split()
+                result.append(formatter.listitem(1))
+                result.append(formatter.url(1, url))
+                result.append(wiki)
+                result.append(formatter.url(0))
+                result.append(formatter.listitem(0))
+        result.append(formatter.number_list(0))
+        self.request.write(''.join(result))
+