view data/plugin/parser/interwiki.py @ 653:127da830be6c

updated copyright
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 19 Apr 2016 16:29:54 +0200
parents 854b5b2a059c
children
line wrap: on
line source
 # -*- coding: iso-8859-1 -*-
"""
    MoinMoin - interwiki parser 
    renders urls from the definition of the InterWikiMap page
    
    @copyright: 2008-2016 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))